From f2d5dc234b4fdeda28f23819f35d21163ed24553 Mon Sep 17 00:00:00 2001 From: logchan Date: Thu, 13 Feb 2020 11:10:05 -0500 Subject: [PATCH] add video option --- chuni-hands/ChuniCanvas.cs | 16 +++++++++++++++- chuni-hands/Config.cs | 1 + chuni-hands/MainWindow.xaml | 7 ++++--- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/chuni-hands/ChuniCanvas.cs b/chuni-hands/ChuniCanvas.cs index 1eb4f75..a45c798 100644 --- a/chuni-hands/ChuniCanvas.cs +++ b/chuni-hands/ChuniCanvas.cs @@ -17,6 +17,14 @@ namespace chuni_hands { public static readonly DependencyProperty ImageProperty = DependencyProperty.Register("Image", typeof(ImageSource), typeof(ChuniCanvas), new PropertyMetadata(null)); + public bool DrawImage { + get { return (bool)GetValue(DrawImageProperty); } + set { SetValue(DrawImageProperty, value); } + } + + public static readonly DependencyProperty DrawImageProperty = + DependencyProperty.Register("DrawImage", typeof(bool), typeof(ChuniCanvas), new PropertyMetadata(false)); + protected override void OnRender(DrawingContext dc) { base.OnRender(dc); @@ -29,8 +37,14 @@ namespace chuni_hands { factor = Math.Min(factor, ActualHeight / image.Height); var paddingX = (ActualWidth - image.Width * factor) / 2; var paddingY = (ActualHeight - image.Height * factor) / 2; + var imageRect = new Rect(paddingX, paddingY, image.Width * factor, image.Height * factor); - dc.DrawImage(image, new Rect(paddingX, paddingY, image.Width * factor, image.Height * factor)); + if (DrawImage) { + dc.DrawImage(image, imageRect); + } + else { + dc.DrawRectangle(Brushes.LightGray, null, imageRect); + } } } } diff --git a/chuni-hands/Config.cs b/chuni-hands/Config.cs index b1eb215..f567d52 100644 --- a/chuni-hands/Config.cs +++ b/chuni-hands/Config.cs @@ -18,5 +18,6 @@ public bool LogDiff { get; set; } public string SendKeyMode { get; set; } = "be"; public string EndPoint { get; set; } = "http://10.233.3.22:4420/update_air"; + public bool ShowVideo { get; set; } = true; } } diff --git a/chuni-hands/MainWindow.xaml b/chuni-hands/MainWindow.xaml index 2147251..f14a56e 100644 --- a/chuni-hands/MainWindow.xaml +++ b/chuni-hands/MainWindow.xaml @@ -7,18 +7,19 @@ mc:Ignorable="d" x:Name="TheWindow" Title="chuni-hands" Height="720" Width="1280" Loaded="Window_Loaded" Closing="Window_Closing"> - + - + - + + Video Threshold