Commit 0cb7ff64 by liulongfei

快捷键实现

parent 7e06c328
......@@ -63,7 +63,7 @@ namespace VIZ.Package.Module
/// </summary>
private void Clear()
{
VizCommandWindow view = this.GetView<VizCommandWindow>();
ErrorLogWindow view = this.GetView<ErrorLogWindow>();
if (view == null)
return;
......
......@@ -41,10 +41,6 @@ namespace VIZ.Package.Module
WPFHelper.BeginInvoke(() =>
{
// 主视图未打开时不处理快捷键
if (!ApplicationDomainEx.MainWindow.IsActive)
return;
// 插件视图
FrameworkElement pluginView = this.GetPluginView();
......
......@@ -74,11 +74,8 @@ namespace VIZ.Package.Module
// 注册键盘钩子
this.KeyboardMouseEvents = Hook.AppEvents();
//this.KeyboardMouseEvents.KeyDown -= KeyboardMouseEvents_KeyDown;
//this.KeyboardMouseEvents.KeyDown += KeyboardMouseEvents_KeyDown;
this.KeyboardMouseEvents.KeyUp -= KeyboardMouseEvents_KeyUp;
this.KeyboardMouseEvents.KeyUp += KeyboardMouseEvents_KeyUp;
this.KeyboardMouseEvents.KeyDown -= KeyboardMouseEvents_KeyDown;
this.KeyboardMouseEvents.KeyDown += KeyboardMouseEvents_KeyDown;
}
// ============================================================
......@@ -298,7 +295,7 @@ namespace VIZ.Package.Module
/// <summary>
/// 键盘钩子事件
/// </summary>
private void KeyboardMouseEvents_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
private void KeyboardMouseEvents_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
try
{
......
......@@ -20,6 +20,10 @@
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="PreviewKeyDown" Command="{Binding Path=PreviewKeyDownCommand}" PassEventArgsToCommand="True"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
......@@ -306,7 +310,7 @@
ShowBandsPanel="False"
ShowTotalSummary="False"
ShowFixedTotalSummary="False"
ShowDragDropHint="False"
ShowDragDropHint="False" IsVisibleChanged="TableView_IsVisibleChanged"
ShowTargetInfoInDragDropHint="false">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="RowDoubleClick" Command="{Binding ElementName=uc, Path=DataContext.OpenPageCommand}"></dxmvvm:EventToCommand>
......@@ -329,14 +333,14 @@
Command="{Binding ElementName=uc,Path=DataContext.TakeInitCommand}"
Tag="{x:Static Member=common:GridControlHelper.KEEP_MENU_TAG}"/>
<dxb:BarItemLinkSeparator />
<dxb:BarButtonItem Name="CopyPage" Content="复制选中页"
<dxb:BarButtonItem Name="CopyPage" Content="复制选中页 ( Ctrl + C )"
Command="{Binding ElementName=uc,Path=DataContext.BeginCopyPageCommand}"
Tag="{x:Static Member=common:GridControlHelper.KEEP_MENU_TAG}"/>
<dxb:BarButtonItem Name="PastePage" Content="粘贴页"
<dxb:BarButtonItem Name="PastePage" Content="粘贴页 ( Ctrl + V )"
Command="{Binding ElementName=uc,Path=DataContext.PastePageCommand}"
Tag="{x:Static Member=common:GridControlHelper.KEEP_MENU_TAG}"/>
<dxb:BarItemLinkSeparator />
<dxb:BarButtonItem Name="DeleteItem" Content="删除选中页"
<dxb:BarButtonItem Name="DeleteItem" Content="删除选中页 ( Delete )"
Command="{Binding ElementName=uc,Path=DataContext.DeleteItemCommand}"
Tag="{x:Static Member=common:GridControlHelper.KEEP_MENU_TAG}"/>
......
......@@ -29,5 +29,21 @@ namespace VIZ.Package.Module
WPFHelper.BindingViewModel(this, new PageGroupViewModel());
}
/// <summary>
/// 当前可见的表视图
/// </summary>
public TableView CurrentIsVisibleTableView;
/// <summary>
/// 表视图可见性改变时触发
/// </summary>
private void TableView_IsVisibleChanged(object sender, DependencyPropertyChangedEventArgs e)
{
if ((bool)e.NewValue == true)
{
this.CurrentIsVisibleTableView = sender as TableView;
}
}
}
}
......@@ -17,6 +17,9 @@ using VIZ.Package.Common;
using VIZ.Package.Service;
using VIZ.Package.Storage;
using DevExpress.Xpf.Editors.Helpers;
using System.Windows.Input;
using VIZ.Framework.Common;
using System.Windows.Controls.Primitives;
namespace VIZ.Package.Module
{
......@@ -102,6 +105,7 @@ namespace VIZ.Package.Module
this.CopyPageGroupCommand = new VCommand(this.CopyPageGroup, this.CanCopyPageGroup);
this.BeginCopyPageCommand = new VCommand(this.BeginCopyPage, this.CanBeginCopyPage);
this.PastePageCommand = new VCommand(this.PastePage, this.CanPastePage);
this.PreviewKeyDownCommand = new VCommand<KeyEventArgs>(this.PreviewKeyDown);
}
/// <summary>
......@@ -718,6 +722,56 @@ namespace VIZ.Package.Module
#endregion
#region PreviewKeyDownCommand -- 按键按下命令
/// <summary>
/// 按键按下命令
/// </summary>
public VCommand<KeyEventArgs> PreviewKeyDownCommand { get; set; }
/// <summary>
/// 按键按下
/// </summary>
/// <param name="e">事件参数</param>
private void PreviewKeyDown(KeyEventArgs e)
{
try
{
TextBoxBase tb = e.OriginalSource as TextBoxBase;
if (tb != null)
return;
string key = HotkeyHelper.GetHotkey(e);
// 复制页
if (string.Equals(key, HotKeyConfigEntity.COPY))
{
this.BeginCopyPage();
return;
}
// 粘贴页
if (string.Equals(key, HotKeyConfigEntity.PASTE))
{
this.PastePage();
return;
}
// 删除页
if (string.Equals(key, HotKeyConfigEntity.DELETE))
{
this.DeleteItem();
return;
}
}
catch (Exception ex)
{
log.Error(ex);
}
}
#endregion
// ======================================================================================
// Message
// ======================================================================================
......@@ -834,17 +888,6 @@ namespace VIZ.Package.Module
this.OpenNextPageItem();
return;
}
// 只有当前激活视图为节目单视图时处理
PageGroupView view = this.GetView<PageGroupView>();
if (view == null || msg.View != view)
return;
// 删除页
if (string.Equals(msg.Key, ApplicationDomainEx.HotKeyConfig.DeletePageOrTemplate))
{
this.DeleteItem();
}
}
catch (Exception ex)
{
......@@ -982,11 +1025,17 @@ namespace VIZ.Package.Module
return;
++index;
if (index < this.SelectedPageGroupModel.Pages.Count)
{
if (this.SelectedPageGroupModel.Pages.Count <= index)
return;
this.SelectedPageGroupModel.SelectedPage = this.SelectedPageGroupModel.Pages[index];
this.OpenPage();
}
PageGroupView view = this.GetView<PageGroupView>();
if (view == null)
return;
view.CurrentIsVisibleTableView?.ScrollIntoView(this.SelectedPageGroupModel.SelectedPage);
}
// ======================================================================================
......
......@@ -18,6 +18,11 @@
d:DataContext="{d:DesignInstance Type=local:PageTemplateViewModel}"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<dxmvvm:Interaction.Behaviors>
<dxmvvm:EventToCommand EventName="PreviewKeyDown" Command="{Binding Path=PreviewKeyDownCommand}" PassEventArgsToCommand="True"></dxmvvm:EventToCommand>
</dxmvvm:Interaction.Behaviors>
<UserControl.Resources>
<ResourceDictionary>
<resource:RowHandleConverter x:Key="RowHandleConverter"></resource:RowHandleConverter>
......@@ -31,7 +36,7 @@
<Grid IsEnabled="{Binding Path=IsEnabled}" Margin="0,10,0,10">
<dxg:GridControl ItemsSource="{Binding Path=SceneTemplateModels}" ShowBorder="False" SelectionMode="Row"
SelectedItem="{Binding Path=SelectedSceneTemplateModel}"
SelectedItem="{Binding Path=SelectedSceneTemplateModel}" x:Name="t"
SelectedItems="{Binding Path=SelectedSceneTemplateModels}">
<dxg:GridControl.ContextMenu>
<ContextMenu>
......@@ -40,7 +45,7 @@
<MenuItem Header="添加至节目单" Command="{Binding Path=PlacementTarget.DataContext.AddToPageGroupCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="更新模板" Command="{Binding Path=PlacementTarget.DataContext.UpdateCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<Separator></Separator>
<MenuItem Header="删除模板" Command="{Binding Path=PlacementTarget.DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
<MenuItem Header="删除模板 ( Delete )" Command="{Binding Path=PlacementTarget.DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ContextMenu}}"/>
</ContextMenu>
</dxg:GridControl.ContextMenu>
<dxg:GridControl.Columns>
......
......@@ -10,7 +10,9 @@ using System.Threading.Tasks;
using System.Web.UI;
using System.Windows;
using System.Windows.Controls.Primitives;
using System.Windows.Input;
using System.Windows.Media.Animation;
using VIZ.Framework.Common;
using VIZ.Framework.Core;
using VIZ.Package.Domain;
using VIZ.Package.Service;
......@@ -49,6 +51,7 @@ namespace VIZ.Package.Module
this.OpenScenePageCommand = new VCommand(this.OpenScenePage);
this.UpdateCommand = new VCommand(this.Update);
this.DeleteCommand = new VCommand(this.Delete);
this.PreviewKeyDownCommand = new VCommand<KeyEventArgs>(this.PreviewKeyDown);
}
/// <summary>
......@@ -56,7 +59,6 @@ namespace VIZ.Package.Module
/// </summary>
private void InitMessage()
{
ApplicationDomainEx.MessageManager.Register<HotkeyMessage>(this, this.OnHotkeyMessage);
ApplicationDomainEx.MessageManager.Register<ProjectOpenMessage>(this, this.OnProjectOpenMessage);
ApplicationDomainEx.MessageManager.Register<ProjectCloseMessage>(this, this.OnProjectCloseMessage);
ApplicationDomainEx.MessageManager.Register<ProjectSaveMessage>(this, this.OnProjectSaveMessage);
......@@ -306,6 +308,42 @@ namespace VIZ.Package.Module
#endregion
#region PreviewKeyDownCommand -- 按键按下命令
/// <summary>
/// 按键按下命令
/// </summary>
public VCommand<KeyEventArgs> PreviewKeyDownCommand { get; set; }
/// <summary>
/// 按键按下
/// </summary>
/// <param name="e">事件参数</param>
private void PreviewKeyDown(KeyEventArgs e)
{
try
{
TextBoxBase tb = e.OriginalSource as TextBoxBase;
if (tb != null)
return;
string key = HotkeyHelper.GetHotkey(e);
// 删除模板
if (string.Equals(key, HotKeyConfigEntity.DELETE))
{
this.Delete();
return;
}
}
catch (Exception ex)
{
log.Error(ex);
}
}
#endregion
// ======================================================================================
// Message
// ======================================================================================
......@@ -358,32 +396,6 @@ namespace VIZ.Package.Module
this.pageService.SavePageTemplates(this.SceneTemplateModels);
}
/// <summary>
/// 处理热键消息
/// </summary>
/// <param name="msg">消息</param>
private void OnHotkeyMessage(HotkeyMessage msg)
{
try
{
// 只有当前激活视图是模板页时处理
PageTemplateView view = this.GetView<PageTemplateView>();
if (msg.View == null || msg.View != view)
return;
// 删除
if (string.Equals(msg.Key, ApplicationDomainEx.HotKeyConfig.DeletePageOrTemplate))
{
this.Delete();
return;
}
}
catch (Exception ex)
{
log.Error(ex);
}
}
// ======================================================================================
// Public Function
// ======================================================================================
......
......@@ -80,16 +80,10 @@
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
<RowDefinition Height="40"></RowDefinition>
</Grid.RowDefinitions>
<!-- 删除当前选择的页 -->
<TextBlock Text="删除当前选择的页:" VerticalAlignment="Center" HorizontalAlignment="Right"></TextBlock>
<fcommon:HotkeyBox IsEnabled="False" Grid.Column="1" Height="30" Margin="15,0,10,0"
Hotkey="{Binding Path=DeletePageOrTemplate,Mode=TwoWay}"></fcommon:HotkeyBox>
<!-- 保存当前打开的页及项目 -->
<TextBlock Text="保存当前打开的页及项目:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="1"></TextBlock>
<fcommon:HotkeyBox IsEnabled="False" Grid.Column="1" Height="30" Grid.Row="1" Margin="15,0,10,0"
<TextBlock Text="保存当前打开的页及项目:" VerticalAlignment="Center" HorizontalAlignment="Right" Grid.Row="0"></TextBlock>
<fcommon:HotkeyBox IsEnabled="False" Grid.Column="1" Height="30" Grid.Row="0" Margin="15,0,10,0"
Hotkey="{Binding Path=SaveOpendPageOrTemplateAndProject,Mode=TwoWay}"></fcommon:HotkeyBox>
</Grid>
</GroupBox>
......
......@@ -139,25 +139,6 @@ namespace VIZ.Package.Module
#endregion
#region DeletePageOrTemplate -- 删除当前选中的页或模板
private string deletePageOrTemplate;
/// <summary>
/// 删除当前选中的页或模板
/// </summary>
public string DeletePageOrTemplate
{
get { return deletePageOrTemplate; }
set
{
this.CheckHotkey(value);
deletePageOrTemplate = value;
this.RaisePropertyChanged(nameof(DeletePageOrTemplate));
}
}
#endregion
#region SaveOpendPageOrTemplateAndProject -- 保存当前打开的页或模板和项目
private string saveOpendPageOrTemplateAndProject;
......@@ -200,7 +181,6 @@ namespace VIZ.Package.Module
this.TakeOut = config.TakeOut;
this.TakeUpdate = config.TakeUpdate;
this.OpenNextPage = config.OpenNextPage;
this.DeletePageOrTemplate = config.DeletePageOrTemplate;
this.SaveOpendPageOrTemplateAndProject = config.SaveOpendPageOrTemplateAndProject;
}
......@@ -222,7 +202,6 @@ namespace VIZ.Package.Module
config.TakeOut = this.TakeOut;
config.TakeUpdate = this.TakeUpdate;
config.OpenNextPage = this.OpenNextPage;
config.DeletePageOrTemplate = this.DeletePageOrTemplate;
config.SaveOpendPageOrTemplateAndProject = this.SaveOpendPageOrTemplateAndProject;
ApplicationDomainEx.LocalDbContext.HotKeyConfig.Update(config);
......@@ -263,10 +242,6 @@ namespace VIZ.Package.Module
{
this.OpenNextPage = string.Empty;
}
if (string.Equals(this.DeletePageOrTemplate, key))
{
this.DeletePageOrTemplate = string.Empty;
}
if (string.Equals(this.SaveOpendPageOrTemplateAndProject, key))
{
this.SaveOpendPageOrTemplateAndProject = string.Empty;
......
......@@ -13,6 +13,26 @@ namespace VIZ.Package.Storage
public class HotKeyConfigEntity
{
/// <summary>
/// 拷贝
/// </summary>
public const string COPY = "Ctrl + C";
/// <summary>
/// 剪切
/// </summary>
public const string CUT = "Ctrl + X";
/// <summary>
/// 粘贴
/// </summary>
public const string PASTE = "Ctrl + V";
/// <summary>
/// 删除
/// </summary>
public const string DELETE = "Delete";
/// <summary>
/// 编号
/// </summary>
[BsonId(true)]
......@@ -44,11 +64,6 @@ namespace VIZ.Package.Storage
public string OpenNextPage { get; set; } = "F9";
/// <summary>
/// 删除当前选中的页或模板
/// </summary>
public string DeletePageOrTemplate { get; set; } = "Delete";
/// <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