CustomDrawing.xaml 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <UserControl xmlns="https://github.com/avaloniaui"
  2. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  3. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  4. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  5. xmlns:local="using:ControlCatalog.Pages"
  6. xmlns:converters="using:ControlCatalog.Converter"
  7. mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
  8. x:Class="ControlCatalog.Pages.CustomDrawing">
  9. <UserControl.Resources>
  10. <converters:DegToRadConverter x:Key="DegToRadConverter"/>
  11. </UserControl.Resources>
  12. <Grid>
  13. <Grid.ColumnDefinitions>
  14. <ColumnDefinition/>
  15. <ColumnDefinition/>
  16. <ColumnDefinition/>
  17. </Grid.ColumnDefinitions>
  18. <Grid.RowDefinitions>
  19. <RowDefinition Height="Auto"/>
  20. <RowDefinition/>
  21. </Grid.RowDefinitions>
  22. <StackPanel Orientation="Vertical">
  23. <TextBlock Text="Translation" HorizontalAlignment="Center"/>
  24. <Grid ColumnDefinitions="*,*"
  25. RowDefinitions="Auto,Auto"
  26. >
  27. <TextBlock Text="Horizontal"/>
  28. <TextBlock Text="Vertical" Grid.Column="1"/>
  29. <TextBox IsEnabled="False"
  30. Text="{Binding ElementName=CustomDrawingControl,
  31. Path=ViewportCenterX,
  32. Mode=OneWay,
  33. StringFormat=\{0:g4\}}"
  34. Grid.Row="1"
  35. />
  36. <TextBox IsEnabled="False"
  37. Text="{Binding ElementName=CustomDrawingControl,
  38. Path=ViewportCenterY,
  39. Mode=OneWay,
  40. StringFormat=\{0:g4\}}"
  41. Grid.Row="1" Grid.Column="1"
  42. />
  43. </Grid>
  44. </StackPanel>
  45. <StackPanel Orientation="Vertical" Grid.Column="1"
  46. >
  47. <TextBlock Text="Rotation" HorizontalAlignment="Center"/>
  48. <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"
  49. >
  50. <Button Content="➖" Width="40" Height="40"
  51. VerticalContentAlignment="Center"
  52. VerticalAlignment="Center"
  53. Click="RotateMinus"
  54. />
  55. <TextBox IsEnabled="False"
  56. Text="{Binding ElementName=CustomDrawingControl,
  57. Path=Rotation,
  58. Converter={StaticResource DegToRadConverter},
  59. Mode=OneWay,
  60. StringFormat=\{0:g4\}}"
  61. Grid.Row="1" Grid.Column="1"
  62. />
  63. <Button Content="➕" Width="40" Height="40"
  64. VerticalContentAlignment="Center"
  65. VerticalAlignment="Center"
  66. Click="RotatePlus"
  67. />
  68. </StackPanel>
  69. </StackPanel>
  70. <StackPanel Orientation="Vertical" Grid.Column="2"
  71. >
  72. <TextBlock Text="Scale" HorizontalAlignment="Center"/>
  73. <StackPanel Orientation="Horizontal" HorizontalAlignment="Center"
  74. >
  75. <Button Content="➖" Width="40" Height="40"
  76. VerticalContentAlignment="Center"
  77. VerticalAlignment="Center"
  78. Click="ZoomOut"
  79. />
  80. <TextBox IsEnabled="False"
  81. Text="{Binding ElementName=CustomDrawingControl,
  82. Path=Scale,
  83. Mode=OneWay,
  84. StringFormat=\{0:g4\}}"
  85. Grid.Row="1" Grid.Column="1"
  86. />
  87. <Button Content="➕" Width="40" Height="40"
  88. VerticalContentAlignment="Center"
  89. VerticalAlignment="Center"
  90. Click="ZoomIn"
  91. />
  92. </StackPanel>
  93. </StackPanel>
  94. <Grid Grid.Row="1" Grid.ColumnSpan="3" ClipToBounds="True">
  95. <local:CustomDrawingExampleControl
  96. x:Name="CustomDrawingControl"
  97. />
  98. </Grid>
  99. </Grid>
  100. </UserControl>