|
@@ -4,6 +4,7 @@ using System.Windows;
|
|
using System.Windows.Automation;
|
|
using System.Windows.Automation;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Input;
|
|
using System.Windows.Input;
|
|
|
|
+using PixiEditor.Models.Tools.Tools;
|
|
using Xceed.Wpf.Toolkit.Core.Input;
|
|
using Xceed.Wpf.Toolkit.Core.Input;
|
|
using Xceed.Wpf.Toolkit.Zoombox;
|
|
using Xceed.Wpf.Toolkit.Zoombox;
|
|
|
|
|
|
@@ -41,6 +42,9 @@ namespace PixiEditor.Views
|
|
public static readonly DependencyProperty ItemProperty =
|
|
public static readonly DependencyProperty ItemProperty =
|
|
DependencyProperty.Register("Item", typeof(object), typeof(MainDrawingPanel), new PropertyMetadata(default(FrameworkElement)));
|
|
DependencyProperty.Register("Item", typeof(object), typeof(MainDrawingPanel), new PropertyMetadata(default(FrameworkElement)));
|
|
|
|
|
|
|
|
+ // Using a DependencyProperty as the backing store for Item. This enables animation, styling, binding, etc...
|
|
|
|
+ public static readonly DependencyProperty IsUsingZoomToolProperty =
|
|
|
|
+ DependencyProperty.Register("IsUsingZoomTool", typeof(bool), typeof(MainDrawingPanel), new PropertyMetadata(false));
|
|
|
|
|
|
|
|
|
|
public double ZoomPercentage
|
|
public double ZoomPercentage
|
|
@@ -53,6 +57,52 @@ namespace PixiEditor.Views
|
|
public static readonly DependencyProperty ZoomPrecentageProperty =
|
|
public static readonly DependencyProperty ZoomPrecentageProperty =
|
|
DependencyProperty.Register("ZoomPercentage", typeof(double), typeof(MainDrawingPanel), new PropertyMetadata(0.0, ZoomPercentegeChanged));
|
|
DependencyProperty.Register("ZoomPercentage", typeof(double), typeof(MainDrawingPanel), new PropertyMetadata(0.0, ZoomPercentegeChanged));
|
|
|
|
|
|
|
|
+
|
|
|
|
+ public bool Center
|
|
|
|
+ {
|
|
|
|
+ get => (bool) GetValue(CenterProperty);
|
|
|
|
+ set => SetValue(CenterProperty, value);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public double MouseX
|
|
|
|
+ {
|
|
|
|
+ get => (double) GetValue(MouseXProperty);
|
|
|
|
+ set => SetValue(MouseXProperty, value);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public double MouseY
|
|
|
|
+ {
|
|
|
|
+ get => (double) GetValue(MouseYProperty);
|
|
|
|
+ set => SetValue(MouseYProperty, value);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public ICommand MouseMoveCommand
|
|
|
|
+ {
|
|
|
|
+ get => (ICommand) GetValue(MouseMoveCommandProperty);
|
|
|
|
+ set => SetValue(MouseMoveCommandProperty, value);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public bool CenterOnStart
|
|
|
|
+ {
|
|
|
|
+ get => (bool) GetValue(CenterOnStartProperty);
|
|
|
|
+ set => SetValue(CenterOnStartProperty, value);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ public object Item
|
|
|
|
+ {
|
|
|
|
+ get => GetValue(ItemProperty);
|
|
|
|
+ set => SetValue(ItemProperty, value);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public bool IsUsingZoomTool
|
|
|
|
+ {
|
|
|
|
+ get => (bool) GetValue(IsUsingZoomToolProperty);
|
|
|
|
+ set => SetValue(IsUsingZoomToolProperty, value);
|
|
|
|
+ }
|
|
|
|
+
|
|
private static void ZoomPercentegeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
private static void ZoomPercentegeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
{
|
|
MainDrawingPanel panel = (MainDrawingPanel)d;
|
|
MainDrawingPanel panel = (MainDrawingPanel)d;
|
|
@@ -88,6 +138,7 @@ namespace PixiEditor.Views
|
|
|
|
|
|
private void SetClickValues()
|
|
private void SetClickValues()
|
|
{
|
|
{
|
|
|
|
+ if (!IsUsingZoomTool) return;
|
|
ClickScale = Zoombox.Scale;
|
|
ClickScale = Zoombox.Scale;
|
|
var item = (FrameworkElement)Item;
|
|
var item = (FrameworkElement)Item;
|
|
if (item == null) return;
|
|
if (item == null) return;
|
|
@@ -95,45 +146,6 @@ namespace PixiEditor.Views
|
|
Zoombox.ZoomOrigin = new Point(Math.Clamp(mousePos.X / item.Width, 0, 1), Math.Clamp(mousePos.Y / item.Height,0,1));
|
|
Zoombox.ZoomOrigin = new Point(Math.Clamp(mousePos.X / item.Width, 0, 1), Math.Clamp(mousePos.Y / item.Height,0,1));
|
|
}
|
|
}
|
|
|
|
|
|
- public bool Center
|
|
|
|
- {
|
|
|
|
- get => (bool) GetValue(CenterProperty);
|
|
|
|
- set => SetValue(CenterProperty, value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public double MouseX
|
|
|
|
- {
|
|
|
|
- get => (double) GetValue(MouseXProperty);
|
|
|
|
- set => SetValue(MouseXProperty, value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public double MouseY
|
|
|
|
- {
|
|
|
|
- get => (double) GetValue(MouseYProperty);
|
|
|
|
- set => SetValue(MouseYProperty, value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public ICommand MouseMoveCommand
|
|
|
|
- {
|
|
|
|
- get => (ICommand) GetValue(MouseMoveCommandProperty);
|
|
|
|
- set => SetValue(MouseMoveCommandProperty, value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public bool CenterOnStart
|
|
|
|
- {
|
|
|
|
- get => (bool) GetValue(CenterOnStartProperty);
|
|
|
|
- set => SetValue(CenterOnStartProperty, value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- public object Item
|
|
|
|
- {
|
|
|
|
- get => GetValue(ItemProperty);
|
|
|
|
- set => SetValue(ItemProperty, value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private static void OnCenterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
private static void OnCenterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
{
|
|
MainDrawingPanel panel = (MainDrawingPanel) d;
|
|
MainDrawingPanel panel = (MainDrawingPanel) d;
|
|
@@ -155,25 +167,9 @@ namespace PixiEditor.Views
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public void ResetView()
|
|
|
|
- {
|
|
|
|
- Point point = new Point(0.5, 0.5);
|
|
|
|
- if (Zoombox.ZoomOrigin != point)
|
|
|
|
- {
|
|
|
|
- Zoombox.CenterContent();
|
|
|
|
- Zoombox.ZoomOrigin = point;
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private void mainDrawingPanel_MouseDown(object sender, MouseButtonEventArgs e)
|
|
private void mainDrawingPanel_MouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
{
|
|
- ((MainDrawingPanel)sender).CaptureMouse();
|
|
|
|
- ResetView();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void mainDrawingPanel_MouseUp(object sender, MouseButtonEventArgs e)
|
|
|
|
- {
|
|
|
|
- ReleaseMouseCapture();
|
|
|
|
|
|
+ IsUsingZoomTool = ViewModelMain.Current.BitmapManager.SelectedTool is ZoomTool;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|