|
@@ -1,48 +1,19 @@
|
|
-using PixiEditor.Models.Tools.Tools;
|
|
|
|
-using PixiEditor.ViewModels;
|
|
|
|
|
|
+using PixiEditor.Views.UserControls;
|
|
using System.Windows;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Controls;
|
|
-using System.Windows.Input;
|
|
|
|
-using Xceed.Wpf.Toolkit.Core.Input;
|
|
|
|
-using Xceed.Wpf.Toolkit.Zoombox;
|
|
|
|
|
|
|
|
namespace PixiEditor.Views
|
|
namespace PixiEditor.Views
|
|
{
|
|
{
|
|
public partial class MainDrawingPanel : UserControl
|
|
public partial class MainDrawingPanel : UserControl
|
|
{
|
|
{
|
|
- public static readonly DependencyProperty MouseXProperty =
|
|
|
|
- DependencyProperty.Register(nameof(MouseX), typeof(double), typeof(MainDrawingPanel), new PropertyMetadata(null));
|
|
|
|
-
|
|
|
|
- public static readonly DependencyProperty MouseYProperty =
|
|
|
|
- DependencyProperty.Register(nameof(MouseY), typeof(double), typeof(MainDrawingPanel), new PropertyMetadata(null));
|
|
|
|
-
|
|
|
|
- public static readonly DependencyProperty MouseMoveCommandProperty =
|
|
|
|
- DependencyProperty.Register(nameof(MouseMoveCommand), typeof(ICommand), typeof(MainDrawingPanel),
|
|
|
|
- new PropertyMetadata(null));
|
|
|
|
-
|
|
|
|
public static readonly DependencyProperty ItemProperty =
|
|
public static readonly DependencyProperty ItemProperty =
|
|
DependencyProperty.Register(nameof(Item), typeof(object), typeof(MainDrawingPanel), new PropertyMetadata(default(FrameworkElement)));
|
|
DependencyProperty.Register(nameof(Item), typeof(object), typeof(MainDrawingPanel), new PropertyMetadata(default(FrameworkElement)));
|
|
|
|
|
|
public static readonly DependencyProperty IsUsingZoomToolProperty =
|
|
public static readonly DependencyProperty IsUsingZoomToolProperty =
|
|
- DependencyProperty.Register(nameof(IsUsingZoomTool), typeof(bool), typeof(MainDrawingPanel), new PropertyMetadata(false));
|
|
|
|
-
|
|
|
|
- public double MouseX
|
|
|
|
- {
|
|
|
|
- get => (double)GetValue(MouseXProperty);
|
|
|
|
- set => SetValue(MouseXProperty, value);
|
|
|
|
- }
|
|
|
|
|
|
+ DependencyProperty.Register(nameof(IsUsingZoomTool), typeof(bool), typeof(MainDrawingPanel), new PropertyMetadata(false, ToolChanged));
|
|
|
|
|
|
- public double MouseY
|
|
|
|
- {
|
|
|
|
- get => (double)GetValue(MouseYProperty);
|
|
|
|
- set => SetValue(MouseYProperty, value);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- public ICommand MouseMoveCommand
|
|
|
|
- {
|
|
|
|
- get => (ICommand)GetValue(MouseMoveCommandProperty);
|
|
|
|
- set => SetValue(MouseMoveCommandProperty, value);
|
|
|
|
- }
|
|
|
|
|
|
+ public static readonly DependencyProperty IsUsingMoveViewportToolProperty =
|
|
|
|
+ DependencyProperty.Register(nameof(IsUsingMoveViewportTool), typeof(bool), typeof(MainDrawingPanel), new PropertyMetadata(false, ToolChanged));
|
|
|
|
|
|
public object Item
|
|
public object Item
|
|
{
|
|
{
|
|
@@ -55,30 +26,26 @@ namespace PixiEditor.Views
|
|
get => (bool)GetValue(IsUsingZoomToolProperty);
|
|
get => (bool)GetValue(IsUsingZoomToolProperty);
|
|
set => SetValue(IsUsingZoomToolProperty, value);
|
|
set => SetValue(IsUsingZoomToolProperty, value);
|
|
}
|
|
}
|
|
-
|
|
|
|
- public Point ClickPosition;
|
|
|
|
-
|
|
|
|
- public MainDrawingPanel()
|
|
|
|
- {
|
|
|
|
- InitializeComponent();
|
|
|
|
- Zoombox.ZoomToSelectionModifiers = new KeyModifierCollection() { KeyModifier.RightAlt };
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- private void MainDrawingPanel_PreviewMouseDown(object sender, MouseButtonEventArgs e)
|
|
|
|
|
|
+ public bool IsUsingMoveViewportTool
|
|
{
|
|
{
|
|
- IsUsingZoomTool = ViewModelMain.Current.BitmapManager.SelectedTool is ZoomTool;
|
|
|
|
- Mouse.Capture((IInputElement)sender, CaptureMode.SubTree);
|
|
|
|
- ClickPosition = ((FrameworkElement)Item).TranslatePoint(new Point(0, 0), Zoombox);
|
|
|
|
|
|
+ get => (bool)GetValue(IsUsingMoveViewportToolProperty);
|
|
|
|
+ set => SetValue(IsUsingMoveViewportToolProperty, value);
|
|
}
|
|
}
|
|
|
|
|
|
- private void MainDrawingPanel_PreviewMouseUp(object sender, MouseButtonEventArgs e)
|
|
|
|
|
|
+ public MainDrawingPanel()
|
|
{
|
|
{
|
|
- ((IInputElement)sender).ReleaseMouseCapture();
|
|
|
|
|
|
+ InitializeComponent();
|
|
}
|
|
}
|
|
|
|
|
|
- private void Zoombox_CurrentViewChanged(object sender, ZoomboxViewChangedEventArgs e)
|
|
|
|
|
|
+ private static void ToolChanged(DependencyObject sender, DependencyPropertyChangedEventArgs args)
|
|
{
|
|
{
|
|
- Zoombox.MinScale = 32 / ((FrameworkElement)Item).Width;
|
|
|
|
|
|
+ var panel = (MainDrawingPanel)sender;
|
|
|
|
+ if (panel.IsUsingZoomTool)
|
|
|
|
+ panel.zoombox.ZoomMode = Zoombox.Mode.ZoomTool;
|
|
|
|
+ else if (panel.IsUsingMoveViewportTool)
|
|
|
|
+ panel.zoombox.ZoomMode = Zoombox.Mode.MoveTool;
|
|
|
|
+ else
|
|
|
|
+ panel.zoombox.ZoomMode = Zoombox.Mode.Normal;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|