MainWindow.xaml 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. <Window x:Class="PixiEditor.MainWindow" MinHeight="1000" MinWidth="1100"
  2. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  3. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  4. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  5. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  6. xmlns:local="clr-namespace:PixiEditor"
  7. xmlns:vm="clr-namespace:PixiEditor.ViewModels"
  8. xmlns:vws="clr-namespace:PixiEditor.Views"
  9. xmlns:helpers="clr-namespace:PixiEditor.Helpers"
  10. xmlns:behaviors="clr-namespace:PixiEditor.Helpers.Behaviours"
  11. xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
  12. xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
  13. mc:Ignorable="d"
  14. Title="Pixi" Height="1000" Width="1600" Background="#FF252424" WindowStartupLocation="CenterScreen" WindowState="Maximized" DataContext="{DynamicResource ViewModelMain}">
  15. <Window.Resources>
  16. <vm:ViewModelMain x:Key="ViewModelMain"/>
  17. <BooleanToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
  18. <helpers:ToolSizeToIntConverter x:Key="ToolSizeToIntConverter"/>
  19. </Window.Resources>
  20. <Window.InputBindings>
  21. <KeyBinding
  22. Modifiers="Ctrl"
  23. Key="N"
  24. Command="{Binding GenerateDrawAreaCommand}"/>
  25. <KeyBinding
  26. Modifiers="Ctrl"
  27. Key="S"
  28. Command="{Binding SaveFileCommand}"/>
  29. <KeyBinding
  30. Modifiers="Ctrl"
  31. Key="Z"
  32. Command="{Binding UndoCommand}"/>
  33. <KeyBinding
  34. Modifiers="Ctrl"
  35. Key="Y"
  36. Command="{Binding RedoCommand}"/>
  37. <KeyBinding
  38. Key="B"
  39. Command="{Binding SelectToolCommand}"
  40. CommandParameter="Pen"/>
  41. <KeyBinding
  42. Key="G"
  43. Command="{Binding SelectToolCommand}"
  44. CommandParameter="Bucket"/>
  45. <KeyBinding
  46. Key="L"
  47. Command="{Binding SelectToolCommand}"
  48. CommandParameter="Line"/>
  49. <KeyBinding
  50. Key="C"
  51. Command="{Binding SelectToolCommand}"
  52. CommandParameter="Circle"/>
  53. <KeyBinding Key="R"
  54. Command="{Binding SelectToolCommand}"
  55. CommandParameter="Rectangle"/>
  56. <KeyBinding Key="O"
  57. Command="{Binding SelectToolCommand}"
  58. CommandParameter="ColorPicker"/>
  59. <KeyBinding Key="E"
  60. Command="{Binding SelectToolCommand}"
  61. CommandParameter="Earser"/>
  62. <KeyBinding Key="U"
  63. Command="{Binding SelectToolCommand}"
  64. CommandParameter="Lighten"/>
  65. <KeyBinding Key="O" Modifiers="Ctrl"
  66. Command="{Binding OpenFileCommand}"/>
  67. </Window.InputBindings>
  68. <Grid>
  69. <Grid.ColumnDefinitions>
  70. <ColumnDefinition Width="70*"/>
  71. <ColumnDefinition Width="1420*"/>
  72. <ColumnDefinition Width="110*"/>
  73. </Grid.ColumnDefinitions>
  74. <Grid.RowDefinitions>
  75. <RowDefinition Height="30*"/>
  76. <RowDefinition Height="908*"/>
  77. <RowDefinition Height="30*"/>
  78. </Grid.RowDefinitions>
  79. <Border Grid.ColumnSpan="3" Background="#FF363434" Grid.Row="0" Height="30"/>
  80. <WrapPanel Grid.ColumnSpan="2" Grid.RowSpan="2" Panel.ZIndex="100">
  81. <vws:MenuButton Text="File" Margin="0,0,-140,0">
  82. <vws:MenuButton.Item>
  83. <StackPanel>
  84. <Button Style="{StaticResource MenuInsideButtonStyle}" Content="New" Command="{Binding GenerateDrawAreaCommand}"/>
  85. <Button Style="{StaticResource MenuInsideButtonStyle}" Content="Save" Command="{Binding SaveFileCommand}"/>
  86. <Button Style="{StaticResource MenuInsideButtonStyle}" Content="Open" Command="{Binding OpenFileCommand}"/>
  87. </StackPanel>
  88. </vws:MenuButton.Item>
  89. </vws:MenuButton>
  90. <vws:MenuButton Text="Edit" Margin="0,0,-140,0">
  91. <vws:MenuButton.Item>
  92. <StackPanel>
  93. <Button Style="{StaticResource MenuInsideButtonStyle}" Content="Undo" Command="{Binding UndoCommand}"/>
  94. <Button Style="{StaticResource MenuInsideButtonStyle}" Content="Redo" Command="{Binding RedoCommand}"/>
  95. </StackPanel>
  96. </vws:MenuButton.Item>
  97. </vws:MenuButton>
  98. <vws:MenuButton Text="View" Margin="0,0,-140,0">
  99. <vws:MenuButton.Item>
  100. <StackPanel>
  101. <Button Style="{StaticResource MenuInsideButtonStyle}" Content="Recenter" Command="{Binding RecenterZoomboxCommand}" CommandParameter="{Binding ElementName=Zoombox}"/>
  102. </StackPanel>
  103. </vws:MenuButton.Item>
  104. </vws:MenuButton>
  105. </WrapPanel>
  106. <Grid Grid.Column="1" Grid.Row="1" Background="DimGray" Margin="0,5,0,0">
  107. <Grid>
  108. <vws:MainDrawingPanel CenterOnStart="True">
  109. <vws:MainDrawingPanel.Item>
  110. <Canvas Width="{Binding ActiveLayer.Width}" Height="{Binding ActiveLayer.Height}" VerticalAlignment="Center" HorizontalAlignment="Center">
  111. <i:Interaction.Triggers>
  112. <i:EventTrigger EventName="MouseMove">
  113. <i:InvokeCommandAction Command="{Binding MouseMoveOrClickCommand}"/>
  114. </i:EventTrigger>
  115. <i:EventTrigger EventName="MouseDown">
  116. <i:InvokeCommandAction Command="{Binding MouseMoveOrClickCommand}"/>
  117. </i:EventTrigger>
  118. <i:EventTrigger EventName="MouseUp">
  119. <i:InvokeCommandAction Command="{Binding MouseUpCommand}"/>
  120. </i:EventTrigger>
  121. </i:Interaction.Triggers>
  122. <i:Interaction.Behaviors>
  123. <behaviors:MouseBehaviour MouseX="{Binding MouseXOnCanvas, Mode=OneWayToSource}" MouseY="{Binding MouseYOnCanvas, Mode=OneWayToSource}"/>
  124. </i:Interaction.Behaviors>
  125. <Image Source="/Images/transparentbg.png" Height="{Binding ActiveLayer.Height}" Width="{Binding ActiveLayer.Width}" Opacity="0.2" Stretch="UniformToFill"/>
  126. <ContentControl Content="{Binding ActiveImage}"/>
  127. </Canvas>
  128. </vws:MainDrawingPanel.Item>
  129. </vws:MainDrawingPanel>
  130. </Grid>
  131. </Grid>
  132. <StackPanel Grid.Row="1" Grid.Column="0" Margin="0,5,5,0" Background="#363434" Grid.RowSpan="2">
  133. <TextBox Style="{StaticResource DarkTextBoxStyle}" Margin="0,10,0,0" Text="{Binding ToolSize, Mode=TwoWay,Converter={StaticResource ToolSizeToIntConverter}}" TextAlignment="Center" MaxLength="4">
  134. <i:Interaction.Behaviors>
  135. <behaviors:TextBoxNumericFinisherBehavior/>
  136. </i:Interaction.Behaviors>
  137. </TextBox>
  138. <Button Style="{StaticResource ToolButtonStyle}" Command="{Binding SelectToolCommand, Mode=OneWay}" CommandParameter="Pen" ToolTip="Standard brush (B)">
  139. <Button.Background>
  140. <ImageBrush ImageSource="/Images/PenImage.png" Stretch="Uniform"/>
  141. </Button.Background>
  142. </Button>
  143. <Button Style="{StaticResource ToolButtonStyle}" Command="{Binding SelectToolCommand, Mode=OneWay}" CommandParameter="Bucket" ToolTip="Fills area with color (G)">
  144. <Button.Background>
  145. <ImageBrush ImageSource="/Images/BucketImage.png" Stretch="Uniform"/>
  146. </Button.Background>
  147. </Button>
  148. <Button Style="{StaticResource ToolButtonStyle}" Command="{Binding SelectToolCommand, Mode=OneWay}" CommandParameter="Line" ToolTip="Draws line on canvas (L)">
  149. <Button.Background>
  150. <ImageBrush ImageSource="/Images/LineImage.png" Stretch="Uniform"/>
  151. </Button.Background>
  152. </Button>
  153. <Button Style="{StaticResource ToolButtonStyle}" Command="{Binding SelectToolCommand, Mode=OneWay}" CommandParameter="Circle" ToolTip="Draws circle on cavnas (C)">
  154. <Button.Background>
  155. <ImageBrush ImageSource="/Images/CircleImage.png" Stretch="Uniform"/>
  156. </Button.Background>
  157. </Button>
  158. <Button Style="{StaticResource ToolButtonStyle}" Command="{Binding SelectToolCommand, Mode=OneWay}" CommandParameter="Rectangle" ToolTip="Draws rectanlge on cavnas (R)">
  159. <Button.Background>
  160. <ImageBrush ImageSource="/Images/RectangleImage.png" Stretch="Uniform"/>
  161. </Button.Background>
  162. </Button>
  163. <Button Style="{StaticResource ToolButtonStyle}" Command="{Binding SelectToolCommand, Mode=OneWay}" CommandParameter="ColorPicker" ToolTip="Color picker, sets color from pixel as active (O)">
  164. <Button.Background>
  165. <ImageBrush ImageSource="/Images/PipetteImage.png" Stretch="Uniform"/>
  166. </Button.Background>
  167. </Button>
  168. <Button Style="{StaticResource ToolButtonStyle}" Command="{Binding SelectToolCommand, Mode=OneWay}" CommandParameter="Earser" ToolTip="Earser, Earsers color from pixel (E)">
  169. <Button.Background>
  170. <ImageBrush ImageSource="/Images/EarserImage.png" Stretch="Uniform"/>
  171. </Button.Background>
  172. </Button>
  173. <Button Style="{StaticResource ToolButtonStyle}" Command="{Binding SelectToolCommand, Mode=OneWay}" CommandParameter="Brightness" ToolTip="Makes pixel brighter or darker pixel (U)">
  174. <Button.Background>
  175. <ImageBrush ImageSource="/Images/LightenImage.png" Stretch="Uniform"/>
  176. </Button.Background>
  177. </Button>
  178. </StackPanel>
  179. <Grid VerticalAlignment="Bottom" HorizontalAlignment="Center" Width="60" Grid.Column="0" Grid.Row="1" Margin="0,0,0,0" Height="65">
  180. <Rectangle Height="40" Width="40" HorizontalAlignment="Left" VerticalAlignment="Top" Stroke="Black" StrokeThickness="1" Panel.ZIndex="1">
  181. <Rectangle.Fill>
  182. <SolidColorBrush Color="{Binding PrimaryColor, Mode=OneWay}"/>
  183. </Rectangle.Fill>
  184. </Rectangle>
  185. <xctk:ColorPicker Width="40" Panel.ZIndex="2" Height="40" VerticalAlignment="Top" HorizontalAlignment="Left" UsingAlphaChannel="True" AvailableColorsSortingMode="Alphabetical" ShowDropDownButton="False" Background="Transparent" BorderThickness="0" ShowRecentColors="True" SelectedColor="{Binding PrimaryColor, Mode=TwoWay}"></xctk:ColorPicker>
  186. <Rectangle Height="40" Width="40" HorizontalAlignment="Right" VerticalAlignment="Bottom" Stroke="Black" StrokeThickness="1" Margin="0,0,4,5">
  187. <Rectangle.Fill>
  188. <SolidColorBrush Color="{Binding SecondaryColor, Mode=OneWay}"/>
  189. </Rectangle.Fill>
  190. </Rectangle>
  191. <xctk:ColorPicker Width="40" Height="40" HorizontalAlignment="Right" VerticalAlignment="Bottom" UsingAlphaChannel="True" AvailableColorsSortingMode="Alphabetical" ShowDropDownButton="False" Background="Transparent" BorderThickness="0" ShowRecentColors="True" Margin="0,0,4,5" SelectedColor="{Binding SecondaryColor, Mode=TwoWay}"/>
  192. </Grid>
  193. </Grid>
  194. </Window>