Commit d9a15b44 by liulongfei

1. 热键设置

2. 模式切换热键支持
parent 352f4242
......@@ -30,5 +30,10 @@ namespace VIZ.H2V.Domain
/// CAM 4
/// </summary>
public const string CAM_4 = "CAM_4";
/// <summary>
/// 主视图
/// </summary>
public const string MainView = "MainView";
}
}
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:common="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common">
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/VIZ.H2V.Module.Resource;component/Style/TextBox/TextBox_Setting.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
<Style x:Key="HotkeyBox_Setting" TargetType="{x:Type common:HotkeyBox}">
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type common:HotkeyBox}">
<Border x:Name="border">
<TextBox x:Name="PART_TextBox" IsReadOnly="True" AcceptsReturn="False" TextWrapping="NoWrap" VerticalContentAlignment="Center"
Text="{TemplateBinding Hotkey}" Style="{StaticResource TextBox_Setting}"></TextBox>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Opacity" TargetName="border" Value="0.56"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</ResourceDictionary>
\ No newline at end of file
......@@ -82,6 +82,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style\HotkeyBox\HotkeyBox_Setting.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Style\RadioButton\RadioButton_NdiView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -155,6 +159,10 @@
<Resource Include="Icons\setting-32x32l.png" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\VIZ.Framework\VIZ.Framework.Common\VIZ.Framework.Common.csproj">
<Project>{92834c05-703e-4f05-9224-f36220939d8f}</Project>
<Name>VIZ.Framework.Common</Name>
</ProjectReference>
<ProjectReference Include="..\VIZ.H2V.Domain\VIZ.H2V.Domain.csproj">
<Project>{3C61290E-D9C3-4F00-83CB-AE5F64C3298C}</Project>
<Name>VIZ.H2V.Domain</Name>
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.H2V.Module;
using VIZ.H2V.Domain;
using VIZ.H2V.Storage;
namespace VIZ.H2V.Module
{
/// <summary>
/// 热键控制器
/// </summary>
public class HotkeyController
{
/// <summary>
/// 热键控制器
/// </summary>
/// <param name="support">支持</param>
public HotkeyController(IHotkeySupport support)
{
this.Support = support;
}
/// <summary>
/// 支持
/// </summary>
public IHotkeySupport Support { get; private set; }
/// <summary>
/// 执行
/// </summary>
/// <param name="hotkey">热键</param>
public void Execute(string hotkey)
{
if (string.IsNullOrWhiteSpace(hotkey))
return;
// 自动裁切
if (this.ExecuteAuto(hotkey))
return;
// 居中裁切
if (this.ExecuteCenter(hotkey))
return;
// 手动裁切
if (this.ExecuteManual(hotkey))
return;
}
/// <summary>
/// 处理自动裁切
/// </summary>
/// <param name="hotkey">热键</param>
/// <returns>是否完成处理</returns>
private bool ExecuteAuto(string hotkey)
{
INDIViewService service = null;
if (string.Equals(this.Support.HotkeyConfig.AutoCAM1, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_1);
}
if (string.Equals(this.Support.HotkeyConfig.AutoCAM2, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_2);
}
if (string.Equals(this.Support.HotkeyConfig.AutoCAM3, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_3);
}
if (string.Equals(this.Support.HotkeyConfig.AutoCAM4, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_4);
}
if (service == null)
return false;
ChangeStrategyContext context = new ChangeStrategyContext();
context.Mode = AlgorithmStrategyMode.auto_mode;
context.IsNeedRestart = false;
context.TriggerScene = NDIViewScene.Hotkey;
service.ChangeStrategyMode(context);
return true;
}
/// <summary>
/// 处理居中裁切
/// </summary>
/// <param name="hotkey">热键</param>
/// <returns>是否处理完成</returns>
private bool ExecuteCenter(string hotkey)
{
INDIViewService service = null;
if (string.Equals(this.Support.HotkeyConfig.CenterCAM1, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_1);
}
if (string.Equals(this.Support.HotkeyConfig.CenterCAM2, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_2);
}
if (string.Equals(this.Support.HotkeyConfig.CenterCAM3, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_3);
}
if (string.Equals(this.Support.HotkeyConfig.CenterCAM4, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_4);
}
if (service == null)
return false;
ChangeStrategyContext context = new ChangeStrategyContext();
context.Mode = AlgorithmStrategyMode.center_mode;
context.IsNeedRestart = false;
context.TriggerScene = NDIViewScene.Hotkey;
service.ChangeStrategyMode(context);
return true;
}
/// <summary>
/// 处理手动裁切
/// </summary>
/// <param name="hotkey">热键</param>
/// <returns>是否处理完成</returns>
private bool ExecuteManual(string hotkey)
{
// Step 1. 先将当前手动模式的视图切换为自动模式
ApplicationDomainEx.ServiceManager.GetServiceList<INDIViewService>()
.Where(p => p.StrategyMode == AlgorithmStrategyMode.manual_mode)
.ToList()
.ForEach(p =>
{
ChangeStrategyContext cxt = new ChangeStrategyContext();
cxt.Mode = AlgorithmStrategyMode.auto_mode;
cxt.IsNeedRestart = false;
cxt.TriggerScene = NDIViewScene.Hotkey;
p.ChangeStrategyMode(cxt);
});
// Step 2. 将目标视图切换为手动模式
INDIViewService service = null;
if (string.Equals(this.Support.HotkeyConfig.ManualCAM1, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_1);
}
if (string.Equals(this.Support.HotkeyConfig.ManualCAM2, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_2);
}
if (string.Equals(this.Support.HotkeyConfig.ManualCAM3, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_3);
}
if (string.Equals(this.Support.HotkeyConfig.ManualCAM4, hotkey))
{
service = ApplicationDomainEx.ServiceManager.GetService<INDIViewService>(NDIViewKeys.CAM_4);
}
if (service == null)
return false;
ChangeStrategyContext context = new ChangeStrategyContext();
context.Mode = AlgorithmStrategyMode.manual_mode;
context.IsNeedRestart = false;
context.TriggerScene = NDIViewScene.Hotkey;
service.ChangeStrategyMode(context);
return true;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.H2V.Storage;
namespace VIZ.H2V.Module
{
/// <summary>
/// 热键支持
/// </summary>
public interface IHotkeySupport
{
/// <summary>
/// 热键配置
/// </summary>
HotkeyConfig HotkeyConfig { get; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.H2V.Storage;
namespace VIZ.H2V.Module
{
/// <summary>
/// 主视图服务
/// </summary>
public interface INDIMainViewService : IService
{
/// <summary>
/// 热键配置
/// </summary>
HotkeyConfig HotkeyConfig { get; set; }
}
}
......@@ -20,6 +20,12 @@
</ResourceDictionary>
</UserControl.Resources>
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="Loaded">
<behaviors:InvokeCommandAction Command="{Binding LoadedCommand}" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
......@@ -27,6 +33,7 @@
<RowDefinition Height="50"></RowDefinition>
</Grid.RowDefinitions>
<!-- 顶部 -->
<TextBox x:Name="tbFocus" Visibility="Collapsed"></TextBox>
<Grid Background="#ff12202d">
<TextBlock Text="AI横转竖智能裁切系统" FontSize="18" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
<StackPanel Orientation="Horizontal" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Top">
......
......@@ -8,14 +8,17 @@ using System.Windows.Input;
using VIZ.Framework.Common;
using VIZ.Framework.Core;
using VIZ.Framework.Domain;
using VIZ.H2V.Storage;
using VIZ.H2V.Domain;
using System.Diagnostics;
using Gma.System.MouseKeyHook;
namespace VIZ.H2V.Module
{
/// <summary>
/// NDI主视图模型
/// </summary>
public class NDIMainViewModel : ViewModelBase
public class NDIMainViewModel : ViewModelBase, INDIMainViewService, IHotkeySupport
{
/// <summary>
/// NDI主视图模型
......@@ -31,10 +34,18 @@ namespace VIZ.H2V.Module
// 初始化属性
this.InitProperty();
// 初始化控制器
this.InitController();
// 初始化鼠标键盘钩子
this.InitKeyboardMouseEvents();
// 注册系统检测循环
ApplicationDomainEx.LoopManager.Register("NDIMainViewModel.UpdateSystemMonitor", 1, this.UpdateSystemMonitor);
}
// 注册服务
ApplicationDomainEx.ServiceManager.AddService(NDIViewKeys.MainView, this);
}
/// <summary>
/// 初始化命令
......@@ -45,6 +56,7 @@ namespace VIZ.H2V.Module
this.MinCommand = new VCommand(this.Min);
this.CloseCommand = new VCommand(this.Close);
this.SettingCommand = new VCommand(this.Setting);
this.KeyDownCommand = new VCommand<KeyEventArgs>(this.KeyDown);
}
/// <summary>
......@@ -63,10 +75,58 @@ namespace VIZ.H2V.Module
}
/// <summary>
/// 初始化热键控制器
/// </summary>
private void InitController()
{
this.hotkeyController = new HotkeyController(this);
}
/// <summary>
/// 初始化鼠标键盘钩子
/// </summary>
private void InitKeyboardMouseEvents()
{
// 注册键盘钩子
this.globalHook = Hook.GlobalEvents();
this.globalHook.KeyDown -= GlobalHook_KeyDown;
this.globalHook.KeyDown += GlobalHook_KeyDown;
}
// ======================================================================================
// === Field ===
// ======================================================================================
/// <summary>
/// 全局鼠标键盘钩子
/// </summary>
private IKeyboardMouseEvents globalHook;
/// <summary>
/// 热键控制器
/// </summary>
private HotkeyController hotkeyController;
// ======================================================================================
// === Property ===
// ======================================================================================
#region HotkeyConfig -- 热键配置
private HotkeyConfig hotkeyConfig;
/// <summary>
/// 热键配置
/// </summary>
public HotkeyConfig HotkeyConfig
{
get { return hotkeyConfig; }
set { hotkeyConfig = value; this.RaisePropertyChanged(nameof(HotkeyConfig)); }
}
#endregion
#region SystemMonitorModel -- 系统监控模型
private SystemMonitorModel systemMonitorModel = new SystemMonitorModel();
......@@ -93,11 +153,11 @@ namespace VIZ.H2V.Module
public VCommand LoadedCommand { get; set; }
/// <summary>
///
/// 加载
/// </summary>
private void Loaded()
{
this.HotkeyConfig = ApplicationDomainEx.LiteDbContext.HotkeyConfig.FindAll().FirstOrDefault();
}
#endregion
......@@ -161,6 +221,26 @@ namespace VIZ.H2V.Module
#endregion
#region KeyDownCommand -- 按键命令
/// <summary>
/// 按键命令
/// </summary>
public VCommand<KeyEventArgs> KeyDownCommand { get; set; }
/// <summary>
/// 按键
/// </summary>
/// <param name="e">按键事件</param>
private void KeyDown(KeyEventArgs e)
{
string hotkey = HotkeyHelper.GetHotkey(e);
Debug.WriteLine(hotkey);
}
#endregion
// ======================================================================================
// === Privatee Function ===
// ======================================================================================
......@@ -197,5 +277,25 @@ namespace VIZ.H2V.Module
}
});
}
/// <summary>
/// 按键时触发
/// </summary>
private void GlobalHook_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (this.hotkeyController == null)
return;
Window window = Window.GetWindow(this.GetView<NDIMainView>());
if (window == null)
return;
if (!window.IsActive)
return;
string hotkey = HotkeyHelper.GetHotkey(e);
this.hotkeyController.Execute(hotkey);
}
}
}
......@@ -18,6 +18,10 @@ namespace VIZ.H2V.Module
/// <summary>
/// 设置面板
/// </summary>
SettingPanel
SettingPanel,
/// <summary>
/// 热键
/// </summary>
Hotkey
}
}
......@@ -4,6 +4,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
using VIZ.Framework.Core;
using VIZ.H2V.Domain;
using VIZ.H2V.Storage;
namespace VIZ.H2V.Module
......@@ -29,11 +30,21 @@ namespace VIZ.H2V.Module
AlgorithmStrategyType StrategyType { get; set; }
/// <summary>
/// 剪切策略
/// </summary>
AlgorithmStrategyMode StrategyMode { get; }
/// <summary>
/// 视图配置
/// </summary>
NdiViewConfig ViewConfig { get; }
/// <summary>
/// NDI视图状态
/// </summary>
NDIViewStatus ViewStatus { get; }
/// <summary>
/// 加载样式
/// </summary>
void LoadStyle();
......
......@@ -114,30 +114,8 @@ namespace VIZ.H2V.Module
/// </summary>
private void Loaded_InitModeChecked()
{
// 更新是否使用裁切
this.isUseClip = this.ViewConfig.IsUseClip;
this.RaisePropertyChanged(nameof(IsUseClip));
// 更新当前模式
switch (this.ViewConfig.StrategyMode)
{
case AlgorithmStrategyMode.center_mode:
this.isCenterModeChecked = true;
this.RaisePropertyChanged(nameof(IsCenterModeChecked));
break;
case AlgorithmStrategyMode.manual_mode:
this.isManualModeChecked = true;
this.RaisePropertyChanged(nameof(IsManualModeChecked));
break;
case AlgorithmStrategyMode.auto_mode:
this.isAutoModeChecked = true;
this.RaisePropertyChanged(nameof(IsAutoModeChecked));
break;
default:
this.isAutoModeChecked = true;
this.RaisePropertyChanged(nameof(IsAutoModeChecked));
break;
}
// 跟下模式属性
this.UpdateModeProperty();
// 重启算法
this.AlgorithmControllerDic[this.StrategyType].RestartAlgorithm();
......
......@@ -111,6 +111,9 @@ namespace VIZ.H2V.Module
this.ViewConfig.IsUseClip = this.IsUseClip;
ApplicationDomainEx.LiteDbContext.ViewConfig.Update(this.ViewConfig);
// 更新模式属性
this.UpdateModeProperty();
// ----------------------------------------------------------------------------------------------
// Step 2. 清理界面状态 & 发送手动裁切消息
// ----------------------------------------------------------------------------------------------
......@@ -208,11 +211,6 @@ namespace VIZ.H2V.Module
public void LoadStyle()
{
SystemConfig config = ApplicationDomainEx.LiteDbContext.SystemConfig.FindAll().FirstOrDefault();
if (config == null)
{
config = new SystemConfig();
ApplicationDomainEx.LiteDbContext.SystemConfig.Upsert(config);
}
this.ClipBoxStrokeColor_Normal = SharpDxColorHelper.FromString(config.ClipNormalColor);
this.ClipBoxStrokeColor_Exception = SharpDxColorHelper.FromString(config.ClipExceptionColor);
......@@ -226,5 +224,36 @@ namespace VIZ.H2V.Module
{
this.AlgorithmControllerDic[this.StrategyType].StopAlgorithm();
}
/// <summary>
/// 加载 -- 更新模式属性
/// </summary>
private void UpdateModeProperty()
{
// 更新是否使用裁切
this.isUseClip = this.ViewConfig.IsUseClip;
this.RaisePropertyChanged(nameof(IsUseClip));
// 更新当前模式
switch (this.ViewConfig.StrategyMode)
{
case AlgorithmStrategyMode.center_mode:
this.isCenterModeChecked = true;
this.RaisePropertyChanged(nameof(IsCenterModeChecked));
break;
case AlgorithmStrategyMode.manual_mode:
this.isManualModeChecked = true;
this.RaisePropertyChanged(nameof(IsManualModeChecked));
break;
case AlgorithmStrategyMode.auto_mode:
this.isAutoModeChecked = true;
this.RaisePropertyChanged(nameof(IsAutoModeChecked));
break;
default:
this.isAutoModeChecked = true;
this.RaisePropertyChanged(nameof(IsAutoModeChecked));
break;
}
}
}
}
......@@ -44,6 +44,7 @@ namespace VIZ.H2V.Module
ApplicationDomainEx.LiteDbContext = new Storage.LiteDbContext(path);
this.InitSystem();
this.InitHotkey();
this.InitData(NDIViewKeys.CAM_1);
this.InitData(NDIViewKeys.CAM_2);
......@@ -137,12 +138,24 @@ namespace VIZ.H2V.Module
private void InitSystem()
{
SystemConfig config = ApplicationDomainEx.LiteDbContext.SystemConfig.FindAll().FirstOrDefault();
if (config != null)
return;
config = new SystemConfig();
ApplicationDomainEx.LiteDbContext.SystemConfig.Upsert(config);
}
/// <summary>
/// 初始化热键配置
/// </summary>
private void InitHotkey()
{
HotkeyConfig config = ApplicationDomainEx.LiteDbContext.HotkeyConfig.FindAll().FirstOrDefault();
if (config != null)
return;
config = new HotkeyConfig();
ApplicationDomainEx.LiteDbContext.HotkeyConfig.Upsert(config);
}
}
}
<UserControl x:Class="VIZ.H2V.Module.HotkeySettingPanelView"
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.H2V.Module"
xmlns:fcommon="clr-namespace:VIZ.Framework.Common;assembly=VIZ.Framework.Common"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
d:DataContext="{d:DesignInstance Type=local:HotkeySettingPanelViewModel}"
mc:Ignorable="d"
d:DesignHeight="800" d:DesignWidth="800">
<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/VIZ.H2V.Module.Resource;component/Style/HotkeyBox/HotkeyBox_Setting.xaml"></ResourceDictionary>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="Loaded">
<behaviors:InvokeCommandAction Command="{Binding LoadedCommand}" />
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
<Border>
<Grid Margin="45,60,40,0">
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="120"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="120"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="120"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
<!-- 算法裁切热键 -->
<TextBlock Text="算法裁切热键" Foreground="White" FontSize="20" VerticalAlignment="Center"></TextBlock>
<Rectangle Height="1" VerticalAlignment="Bottom" Fill="#ff3d4758"></Rectangle>
<Grid Grid.Row="1">
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- CAM 1 -->
<TextBlock Text="CAM 1" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="0"></TextBlock>
<fcommon:HotkeyBox Grid.Column="1" Hotkey="{Binding Path=AutoCAM1,Mode=TwoWay}" Height="30"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
<!-- CAM 2 -->
<TextBlock Text="CAM 2" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="0" Grid.Column="2"></TextBlock>
<fcommon:HotkeyBox Grid.Column="3" Hotkey="{Binding Path=AutoCAM2,Mode=TwoWay}" Height="30" Grid.Row="0"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
<!-- CAM 3 -->
<TextBlock Text="CAM 3" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="1"></TextBlock>
<fcommon:HotkeyBox Grid.Column="1" Hotkey="{Binding Path=AutoCAM3,Mode=TwoWay}" Height="30" Grid.Row="1"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
<!-- CAM 4 -->
<TextBlock Text="CAM 4" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="1" Grid.Column="2"></TextBlock>
<fcommon:HotkeyBox Grid.Column="3" Hotkey="{Binding Path=AutoCAM4,Mode=TwoWay}" Height="30" Grid.Row="1"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
</Grid>
<!-- 居中裁切热键 -->
<TextBlock Text="居中裁切热键" Foreground="White" FontSize="20" VerticalAlignment="Center" Grid.Row="2"></TextBlock>
<Rectangle Grid.Row="2" VerticalAlignment="Bottom" Height="2" Fill="#ff364051"></Rectangle>
<Grid Grid.Row="3">
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- CAM 1 -->
<TextBlock Text="CAM 1" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="0"></TextBlock>
<fcommon:HotkeyBox Grid.Column="1" Hotkey="{Binding Path=CenterCAM1,Mode=TwoWay}" Height="30"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
<!-- CAM 2 -->
<TextBlock Text="CAM 2" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="0" Grid.Column="2"></TextBlock>
<fcommon:HotkeyBox Grid.Column="3" Hotkey="{Binding Path=CenterCAM2,Mode=TwoWay}" Height="30" Grid.Row="0"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
<!-- CAM 3 -->
<TextBlock Text="CAM 3" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="1"></TextBlock>
<fcommon:HotkeyBox Grid.Column="1" Hotkey="{Binding Path=CenterCAM3,Mode=TwoWay}" Height="30" Grid.Row="1"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
<!-- CAM 4 -->
<TextBlock Text="CAM 4" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="1" Grid.Column="2"></TextBlock>
<fcommon:HotkeyBox Grid.Column="3" Hotkey="{Binding Path=CenterCAM4,Mode=TwoWay}" Height="30" Grid.Row="1"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
</Grid>
<!-- 手动裁切热键 -->
<TextBlock Text="手动裁切热键" Foreground="White" FontSize="20" VerticalAlignment="Center" Grid.Row="4"></TextBlock>
<Rectangle Grid.Row="4" VerticalAlignment="Bottom" Height="2" Fill="#ff364051"></Rectangle>
<Grid Grid.Row="5">
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
<ColumnDefinition Width="120"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<!-- CAM 1 -->
<TextBlock Text="CAM 1" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="0"></TextBlock>
<fcommon:HotkeyBox Grid.Column="1" Hotkey="{Binding Path=ManualCAM1,Mode=TwoWay}" Height="30"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
<!-- CAM 2 -->
<TextBlock Text="CAM 2" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="0" Grid.Column="2"></TextBlock>
<fcommon:HotkeyBox Grid.Column="3" Hotkey="{Binding Path=ManualCAM2,Mode=TwoWay}" Height="30" Grid.Row="0"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
<!-- CAM 3 -->
<TextBlock Text="CAM 3" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="1"></TextBlock>
<fcommon:HotkeyBox Grid.Column="1" Hotkey="{Binding Path=ManualCAM3,Mode=TwoWay}" Height="30" Grid.Row="1"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
<!-- CAM 4 -->
<TextBlock Text="CAM 4" Foreground="White" FontSize="18" VerticalAlignment="Center" Grid.Row="1" Grid.Column="2"></TextBlock>
<fcommon:HotkeyBox Grid.Column="3" Hotkey="{Binding Path=ManualCAM4,Mode=TwoWay}" Height="30" Grid.Row="1"
Style="{StaticResource HotkeyBox_Setting}" Margin="0,0,20,0"></fcommon:HotkeyBox>
</Grid>
</Grid>
</Border>
</UserControl>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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.Navigation;
using System.Windows.Shapes;
using VIZ.Framework.Core;
namespace VIZ.H2V.Module
{
/// <summary>
/// HotkeySettingPanelView.xaml 的交互逻辑
/// </summary>
public partial class HotkeySettingPanelView : UserControl
{
public HotkeySettingPanelView()
{
InitializeComponent();
WPFHelper.BindingViewModel(this, new HotkeySettingPanelViewModel());
}
}
}
......@@ -43,6 +43,8 @@
<StackPanel Grid.Row="1" Grid.RowSpan="2">
<RadioButton Content="个性化" Height="50" Foreground="White" FontSize="24" VerticalContentAlignment="Center"
x:Name="rbStyle" Style="{StaticResource RadioButton_Setting}" IsChecked="True"></RadioButton>
<RadioButton Content="热键" Height="50" Foreground="White" FontSize="24" VerticalContentAlignment="Center"
x:Name="rbHotkey" Style="{StaticResource RadioButton_Setting}"></RadioButton>
<RadioButton Content="关于" Height="50" Foreground="White" FontSize="24" VerticalContentAlignment="Center"
x:Name="rbAbout" Style="{StaticResource RadioButton_Setting}"></RadioButton>
</StackPanel>
......@@ -53,6 +55,8 @@
<fcommon:NavigationControl Grid.Row="0" Grid.RowSpan="2" Grid.Column="1">
<fcommon:NavigationItemControl ViewType="{x:Type local:StyleSettingPanelView}"
IsSelected="{Binding ElementName=rbStyle,Path=IsChecked,Mode=OneWay}"></fcommon:NavigationItemControl>
<fcommon:NavigationItemControl ViewType="{x:Type local:HotkeySettingPanelView}"
IsSelected="{Binding ElementName=rbHotkey,Path=IsChecked,Mode=OneWay}"></fcommon:NavigationItemControl>
<fcommon:NavigationItemControl ViewType="{x:Type local:AboutPanelView}"
IsSelected="{Binding ElementName=rbAbout,Path=IsChecked,Mode=OneWay}"></fcommon:NavigationItemControl>
</fcommon:NavigationControl>
......
......@@ -50,6 +50,9 @@
<ErrorReport>prompt</ErrorReport>
</PropertyGroup>
<ItemGroup>
<Reference Include="Gma.System.MouseKeyHook, Version=5.6.130.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\MouseKeyHook.5.6.0\lib\net40\Gma.System.MouseKeyHook.dll</HintPath>
</Reference>
<Reference Include="LiteDB, Version=5.0.12.0, Culture=neutral, PublicKeyToken=4ee40123013c9f27, processorArchitecture=MSIL">
<HintPath>..\packages\LiteDB.5.0.12\lib\net45\LiteDB.dll</HintPath>
</Reference>
......@@ -110,6 +113,10 @@
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SystemSetting\View\HotkeySettingPanelView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SystemSetting\View\SystemSettingView.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
......@@ -160,6 +167,9 @@
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="NDIMainView\Controller\Hotkey\HotkeyController.cs" />
<Compile Include="NDIMainView\Controller\Hotkey\IHotkeySupport.cs" />
<Compile Include="NDIMainView\Service\INDIMainViewService.cs" />
<Compile Include="NDISettingView\ViewModel\Algorithm\AlgorithmCablewayPanelViewModel.cs" />
<Compile Include="NDISettingView\ViewModel\Algorithm\AlgorithmTacticsPanelViewModel.cs" />
<Compile Include="NDISettingView\ViewModel\INDISetting.cs" />
......@@ -186,6 +196,7 @@
<Compile Include="NDIView\VieweModel\NDIViewModel.cs" />
<Compile Include="Setup\Provider\AppSetup_StopAlgorithm.cs" />
<Compile Include="Setup\Provider\AppSetup_InitUDP.cs" />
<Compile Include="SystemSetting\ViewModel\HotkeySettingPanelViewModel.cs" />
<Compile Include="SystemSetting\ViewModel\AboutPanelViewModel.cs" />
<Compile Include="SystemSetting\ViewModel\ISystemSetting.cs" />
<Compile Include="SystemSetting\ViewModel\SystemSettingViewModel.cs" />
......@@ -206,6 +217,9 @@
<Compile Include="SystemSetting\View\AboutPanelView.xaml.cs">
<DependentUpon>AboutPanelView.xaml</DependentUpon>
</Compile>
<Compile Include="SystemSetting\View\HotkeySettingPanelView.xaml.cs">
<DependentUpon>HotkeySettingPanelView.xaml</DependentUpon>
</Compile>
<Compile Include="SystemSetting\View\SystemSettingView.xaml.cs">
<DependentUpon>SystemSettingView.xaml</DependentUpon>
</Compile>
......@@ -278,7 +292,6 @@
</None>
</ItemGroup>
<ItemGroup>
<Folder Include="NDIMainView\Service\" />
<Folder Include="NDISettingView\Service\" />
</ItemGroup>
<ItemGroup>
......
......@@ -3,5 +3,6 @@
<package id="LiteDB" version="5.0.12" targetFramework="net48" />
<package id="log4net" version="2.0.14" targetFramework="net48" />
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.39" targetFramework="net48" />
<package id="MouseKeyHook" version="5.6.0" targetFramework="net48" />
<package id="SharpDX" version="4.2.0" targetFramework="net48" />
</packages>
\ No newline at end of file
......@@ -45,6 +45,7 @@ namespace VIZ.H2V.Storage
this.ViewConfig = this.Database.GetCollection<NdiViewConfig>();
// 系统设置
this.SystemConfig = this.Database.GetCollection<SystemConfig>();
this.HotkeyConfig = this.Database.GetCollection<HotkeyConfig>();
}
// -----------------------------------------------------------------------------------------------------------
......@@ -110,6 +111,11 @@ namespace VIZ.H2V.Storage
public ILiteCollection<SystemConfig> SystemConfig { get; private set; }
/// <summary>
/// 热键
/// </summary>
public ILiteCollection<HotkeyConfig> HotkeyConfig { get; private set; }
/// <summary>
/// 销毁
/// </summary>
public void Dispose()
......@@ -123,6 +129,7 @@ namespace VIZ.H2V.Storage
this.AlgorithmCableway = null;
this.ViewConfig = null;
this.SystemConfig = null;
this.HotkeyConfig = null;
this.Database?.Dispose();
}
......
......@@ -19,7 +19,7 @@ namespace VIZ.H2V.Storage
/// <summary>
/// 视图键
/// <see cref="VIZ.H2V.Domain.NDViewKeys"/>
/// <see cref="VIZ.H2V.Domain.NDIViewKeys"/>
/// </summary>
public string ViewKey { get; set; }
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace VIZ.H2V.Storage
{
/// <summary>
/// 热键配置
/// </summary>
public class HotkeyConfig
{
/// <summary>
/// 编号
/// </summary>
[LiteDB.BsonId(true)]
public int Id { get; set; }
/// <summary>
/// 算法裁切 视图1
/// </summary>
public string AutoCAM1 { get; set; } = "Alt + D1";
/// <summary>
/// 算法裁切 视图2
/// </summary>
public string AutoCAM2 { get; set; } = "Alt + D2";
/// <summary>
/// 算法裁切 视图3
/// </summary>
public string AutoCAM3 { get; set; } = "Alt + D3";
/// <summary>
/// 算法裁切 视图4
/// </summary>
public string AutoCAM4 { get; set; } = "Alt + D4";
/// <summary>
/// 居中裁切 视图1
/// </summary>
public string CenterCAM1 { get; set; } = "Shift + D1";
/// <summary>
/// 居中裁切 视图2
/// </summary>
public string CenterCAM2 { get; set; } = "Shift + D2";
/// <summary>
/// 居中裁切 视图3
/// </summary>
public string CenterCAM3 { get; set; } = "Shift + D3";
/// <summary>
/// 居中裁切 视图4
/// </summary>
public string CenterCAM4 { get; set; } = "Shift + D4";
/// <summary>
/// 手动裁切 视图1
/// </summary>
public string ManualCAM1 { get; set; } = "D1";
/// <summary>
/// 手动裁切 视图2
/// </summary>
public string ManualCAM2 { get; set; } = "D2";
/// <summary>
/// 手动裁切 视图3
/// </summary>
public string ManualCAM3 { get; set; } = "D3";
/// <summary>
/// 手动裁切 视图4
/// </summary>
public string ManualCAM4 { get; set; } = "D4";
}
}
......@@ -100,6 +100,7 @@
<Compile Include="LiteDB\Algorithm\Algorithm\AlgorithmSixteen.cs" />
<Compile Include="LiteDB\LiteDbContext.cs" />
<Compile Include="LiteDB\NdiView\NdiViewConfig.cs" />
<Compile Include="LiteDB\System\HotkeyConfig.cs" />
<Compile Include="LiteDB\System\SystemConfig.cs" />
<Compile Include="LiteDB\Video\VideoEntity.cs" />
<Compile Include="LiteDB\Video\VideoGroupEntity.cs" />
......
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