Compare commits
5 Commits
036acd4d19
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7a8e8a0bd3 | |||
| aaa2715243 | |||
| 9d4961af86 | |||
| da3dc87ed3 | |||
| e811a54c61 |
+6
-6
@@ -13,13 +13,13 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Avalonia" Version="11.2.4" />
|
<PackageReference Include="Avalonia" Version="11.2.5" />
|
||||||
<PackageReference Include="Avalonia.Desktop" Version="11.2.4" />
|
<PackageReference Include="Avalonia.Desktop" Version="11.2.5" />
|
||||||
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.4" />
|
<PackageReference Include="Avalonia.Themes.Fluent" Version="11.2.5" />
|
||||||
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.4" />
|
<PackageReference Include="Avalonia.Fonts.Inter" Version="11.2.5" />
|
||||||
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
<!--Condition below is needed to remove Avalonia.Diagnostics package from build output in Release configuration.-->
|
||||||
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.4" />
|
<PackageReference Condition="'$(Configuration)' == 'Debug'" Include="Avalonia.Diagnostics" Version="11.2.5" />
|
||||||
<PackageReference Include="Avalonia.Xaml.Interactions" Version="11.2.0.9" />
|
<PackageReference Include="Avalonia.Xaml.Interactions" Version="11.2.0.14" />
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -84,7 +84,8 @@ public class MainWindowViewModel : ViewModelBase
|
|||||||
private void OnCanvasPointerPressed(PointerPressedEventArgs? e)
|
private void OnCanvasPointerPressed(PointerPressedEventArgs? e)
|
||||||
{
|
{
|
||||||
if (e == null) return;
|
if (e == null) return;
|
||||||
|
if(UndoDrawingPoints.Count > 0) UndoDrawingPoints.Clear();
|
||||||
|
|
||||||
IsDrawing = true;
|
IsDrawing = true;
|
||||||
DrawingPoints.Add(new DrawingPoints(Brush, BrushThickness));
|
DrawingPoints.Add(new DrawingPoints(Brush, BrushThickness));
|
||||||
DrawingPoint = DrawingPoints[^1];
|
DrawingPoint = DrawingPoints[^1];
|
||||||
@@ -111,4 +112,26 @@ public class MainWindowViewModel : ViewModelBase
|
|||||||
{
|
{
|
||||||
IsDrawing = false;
|
IsDrawing = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void GlobalKeyUpHandler(KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.KeyModifiers != KeyModifiers.Control) return;
|
||||||
|
switch (e.Key)
|
||||||
|
{
|
||||||
|
case Key.Z:
|
||||||
|
if (DrawingPoints.Count > 0)
|
||||||
|
{
|
||||||
|
UndoDrawingPoints.Add(DrawingPoints[^1]);
|
||||||
|
DrawingPoints.Remove(DrawingPoints[^1]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Key.Y:
|
||||||
|
if (UndoDrawingPoints.Count > 0)
|
||||||
|
{
|
||||||
|
DrawingPoints.Add(UndoDrawingPoints[^1]);
|
||||||
|
UndoDrawingPoints.Remove(UndoDrawingPoints[^1]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel.DataAnnotations;
|
using System.ComponentModel.DataAnnotations;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
@@ -27,7 +28,8 @@ public class ViewModelBase : ObservableObject
|
|||||||
public IRelayCommand<PointerReleasedEventArgs>? CanvasPointerReleasedCommand { get; set; }
|
public IRelayCommand<PointerReleasedEventArgs>? CanvasPointerReleasedCommand { get; set; }
|
||||||
public ObservableCollection<DrawingPoints> DrawingPoints { get; set; } = new();
|
public ObservableCollection<DrawingPoints> DrawingPoints { get; set; } = new();
|
||||||
public DrawingPoints? DrawingPoint { get; set; }
|
public DrawingPoints? DrawingPoint { get; set; }
|
||||||
|
protected List<DrawingPoints> UndoDrawingPoints = new();
|
||||||
|
|
||||||
protected bool IsDrawing { get; set; }
|
protected bool IsDrawing { get; set; }
|
||||||
|
|
||||||
private string _selectedColor = "Black";
|
private string _selectedColor = "Black";
|
||||||
|
|||||||
@@ -36,10 +36,10 @@
|
|||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
|
|
||||||
<Panel Background="Transparent">
|
<Panel Background="Transparent">
|
||||||
<SplitView Background="Transparent" IsPaneOpen="{Binding IsSplitOpen, Mode=TwoWay}" DisplayMode="Overlay" OpenPaneLength="250" ClipToBounds="False">
|
<SplitView Background="Transparent" IsPaneOpen="{Binding IsSplitOpen, Mode=TwoWay}" DisplayMode="Overlay" OpenPaneLength="250" ClipToBounds="False" PaneBackground="Transparent">
|
||||||
<SplitView.Pane>
|
<SplitView.Pane>
|
||||||
<Border Background="Transparent" BorderBrush="Gray" BorderThickness="0" CornerRadius="0, 12.5,12.5,0" >
|
<Border Background="#d4d4fc" BorderBrush="Gray" BorderThickness="1" CornerRadius="0, 12.5,12.5,0">
|
||||||
<Grid Background="#66ffffff">
|
<Grid Background="#d4d4fc" Margin="5"> <!-- Background of left panel opened -->
|
||||||
<Grid Background="Transparent">
|
<Grid Background="Transparent">
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="50*"></RowDefinition>
|
<RowDefinition Height="50*"></RowDefinition>
|
||||||
@@ -133,6 +133,7 @@
|
|||||||
</Grid>
|
</Grid>
|
||||||
</SplitView>
|
</SplitView>
|
||||||
<!-- left Info bar -->
|
<!-- left Info bar -->
|
||||||
|
|
||||||
<StackPanel Width="30" HorizontalAlignment="Left" IsVisible="{Binding !IsSplitOpen}" Background="#d4d4fc">
|
<StackPanel Width="30" HorizontalAlignment="Left" IsVisible="{Binding !IsSplitOpen}" Background="#d4d4fc">
|
||||||
<!-- Menu-Opener -->
|
<!-- Menu-Opener -->
|
||||||
<Button Content="≡"
|
<Button Content="≡"
|
||||||
|
|||||||
@@ -19,6 +19,16 @@ public partial class MainWindow : Window
|
|||||||
DataContext = new MainWindowViewModel();
|
DataContext = new MainWindowViewModel();
|
||||||
Topmost = true;
|
Topmost = true;
|
||||||
Topmost = false;
|
Topmost = false;
|
||||||
|
|
||||||
|
this.KeyUp += OnKeyUp;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnKeyUp(object? sender, KeyEventArgs e)
|
||||||
|
{
|
||||||
|
if (DataContext is MainWindowViewModel vm)
|
||||||
|
{
|
||||||
|
vm.GlobalKeyUpHandler(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MVVM like implementations burst the bounds -> implemented the old school way
|
// MVVM like implementations burst the bounds -> implemented the old school way
|
||||||
|
|||||||
Reference in New Issue
Block a user