add video option

master
logchan 2020-02-13 11:10:05 -05:00
parent 126691c780
commit f2d5dc234b
3 changed files with 20 additions and 4 deletions

View File

@ -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);
}
}
}
}

View File

@ -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;
}
}

View File

@ -7,18 +7,19 @@
mc:Ignorable="d" x:Name="TheWindow"
Title="chuni-hands" Height="720" Width="1280"
Loaded="Window_Loaded" Closing="Window_Closing">
<Grid>
<Grid DataContext="{Binding ElementName=TheWindow, Path=Config}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5*"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid Grid.Column="0" Margin="12">
<local:ChuniCanvas x:Name="TheCanvas"></local:ChuniCanvas>
<local:ChuniCanvas x:Name="TheCanvas" DrawImage="{Binding Path=ShowVideo}"></local:ChuniCanvas>
</Grid>
<DockPanel Grid.Column="1" LastChildFill="True" DataContext="{Binding ElementName=TheWindow, Path=Config}">
<DockPanel Grid.Column="1" LastChildFill="True">
<StackPanel DockPanel.Dock="Top" Margin="12">
<Button x:Name="ResetButton" Click="ResetButton_Click">Reset</Button>
<CheckBox IsChecked="{Binding Path=ShowVideo, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">Video</CheckBox>
<DockPanel LastChildFill="True">
<TextBlock DockPanel.Dock="Left">Threshold</TextBlock>
<Button DockPanel.Dock="Right" x:Name="SetThresholdButton" Click="SetThresholdButton_Click">Set</Button>