[ADDED] made a color picker for the canvas
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.0.1" />
|
||||
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="3.2.9" />
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:local="clr-namespace:Client.Views"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
mc:Ignorable="d"
|
||||
Title="Scrubl.io" Height="600" Width="1200">
|
||||
<Grid>
|
||||
@@ -11,7 +12,7 @@
|
||||
<RowDefinition Height="50"/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="200"/>
|
||||
<ColumnDefinition/>
|
||||
@@ -29,23 +30,19 @@
|
||||
<RowDefinition/>
|
||||
<RowDefinition/>
|
||||
</Grid.RowDefinitions>
|
||||
<Label Grid.Row="0" Content="{Binding Path=...}" FontSize="15"/>
|
||||
<Label Grid.Row="1" Content="{Binding Path=...}" FontSize="15"/>
|
||||
<Label Grid.Row="2" Content="{Binding Path=...}" FontSize="15"/>
|
||||
<Label Grid.Row="3" Content="{Binding Path=...}" FontSize="15"/>
|
||||
<Label Grid.Row="4" Content="{Binding Path=...}" FontSize="15"/>
|
||||
<Label Grid.Row="5" Content="{Binding Path=...}" FontSize="15"/>
|
||||
<Label Grid.Row="6" Content="{Binding Path=...}" FontSize="15"/>
|
||||
<Label Grid.Row="7" Content="{Binding Path=...}" FontSize="15"/>
|
||||
|
||||
|
||||
</Grid>
|
||||
|
||||
<Button Name="CanvasReset" Click="CanvasReset_Click" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Right" Width="100" Margin="10, 10, 10, 10" Content="RESET" />
|
||||
<Canvas Name="CanvasForPaint" Grid.Row="1" Grid.Column="1" MouseDown="CanvasForPaint_MouseDown" MouseMove="CanvasForPaint_MouseMove" Margin="10, 10, 10, 10">
|
||||
<Button Name="CanvasReset" Click="CanvasReset_Click" Grid.Row="0" Grid.Column="1" Margin="890,10,10,10" Content="RESET" />
|
||||
|
||||
<xctk:ColorPicker Name="ClrPcker_Background" SelectedColorChanged="ClrPcker_Background_SelectedColorChanged_1" Grid.Row="0" Grid.Column="1" HorizontalAlignment="Left" VerticalAlignment="Center"></xctk:ColorPicker>
|
||||
|
||||
<Canvas Name="CanvasForPaint" Grid.Row="1" Grid.Column="1" MouseDown="CanvasForPaint_MouseDown" MouseMove="CanvasForPaint_MouseMove" Margin="10, 10, 10, 10" >
|
||||
<Canvas.Background>
|
||||
<SolidColorBrush Color="White" Opacity="0"/>
|
||||
</Canvas.Background>
|
||||
</Canvas>
|
||||
|
||||
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
@@ -40,7 +40,9 @@ namespace Client.Views
|
||||
{
|
||||
Line line = new Line();
|
||||
|
||||
line.Stroke = SystemColors.WindowFrameBrush;
|
||||
|
||||
line.Stroke = new SolidColorBrush(color);
|
||||
//line.Stroke = SystemColors.WindowFrameBrush;
|
||||
line.X1 = currentPoint.X;
|
||||
line.Y1 = currentPoint.Y;
|
||||
line.X2 = e.GetPosition(CanvasForPaint).X;
|
||||
@@ -53,11 +55,22 @@ namespace Client.Views
|
||||
|
||||
}
|
||||
|
||||
private Color color;
|
||||
|
||||
private void ClrPcker_Background_SelectedColorChanged(object sender, RoutedPropertyChangedEventArgs<Color> e)
|
||||
{
|
||||
Color colorSelected = new Color();
|
||||
colorSelected.A = 255;
|
||||
colorSelected.R = ClrPcker_Background.SelectedColor.Value.R;
|
||||
colorSelected.G = ClrPcker_Background.SelectedColor.Value.G;
|
||||
colorSelected.B = ClrPcker_Background.SelectedColor.Value.B;
|
||||
color = colorSelected;
|
||||
}
|
||||
|
||||
private void CanvasReset_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
CanvasForPaint.Children.Clear();
|
||||
|
||||
|
||||
//FOR FUTURE USE, IF NECCESSARY
|
||||
//TEST.Children.Clear();
|
||||
|
||||
@@ -69,5 +82,15 @@ namespace Client.Views
|
||||
//}
|
||||
|
||||
}
|
||||
|
||||
private void ClrPcker_Background_SelectedColorChanged_1(object sender, RoutedPropertyChangedEventArgs<Color?> e)
|
||||
{
|
||||
Color colorSelected = new Color();
|
||||
colorSelected.A = 255;
|
||||
colorSelected.R = ClrPcker_Background.SelectedColor.Value.R;
|
||||
colorSelected.G = ClrPcker_Background.SelectedColor.Value.G;
|
||||
colorSelected.B = ClrPcker_Background.SelectedColor.Value.B;
|
||||
color = colorSelected;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="AsyncAwaitBestPractices" Version="4.3.0" />
|
||||
<PackageReference Include="Extended.Wpf.Toolkit" Version="4.0.1" />
|
||||
<PackageReference Include="MvvmLightLibs" Version="5.4.1.1" />
|
||||
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
|
||||
<PackageReference Include="PropertyChanged.Fody" Version="3.2.9" />
|
||||
|
||||
Reference in New Issue
Block a user