ImageView.xaml 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <UserControl x:Class="TeamAAS_VP.Views.ImageView"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:prism="http://prismlibrary.com/"
  7. mc:Ignorable="d"
  8. prism:ViewModelLocator.AutoWireViewModel="True"
  9. d:DesignHeight="450" d:DesignWidth="800">
  10. <Grid>
  11. <Grid.RowDefinitions>
  12. <RowDefinition Height="Auto"/>
  13. <RowDefinition Height="*"/>
  14. </Grid.RowDefinitions>
  15. <StackPanel Orientation="Horizontal" Margin="8">
  16. <Button Content="导入图片" Command="{Binding ImportImageCommand}" Margin="0,0,8,0"/>
  17. <Button Content="保存" Command="{Binding SaveCommand}" Margin="0,0,8,0"/>
  18. <Button Content="清空批注" Command="{Binding ClearCommand}" Margin="0,0,16,0"/>
  19. <TextBlock VerticalAlignment="Center" Text="工具:" Margin="0,0,4,0"/>
  20. <ComboBox Width="120" SelectedValue="{Binding Tool}" SelectedValuePath="Tag">
  21. <ComboBoxItem Content="矩形" Tag="Rect"/>
  22. <ComboBoxItem Content="箭头" Tag="Arrow"/>
  23. <ComboBoxItem Content="文字" Tag="Text"/>
  24. <ComboBoxItem Content="选择/移动" Tag="Select"/>
  25. </ComboBox>
  26. <TextBlock VerticalAlignment="Center" Text="颜色:" Margin="16,0,4,0"/>
  27. <ComboBox Width="110" SelectedValue="{Binding ColorName}">
  28. <ComboBoxItem Content="Red"/>
  29. <ComboBoxItem Content="Yellow"/>
  30. <ComboBoxItem Content="Lime"/>
  31. <ComboBoxItem Content="DodgerBlue"/>
  32. <ComboBoxItem Content="White"/>
  33. <ComboBoxItem Content="Black"/>
  34. </ComboBox>
  35. <TextBlock VerticalAlignment="Center" Text="线宽:" Margin="16,0,4,0"/>
  36. <Slider Width="120" Minimum="1" Maximum="10" Value="{Binding Thickness}"/>
  37. </StackPanel>
  38. <Border Grid.Row="1" Margin="8" BorderBrush="#33000000" BorderThickness="1" Background="Black">
  39. <!-- 显示缩放层:只用于显示,不参与保存 -->
  40. <Viewbox x:Name="DisplayViewbox" Stretch="Uniform">
  41. <!-- 像素层:尺寸=原图像素,批注也在这个坐标系 -->
  42. <Grid x:Name="RootPixelRender"
  43. Width="{Binding PixelWidth}"
  44. Height="{Binding PixelHeight}"
  45. Background="Black">
  46. <Image x:Name="Img"
  47. Source="{Binding ImageSource}"
  48. Width="{Binding PixelWidth}"
  49. Height="{Binding PixelHeight}"
  50. Stretch="Fill" />
  51. <Canvas x:Name="AnnoCanvas"
  52. Width="{Binding PixelWidth}"
  53. Height="{Binding PixelHeight}"
  54. Background="Transparent"
  55. Focusable="True"
  56. MouseLeftButtonDown="AnnoCanvas_MouseLeftButtonDown"
  57. MouseMove="AnnoCanvas_MouseMove"
  58. MouseLeftButtonUp="AnnoCanvas_MouseLeftButtonUp"
  59. MouseRightButtonDown="AnnoCanvas_MouseRightButtonDown"
  60. KeyDown="AnnoCanvas_KeyDown"/>
  61. </Grid>
  62. </Viewbox>
  63. </Border>
  64. </Grid>
  65. </UserControl>