109 lines
2.9 KiB
C#
109 lines
2.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.IO;
|
|
using System.Threading.Tasks;
|
|
using Avalonia;
|
|
using Avalonia.Controls;
|
|
using Avalonia.Input;
|
|
using Avalonia.Media;
|
|
using Avalonia.Media.Imaging;
|
|
using Avalonia.Platform;
|
|
using Avalonia.Platform.Storage;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using SimpleDraw.Models;
|
|
using SimpleDraw.Views;
|
|
|
|
namespace SimpleDraw.ViewModels;
|
|
|
|
public class ViewModelBase : ObservableObject
|
|
{
|
|
public int WindowWidth { get; set; } = 1200;
|
|
public int WindowHeight { get; set; } = 800;
|
|
public ObservableCollection<ColorPickerButton>? ColorPalette { get; set; }
|
|
public IRelayCommand<PointerPressedEventArgs>? CanvasPointerPressedCommand { get; set; }
|
|
public IRelayCommand<PointerEventArgs>? CanvasPointerMovedCommand { get; set; }
|
|
public IRelayCommand<PointerReleasedEventArgs>? CanvasPointerReleasedCommand { get; set; }
|
|
public ObservableCollection<DrawingPoints> DrawingPoints { get; set; } = new();
|
|
public DrawingPoints? DrawingPoint { get; set; }
|
|
protected List<DrawingPoints> UndoDrawingPoints = new();
|
|
|
|
protected bool IsDrawing { get; set; }
|
|
|
|
private string _selectedColor = "Black";
|
|
|
|
public string SelectedColor
|
|
{
|
|
get => _selectedColor;
|
|
set => SetProperty(ref _selectedColor, value);
|
|
}
|
|
|
|
private Brush _brush = new SolidColorBrush(new Color(a: 255, r: 0, g: 0, b: 0));
|
|
private int _brushThickness = 2;
|
|
|
|
protected Brush Brush
|
|
{
|
|
get => _brush;
|
|
set => SetProperty(ref _brush, value);
|
|
}
|
|
|
|
public int BrushThickness
|
|
{
|
|
get => _brushThickness;
|
|
set => SetProperty(ref _brushThickness, value);
|
|
}
|
|
|
|
private double _buttonOffset = 0;
|
|
|
|
public double ButtonOffset
|
|
{
|
|
get => _buttonOffset;
|
|
set => SetProperty(ref _buttonOffset, value);
|
|
}
|
|
|
|
private bool _isSplitOpen = false;
|
|
|
|
public bool IsSplitOpen
|
|
{
|
|
get => _isSplitOpen;
|
|
set => SetProperty(ref _isSplitOpen, value);
|
|
}
|
|
|
|
public IRelayCommand DisplaySplitEvent { get; protected set; }
|
|
protected void DisplaySplit()
|
|
{
|
|
IsSplitOpen = !IsSplitOpen;
|
|
}
|
|
|
|
private WindowState _windowStateProperty;
|
|
|
|
public WindowState WindowStateProperty
|
|
{
|
|
get => _windowStateProperty;
|
|
set => SetProperty(ref _windowStateProperty, value);
|
|
}
|
|
|
|
public IRelayCommand CloseAppEvent { get; protected set; }
|
|
|
|
protected void CloseApp()
|
|
{
|
|
Environment.Exit(0);
|
|
}
|
|
|
|
public IRelayCommand MaximizeAppEvent { get; protected set; }
|
|
|
|
protected void MaximizeApp()
|
|
{
|
|
WindowStateProperty = WindowState.Maximized;
|
|
}
|
|
|
|
public IRelayCommand MinimizeAppEvent { get; protected set; }
|
|
|
|
protected void MinimizeApp()
|
|
{
|
|
WindowStateProperty = WindowState.Minimized;
|
|
}
|
|
}
|