Made minor changes in behavior
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using Avalonia.Input;
|
||||
using Avalonia.Media;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
@@ -9,6 +10,9 @@ 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; }
|
||||
@@ -26,7 +30,7 @@ public class ViewModelBase : ObservableObject
|
||||
get => _brush;
|
||||
set => SetProperty(ref _brush, value);
|
||||
}
|
||||
|
||||
|
||||
public double BrushThickness
|
||||
{
|
||||
get => _brushThickness;
|
||||
|
||||
+30
-18
@@ -9,23 +9,36 @@
|
||||
xmlns:i="using:Avalonia.Xaml.Interactivity"
|
||||
xmlns:behaviors="using:Avalonia.Xaml.Interactions.Core"
|
||||
xmlns:componentModel="clr-namespace:CommunityToolkit.Mvvm.ComponentModel;assembly=CommunityToolkit.Mvvm"
|
||||
xmlns:system="clr-namespace:System;assembly=System.Runtime"
|
||||
x:DataType="vm:MainWindowViewModel"
|
||||
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>
|
||||
<!-- 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) -->
|
||||
<vm:MainWindowViewModel/>
|
||||
</Design.DataContext>
|
||||
|
||||
<Panel>
|
||||
<Menu>
|
||||
<MenuItem>
|
||||
File
|
||||
<DockPanel>
|
||||
<Menu DockPanel.Dock="Top">
|
||||
<MenuItem Header="_File">
|
||||
<MenuItem Header="_Open..."/>
|
||||
<Separator/>
|
||||
<MenuItem Header="_Exit"/>
|
||||
</MenuItem>
|
||||
<MenuItem>
|
||||
Edit
|
||||
<MenuItem Header="_Edit">
|
||||
<MenuItem Header="Copy"/>
|
||||
<MenuItem Header="Paste"/>
|
||||
</MenuItem>
|
||||
</Menu>
|
||||
<Grid Background="Gray">
|
||||
@@ -33,11 +46,7 @@
|
||||
<ColumnDefinition Width="105"></ColumnDefinition>
|
||||
<ColumnDefinition Width="1*" MinWidth="300"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="25"></RowDefinition>
|
||||
<RowDefinition Height="1*" MinHeight="300"></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<Grid Grid.Row="1" Grid.Column="0" Background="LightGray">
|
||||
<Grid Grid.Column="0" Background="LightGray">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50*"></RowDefinition>
|
||||
<RowDefinition Height="50*"></RowDefinition>
|
||||
@@ -66,10 +75,14 @@
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</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>
|
||||
</Grid>
|
||||
<Canvas Grid.Row="1" Grid.Column="1" Background="White">
|
||||
<Canvas Grid.Column="1" Background="White" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
|
||||
<i:Interaction.Behaviors>
|
||||
<behaviors:EventTriggerBehavior EventName="PointerPressed">
|
||||
<behaviors:InvokeCommandAction
|
||||
@@ -91,7 +104,7 @@
|
||||
<ItemsControl ItemsSource="{Binding DrawingPoints}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<Panel/>
|
||||
<Panel HorizontalAlignment="Stretch" VerticalAlignment="Stretch" MinWidth="{Binding WindowWidth}" MinHeight="{Binding WindowHeight}"/>
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
@@ -106,6 +119,5 @@
|
||||
</ItemsControl>
|
||||
</Canvas>
|
||||
</Grid>
|
||||
</Panel>
|
||||
|
||||
</DockPanel>
|
||||
</Window>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Input;
|
||||
using SimpleDraw.ViewModels;
|
||||
|
||||
namespace SimpleDraw.Views;
|
||||
@@ -9,5 +10,7 @@ public partial class MainWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new MainWindowViewModel();
|
||||
Topmost = true;
|
||||
Topmost = false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user