Browse Source

Added cursors

Frytek 5 years ago
parent
commit
78bde4bbd5

+ 2 - 1
PixiEditor/Models/Tools/ShapeTool.cs

@@ -2,7 +2,7 @@
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
-using System.Text;
+using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media;
 
 
 namespace PixiEditor.Models.Tools
 namespace PixiEditor.Models.Tools
@@ -16,6 +16,7 @@ namespace PixiEditor.Models.Tools
         public ShapeTool()
         public ShapeTool()
         {
         {
             RequiresPreviewLayer = true;
             RequiresPreviewLayer = true;
+            Cursor = Cursors.Cross;
         }
         }
 
 
         protected Coordinates[] BresenhamLine(int x1, int y1, int x2, int y2)
         protected Coordinates[] BresenhamLine(int x1, int y1, int x2, int y2)

+ 2 - 3
PixiEditor/Models/Tools/Tool.cs

@@ -1,8 +1,6 @@
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Layers;
 using PixiEditor.Models.Position;
 using PixiEditor.Models.Position;
-using System;
-using System.Collections.Generic;
-using System.Text;
+using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media;
 
 
 namespace PixiEditor.Models.Tools
 namespace PixiEditor.Models.Tools
@@ -12,5 +10,6 @@ namespace PixiEditor.Models.Tools
         public abstract BitmapPixelChanges Use(Layer layer, Coordinates[] pixels, Color color, int toolSize);
         public abstract BitmapPixelChanges Use(Layer layer, Coordinates[] pixels, Color color, int toolSize);
         public abstract ToolType ToolType { get; }
         public abstract ToolType ToolType { get; }
         public bool RequiresPreviewLayer { get; set; }
         public bool RequiresPreviewLayer { get; set; }
+        public Cursor Cursor { get; set; } = Cursors.Arrow;
     }
     }
 }
 }

+ 5 - 0
PixiEditor/Models/Tools/Tools/PenTool.cs

@@ -3,6 +3,7 @@ using PixiEditor.Models.Position;
 using System;
 using System;
 using System.Collections.Generic;
 using System.Collections.Generic;
 using System.Text;
 using System.Text;
+using System.Windows.Input;
 using System.Windows.Media;
 using System.Windows.Media;
 
 
 namespace PixiEditor.Models.Tools.Tools
 namespace PixiEditor.Models.Tools.Tools
@@ -11,6 +12,10 @@ namespace PixiEditor.Models.Tools.Tools
     {
     {
         public override ToolType ToolType => ToolType.Pen;
         public override ToolType ToolType => ToolType.Pen;
 
 
+        public PenTool()
+        {
+            Cursor = Cursors.Pen;
+        }
 
 
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color, int toolSize)
         public override BitmapPixelChanges Use(Layer layer, Coordinates[] coordinates, Color color, int toolSize)
         {
         {

+ 22 - 12
PixiEditor/Styles/ThemeStyle.xaml

@@ -94,18 +94,28 @@
             </Setter.Value>
             </Setter.Value>
         </Setter>
         </Setter>
     </Style>
     </Style>
-    <ControlTemplate x:Key="{x:Static MenuItem.TopLevelItemTemplateKey}" TargetType="{x:Type MenuItem}">
-        <Border x:Name="Bd">
-            <Grid>
-                <ContentPresenter Margin="6,3,6,3" ContentSource="Header" RecognizesAccessKey="True" />
-            </Grid>
-        </Border>
-        <ControlTemplate.Triggers>
-            <Trigger Property="IsHighlighted"  Value="True">
-                <Setter Property="Background" TargetName="Bd" Value="Gray"/>
-            </Trigger>
-        </ControlTemplate.Triggers>
-    </ControlTemplate>
+    <Style TargetType="MenuItem">
+        <Setter Property="OverridesDefaultStyle" Value="True"/>
+        <Setter Property="Template">
+            <Setter.Value>
+                <ControlTemplate TargetType="MenuItem">
+                    <Border x:Name="Bd" Background="Transparent" Margin="10 0 10 0">
+                        <Grid>
+                            <ContentPresenter Margin="6,3,6,3" ContentSource="Header" RecognizesAccessKey="True" />
+                        </Grid>
+                    </Border>
+                    <ControlTemplate.Triggers>
+                        <Trigger Property="IsHighlighted"  Value="True">
+                            <Setter Property="Background" TargetName="Bd" Value="Gray"/>
+                        </Trigger>
+                        <Trigger Property="IsEnabled" Value="False">
+                            <Setter Property="Foreground" Value="Gray"/>
+                        </Trigger>
+                    </ControlTemplate.Triggers>
+                </ControlTemplate>
+            </Setter.Value>
+        </Setter>
+    </Style>
 
 
     <Style TargetType="Button" x:Key="ImageButtonStyle">
     <Style TargetType="Button" x:Key="ImageButtonStyle">
         <Setter Property="OverridesDefaultStyle" Value="True"/>
         <Setter Property="OverridesDefaultStyle" Value="True"/>

+ 10 - 0
PixiEditor/ViewModels/ViewModelMain.cs

@@ -298,6 +298,16 @@ namespace PixiEditor.ViewModels
         private void SetActiveTool(ToolType tool)
         private void SetActiveTool(ToolType tool)
         {
         {
             BitmapUtility.SelectedTool = ToolSet.Find(x=> x.ToolType == tool);
             BitmapUtility.SelectedTool = ToolSet.Find(x=> x.ToolType == tool);
+            Cursor cursor;
+            if (tool != ToolType.None && tool != ToolType.ColorPicker)
+            {
+               cursor = BitmapUtility.SelectedTool.Cursor;
+            }
+            else
+            {
+                cursor = Cursors.Arrow;
+            }
+            Mouse.OverrideCursor = cursor;
         }
         }
         /// <summary>
         /// <summary>
         /// When mouse is up stops recording changes.
         /// When mouse is up stops recording changes.

+ 1 - 1
PixiEditor/Views/MainWindow.xaml

@@ -106,7 +106,7 @@
             </Grid>
             </Grid>
         </Grid>
         </Grid>
 
 
-        <StackPanel Grid.Row="1" Grid.Column="0" Margin="0,5,5,0" Background="#404040">
+        <StackPanel Cursor="Arrow" Grid.Row="1" Grid.Column="0" Margin="0,5,5,0" Background="#404040">
             <TextBox Style="{StaticResource DarkTextBoxStyle}" Margin="0,10,0,0" Text="{Binding ToolSize, Mode=TwoWay,Converter={StaticResource ToolSizeToIntConverter}}" TextAlignment="Center" MaxLength="4">
             <TextBox Style="{StaticResource DarkTextBoxStyle}" Margin="0,10,0,0" Text="{Binding ToolSize, Mode=TwoWay,Converter={StaticResource ToolSizeToIntConverter}}" TextAlignment="Center" MaxLength="4">
                 <i:Interaction.Behaviors>
                 <i:Interaction.Behaviors>
                     <behaviors:TextBoxNumericFinisherBehavior/>
                     <behaviors:TextBoxNumericFinisherBehavior/>