Made minor changes in behavior
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
using Avalonia.Input;
|
using Avalonia.Input;
|
||||||
using Avalonia.Media;
|
using Avalonia.Media;
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
@@ -9,6 +10,9 @@ namespace SimpleDraw.ViewModels;
|
|||||||
|
|
||||||
public class ViewModelBase : ObservableObject
|
public class ViewModelBase : ObservableObject
|
||||||
{
|
{
|
||||||
|
public int WindowWidth { get; set; } = 1200;
|
||||||
|
public int WindowHeight { get; set; } = 800;
|
||||||
|
|
||||||
public ObservableCollection<ColorPickerButton>? ColorPalette { get; set; }
|
public ObservableCollection<ColorPickerButton>? ColorPalette { get; set; }
|
||||||
public IRelayCommand<PointerPressedEventArgs>? CanvasPointerPressedCommand { get; set; }
|
public IRelayCommand<PointerPressedEventArgs>? CanvasPointerPressedCommand { get; set; }
|
||||||
public IRelayCommand<PointerEventArgs>? CanvasPointerMovedCommand { get; set; }
|
public IRelayCommand<PointerEventArgs>? CanvasPointerMovedCommand { get; set; }
|
||||||
@@ -26,7 +30,7 @@ public class ViewModelBase : ObservableObject
|
|||||||
get => _brush;
|
get => _brush;
|
||||||
set => SetProperty(ref _brush, value);
|
set => SetProperty(ref _brush, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double BrushThickness
|
public double BrushThickness
|
||||||
{
|
{
|
||||||
get => _brushThickness;
|
get => _brushThickness;
|
||||||
|
|||||||
+30
-18
@@ -9,23 +9,36 @@
|
|||||||
xmlns:i="using:Avalonia.Xaml.Interactivity"
|
xmlns:i="using:Avalonia.Xaml.Interactivity"
|
||||||
xmlns:behaviors="using:Avalonia.Xaml.Interactions.Core"
|
xmlns:behaviors="using:Avalonia.Xaml.Interactions.Core"
|
||||||
xmlns:componentModel="clr-namespace:CommunityToolkit.Mvvm.ComponentModel;assembly=CommunityToolkit.Mvvm"
|
xmlns:componentModel="clr-namespace:CommunityToolkit.Mvvm.ComponentModel;assembly=CommunityToolkit.Mvvm"
|
||||||
|
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||||
x:DataType="vm:MainWindowViewModel"
|
x:DataType="vm:MainWindowViewModel"
|
||||||
Icon="/Assets/avalonia-logo.ico"
|
Icon="/Assets/avalonia-logo.ico"
|
||||||
Title="SimpleDraw">
|
Title="SimpleDraw"
|
||||||
|
Width="{Binding WindowWidth}"
|
||||||
|
Height="{Binding WindowHeight}"
|
||||||
|
MinWidth="400"
|
||||||
|
MinHeight="300"
|
||||||
|
WindowStartupLocation="CenterScreen"
|
||||||
|
>
|
||||||
|
<Window.Resources>
|
||||||
|
<system:String x:Key="BrushSizeFormat">{0:0.#####}</system:String>
|
||||||
|
</Window.Resources>
|
||||||
|
|
||||||
<Design.DataContext>
|
<Design.DataContext>
|
||||||
<!-- This only sets the DataContext for the previewer in an IDE,
|
<!-- This only sets the DataContext for the previewer in an IDE,
|
||||||
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
to set the actual DataContext for runtime, set the DataContext property in code (look at App.axaml.cs) -->
|
||||||
<vm:MainWindowViewModel/>
|
<vm:MainWindowViewModel/>
|
||||||
</Design.DataContext>
|
</Design.DataContext>
|
||||||
|
|
||||||
<Panel>
|
<DockPanel>
|
||||||
<Menu>
|
<Menu DockPanel.Dock="Top">
|
||||||
<MenuItem>
|
<MenuItem Header="_File">
|
||||||
File
|
<MenuItem Header="_Open..."/>
|
||||||
|
<Separator/>
|
||||||
|
<MenuItem Header="_Exit"/>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem>
|
<MenuItem Header="_Edit">
|
||||||
Edit
|
<MenuItem Header="Copy"/>
|
||||||
|
<MenuItem Header="Paste"/>
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
</Menu>
|
</Menu>
|
||||||
<Grid Background="Gray">
|
<Grid Background="Gray">
|
||||||
@@ -33,11 +46,7 @@
|
|||||||
<ColumnDefinition Width="105"></ColumnDefinition>
|
<ColumnDefinition Width="105"></ColumnDefinition>
|
||||||
<ColumnDefinition Width="1*" MinWidth="300"></ColumnDefinition>
|
<ColumnDefinition Width="1*" MinWidth="300"></ColumnDefinition>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<Grid.RowDefinitions>
|
<Grid Grid.Column="0" Background="LightGray">
|
||||||
<RowDefinition Height="25"></RowDefinition>
|
|
||||||
<RowDefinition Height="1*" MinHeight="300"></RowDefinition>
|
|
||||||
</Grid.RowDefinitions>
|
|
||||||
<Grid Grid.Row="1" Grid.Column="0" Background="LightGray">
|
|
||||||
<Grid.RowDefinitions>
|
<Grid.RowDefinitions>
|
||||||
<RowDefinition Height="50*"></RowDefinition>
|
<RowDefinition Height="50*"></RowDefinition>
|
||||||
<RowDefinition Height="50*"></RowDefinition>
|
<RowDefinition Height="50*"></RowDefinition>
|
||||||
@@ -66,10 +75,14 @@
|
|||||||
</DataTemplate>
|
</DataTemplate>
|
||||||
</ItemsControl.ItemTemplate>
|
</ItemsControl.ItemTemplate>
|
||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
<Slider Margin="5" Value="{Binding BrushThickness}" Maximum="50" Minimum="0.5"></Slider>
|
<TextBox HorizontalAlignment="Left" TextAlignment="Left" Margin="5,5,5,0" IsHitTestVisible="False" IsReadOnly="True" BorderThickness="0" Background="Transparent">
|
||||||
|
Brush Size:
|
||||||
|
</TextBox>
|
||||||
|
<TextBox Text="{Binding BrushThickness, Mode=TwoWay}" Margin="5,0" HorizontalAlignment="Stretch" TextAlignment="Left" BorderThickness="2" Background="Transparent"></TextBox>
|
||||||
|
<Slider Margin="5, 0" Value="{Binding BrushThickness}" Maximum="50" Minimum="0.5"></Slider>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Canvas Grid.Row="1" Grid.Column="1" Background="White">
|
<Canvas Grid.Column="1" Background="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||||
<i:Interaction.Behaviors>
|
<i:Interaction.Behaviors>
|
||||||
<behaviors:EventTriggerBehavior EventName="PointerPressed">
|
<behaviors:EventTriggerBehavior EventName="PointerPressed">
|
||||||
<behaviors:InvokeCommandAction
|
<behaviors:InvokeCommandAction
|
||||||
@@ -91,7 +104,7 @@
|
|||||||
<ItemsControl ItemsSource="{Binding DrawingPoints}">
|
<ItemsControl ItemsSource="{Binding DrawingPoints}">
|
||||||
<ItemsControl.ItemsPanel>
|
<ItemsControl.ItemsPanel>
|
||||||
<ItemsPanelTemplate>
|
<ItemsPanelTemplate>
|
||||||
<Panel/>
|
<Panel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinWidth="{Binding WindowWidth}" MinHeight="{Binding WindowHeight}"/>
|
||||||
</ItemsPanelTemplate>
|
</ItemsPanelTemplate>
|
||||||
</ItemsControl.ItemsPanel>
|
</ItemsControl.ItemsPanel>
|
||||||
<ItemsControl.ItemTemplate>
|
<ItemsControl.ItemTemplate>
|
||||||
@@ -106,6 +119,5 @@
|
|||||||
</ItemsControl>
|
</ItemsControl>
|
||||||
</Canvas>
|
</Canvas>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Panel>
|
</DockPanel>
|
||||||
|
|
||||||
</Window>
|
</Window>
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
|
using Avalonia.Input;
|
||||||
using SimpleDraw.ViewModels;
|
using SimpleDraw.ViewModels;
|
||||||
|
|
||||||
namespace SimpleDraw.Views;
|
namespace SimpleDraw.Views;
|
||||||
@@ -9,5 +10,7 @@ public partial class MainWindow : Window
|
|||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
DataContext = new MainWindowViewModel();
|
DataContext = new MainWindowViewModel();
|
||||||
|
Topmost = true;
|
||||||
|
Topmost = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user