Commit 69e61fa6 by liulongfei

添加空格快捷键

parent dc3a7286
...@@ -40,4 +40,33 @@ ...@@ -40,4 +40,33 @@
</Style.Triggers> </Style.Triggers>
</Style> </Style>
<Style TargetType="RadioButton" x:Key="RadioButton_NdiView_Title">
<Setter Property="FocusVisualStyle" Value="{x:Null}"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="RadioButton">
<Border x:Name="bd_outer" Background="Transparent">
<Border x:Name="bd_inner" Background="Transparent">
<ContentPresenter HorizontalAlignment="Center" VerticalAlignment="Center"></ContentPresenter>
</Border>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsChecked" Value="True">
<Setter TargetName="bd_inner" Property="Background" Value="#ffff0000"></Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter TargetName="bd_outer" Property="Background" Value="#11ffffff"></Setter>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="IsEnabled" Value="False">
<Setter Property="Opacity" Value="0.7"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</ResourceDictionary> </ResourceDictionary>
\ No newline at end of file
...@@ -29,6 +29,67 @@ namespace VIZ.H2V.Module ...@@ -29,6 +29,67 @@ namespace VIZ.H2V.Module
public IHotkeySupport Support { get; private set; } public IHotkeySupport Support { get; private set; }
/// <summary> /// <summary>
/// 当前聚焦的NDI视图模型
/// </summary>
private NDIViewModel focusNDIViewModel;
/// <summary>
/// 执行空格键按下
/// </summary>
public void ExecuteSpaceDown()
{
this.focusNDIViewModel = NDIViewModel.ActiveViewModel;
if (this.focusNDIViewModel == null)
return;
this.focusNDIViewModel.IsFocus = true;
// 先将出自身外手动模式的视图切换为自动模式
ApplicationDomainEx.ServiceManager.GetServiceList<INDIViewService>()
.Where(p => p.StrategyMode == AlgorithmStrategyMode.manual_mode && p != this.focusNDIViewModel)
.ToList()
.ForEach(p =>
{
ChangeStrategyContext cxt = new ChangeStrategyContext();
cxt.IsUseClip = p.IsUseClip;
cxt.Mode = AlgorithmStrategyMode.auto_mode;
cxt.IsNeedRestart = false;
cxt.TriggerScene = NDIViewScene.Hotkey;
p.ChangeStrategyMode(cxt);
});
// 切换为手动模式
ChangeStrategyContext context = new ChangeStrategyContext();
context.IsUseClip = this.focusNDIViewModel.IsUseClip;
context.Mode = AlgorithmStrategyMode.manual_mode;
context.IsNeedRestart = false;
context.TriggerScene = NDIViewScene.SpaceHotkey;
this.focusNDIViewModel.ChangeStrategyMode(context);
}
/// <summary>
/// 执行空格键弹起
/// </summary>
public void ExecuteSpaceUp()
{
if (this.focusNDIViewModel == null)
return;
ChangeStrategyContext context = new ChangeStrategyContext();
context.IsUseClip = this.focusNDIViewModel.IsUseClip;
context.Mode = AlgorithmStrategyMode.auto_mode;
context.IsNeedRestart = false;
context.TriggerScene = NDIViewScene.SpaceHotkey;
this.focusNDIViewModel.ChangeStrategyMode(context);
this.focusNDIViewModel.IsFocus = false;
this.focusNDIViewModel = null;
}
/// <summary>
/// 执行 /// 执行
/// </summary> /// </summary>
/// <param name="hotkey">热键</param> /// <param name="hotkey">热键</param>
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
<!-- 顶部 --> <!-- 顶部 -->
<TextBox x:Name="tbFocus" Visibility="Collapsed"></TextBox> <TextBox x:Name="tbFocus" Visibility="Collapsed"></TextBox>
<Grid Background="#ff12202d"> <Grid Background="#ff12202d">
<TextBlock Text="AI横转竖智能裁切系统" FontSize="12" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock> <TextBlock Text="横转竖智能裁切系统" FontSize="12" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"></TextBlock>
<StackPanel Orientation="Horizontal" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Top"> <StackPanel Orientation="Horizontal" Grid.Column="2" HorizontalAlignment="Right" VerticalAlignment="Top">
<Button Command="{Binding Path=SettingCommand}" Style="{StaticResource Button_Setting}" Height="30"></Button> <Button Command="{Binding Path=SettingCommand}" Style="{StaticResource Button_Setting}" Height="30"></Button>
<Button Command="{Binding Path=MinCommand}" Style="{StaticResource Button_Min}" Height="30"></Button> <Button Command="{Binding Path=MinCommand}" Style="{StaticResource Button_Min}" Height="30"></Button>
......
...@@ -93,6 +93,9 @@ namespace VIZ.H2V.Module ...@@ -93,6 +93,9 @@ namespace VIZ.H2V.Module
this.globalHook.KeyDown -= GlobalHook_KeyDown; this.globalHook.KeyDown -= GlobalHook_KeyDown;
this.globalHook.KeyDown += GlobalHook_KeyDown; this.globalHook.KeyDown += GlobalHook_KeyDown;
this.globalHook.KeyUp -= GlobalHook_KeyUp;
this.globalHook.KeyUp += GlobalHook_KeyUp;
} }
// ====================================================================================== // ======================================================================================
...@@ -295,10 +298,39 @@ namespace VIZ.H2V.Module ...@@ -295,10 +298,39 @@ namespace VIZ.H2V.Module
if (!window.IsActive) if (!window.IsActive)
return; return;
// 空格键特殊处理
if (e.KeyCode == System.Windows.Forms.Keys.Space)
{
this.hotkeyController.ExecuteSpaceDown();
return;
}
// 快捷键
string hotkey = HotkeyHelper.GetHotkey(e); string hotkey = HotkeyHelper.GetHotkey(e);
this.hotkeyController.Execute(hotkey); this.hotkeyController.Execute(hotkey);
}); });
} }
/// <summary>
/// 按键释放时触发
/// </summary>
private void GlobalHook_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
if (this.hotkeyController == null)
return;
WPFHelper.BeginInvoke(() =>
{
// 空格键特殊处理
if (e.KeyCode == System.Windows.Forms.Keys.Space)
{
this.hotkeyController.ExecuteSpaceUp();
return;
}
});
}
} }
} }
...@@ -22,6 +22,10 @@ namespace VIZ.H2V.Module ...@@ -22,6 +22,10 @@ namespace VIZ.H2V.Module
/// <summary> /// <summary>
/// 热键 /// 热键
/// </summary> /// </summary>
Hotkey Hotkey,
/// <summary>
/// 空格热键
/// </summary>
SpaceHotkey
} }
} }
...@@ -81,37 +81,42 @@ ...@@ -81,37 +81,42 @@
<!-- 标题 --> <!-- 标题 -->
<Border HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1"> <Border HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="1">
<TextBlock Text="{Binding Path=DisplayName,Mode=OneWay}" Foreground="White" FontSize="20" FontWeight="Black" <RadioButton Content="{Binding Path=DisplayName,Mode=OneWay}" Foreground="White" FontSize="20" FontWeight="Black"
Margin="10,0,10,0" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"></TextBlock> Width="200" Height="30" GroupName="NDIView_Title_Group"
IsChecked="{Binding Path=IsActive,Mode=TwoWay}"
Style="{StaticResource RadioButton_NdiView_Title}"></RadioButton>
</Border> </Border>
<!-- 算法 --> <!-- 算法 -->
<Grid Grid.RowSpan="2" Margin="0,20,0,0" IsEnabled="{Binding Path=ViewStatus,Converter={StaticResource NDIViewStatus2IsEnabledConverter}}"> <Grid Grid.RowSpan="2" Margin="0,20,0,0"
<Grid.RowDefinitions> IsEnabled="{Binding Path=IsFocus,Converter={StaticResource Bool2BoolConverter}}">
<RowDefinition Height="60"></RowDefinition> <Grid IsEnabled="{Binding Path=ViewStatus,Converter={StaticResource NDIViewStatus2IsEnabledConverter}}">
<RowDefinition Height="180"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<CheckBox FontSize="16" Content="裁切策略:" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"
IsChecked="{Binding Path=IsUseClip,Mode=TwoWay}"
Style="{StaticResource CheckBox_NdiView}"></CheckBox>
<Rectangle Grid.Row="1" Grid.RowSpan="10" Fill="#ff181d2b"></Rectangle>
<Grid Grid.Row="1" IsEnabled="{Binding IsUseClip,Mode=OneWay}">
<Grid.RowDefinitions> <Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition> <RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition> <RowDefinition Height="180"></RowDefinition>
<RowDefinition Height="60"></RowDefinition> <RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions> </Grid.RowDefinitions>
<RadioButton Content="{Binding Path=StrategyDisplayName,Mode=OneWay}" Grid.Row="0" FontSize="16" Foreground="White" <CheckBox FontSize="16" Content="裁切策略:" Foreground="White" VerticalAlignment="Center" HorizontalAlignment="Center"
IsChecked="{Binding Path=IsUseClip,Mode=TwoWay}"
Style="{StaticResource CheckBox_NdiView}"></CheckBox>
<Rectangle Grid.Row="1" Grid.RowSpan="10" Fill="#ff181d2b"></Rectangle>
<Grid Grid.Row="1" IsEnabled="{Binding IsUseClip,Mode=OneWay}">
<Grid.RowDefinitions>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
<RowDefinition Height="60"></RowDefinition>
</Grid.RowDefinitions>
<RadioButton Content="{Binding Path=StrategyDisplayName,Mode=OneWay}" Grid.Row="0" FontSize="16" Foreground="White"
Style="{StaticResource RadioButton_NdiView}" IsChecked="{Binding IsAutoModeChecked,Mode=TwoWay}"> Style="{StaticResource RadioButton_NdiView}" IsChecked="{Binding IsAutoModeChecked,Mode=TwoWay}">
</RadioButton> </RadioButton>
<RadioButton Content="居中" Grid.Row="1" FontSize="16" Foreground="White" <RadioButton Content="居中" Grid.Row="1" FontSize="16" Foreground="White"
Style="{StaticResource RadioButton_NdiView}" IsChecked="{Binding IsCenterModeChecked,Mode=TwoWay}"> Style="{StaticResource RadioButton_NdiView}" IsChecked="{Binding IsCenterModeChecked,Mode=TwoWay}">
</RadioButton> </RadioButton>
<RadioButton Content="手动" Grid.Row="2" FontSize="16" Foreground="White" <RadioButton Content="手动" Grid.Row="2" FontSize="16" Foreground="White"
IsEnabled="{Binding Path=IsManualModeEnabled,Mode=OneWay}" IsEnabled="{Binding Path=IsManualModeEnabled,Mode=OneWay}"
IsChecked="{Binding Path=IsManualModeChecked,Mode=TwoWay}" IsChecked="{Binding Path=IsManualModeChecked,Mode=TwoWay}"
Style="{StaticResource RadioButton_NdiView}"> Style="{StaticResource RadioButton_NdiView}">
</RadioButton> </RadioButton>
</Grid>
</Grid> </Grid>
</Grid> </Grid>
...@@ -137,7 +142,7 @@ ...@@ -137,7 +142,7 @@
</Button.Visibility> </Button.Visibility>
</Button> </Button>
<!-- 近景机位 & 16米机位 & 战术机位 ===== 边线检测选择面板 --> <!-- 近景机位 & 16米机位 & 战术机位 ===== 边线检测选择面板 -->
<common:FootballFieldPanel HorizontalAlignment="Center" VerticalAlignment="Bottom" <!--<common:FootballFieldPanel HorizontalAlignment="Center" VerticalAlignment="Bottom"
FootballFieldWidth="150" FootballFieldHeight="100" FootballFieldWidth="150" FootballFieldHeight="100"
DataContext="{Binding Path=FootballFieldPanelModel}" DataContext="{Binding Path=FootballFieldPanelModel}"
Orientation="{Binding ElementName=uc,Path=DataContext.StrategyType,Converter={StaticResource AlgorithmStrategyType2FootballFieldOrientationConverter}}"> Orientation="{Binding ElementName=uc,Path=DataContext.StrategyType,Converter={StaticResource AlgorithmStrategyType2FootballFieldOrientationConverter}}">
...@@ -148,7 +153,7 @@ ...@@ -148,7 +153,7 @@
<Binding Path="DataContext.StrategyType" ElementName="uc"></Binding> <Binding Path="DataContext.StrategyType" ElementName="uc"></Binding>
</MultiBinding> </MultiBinding>
</common:FootballFieldPanel.Visibility> </common:FootballFieldPanel.Visibility>
</common:FootballFieldPanel> </common:FootballFieldPanel>-->
</Grid> </Grid>
<!-- 视频区域 --> <!-- 视频区域 -->
<Border BorderBrush="Transparent" BorderThickness="0" Grid.Row="1" Grid.Column="1"> <Border BorderBrush="Transparent" BorderThickness="0" Grid.Row="1" Grid.Column="1">
......
...@@ -171,7 +171,7 @@ namespace VIZ.H2V.Module ...@@ -171,7 +171,7 @@ namespace VIZ.H2V.Module
} }
// 更新跟踪框 // 更新跟踪框
if (msg.target_bbox != null) if (msg.target_bbox != null && this.ALGORITHM_IS_SHOW_TARGET_BOX)
{ {
RawRectangleF rect = RawRectangleFExpand.ClipInVideoFrame(msg.target_bbox.Value, 0, 0, renderInfo.Frame.Width, renderInfo.Frame.Height); RawRectangleF rect = RawRectangleFExpand.ClipInVideoFrame(msg.target_bbox.Value, 0, 0, renderInfo.Frame.Width, renderInfo.Frame.Height);
......
...@@ -54,6 +54,11 @@ namespace VIZ.H2V.Module ...@@ -54,6 +54,11 @@ namespace VIZ.H2V.Module
private readonly int TRACKING_BOX_BORDER_WIDTH = ApplicationDomainEx.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_TRACKING_BOX_BORDER_WIDTH); private readonly int TRACKING_BOX_BORDER_WIDTH = ApplicationDomainEx.IniStorage.GetValue<VideoConfig, int>(p => p.VIDEO_TRACKING_BOX_BORDER_WIDTH);
/// <summary> /// <summary>
/// 是否显示目标框
/// </summary>
private readonly bool ALGORITHM_IS_SHOW_TARGET_BOX = ApplicationDomainEx.IniStorage.GetValue<AlgorithmConfig, bool>(p => p.ALGORITHM_IS_SHOW_TARGET_BOX);
/// <summary>
/// 剪切框颜色 -- 正常 /// 剪切框颜色 -- 正常
/// </summary> /// </summary>
private RawColor4 ClipBoxStrokeColor_Normal; private RawColor4 ClipBoxStrokeColor_Normal;
...@@ -240,6 +245,43 @@ namespace VIZ.H2V.Module ...@@ -240,6 +245,43 @@ namespace VIZ.H2V.Module
#endregion #endregion
#region IsActive -- 是否被激活
private bool isActive;
/// <summary>
/// 是否被激活
/// </summary>
public bool IsActive
{
get { return isActive; }
set
{
isActive = value;
this.RaisePropertyChanged(nameof(IsActive));
if (value)
{
NDIViewModel.ActiveViewModel = this;
}
}
}
#endregion
#region IsFocus -- 是否聚焦
private bool isFocus;
/// <summary>
/// 是否聚焦
/// </summary>
public bool IsFocus
{
get { return isFocus; }
set { isFocus = value; this.RaisePropertyChanged(nameof(IsFocus)); }
}
#endregion
// -------------------------------------------------------------------------------------- // --------------------------------------------------------------------------------------
#region IsUseClip -- 是否使用裁切 #region IsUseClip -- 是否使用裁切
......
...@@ -22,6 +22,11 @@ namespace VIZ.H2V.Module ...@@ -22,6 +22,11 @@ namespace VIZ.H2V.Module
private static ILog log = LogManager.GetLogger(typeof(NDIViewModel)); private static ILog log = LogManager.GetLogger(typeof(NDIViewModel));
/// <summary> /// <summary>
/// 当前激活的NDI视图模型
/// </summary>
public static NDIViewModel ActiveViewModel { get; private set; }
/// <summary>
/// NDI视图模型 /// NDI视图模型
/// </summary> /// </summary>
public NDIViewModel() public NDIViewModel()
......
...@@ -17,5 +17,11 @@ namespace VIZ.H2V.Storage ...@@ -17,5 +17,11 @@ namespace VIZ.H2V.Storage
/// </summary> /// </summary>
[Ini(Section = "Algorithm", DefaultValue = "30000", Type = typeof(int))] [Ini(Section = "Algorithm", DefaultValue = "30000", Type = typeof(int))]
public string ALGORITHM_STOP_TIMEOUT { get; set; } public string ALGORITHM_STOP_TIMEOUT { get; set; }
/// <summary>
/// 是否显示目标框
/// </summary>
[Ini(Section = "Algorithm", DefaultValue = "true", Type = typeof(bool))]
public string ALGORITHM_IS_SHOW_TARGET_BOX { get; set; }
} }
} }
...@@ -207,8 +207,8 @@ Global ...@@ -207,8 +207,8 @@ Global
{8FC38D2A-D2E5-44D0-86E4-7136A6D19F2E}.Release|x64.Build.0 = Release|x64 {8FC38D2A-D2E5-44D0-86E4-7136A6D19F2E}.Release|x64.Build.0 = Release|x64
{750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Debug|Any CPU.Build.0 = Debug|Any CPU {750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Debug|x64.ActiveCfg = Debug|Any CPU {750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Debug|x64.ActiveCfg = Debug|x64
{750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Debug|x64.Build.0 = Debug|Any CPU {750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Debug|x64.Build.0 = Debug|x64
{750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Release|Any CPU.ActiveCfg = Release|Any CPU {750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Release|Any CPU.Build.0 = Release|Any CPU {750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Release|Any CPU.Build.0 = Release|Any CPU
{750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Release|x64.ActiveCfg = Release|x64 {750ECE65-60DD-425A-B1D3-68E5158B6E9B}.Release|x64.ActiveCfg = Release|x64
......
...@@ -55,4 +55,6 @@ UDP_BINDING_PORT=8101 ...@@ -55,4 +55,6 @@ UDP_BINDING_PORT=8101
; ============================================================ ; ============================================================
[Algorithm] [Algorithm]
;算法停止超时时间(单位:毫秒) ;算法停止超时时间(单位:毫秒)
ALGORITHM_STOP_TIMEOUT=5000 ALGORITHM_STOP_TIMEOUT=5000
\ No newline at end of file ;是否显示目标框
ALGORITHM_IS_SHOW_TARGET_BOX=true
\ No newline at end of file
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