Skip to content
This repository was archived by the owner on Nov 27, 2024. It is now read-only.

Commit 3ed36b1

Browse files
committed
Recent Colors, Tool Changer
1 parent 0bbc8e0 commit 3ed36b1

File tree

4 files changed

+290
-96
lines changed

4 files changed

+290
-96
lines changed

OnnxStack.UI/MainWindow.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
TextOptions.TextFormattingMode="Ideal"
1919
TextOptions.TextRenderingMode="ClearType"
2020
TextOptions.TextHintingMode="Fixed"
21-
UseLayoutRounding="True"
2221
SnapsToDevicePixels="True"
2322
Style="{StaticResource BaseWindow}">
2423
<Grid DataContext="{Binding ElementName=UI}">

OnnxStack.UI/UserControls/PaintInputControl.xaml

Lines changed: 180 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,15 @@
1010
xmlns:behaviors="clr-namespace:OnnxStack.UI.Behaviors"
1111
xmlns:models="clr-namespace:OnnxStack.UI.Models"
1212
mc:Ignorable="d"
13-
d:DesignWidth="500" Name="UI" Focusable="True" PreviewKeyDown="OnPreviewKeyDown" MouseEnter="OnMouseEnter" AllowDrop="True" PreviewDrop="OnPreviewDrop">
13+
d:DesignWidth="500" Name="UI" Focusable="True" PreviewKeyDown="OnPreviewKeyDown" MouseEnter="OnMouseEnter" AllowDrop="True" PreviewDrop="OnPreviewDrop" PreviewMouseWheel="OnMouseWheel">
1414
<UserControl.Resources>
1515
<Style TargetType="{x:Type Label}">
1616
<Setter Property="Margin" Value="-4,0,0,-4"/>
1717
</Style>
1818
</UserControl.Resources>
1919

2020
<Border DataContext="{Binding ElementName=UI}" BorderBrush="{StaticResource ControlBrightDefaultBorderBrush}" BorderThickness="2" >
21+
2122
<StackPanel Margin="2" >
2223
<Canvas Width="{Binding SchedulerOptions.Width}" Height="{Binding SchedulerOptions.Height}" MinHeight="512" MinWidth="512" ClipToBounds="True">
2324
<InkCanvas x:Name="PaintCanvas" Background="{Binding BackgroundBrush}" ForceCursor="True" Cursor="Pen" MinHeight="512" MinWidth="512"
@@ -30,56 +31,196 @@
3031
DefaultDrawingAttributes="{Binding BrushAttributes}" />
3132
</Canvas>
3233

33-
<UniformGrid Columns="1" Height="30" Visibility="{Binding HasResult, Converter={StaticResource BooleanToHiddenConverter}}">
34+
<UniformGrid Columns="2" Height="30" Margin="0,0,0,0">
3435

35-
</UniformGrid>
36-
<DockPanel Height="30">
37-
<Button DockPanel.Dock="Right" Command="{Binding ClearImageCommand}" BorderThickness="0,1,1,1" Width="50" >
38-
<userControls:FontAwesome Icon="&#xf2ed;" IconStyle="Light" />
39-
</Button>
36+
<UniformGrid Columns="2">
4037

41-
<DockPanel>
42-
<Button DockPanel.Dock="Left" Command="{Binding LoadImageCommand}" ToolTip="Load Image File" Height="30" Width="150" >
43-
<StackPanel Orientation="Horizontal">
44-
<userControls:FontAwesome Icon="&#xf1c5;" IconStyle="Light" Size="13" />
45-
<TextBlock Text="Load Image" Margin="5,0,0,0"/>
46-
</StackPanel>
47-
</Button>
38+
<!--Recent Colors-->
39+
<ListView ItemsSource="{Binding RecentColors, ElementName=ColorPickerControl}" SelectedValue="{Binding SelectedColor}" SelectedValuePath="Color" Background="Transparent" BorderBrush="Transparent">
40+
<ListView.ItemContainerStyle>
41+
<Style TargetType="{x:Type ListViewItem}">
42+
<Setter Property="Background">
43+
<Setter.Value>
44+
<SolidColorBrush Color="{Binding Color}" />
45+
</Setter.Value>
46+
</Setter>
47+
<Setter Property="Template">
48+
<Setter.Value>
49+
<ControlTemplate TargetType="{x:Type ListViewItem}">
50+
<Border BorderBrush="Transparent" BorderThickness="0" Margin="1" Background="White">
51+
<Border Background="{TemplateBinding Background}">
52+
<GridViewRowPresenter HorizontalAlignment="Stretch" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" Width="Auto" Margin="0" Content="{TemplateBinding Content}"/>
53+
</Border>
54+
</Border>
55+
</ControlTemplate>
56+
</Setter.Value>
57+
</Setter>
58+
<Style.Triggers>
59+
<DataTrigger Binding="{Binding CanvasDrawingTool, ElementName=UI}" Value="Highlight">
60+
<Setter Property="Opacity" Value=".6" />
61+
</DataTrigger>
62+
</Style.Triggers>
63+
</Style>
64+
</ListView.ItemContainerStyle>
65+
<ListView.ItemsPanel>
66+
<ItemsPanelTemplate>
67+
<UniformGrid Rows="2" Columns="5" />
68+
</ItemsPanelTemplate>
69+
</ListView.ItemsPanel>
70+
</ListView>
4871

49-
<xctk:ColorPicker
50-
Width="80"
72+
<xctk:ColorPicker x:Name="ColorPickerControl"
5173
DisplayColorAndName="False"
52-
ShowRecentColors="True"
74+
ShowRecentColors="False"
5375
SelectedColor="{Binding SelectedColor}"
54-
ShowStandardColors="False"
55-
ShowTabHeaders="False"
76+
RecentColors="{Binding RecentColors}"
77+
BorderBrush="{StaticResource ControlDefaultBorderBrush}"
78+
ShowTabHeaders="True"
5679
ColorMode="ColorCanvas"
80+
Background="{StaticResource ControlDefaultBackground}"
81+
ShowDropDownButton="False"
82+
ShowStandardColors="False"
83+
DropDownBackground="{StaticResource ContainerBackground}"
84+
TabBackground="{StaticResource ControlDarkerBackground}"
5785
AvailableColorsSortingMode="HueSaturationBrightness" >
5886
</xctk:ColorPicker>
5987

60-
<StackPanel DockPanel.Dock="Right" Orientation="Horizontal" >
61-
<Button DockPanel.Dock="Right" Command="{Binding CanvasModeCommand}" Width="50" Visibility="{Binding IsEraserEnabled, Converter={StaticResource BooleanToVisibilityConverter}}">
62-
<userControls:FontAwesome Icon="&#xf304;" IconStyle="Light" />
63-
</Button>
64-
<Button DockPanel.Dock="Right" Command="{Binding CanvasModeCommand}" Width="50" Visibility="{Binding IsEraserEnabled, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
65-
<userControls:FontAwesome Icon="&#xf12d;" IconStyle="Light" />
66-
</Button>
67-
</StackPanel>
88+
</UniformGrid>
89+
90+
91+
92+
<UniformGrid Columns="5">
93+
94+
<!--Paint Brush-->
95+
<Button Command="{Binding SelectToolCommand}" CommandParameter="{x:Static local:DrawingTool.Brush}">
96+
<userControls:FontAwesome Icon="&#xf1fc;" IconStyle="Light" >
97+
<userControls:FontAwesome.Style>
98+
<Style TargetType="{x:Type userControls:FontAwesome}" >
99+
<Setter Property="BorderThickness" Value="0" />
100+
<Setter Property="Color" Value="{StaticResource ButtonForeground}" />
101+
<Style.Triggers>
102+
<DataTrigger Binding="{Binding CanvasDrawingTool, ElementName=UI}" Value="Brush" >
103+
<Setter Property="BorderThickness" Value="1" />
104+
<Setter Property="Color" Value="{StaticResource ControlPrimaryColourBackground}" />
105+
</DataTrigger>
106+
</Style.Triggers>
107+
</Style>
108+
</userControls:FontAwesome.Style>
109+
</userControls:FontAwesome>
110+
<Button.Style>
111+
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}" >
112+
<Setter Property="BorderThickness" Value="0" />
113+
<Setter Property="BorderBrush" Value="{StaticResource ControlPrimaryColourBackground}" />
114+
<Style.Triggers>
115+
<DataTrigger Binding="{Binding CanvasDrawingTool, ElementName=UI}" Value="Brush" >
116+
<Setter Property="BorderThickness" Value="2" />
117+
</DataTrigger>
118+
</Style.Triggers>
119+
</Style>
120+
</Button.Style>
121+
</Button>
122+
123+
<!--Highlighter-->
124+
<Button Command="{Binding SelectToolCommand}" CommandParameter="{x:Static local:DrawingTool.Highlight}">
125+
<userControls:FontAwesome Icon="&#xf591;" IconStyle="Light" >
126+
<userControls:FontAwesome.Style>
127+
<Style TargetType="{x:Type userControls:FontAwesome}" >
128+
<Setter Property="BorderThickness" Value="0" />
129+
<Setter Property="Color" Value="{StaticResource ButtonForeground}" />
130+
<Style.Triggers>
131+
<DataTrigger Binding="{Binding CanvasDrawingTool, ElementName=UI}" Value="Highlight" >
132+
<Setter Property="BorderThickness" Value="1" />
133+
<Setter Property="Color" Value="{StaticResource ControlPrimaryColourBackground}" />
134+
</DataTrigger>
135+
</Style.Triggers>
136+
</Style>
137+
</userControls:FontAwesome.Style>
138+
</userControls:FontAwesome>
139+
<Button.Style>
140+
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}" >
141+
<Setter Property="BorderThickness" Value="0" />
142+
<Setter Property="BorderBrush" Value="{StaticResource ControlPrimaryColourBackground}" />
143+
<Style.Triggers>
144+
<DataTrigger Binding="{Binding CanvasDrawingTool, ElementName=UI}" Value="Highlight" >
145+
<Setter Property="BorderThickness" Value="2" />
146+
</DataTrigger>
147+
</Style.Triggers>
148+
</Style>
149+
</Button.Style>
150+
</Button>
151+
152+
153+
<!--Eraser-->
154+
<Button Command="{Binding SelectToolCommand}" CommandParameter="{x:Static local:DrawingTool.Eraser}">
155+
<userControls:FontAwesome Icon="&#xf12d;" IconStyle="Light" >
156+
<userControls:FontAwesome.Style>
157+
<Style TargetType="{x:Type userControls:FontAwesome}" >
158+
<Setter Property="BorderThickness" Value="0" />
159+
<Setter Property="Color" Value="{StaticResource ButtonForeground}" />
160+
<Style.Triggers>
161+
<DataTrigger Binding="{Binding CanvasDrawingTool, ElementName=UI}" Value="Eraser" >
162+
<Setter Property="BorderThickness" Value="1" />
163+
<Setter Property="Color" Value="{StaticResource ControlPrimaryColourBackground}" />
164+
</DataTrigger>
165+
</Style.Triggers>
166+
</Style>
167+
</userControls:FontAwesome.Style>
168+
</userControls:FontAwesome>
169+
<Button.Style>
170+
<Style TargetType="{x:Type Button}" BasedOn="{StaticResource {x:Type Button}}" >
171+
<Setter Property="BorderThickness" Value="0" />
172+
<Setter Property="BorderBrush" Value="{StaticResource ControlPrimaryColourBackground}" />
173+
<Style.Triggers>
174+
<DataTrigger Binding="{Binding CanvasDrawingTool, ElementName=UI}" Value="Eraser" >
175+
<Setter Property="BorderThickness" Value="2" />
176+
</DataTrigger>
177+
</Style.Triggers>
178+
</Style>
179+
</Button.Style>
180+
</Button>
181+
182+
183+
<!--Fill-->
184+
<Button Command="{Binding FillCanvasCommand}">
185+
<userControls:FontAwesome Icon="&#xf576;" IconStyle="Light" />
186+
</Button>
187+
188+
<!--Clear-->
189+
<Button Command="{Binding ClearCanvasCommand}">
190+
<userControls:FontAwesome Icon="&#xf2ed;" IconStyle="Light" />
191+
</Button>
192+
</UniformGrid>
193+
194+
</UniformGrid>
195+
196+
<UniformGrid Columns="3" Height="30">
68197

69-
<StackPanel Margin="0,0,5,0" >
70-
<UniformGrid Columns="2" >
71-
<TextBlock Text="Pen Size" VerticalAlignment="Bottom" FontSize="8" Margin="5,-4,6,0" Opacity=".6" FontStyle="Italic" />
72-
<TextBlock Text="{Binding ElementName=SliderMaskDrawSize, Path=Value, StringFormat={}{0}}" VerticalAlignment="Bottom" FontSize="8" Margin="0,-4,6,0" FontWeight="Medium" HorizontalAlignment="Right" />
73-
</UniformGrid>
74-
<Slider Name="SliderMaskDrawSize" Value="{Binding BrushDrawSize}" Minimum="2" Maximum="40" TickFrequency="1" IsSnapToTickEnabled="True" SmallChange="1" LargeChange="1" >
75-
<i:Interaction.Behaviors>
76-
<behaviors:SliderMouseWheelBehavior />
77-
</i:Interaction.Behaviors>
78-
</Slider>
198+
<!--Load Image-->
199+
<Button DockPanel.Dock="Left" Command="{Binding LoadImageCommand}" ToolTip="Load Image File" Height="30" >
200+
<StackPanel Orientation="Horizontal">
201+
<userControls:FontAwesome Icon="&#xf1c5;" IconStyle="Light" Size="13" />
202+
<TextBlock Text="Load Image" Margin="5,0,0,0"/>
79203
</StackPanel>
80-
</DockPanel>
204+
</Button>
205+
81206

82-
</DockPanel>
207+
<StackPanel>
208+
</StackPanel>
209+
210+
<!--Tool Size-->
211+
<StackPanel Margin="0,5,0,0" >
212+
<UniformGrid Columns="2" >
213+
<TextBlock Text="Tool Size" VerticalAlignment="Bottom" FontSize="8" Margin="5,-4,6,0" Opacity=".6" FontStyle="Italic" />
214+
<TextBlock Text="{Binding ElementName=SliderMaskDrawSize, Path=Value, StringFormat={}{0}}" VerticalAlignment="Bottom" FontSize="8" Margin="0,-4,6,0" FontWeight="Medium" HorizontalAlignment="Right" />
215+
</UniformGrid>
216+
<Slider Name="SliderMaskDrawSize" Value="{Binding DrawingToolSize}" Minimum="1" Maximum="40" TickFrequency="1" IsSnapToTickEnabled="True" SmallChange="1" LargeChange="1" >
217+
<i:Interaction.Behaviors>
218+
<behaviors:SliderMouseWheelBehavior />
219+
</i:Interaction.Behaviors>
220+
</Slider>
221+
</StackPanel>
222+
223+
</UniformGrid>
83224
</StackPanel>
84225
</Border>
85226
</UserControl>

0 commit comments

Comments
 (0)