|
@@ -16,8 +16,7 @@ namespace PixiEditor.Views
|
|
{
|
|
{
|
|
// Using a DependencyProperty as the backing store for Center. This enables animation, styling, binding, etc...
|
|
// Using a DependencyProperty as the backing store for Center. This enables animation, styling, binding, etc...
|
|
public static readonly DependencyProperty CenterProperty =
|
|
public static readonly DependencyProperty CenterProperty =
|
|
- DependencyProperty.Register("Center", typeof(bool), typeof(MainDrawingPanel),
|
|
|
|
- new PropertyMetadata(true, OnCenterChanged));
|
|
|
|
|
|
+ DependencyProperty.Register("Center", typeof(bool), typeof(MainDrawingPanel), new PropertyMetadata(true, OnCenterChanged));
|
|
|
|
|
|
// Using a DependencyProperty as the backing store for MouseX. This enables animation, styling, binding, etc...
|
|
// Using a DependencyProperty as the backing store for MouseX. This enables animation, styling, binding, etc...
|
|
public static readonly DependencyProperty MouseXProperty =
|
|
public static readonly DependencyProperty MouseXProperty =
|
|
@@ -29,13 +28,11 @@ namespace PixiEditor.Views
|
|
|
|
|
|
// Using a DependencyProperty as the backing store for MouseMoveCommand. This enables animation, styling, binding, etc...
|
|
// Using a DependencyProperty as the backing store for MouseMoveCommand. This enables animation, styling, binding, etc...
|
|
public static readonly DependencyProperty MouseMoveCommandProperty =
|
|
public static readonly DependencyProperty MouseMoveCommandProperty =
|
|
- DependencyProperty.Register("MouseMoveCommand", typeof(ICommand), typeof(MainDrawingPanel),
|
|
|
|
- new PropertyMetadata(null));
|
|
|
|
|
|
+ DependencyProperty.Register("MouseMoveCommand", typeof(ICommand), typeof(MainDrawingPanel), new PropertyMetadata(null));
|
|
|
|
|
|
// Using a DependencyProperty as the backing store for CenterOnStart. This enables animation, styling, binding, etc...
|
|
// Using a DependencyProperty as the backing store for CenterOnStart. This enables animation, styling, binding, etc...
|
|
public static readonly DependencyProperty CenterOnStartProperty =
|
|
public static readonly DependencyProperty CenterOnStartProperty =
|
|
- DependencyProperty.Register("CenterOnStart", typeof(bool), typeof(MainDrawingPanel),
|
|
|
|
- new PropertyMetadata(false));
|
|
|
|
|
|
+ DependencyProperty.Register("CenterOnStart", typeof(bool), typeof(MainDrawingPanel), new PropertyMetadata(false));
|
|
|
|
|
|
// Using a DependencyProperty as the backing store for Item. This enables animation, styling, binding, etc...
|
|
// Using a DependencyProperty as the backing store for Item. This enables animation, styling, binding, etc...
|
|
public static readonly DependencyProperty ItemProperty =
|
|
public static readonly DependencyProperty ItemProperty =
|
|
@@ -43,17 +40,39 @@ namespace PixiEditor.Views
|
|
|
|
|
|
// Using a DependencyProperty as the backing store for Item. This enables animation, styling, binding, etc...
|
|
// Using a DependencyProperty as the backing store for Item. This enables animation, styling, binding, etc...
|
|
public static readonly DependencyProperty IsUsingZoomToolProperty =
|
|
public static readonly DependencyProperty IsUsingZoomToolProperty =
|
|
- DependencyProperty.Register("IsUsingZoomTool", typeof(bool), typeof(MainDrawingPanel), new PropertyMetadata(false));
|
|
|
|
|
|
+ DependencyProperty.Register("IsUsingZoomTool", typeof(bool), typeof(MainDrawingPanel), new PropertyMetadata(false));
|
|
|
|
+
|
|
|
|
+ // Using a DependencyProperty as the backing store for ZoomPercentage. This enables animation, styling, binding, etc...
|
|
|
|
+ public static readonly DependencyProperty ZoomPercentageProperty =
|
|
|
|
+ DependencyProperty.Register("ZoomPercentage", typeof(double), typeof(MainDrawingPanel), new PropertyMetadata(0.0, ZoomPercentegeChanged));
|
|
|
|
+
|
|
|
|
+ // Using a DependencyProperty as the backing store for ViewportPosition. This enables animation, styling, binding, etc...
|
|
|
|
+ public static readonly DependencyProperty ViewportPositionProperty =
|
|
|
|
+ DependencyProperty.Register("ViewportPosition", typeof(Point), typeof(MainDrawingPanel), new PropertyMetadata(default(Point), ViewportPosCallback));
|
|
|
|
+
|
|
|
|
+ // Using a DependencyProperty as the backing store for MiddleMouseClickedCommand. This enables animation, styling, binding, etc...
|
|
|
|
+ public static readonly DependencyProperty MiddleMouseClickedCommandProperty =
|
|
|
|
+ DependencyProperty.Register("MiddleMouseClickedCommand", typeof(ICommand), typeof(MainDrawingPanel), new PropertyMetadata(default(ICommand)));
|
|
|
|
+
|
|
|
|
+ // Using a DependencyProperty as the backing store for MiddleMouseClickedCommandParameter. This enables animation, styling, binding, etc...
|
|
|
|
+ public static readonly DependencyProperty MiddleMouseClickedCommandParameterProperty =
|
|
|
|
+ DependencyProperty.Register("MiddleMouseClickedCommandParameter", typeof(object), typeof(MainDrawingPanel), new PropertyMetadata(default(object)));
|
|
|
|
+
|
|
|
|
+ public MainDrawingPanel()
|
|
|
|
+ {
|
|
|
|
+ InitializeComponent();
|
|
|
|
+ Zoombox.ZoomToSelectionModifiers = new KeyModifierCollection() { KeyModifier.RightAlt };
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public double ClickScale { get; set; }
|
|
|
|
+
|
|
|
|
+ public Point ClickPosition { get; set; }
|
|
|
|
|
|
public double ZoomPercentage
|
|
public double ZoomPercentage
|
|
{
|
|
{
|
|
get { return (double)GetValue(ZoomPercentageProperty); }
|
|
get { return (double)GetValue(ZoomPercentageProperty); }
|
|
set { SetValue(ZoomPercentageProperty, value); }
|
|
set { SetValue(ZoomPercentageProperty, value); }
|
|
}
|
|
}
|
|
-
|
|
|
|
- // Using a DependencyProperty as the backing store for ZoomPercentage. This enables animation, styling, binding, etc...
|
|
|
|
- public static readonly DependencyProperty ZoomPercentageProperty =
|
|
|
|
- DependencyProperty.Register("ZoomPercentage", typeof(double), typeof(MainDrawingPanel), new PropertyMetadata(0.0, ZoomPercentegeChanged));
|
|
|
|
|
|
|
|
public Point ViewportPosition
|
|
public Point ViewportPosition
|
|
{
|
|
{
|
|
@@ -61,11 +80,6 @@ namespace PixiEditor.Views
|
|
set { SetValue(ViewportPositionProperty, value); }
|
|
set { SetValue(ViewportPositionProperty, value); }
|
|
}
|
|
}
|
|
|
|
|
|
- // Using a DependencyProperty as the backing store for ViewportPosition. This enables animation, styling, binding, etc...
|
|
|
|
- public static readonly DependencyProperty ViewportPositionProperty =
|
|
|
|
- DependencyProperty.Register("ViewportPosition", typeof(Point),
|
|
|
|
- typeof(MainDrawingPanel), new PropertyMetadata(default(Point), ViewportPosCallback));
|
|
|
|
-
|
|
|
|
public bool Center
|
|
public bool Center
|
|
{
|
|
{
|
|
get => (bool)GetValue(CenterProperty);
|
|
get => (bool)GetValue(CenterProperty);
|
|
@@ -113,21 +127,12 @@ namespace PixiEditor.Views
|
|
get { return (ICommand)GetValue(MiddleMouseClickedCommandProperty); }
|
|
get { return (ICommand)GetValue(MiddleMouseClickedCommandProperty); }
|
|
set { SetValue(MiddleMouseClickedCommandProperty, value); }
|
|
set { SetValue(MiddleMouseClickedCommandProperty, value); }
|
|
}
|
|
}
|
|
-
|
|
|
|
- // Using a DependencyProperty as the backing store for MiddleMouseClickedCommand. This enables animation, styling, binding, etc...
|
|
|
|
- public static readonly DependencyProperty MiddleMouseClickedCommandProperty =
|
|
|
|
- DependencyProperty.Register("MiddleMouseClickedCommand", typeof(ICommand), typeof(MainDrawingPanel), new PropertyMetadata(default(ICommand)));
|
|
|
|
|
|
|
|
public object MiddleMouseClickedCommandParameter
|
|
public object MiddleMouseClickedCommandParameter
|
|
{
|
|
{
|
|
get { return (object)GetValue(MiddleMouseClickedCommandParameterProperty); }
|
|
get { return (object)GetValue(MiddleMouseClickedCommandParameterProperty); }
|
|
set { SetValue(MiddleMouseClickedCommandParameterProperty, value); }
|
|
set { SetValue(MiddleMouseClickedCommandParameterProperty, value); }
|
|
- }
|
|
|
|
-
|
|
|
|
- // Using a DependencyProperty as the backing store for MiddleMouseClickedCommandParameter. This enables animation, styling, binding, etc...
|
|
|
|
- public static readonly DependencyProperty MiddleMouseClickedCommandParameterProperty =
|
|
|
|
- DependencyProperty.Register("MiddleMouseClickedCommandParameter", typeof(object), typeof(MainDrawingPanel),
|
|
|
|
- new PropertyMetadata(default(object)));
|
|
|
|
|
|
+ }
|
|
|
|
|
|
private static void ZoomPercentegeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
private static void ZoomPercentegeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
{
|
|
@@ -141,15 +146,6 @@ namespace PixiEditor.Views
|
|
panel.Zoombox.ZoomTo(panel.ClickScale * ((double)e.NewValue / 100.0));
|
|
panel.Zoombox.ZoomTo(panel.ClickScale * ((double)e.NewValue / 100.0));
|
|
}
|
|
}
|
|
|
|
|
|
- public double ClickScale { get; set; }
|
|
|
|
- public Point ClickPosition { get; set; }
|
|
|
|
-
|
|
|
|
- public MainDrawingPanel()
|
|
|
|
- {
|
|
|
|
- InitializeComponent();
|
|
|
|
- Zoombox.ZoomToSelectionModifiers = new KeyModifierCollection() { KeyModifier.RightAlt };
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private static void ViewportPosCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
private static void ViewportPosCallback(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
{
|
|
{
|
|
MainDrawingPanel panel = (MainDrawingPanel)d;
|
|
MainDrawingPanel panel = (MainDrawingPanel)d;
|
|
@@ -164,9 +160,16 @@ namespace PixiEditor.Views
|
|
|
|
|
|
private static void TranslateZoombox(MainDrawingPanel panel, Point vector)
|
|
private static void TranslateZoombox(MainDrawingPanel panel, Point vector)
|
|
{
|
|
{
|
|
- var newPos = new Point(panel.ClickPosition.X + vector.X,
|
|
|
|
|
|
+ var newPos = new Point(
|
|
|
|
+ panel.ClickPosition.X + vector.X,
|
|
panel.ClickPosition.Y + vector.Y);
|
|
panel.ClickPosition.Y + vector.Y);
|
|
panel.Zoombox.Position = newPos;
|
|
panel.Zoombox.Position = newPos;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private static void OnCenterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
|
|
+ {
|
|
|
|
+ MainDrawingPanel panel = (MainDrawingPanel)d;
|
|
|
|
+ panel.Zoombox.CenterContent();
|
|
}
|
|
}
|
|
|
|
|
|
private void Zoombox_CurrentViewChanged(object sender, ZoomboxViewChangedEventArgs e)
|
|
private void Zoombox_CurrentViewChanged(object sender, ZoomboxViewChangedEventArgs e)
|
|
@@ -206,12 +209,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));
|
|
}
|
|
}
|
|
|
|
|
|
- private static void OnCenterChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
|
|
|
|
- {
|
|
|
|
- MainDrawingPanel panel = (MainDrawingPanel)d;
|
|
|
|
- panel.Zoombox.CenterContent();
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
private void Zoombox_Loaded(object sender, RoutedEventArgs e)
|
|
private void Zoombox_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
{
|
|
if (CenterOnStart)
|
|
if (CenterOnStart)
|