зеркало из https://github.com/stride3d/GraphX.git
+ Fixed ZoomControl dynamic content switch to corectly refresh viewfinder
+ Some refactoring
This commit is contained in:
Родитель
e7dec38e52
Коммит
64fd24c4f0
|
@ -159,7 +159,7 @@ namespace GraphX.Controls
|
|||
/// </summary>
|
||||
internal override bool EdgeCurvingEnabled => LogicCore != null && LogicCore.EdgeCurvingEnabled;
|
||||
/// <summary>
|
||||
/// Link to LogicCore. Gets if edge curving tolerance.
|
||||
/// Link to LogicCore. Gets edge curving tolerance.
|
||||
/// </summary>
|
||||
internal override double EdgeCurvingTolerance => LogicCore?.EdgeCurvingTolerance ?? 0;
|
||||
|
||||
|
|
|
@ -128,21 +128,13 @@ namespace GraphX.Controls
|
|||
|
||||
#region AvailableSize Internal Property
|
||||
|
||||
internal Size AvailableSize => _availableSize;
|
||||
|
||||
private Size _availableSize = Size.Empty;
|
||||
internal Size AvailableSize { get; private set; } = Size.Empty;
|
||||
|
||||
#endregion
|
||||
|
||||
#region Scale Internal Property
|
||||
|
||||
internal double Scale
|
||||
{
|
||||
get { return _scale; }
|
||||
set { _scale = value; }
|
||||
}
|
||||
|
||||
private double _scale = 1d;
|
||||
internal double Scale { get; set; } = 1d;
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -162,7 +154,7 @@ namespace GraphX.Controls
|
|||
// as a surface for the view finder's VisualBrush.
|
||||
|
||||
// store the available size for use by the Zoombox control
|
||||
_availableSize = availableSize;
|
||||
AvailableSize = availableSize;
|
||||
|
||||
// Simulate size-to-content for the display panel by ensuring a width and height
|
||||
// based on the content bounds. Otherwise, the display panel may have no size, since it doesn't
|
||||
|
|
|
@ -189,6 +189,11 @@ namespace GraphX.Controls
|
|||
//rem due to fail in template bg binding //_viewFinderDisplay.Background = this.Background;
|
||||
|
||||
// hook up event handlers for dragging and resizing the viewport
|
||||
_viewFinderDisplay.MouseMove -= ViewFinderDisplayMouseMove;
|
||||
_viewFinderDisplay.MouseLeftButtonDown -= ViewFinderDisplayBeginCapture;
|
||||
_viewFinderDisplay.MouseLeftButtonUp -= ViewFinderDisplayEndCapture;
|
||||
_viewFinderDisplay.IsVisibleChanged -= _viewFinderDisplay_IsVisibleChanged;
|
||||
|
||||
_viewFinderDisplay.MouseMove += ViewFinderDisplayMouseMove;
|
||||
_viewFinderDisplay.MouseLeftButtonDown += ViewFinderDisplayBeginCapture;
|
||||
_viewFinderDisplay.MouseLeftButtonUp += ViewFinderDisplayEndCapture;
|
||||
|
@ -654,7 +659,7 @@ namespace GraphX.Controls
|
|||
/// <summary>
|
||||
/// Use Ctrl key to zoom with mouse wheel or without it
|
||||
/// </summary>
|
||||
public bool UseCtrlForMouseWheel { get; set; }
|
||||
public bool UseCtrlForMouseWheel { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets mousewheel zooming mode. Positional: depend on mouse position. Absolute: center area.
|
||||
|
@ -942,7 +947,7 @@ namespace GraphX.Controls
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Minimum zoom distance (Zoom out)
|
||||
/// Minimum zoom distance (Zoom out). Default value is 0.01
|
||||
/// </summary>
|
||||
public double MinZoom
|
||||
{
|
||||
|
@ -951,7 +956,7 @@ namespace GraphX.Controls
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Maximum zoom distance (Zoom in)
|
||||
/// Maximum zoom distance (Zoom in). DEfault value is 100
|
||||
/// </summary>
|
||||
public double MaxZoom
|
||||
{
|
||||
|
@ -1066,11 +1071,8 @@ namespace GraphX.Controls
|
|||
|
||||
public ZoomControl()
|
||||
{
|
||||
// ClipToBounds = true;
|
||||
if (DesignerProperties.GetIsInDesignMode(this))
|
||||
{
|
||||
//Mode = ZoomControlModes.Fill;
|
||||
//Zoom = 0.5;
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1078,7 +1080,6 @@ namespace GraphX.Controls
|
|||
PreviewMouseDown += ZoomControl_PreviewMouseDown;
|
||||
MouseDown += ZoomControl_MouseDown;
|
||||
MouseUp += ZoomControl_MouseUp;
|
||||
UseCtrlForMouseWheel = true;
|
||||
|
||||
AddHandler(SizeChangedEvent, new SizeChangedEventHandler(OnSizeChanged), true);
|
||||
|
||||
|
@ -1092,16 +1093,9 @@ namespace GraphX.Controls
|
|||
BindKey(CommandZoomOut, Key.Down, ModifierKeys.Control,
|
||||
(sender, args) => MouseWheelAction(-120, OrigoPosition));
|
||||
|
||||
this.PreviewKeyDown += ZoomControl_PreviewKeyDown;
|
||||
|
||||
Loaded += ZoomControl_Loaded;
|
||||
}
|
||||
}
|
||||
|
||||
void ZoomControl_PreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected void BindCommand(RoutedUICommand command, ExecutedRoutedEventHandler execute, CanExecuteRoutedEventHandler canExecute = null)
|
||||
{
|
||||
|
@ -1116,12 +1110,6 @@ namespace GraphX.Controls
|
|||
InputBindings.Add(new KeyBinding(command, key, modifier));
|
||||
}
|
||||
|
||||
|
||||
void ZoomControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
//FakeZoom();
|
||||
}
|
||||
|
||||
#region ContentChanged
|
||||
protected override void OnContentChanged(object oldContent, object newContent)
|
||||
{
|
||||
|
@ -1131,8 +1119,6 @@ namespace GraphX.Controls
|
|||
if (old != null) old.ContentSizeChanged -= Content_ContentSizeChanged;
|
||||
if (newContent != null)
|
||||
{
|
||||
UpdateViewFinderDisplayContentBounds();
|
||||
UpdateViewport();
|
||||
var newc = newContent as ITrackableContent;
|
||||
if (newc != null)
|
||||
{
|
||||
|
@ -1140,8 +1126,12 @@ namespace GraphX.Controls
|
|||
newc.ContentSizeChanged += Content_ContentSizeChanged;
|
||||
}
|
||||
else _isga = false;
|
||||
if(Template != null)
|
||||
OnApplyTemplate();
|
||||
UpdateViewFinderDisplayContentBounds();
|
||||
UpdateViewport();
|
||||
}
|
||||
|
||||
|
||||
base.OnContentChanged(oldContent, newContent);
|
||||
}
|
||||
|
||||
|
@ -1569,7 +1559,7 @@ namespace GraphX.Controls
|
|||
|
||||
if (DesignerProperties.GetIsInDesignMode(this))
|
||||
{
|
||||
ViewFinder?.SetCurrentValue(UIElement.VisibilityProperty, Visibility.Collapsed);
|
||||
ViewFinder?.SetCurrentValue(VisibilityProperty, Visibility.Collapsed);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1577,27 +1567,26 @@ namespace GraphX.Controls
|
|||
Presenter = GetTemplateChild(PART_PRESENTER) as ZoomContentPresenter;
|
||||
if (Presenter != null)
|
||||
{
|
||||
Presenter.SizeChanged += (s, a) =>
|
||||
{
|
||||
//UpdateViewFinderDisplayContentBounds();
|
||||
UpdateViewport();
|
||||
if (Mode == ZoomControlModes.Fill)
|
||||
DoZoomToFill();
|
||||
};
|
||||
Presenter.ContentSizeChanged += (s, a) =>
|
||||
{
|
||||
//UpdateViewFinderDisplayContentBounds();
|
||||
if (Mode == ZoomControlModes.Fill)
|
||||
{
|
||||
DoZoomToFill();
|
||||
//IsAnimationDisabled = false;
|
||||
}
|
||||
};
|
||||
Presenter.SizeChanged -= Presenter_SizeChanged;
|
||||
Presenter.ContentSizeChanged -= Presenter_ContentSizeChanged;
|
||||
Presenter.SizeChanged += Presenter_SizeChanged;
|
||||
Presenter.ContentSizeChanged += Presenter_ContentSizeChanged;
|
||||
}
|
||||
if (Mode == ZoomControlModes.Fill)
|
||||
{
|
||||
DoZoomToFill();
|
||||
}
|
||||
}
|
||||
|
||||
private void Presenter_ContentSizeChanged(object sender, Size newSize)
|
||||
{
|
||||
if (Mode == ZoomControlModes.Fill)
|
||||
DoZoomToFill();
|
||||
}
|
||||
|
||||
private void Presenter_SizeChanged(object sender, SizeChangedEventArgs e)
|
||||
{
|
||||
UpdateViewport();
|
||||
if (Mode == ZoomControlModes.Fill)
|
||||
DoZoomToFill();
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using GraphX.PCL.Common.Enums;
|
||||
#if WPF
|
||||
|
@ -107,6 +108,12 @@ namespace GraphX.Controls
|
|||
return oPolyLineSegment;
|
||||
}
|
||||
|
||||
public static IList<Point> GetCurvePointsThroughPoints(Point[] points, double tension, double tolerance)
|
||||
{
|
||||
return GetCurveThroughPoints(points, tension, tolerance).Points;
|
||||
}
|
||||
|
||||
|
||||
private static void AddPointsToPolyLineSegment(PolyLineSegment oPolyLineSegment, Point oPoint0, Point oPoint1, Point oPoint2, Point oPoint3, double dTension, double dTolerance)
|
||||
{
|
||||
Debug.Assert(oPolyLineSegment != null);
|
||||
|
@ -175,6 +182,8 @@ namespace GraphX.Controls
|
|||
return oPathFigure;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static PathGeometry GetPathGeometryFromPathSegments(Point oStartPoint, bool bPathFigureIsFilled, params PathSegment[] aoPathSegments)
|
||||
{
|
||||
Debug.Assert(aoPathSegments != null);
|
||||
|
@ -233,6 +242,21 @@ namespace GraphX.Controls
|
|||
}
|
||||
}
|
||||
|
||||
/* public static Point GetEdgeEndpoint2(Point endPoint, Rect bounds, Point startPoint, VertexShape vertexShape, double angle)
|
||||
{
|
||||
Rect b;
|
||||
if (angle == 0)
|
||||
b = bounds;
|
||||
else
|
||||
{
|
||||
b = new Rect(bounds.X, bounds.Y, bounds.Width, bounds.Height);
|
||||
var matrix = GetRotatedMatrix(bounds.Center(), MathHelper.RadiansToDegrees(angle));
|
||||
b.Transform(matrix);
|
||||
}
|
||||
|
||||
return GetEdgeEndpoint(endPoint, b, startPoint, vertexShape);
|
||||
}*/
|
||||
|
||||
public static Point GetEdgeEndpointOnCircle(Point oVertexALocation, double dVertexARadius, Point oVertexBLocation)
|
||||
{
|
||||
Debug.Assert(dVertexARadius >= 0);
|
||||
|
@ -579,5 +603,7 @@ namespace GraphX.Controls
|
|||
|
||||
return (oPathGeometry);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -76,23 +76,58 @@ namespace GraphX.PCL.Logic.Algorithms.LayoutAlgorithms
|
|||
|
||||
if ((Parameters.Direction == LayoutDirection.TopToBottom || Parameters.Direction == LayoutDirection.BottomToTop) && sourcePosition.X != targetPosition.X)
|
||||
{
|
||||
_edgeRoutingPoints[edge] =
|
||||
new[]
|
||||
{
|
||||
new Point(0, 0),
|
||||
new Point(targetPosition.X + targetSize.Width / 2, sourcePosition.Y + sourceSize.Height / 2),
|
||||
new Point(0, 0)
|
||||
};
|
||||
var pt = new Point(targetPosition.X + targetSize.Width/2, sourcePosition.Y + sourceSize.Height/2);
|
||||
var src = new Point(sourcePosition.X + sourceSize.Width/2, sourcePosition.Y + sourceSize.Height/2);
|
||||
|
||||
if (Parameters.Direction == LayoutDirection.TopToBottom)
|
||||
{
|
||||
var pt2 = new Point(targetPosition.X + targetSize.Width/2, targetPosition.Y);
|
||||
_edgeRoutingPoints[edge] =
|
||||
new[]
|
||||
{
|
||||
src,
|
||||
pt,
|
||||
pt2
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var pt2 = new Point(targetPosition.X + targetSize.Width / 2, targetPosition.Y + targetSize.Height / 2);
|
||||
_edgeRoutingPoints[edge] =
|
||||
new[]
|
||||
{
|
||||
src,
|
||||
pt,
|
||||
pt2
|
||||
};
|
||||
}
|
||||
}
|
||||
else if ((Parameters.Direction == LayoutDirection.LeftToRight || Parameters.Direction == LayoutDirection.RightToLeft) && sourcePosition.Y != targetPosition.Y)
|
||||
{
|
||||
_edgeRoutingPoints[edge] =
|
||||
new[]
|
||||
{
|
||||
new Point(0, 0),
|
||||
new Point(sourcePosition.X + sourceSize.Width/2, targetPosition.Y + targetSize.Height/2),
|
||||
new Point(0, 0)
|
||||
};
|
||||
var src = new Point(sourcePosition.X + sourceSize.Width / 2, sourcePosition.Y + sourceSize.Height/2);
|
||||
var pt = new Point(sourcePosition.X + sourceSize.Width/2, targetPosition.Y + targetSize.Height/2);
|
||||
if (Parameters.Direction == LayoutDirection.LeftToRight)
|
||||
{
|
||||
var pt2 = new Point(targetPosition.X, targetPosition.Y + targetSize.Height / 2);
|
||||
_edgeRoutingPoints[edge] =
|
||||
new[]
|
||||
{
|
||||
src,
|
||||
pt,
|
||||
pt2
|
||||
};
|
||||
}
|
||||
else
|
||||
{
|
||||
var pt2 = new Point(targetPosition.X + targetSize.Width, targetPosition.Y + targetSize.Height / 2);
|
||||
_edgeRoutingPoints[edge] =
|
||||
new[]
|
||||
{
|
||||
src,
|
||||
pt,
|
||||
pt2
|
||||
};
|
||||
}
|
||||
}
|
||||
else _edgeRoutingPoints[edge] = null;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче