Commit 9fed74ce by wangonghui

项目工程添加保存和添加提示信息

parent bebfaab6
......@@ -126,6 +126,12 @@ namespace VIZ.Package.Domain
/// </summary>
public const string OPERATE_PROJECT_SAVE = "保存项目";
/// <summary>
/// 另存项目
/// </summary>
public const string OPERATE_PROJECT_SAVEAS = "另存项目";
/// <summary>
/// 关闭项目
/// </summary>
......
......@@ -74,8 +74,12 @@
Command="{Binding Path=OpenProjectCommand}" />
<dxb:BarButtonItem Content="保存" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_save_20x20.png"
Command="{Binding Path=SaveProjectCommand}" />
<dxb:BarButtonItem Content="另保存" Glyph="/VIZ.Package.Module.Resource;component/Icons/icon_save_as_30x30.png"
Command="{Binding Path=SaveAsProjectCommand}" />
<dxb:BarButtonItem Content="关闭" Glyph="/VIZ.Package.Module.Resource;component/Icons/top_icon_close_20x20.png"
Command="{Binding Path=CloseProjectCommand}" />
</dxb:BarSubItem>
<dxb:BarSubItem Content="设置" Command="{Binding Path=SettingCommand}">
</dxb:BarSubItem>
......
......@@ -51,6 +51,7 @@ namespace VIZ.Package.Module
this.CreateProjectCommand = new VCommand(this.CreateProject);
this.OpenProjectCommand = new VCommand(this.OpenProject);
this.SaveProjectCommand = new VCommand(this.SaveProject, this.CanSaveProject);
this.SaveAsProjectCommand = new VCommand(this.SaveAsProject, this.CanSaveProject);
this.CloseProjectCommand = new VCommand(this.CloseProject, this.CanCloseProject);
this.SettingCommand = new VCommand(this.Setting);
......@@ -392,6 +393,84 @@ namespace VIZ.Package.Module
#endregion
#region SaveAsProjectCommand---另存项目命令
/// <summary>
/// 另存为项目命令
/// </summary>
public VCommand SaveAsProjectCommand { get; set; }
/// <summary>
/// 另存为文件
/// </summary>
private void SaveAsProject()
{
// 创建项目文件
SaveProjectWindow window = new SaveProjectWindow();
window.ShowDialog();
if (window.DialogResult != true)
return;
SaveProjectWindowModel vm = window.DataContext as SaveProjectWindowModel;
if (vm == null)
return;
//取的另取文件路径
string path = System.IO.Path.Combine(vm.SelectedFolderModel.Path, vm.ProjectName);
string logPath = System.IO.Path.Combine(vm.SelectedFolderModel.Path, vm.ProjectLogName);
if (path.Equals(ApplicationDomainEx.VizConfig.ProjectPath))
{
DXMessageBox.Show("文件名与当前打开项目名称一致,保存失败");
return;
}
ApplicationDomainEx.ProjectDbContext.Dispose();
System.IO.File.Copy(ApplicationDomainEx.VizConfig.ProjectPath, path, true);
DirectoryInfo pathInfo = new DirectoryInfo(ApplicationDomainEx.VizConfig.ProjectPath);
string sourceLogPath= System.IO.Path.Combine(pathInfo.Parent.FullName,this.ProjectName+ ApplicationConstants.PROJECT_FILE_LOG_NAME_SUFFIX);
if (System.IO.File.Exists(sourceLogPath))
{
System.IO.File.Copy(sourceLogPath, logPath,true);
}
//把新的东西保存新的库里
ApplicationDomainEx.ProjectDbContext = new ProjectDbContext(path);
ProjectSaveMessage msg = new ProjectSaveMessage();
ApplicationDomainEx.MessageManager.Send(msg);
// 保存当前项目的完整路径
ApplicationDomainEx.VizConfig.ProjectPath = path;
ApplicationDomainEx.LocalDbContext.VizConfig.Update(ApplicationDomainEx.VizConfig);
this.ProjectName = System.IO.Path.GetFileNameWithoutExtension(path);
// 记录操作日志
this.recordLogService.AppendLog(ApplicationConstants.APPLICATION_GROUP_NAME, RecordLogOperate.Operate, RecordLogTrigger.Human, RecordLogConstants.OPERATE_PROJECT_SAVEAS, path);
// 发送弹出提示
AlertMessage alertMessage = new AlertMessage();
alertMessage.Message = "保存成功";
ApplicationDomainEx.MessageManager.Send(alertMessage);
ProjectOpenMessage openMsg = new ProjectOpenMessage();
ApplicationDomainEx.MessageManager.Send(openMsg);
//在还原成之前的库
// ApplicationDomainEx.ProjectDbContext = new ProjectDbContext(ApplicationDomainEx.VizConfig.ProjectPath);
}
#endregion
#region CloseProjectCommand -- 关闭项目命令
/// <summary>
......@@ -567,7 +646,7 @@ namespace VIZ.Package.Module
ManagerLayoutViewModel vm = managerLayout.DataContext as ManagerLayoutViewModel;
vm.ItemsSource = ItemsSource.Where(a => !string.IsNullOrEmpty(a.FilePath)&&Convert.ToString(a.Header)!= "保存布局").ToObservableCollection();
vm.ItemsSource = ItemsSource.Where(a => !string.IsNullOrEmpty(a.FilePath) && Convert.ToString(a.Header) != "保存布局").ToObservableCollection();
managerLayout.ShowDialog();
}
......
......@@ -63,6 +63,16 @@ namespace VIZ.Package.Module
set { projectName = value; this.RaisePropertyChanged(nameof(ProjectName)); }
}
private string projectLogName;
public string ProjectLogName
{
get { return projectLogName; }
set { projectLogName = value; this.RaisePropertyChanged(nameof(ProjectLogName)); }
}
#endregion
// ==========================================================================
......@@ -95,12 +105,19 @@ namespace VIZ.Package.Module
string file = this.ProjectName;
if (!this.ProjectName.ToLower().EndsWith(ApplicationConstants.PROJECT_FILE_EXTENSION))
{
//log日志文件名称
this.ProjectLogName = $"{file}{ApplicationConstants.PROJECT_FILE_LOG_NAME_SUFFIX}";
file = $"{file}{ApplicationConstants.PROJECT_FILE_EXTENSION}";
this.ProjectName = file;
}
string path = System.IO.Path.Combine(this.SelectedFolderModel.Path, file);
if (System.IO.File.Exists(path))
{
var result = DXMessageBox.Show($"项目:\"{file}\" 已经存在,是否覆盖", "提示", MessageBoxButton.YesNo);
......
......@@ -53,6 +53,12 @@ namespace VIZ.Package.Module
return;
}
if(ApplicationDomainEx.ProjectDbContext==null)
{
DXMessageBox.Show("请先创建项目文件或者打开项目文件");
return;
}
IPageTemplateService service = ApplicationDomainEx.ServiceManager.GetService<IPageTemplateService>(ViewServiceKeys.PAGE_TEMPLATE_SERVICE);
if (service == null)
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment