Commit 3dd01479 by wangonghui

Merge branch 'DevPackage'

parents d0318578 9fed74ce
......@@ -60,5 +60,10 @@ namespace VIZ.Package.Domain
/// 包装任务服务
/// </summary>
public const string PACKAGE_TASK_SERVICE = "PACKAGE_TASK_SERVICE";
/// <summary>
/// 主视图Top服务
/// </summary>
public const string MAIN_TOPVIEW_SERVICE = "MAIN_TOPVIEW_SERVICE";
}
}
......@@ -68,18 +68,34 @@ namespace VIZ.Package.Domain.Model
#endregion
#region 文件路径
private string filePath;
/// <summary>
/// 文件路径
/// </summary>
public string FilePath
{
get { return filePath; }
set { filePath=value; this.RaisePropertyChanged(nameof(FilePath)); }
}
#endregion
#region Command -- 命令
private VCommand command;
private VCommand<string> command;
/// <summary>
/// 命令
/// </summary>
public VCommand Command
public VCommand<string> Command
{
get { return command; }
set { command = value; this.RaisePropertyChanged(nameof(Command)); }
}
#endregion
}
}
......@@ -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>
......
using DevExpress.Data;
using DevExpress.Xpf.Grid.GroupRowLayout;
using log4net;
using System;
using System.Collections.Generic;
......@@ -251,6 +252,29 @@ namespace VIZ.Package.Module
#endregion
#region 清屏操作----更新命令
public void ClearSceen()
{
var pageModel = ApplicationDomainEx.CurrentPage as PageModel;
ConnGroupModel group = ApplicationDomainEx.ConnGroups.FirstOrDefault(p => p.GroupID == pageModel.ConnGroupID);
foreach (var item in group.Items)
{
if (!item.IsEnabled || !item.IsConnected)
continue;
vizCommandService.ClearSceen(item, VizLayer.FRONT_LAYER);
vizCommandService.ClearSceen(item, VizLayer.MAIN_LAYER);
vizCommandService.ClearSceen(item, VizLayer.BACK_LAYER);
}
}
#endregion
// ==============================================================
// Message
// ==============================================================
......@@ -302,6 +326,16 @@ namespace VIZ.Package.Module
this.Update();
return;
}
if(string.Equals(msg.Key, ApplicationDomainEx.HotKeyConfig.ClearSceen))
{
//记录操作日志
this.recordLogService.AppendLog(ApplicationConstants.APPLICATION_GROUP_NAME, RecordLogOperate.Operate, RecordLogTrigger.Human, RecordLogConstants.SYSTEM_HOT_KEY, msg.Key);
this.ClearSceen();
return;
}
}
catch (Exception ex)
{
......
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain.Model;
namespace VIZ.Package.Module
{
public interface IMainTopViewService : IService
{
ObservableCollection<MenuItemModel> ItemsSource { get; set; }
VCommand<string> ImportLayoutCommand { get; set; }
}
}
......@@ -27,5 +27,15 @@ namespace VIZ.Package.Module
/// </summary>
/// <param name="isEnabled">是否可用</param>
void SetIsEnabled(bool isEnabled);
/// <summary>
/// 导出布局
/// </summary>
void ExportLayout(string param);
/// <summary>
/// 加载布局
/// </summary>
void ImportLayout(string param);
}
}
......@@ -23,7 +23,7 @@
<DataTemplate>
<ContentControl>
<dxb:BarButtonItem Glyph="{Binding Icon}" Content="{Binding Header}"
Command="{Binding Path=Command}"></dxb:BarButtonItem>
Command="{Binding Path=Command}" CommandParameter="{Binding Path=FilePath}" ></dxb:BarButtonItem>
</ContentControl>
</DataTemplate>
</local:MainTopViewMenuDataTemplateSelector.ButtonDataTemplate>
......@@ -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>
......
<dx:ThemedWindow
x:Class="VIZ.Package.Module.ManagerLayoutView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
ResizeMode="NoResize" WindowStartupLocation="CenterScreen"
Title="管理窗口布局" Height="300" Width="400" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"/>
<RowDefinition Height="*"/>
<RowDefinition Height="30"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
<ColumnDefinition Width="100"/>
</Grid.ColumnDefinitions>
<TextBlock Text="已保存的布局:" VerticalAlignment="Center" Margin="5"/>
<ListBox Name="saveLayoutBox" Grid.Row="1" Margin="5,0,0,0" ItemsSource="{Binding Path=ItemsSource}" SelectedItem="{Binding SelectItem}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Header}"/>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="5,0,0,0">
<Button Content="重命名" Width="60" Command="{Binding ReNameCommand}" Margin="0,0,5,0"/>
<Button Content="删除" Width="60" Command="{Binding DeleteCommand}"/>
</StackPanel>
<StackPanel Grid.Row="2" Grid.Column="1" Orientation="Horizontal" HorizontalAlignment="Right" >
<Button Content="关闭" Width="60" Command="{Binding CloseCommand}"/>
</StackPanel>
</Grid>
</dx:ThemedWindow>
using DevExpress.Xpf.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// Interaction logic for ManagerLayout.xaml
/// </summary>
public partial class ManagerLayoutView : ThemedWindow
{
public ManagerLayoutView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new ManagerLayoutViewModel());
}
}
}
<dx:ThemedWindow
x:Class="VIZ.Package.Module.SaveLayoutView"
xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:VIZ.Package.Module"
Title="{Binding Path=TitleName}"
mc:Ignorable="d"
Width="300" Height="160" ResizeMode="NoResize" WindowStartupLocation="CenterScreen" >
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="30"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<TextBlock Text="布局名称:" VerticalAlignment="Center" HorizontalAlignment="Left" Margin="10,0,10,0" Grid.Row="0"></TextBlock>
<TextBox Text="{Binding Path=FolderName,Mode=TwoWay}" Grid.Row="1" VerticalContentAlignment="Center" HorizontalAlignment="Left" HorizontalContentAlignment="Left"
AcceptsReturn="False" TextWrapping="NoWrap" Height="30" Margin="10,0,10,0" Width="275"></TextBox>
<StackPanel Grid.Row="2" Orientation="Horizontal" HorizontalAlignment="Right">
<Button Content="确定" Width="80" Height="30" Margin="10" Command="{Binding EnterCommand}"></Button>
<Button Content="取消" Width="80" Height="30" Margin="10" Command="{Binding CancelCommand}"></Button>
</StackPanel>
</Grid>
</dx:ThemedWindow>
using DevExpress.Xpf.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.Package.Module
{
/// <summary>
/// Interaction logic for SaveLayout.xaml
/// </summary>
public partial class SaveLayoutView : ThemedWindow
{
public SaveLayoutView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new SaveLayoutViewModel());
}
}
}
......@@ -4,6 +4,7 @@ using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
......@@ -21,7 +22,7 @@ namespace VIZ.Package.Module
/// <summary>
/// 主视图顶部视图模型
/// </summary>
public class MainTopViewModel : ViewModelBase
public class MainTopViewModel : ViewModelBase, IMainTopViewService
{
/// <summary>
/// 日志
......@@ -35,6 +36,9 @@ namespace VIZ.Package.Module
// 初始化消息
this.InitMessage();
// 注册服务
ApplicationDomainEx.ServiceManager.AddService(ViewServiceKeys.MAIN_TOPVIEW_SERVICE, this);
}
/// <summary>
......@@ -47,13 +51,20 @@ 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);
this.ResetLayoutCommand = new VCommand(this.ResetLayout);
this.ResetLayoutCommand = new VCommand<string>(this.ResetLayout);
this.AboutCommand = new VCommand(this.About);
this.AboutCustomControlFieldCommand = new VCommand(this.AboutCustomControlField);
this.AboutPageCommandCommand = new VCommand(this.AboutPageCommand);
this.ExportLayoutCommand = new VCommand<string>(this.ExportLayout);
this.ImportLayoutCommand = new VCommand<string>(this.ImportLayout);
this.ManageLayoutCommand = new VCommand<string>(this.ManageLayout);
}
/// <summary>
......@@ -159,6 +170,31 @@ namespace VIZ.Package.Module
}).ToList();
items.Add(new MenuItemModel { Type = MenuItemType.Separator });
string path = GetLayoutPath();
items.Add(new MenuItemModel
{
Header = "保存布局",
Icon = "/VIZ.Package.Module.Resource;component/Icons/top_icon_layout_20x20.png",
Type = MenuItemType.Button,
FilePath = path,
Command = this.ExportLayoutCommand
});
items.Add(new MenuItemModel
{
Header = "管理布局",
Icon = "/VIZ.Package.Module.Resource;component/Icons/top_icon_layout_20x20.png",
Type = MenuItemType.Button,
// FilePath = path,
Command = this.ManageLayoutCommand
});
items.Add(new MenuItemModel
{
Header = "重置布局",
......@@ -167,6 +203,32 @@ namespace VIZ.Package.Module
Command = this.ResetLayoutCommand
});
items.Add(new MenuItemModel { Type = MenuItemType.Separator });
//读取文件中配置文件
if (Directory.Exists(path))
{
string[] files = Directory.GetFiles(path);
foreach (var file in files)
{
MenuItemModel menuItemModel = new MenuItemModel();
menuItemModel.Header = Path.GetFileNameWithoutExtension(file);
if (Convert.ToString(menuItemModel.Header) != "layout" && (Convert.ToString(menuItemModel.Header) != "default_layout"))
{
menuItemModel.Type = MenuItemType.Button;
menuItemModel.FilePath = file;
menuItemModel.Command = this.ImportLayoutCommand;
items.Add(menuItemModel);
}
}
}
this.ItemsSource = items.ToObservableCollection();
}
......@@ -331,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>
......@@ -409,12 +549,12 @@ namespace VIZ.Package.Module
/// <summary>
/// 重置布局命令
/// </summary>
public VCommand ResetLayoutCommand { get; set; }
public VCommand<string> ResetLayoutCommand { get; set; }
/// <summary>
/// 重置布局
/// </summary>
private void ResetLayout()
private void ResetLayout(string param)
{
IMainViewService service = ApplicationDomainEx.ServiceManager.GetService<IMainViewService>(ViewServiceKeys.MAIN_VIEW_SERVICE);
if (service == null)
......@@ -428,6 +568,91 @@ namespace VIZ.Package.Module
#endregion
#region ImportLayoutCommand --导入布局
public VCommand<string> ImportLayoutCommand { get; set; }
private void ImportLayout(string param)
{
IMainViewService service = ApplicationDomainEx.ServiceManager.GetService<IMainViewService>(ViewServiceKeys.MAIN_VIEW_SERVICE);
if (service == null)
return;
// 记录操作日志
this.recordLogService.AppendLog(ApplicationConstants.APPLICATION_GROUP_NAME, RecordLogOperate.Operate, RecordLogTrigger.Human, "导入布局");
service.ImportLayout(param);
}
/// <summary>
/// 获取布局文件路径
/// </summary>
/// <returns>布局文件路径</returns>
private string GetLayoutPath()
{
string path;
if (string.IsNullOrWhiteSpace(ApplicationDomainEx.VizConfig.PluginGroup))
{
path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "layout");
}
else
{
path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "layout", ApplicationDomainEx.VizConfig.PluginGroup);
}
return path;
}
#endregion
#region ExportLayoutCommand---导出布局
public VCommand<string> ExportLayoutCommand { get; set; }
private void ExportLayout(string param)
{
IMainViewService service = ApplicationDomainEx.ServiceManager.GetService<IMainViewService>(ViewServiceKeys.MAIN_VIEW_SERVICE);
if (service == null)
return;
// 记录操作日志
this.recordLogService.AppendLog(ApplicationConstants.APPLICATION_GROUP_NAME, RecordLogOperate.Operate, RecordLogTrigger.Human, "导出布局");
service.ExportLayout(param);
}
#endregion
#region ManageLayoutCommand---管理布局
public VCommand<string> ManageLayoutCommand { get; set; }
private void ManageLayout(string param)
{
ManagerLayoutView managerLayout = new ManagerLayoutView();
ManagerLayoutViewModel vm = managerLayout.DataContext as ManagerLayoutViewModel;
vm.ItemsSource = ItemsSource.Where(a => !string.IsNullOrEmpty(a.FilePath) && Convert.ToString(a.Header) != "保存布局").ToObservableCollection();
managerLayout.ShowDialog();
}
#endregion
#region AboutCommand -- 关于命令
/// <summary>
......
using Gma.System.MouseKeyHook;
using DevExpress.Xpf.Core;
using DevExpress.Xpf.Docking;
using Gma.System.MouseKeyHook;
using log4net;
using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Shapes;
using VIZ.Framework.Common;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
......@@ -309,5 +315,58 @@ namespace VIZ.Package.Module
}
}
// const string filter = "Configuration (*.xml)|*.xml|All files (*.*)|*.*";
/// <summary>
/// 导出窗口布局
/// </summary>
/// <param name="param"></param>
public void ExportLayout(string param)
{
MainView view = this.GetView<MainView>();
if (view == null)
return;
//SaveFileDialog saveFileDialog = new SaveFileDialog() { Filter = filter }; //RestoreLayoutFromXml
//var saveResult = saveFileDialog.ShowDialog();
//if (saveResult.HasValue && saveResult.Value)
// view.dockLayoutManager.SaveLayoutToXml(saveFileDialog.FileName);
SaveLayoutView saveLayout = new SaveLayoutView();
SaveLayoutViewModel vm = saveLayout.DataContext as SaveLayoutViewModel;
vm.TitleName = "保存窗口布局";
vm.view = view;
// string createPath = "";
//createPath = System.IO.Path.Combine(param, vm.FolderName + ".xml");
vm.createPath = param;
saveLayout.ShowDialog();
}
/// <summary>
/// 导入窗体布局
/// </summary>
/// <param name="param"></param>
public void ImportLayout(string param)
{
MainView view = this.GetView<MainView>();
if (view == null)
return;
if (File.Exists(param))
{
view.dockLayoutManager.RestoreLayoutFromXml(param);
}
}
}
}
using DevExpress.Xpf.Core;
using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Domain.Model;
using VIZ.Package.Service;
using VIZ.Package.Storage;
using static System.Net.WebRequestMethods;
using File = System.IO.File;
namespace VIZ.Package.Module
{
/// <summary>
/// 管理布局菜单实体类
/// </summary>
public class ManagerLayoutViewModel : ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private readonly static ILog log = LogManager.GetLogger(typeof(ManagerLayoutViewModel));
//获取topViewService服务
//IMainTopViewService service;
public ManagerLayoutViewModel()
{
//service = ApplicationDomainEx.ServiceManager.GetService<IMainTopViewService>(ViewServiceKeys.MAIN_TOPVIEW_SERVICE);
// itemsSource = service.ItemsSource.Where(a=> !string.IsNullOrEmpty(a.FilePath)).ToObservableCollection();
//初始化命令
this.ReNameCommand = new VCommand(this.ReName);
this.DeleteCommand = new VCommand(this.Delete);
this.CloseCommand = new VCommand(this.Close);
}
/// <summary>
/// 操作日志服务
/// </summary>
private RecordLogService recordLogService = new RecordLogService();
#region 视图集合
/// <summary>
/// 选中视图集合
/// </summary>
private MenuItemModel selectItem;
public MenuItemModel SelectItem
{
get { return selectItem; }
set { selectItem = value; this.RaisePropertyChanged(nameof(SelectItem)); }
}
/// <summary>
/// 视图项的集合
/// </summary>
private ObservableCollection<MenuItemModel> itemsSource;
/// <summary>
/// 视图项
/// </summary>
public ObservableCollection<MenuItemModel> ItemsSource
{
get { return itemsSource; }
set { itemsSource = value; this.RaisePropertyChanged(nameof(ItemsSource)); }
}
#endregion
#region Command 命令
/// <summary>
/// 重命名命令
/// </summary>
public VCommand ReNameCommand { get; set; }
private void ReName()
{
if (selectItem == null) return;
this.recordLogService.AppendLog(ApplicationConstants.APPLICATION_GROUP_NAME, RecordLogOperate.Operate, RecordLogTrigger.Human, "重命名布局");
SaveLayoutView saveLayout = new SaveLayoutView();
SaveLayoutViewModel vm = saveLayout.DataContext as SaveLayoutViewModel;
vm.TitleName = "重命名窗口布局";
vm.FolderName = SelectItem.Header.ToString();
vm.SelectItem = SelectItem;
vm.ItemsSource = ItemsSource;
saveLayout.ShowDialog();
}
/// <summary>
/// 删除命令
/// </summary>
public VCommand DeleteCommand { get; set; }
private void Delete()
{
if (SelectItem == null) return;
this.recordLogService.AppendLog(ApplicationConstants.APPLICATION_GROUP_NAME, RecordLogOperate.Operate, RecordLogTrigger.Human, "删除布局");
if (DXMessageBox.Show("是否替确定要删除布局 " + SelectItem.Header, "提示", System.Windows.MessageBoxButton.YesNo) == System.Windows.MessageBoxResult.Yes)
{
MenuItemModel tempSelectItem = SelectItem;
if (File.Exists(SelectItem.FilePath))
{
File.Delete(SelectItem.FilePath);
ItemsSource.Remove(SelectItem);
IMainTopViewService service = ApplicationDomainEx.ServiceManager.GetService<IMainTopViewService>(ViewServiceKeys.MAIN_TOPVIEW_SERVICE);
service.ItemsSource.Remove(tempSelectItem);
}
}
}
/// <summary>
/// 关闭命令
/// </summary>
public VCommand CloseCommand { get; set; }
private void Close()
{
ManagerLayoutView view = this.GetView<ManagerLayoutView>();
if (view == null)
return;
view.Close();
}
#endregion
}
}
using DevExpress.Xpf.Core;
using log4net;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Domain.Model;
namespace VIZ.Package.Module
{
public class SaveLayoutViewModel : ViewModelBase
{
/// <summary>
/// 日志
/// </summary>
private static readonly ILog log = LogManager.GetLogger(typeof(CreateFolderViewModel));
/// <summary>
/// 初始化
/// </summary>
public SaveLayoutViewModel()
{
EnterCommand = new VCommand(Enter);
CancelCommand = new VCommand(Cancel);
}
public MainView view { get; set; }
public string createPath { get; set; }
/// <summary>
/// 窗口布局名称
/// </summary>
private string titleName;
public string TitleName
{
get { return titleName; }
set { titleName = value; this.RaisePropertyChanged(nameof(TitleName)); }
}
private string folderName;
/// <summary>
/// 文件夹名称
/// </summary>
public string FolderName
{
get { return folderName; }
set { folderName = value; this.RaisePropertyChanged(nameof(FolderName)); }
}
private bool isEnter;
/// <summary>
/// 是否确定
/// </summary>
public bool IsEnter
{
get { return isEnter; }
set { isEnter = value; this.RaisePropertyChanged(nameof(IsEnter)); }
}
public VCommand EnterCommand { get; set; }
public VCommand CancelCommand { get; set; }
/// <summary>
/// 确定
/// </summary>
private void Enter()
{
if (string.IsNullOrWhiteSpace(this.FolderName))
{
DXMessageBox.Show("请输入文件名");
return;
}
//this.IsEnter = true;
//this.GetWindow()?.Close();
if (TitleName== "保存窗口布局")
{
SaveLayout();
}
else if(TitleName== "重命名窗口布局")
{
ReName();
}
}
private void SaveLayout()
{
createPath = System.IO.Path.Combine(createPath, FolderName + ".xml");
//判断此文件路径是否存在不存在就创建
string dir = System.IO.Path.GetDirectoryName(createPath);
if (!System.IO.Directory.Exists(dir))
{
System.IO.Directory.CreateDirectory(dir);
}
if (File.Exists(createPath))
{
if (DXMessageBox.Show("是否替换当前存在布局", "提示", System.Windows.MessageBoxButton.YesNo) == System.Windows.MessageBoxResult.Yes)
{
view.dockLayoutManager.SaveLayoutToXml(createPath);
this.GetWindow()?.Close();
}
}
else
{
view.dockLayoutManager.SaveLayoutToXml(createPath);
IMainTopViewService service = ApplicationDomainEx.ServiceManager.GetService<IMainTopViewService>(ViewServiceKeys.MAIN_TOPVIEW_SERVICE);
service.ItemsSource.Add(new Domain.Model.MenuItemModel()
{
Header = FolderName,
Type = MenuItemType.Button,
FilePath = createPath,
Command = service.ImportLayoutCommand
});
this.GetWindow()?.Close();
}
}
public MenuItemModel SelectItem { get; set; }
public ObservableCollection<MenuItemModel> ItemsSource { get; set; }
private void ReName()
{
if (File.Exists(SelectItem.FilePath))
{
IMainTopViewService service = ApplicationDomainEx.ServiceManager.GetService<IMainTopViewService>(ViewServiceKeys.MAIN_TOPVIEW_SERVICE);
MenuItemModel tempSelectItem = SelectItem;
//得到没有扩展的文件名称
string fileName = Path.GetFileNameWithoutExtension(SelectItem.FilePath);
//D:\Projects\VIZ.Package\VIZ.Package\bin\x64\Debug\layout\CBA\556.xml
int index = SelectItem.FilePath.LastIndexOf("\\"); //返回“//”最后一次出现的位置
string filepath = SelectItem.FilePath.Substring(0, index);
string newFilePath = filepath + "\\" + FolderName + ".xml";
if (File.Exists(newFilePath))
{
if (DXMessageBox.Show("是否替换当前存在布局", "提示", System.Windows.MessageBoxButton.YesNo) == System.Windows.MessageBoxResult.Yes)
{
File.Delete(newFilePath);
if (System.IO.File.Exists(SelectItem.FilePath))
{
FileInfo fi = new FileInfo(SelectItem.FilePath);
fi.MoveTo(newFilePath);
}
//文件管理页面对应的移除
ItemsSource.Remove(SelectItem);
//视频导航菜单移除
service.ItemsSource.Remove(tempSelectItem);
this.GetWindow()?.Close();
}
}
else
{
if (System.IO.File.Exists(SelectItem.FilePath))
{
FileInfo fi = new FileInfo(SelectItem.FilePath);
fi.MoveTo(newFilePath);
}
SelectItem.Header = FolderName;
SelectItem.FilePath = newFilePath;
this.GetWindow()?.Close();
}
}
}
/// <summary>
/// 取消
/// </summary>
private void Cancel()
{
this.IsEnter = false;
this.GetWindow()?.Close();
}
}
}
......@@ -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;
......
......@@ -51,6 +51,7 @@
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
</Grid.RowDefinitions>
<!-- Take -->
<TextBlock Text="Take:" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
......@@ -80,6 +81,13 @@
<TextBlock Text="打开并Take选中页:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="6"></TextBlock>
<fcommon:HotkeyBox Grid.Column="1" Height="30" Grid.Row="6" Margin="15,0,10,0"
Hotkey="{Binding Path=OpenAndTakeSelectedPage,Mode=TwoWay}"></fcommon:HotkeyBox>
<!--清屏快捷键-->
<TextBlock Text="清屏快捷键:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="7"/>
<fcommon:HotkeyBox Grid.Column="1" Height="30" Grid.Row="7" Margin="15,0,10,0"
Hotkey="{Binding Path=ClearSceen,Mode=TwoWay}"></fcommon:HotkeyBox>
</Grid>
</GroupBox>
<GroupBox Header="其他快捷键" Margin="10,5,10,10" Padding="5" Grid.Row="1">
......
......@@ -167,6 +167,29 @@ namespace VIZ.Package.Module
#endregion
#region ClearSceen --清屏快捷键
/// <summary>
/// 清屏快捷键
/// </summary>
public string clearSceen;
public string ClearSceen
{
get { return clearSceen; }
set
{
this.CheckHotkey(value);
clearSceen = value;
this.RaisePropertyChanged(nameof(ClearSceen));
}
}
#endregion
#region SaveOpendPageOrTemplateAndProject -- 保存当前打开的页或模板和项目
private string saveOpendPageOrTemplateAndProject;
......@@ -211,6 +234,7 @@ namespace VIZ.Package.Module
this.OpenNextPage = config.OpenNextPage;
this.TakeAndOpenNextPage = config.TakeAndOpenNextPage;
this.OpenAndTakeSelectedPage = config.OpenAndTakeSelectedPage;
this.ClearSceen = config.ClearSceen;
this.SaveOpendPageOrTemplateAndProject = config.SaveOpendPageOrTemplateAndProject;
}
......@@ -234,6 +258,7 @@ namespace VIZ.Package.Module
config.OpenNextPage = this.OpenNextPage;
config.TakeAndOpenNextPage = this.TakeAndOpenNextPage;
config.OpenAndTakeSelectedPage = this.OpenAndTakeSelectedPage;
config.ClearSceen = this.ClearSceen;
config.SaveOpendPageOrTemplateAndProject = this.SaveOpendPageOrTemplateAndProject;
ApplicationDomainEx.LocalDbContext.HotKeyConfig.Update(config);
......@@ -287,6 +312,10 @@ namespace VIZ.Package.Module
this.SaveOpendPageOrTemplateAndProject = string.Empty;
}
if(string.Equals(this.ClearSceen,key))
{
this.ClearSceen = string.Empty;
}
this.isInHotkeyCheck = false;
}
}
......
......@@ -156,6 +156,15 @@
<Compile Include="Log\ViewModel\VizCommandWindowModel.cs" />
<Compile Include="Main\Controller\HotkeyController.cs" />
<Compile Include="Main\Core\MainTopViewMenuDataTemplateSelector.cs" />
<Compile Include="Main\Service\IMainTopViewService.cs" />
<Compile Include="Main\ViewModel\ManagerLayoutViewModel.cs" />
<Compile Include="Main\ViewModel\SaveLayoutViewModel.cs" />
<Compile Include="Main\View\ManagerLayoutView.xaml.cs">
<DependentUpon>ManagerLayoutView.xaml</DependentUpon>
</Compile>
<Compile Include="Main\View\SaveLayoutView.xaml.cs">
<DependentUpon>SaveLayoutView.xaml</DependentUpon>
</Compile>
<Compile Include="PageCommand\Controller\PageCommandController.cs" />
<Compile Include="PageCommand\PageCommandLifeCycle.cs" />
<Compile Include="PageCommand\Service\IPageCommandService.cs" />
......@@ -503,6 +512,14 @@
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Main\View\ManagerLayoutView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Main\View\SaveLayoutView.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="PageCommand\View\PageCommandView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......
......@@ -610,5 +610,11 @@ namespace VIZ.Package.Service
conn.EndpointManager.Send($"RENDERER*MAIN_LAYER*TREE*${pageBase.LayerIdentifier}*FUNCTION*Toggle*continue INVOKE");
}
public void ClearSceen(ConnModel conn, VizLayer layer)
{
conn.EndpointManager.Send($"RENDERER*{layer} SET_OBJECT");
}
}
}
......@@ -74,6 +74,11 @@ namespace VIZ.Package.Storage
public string OpenAndTakeSelectedPage { get; set; } = "F11";
/// <summary>
/// 清屏快捷键
/// </summary>
public string ClearSceen { get; set; } = "F12";
/// <summary>
/// 保存当前打开的页或模板和项目
/// </summary>
public string SaveOpendPageOrTemplateAndProject { get; set; } = "Ctrl + S";
......
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