From a12a9592e3158061c9b638dc79337e18a398590c Mon Sep 17 00:00:00 2001 From: t-tellro Date: Thu, 16 Dec 2021 17:38:20 -0600 Subject: [PATCH 1/2] DYN-4252-Shadow-Under-Pointer I had to replace the Polygon (tree points connected by 3 lines) by a Path (tree points connected by 2 lines) due that the shadow was being applied to all sides of the Polygon(triangle), then now due that is a Path with 2 lines the shadow will be applied just in two lines. I had to add a Converter so a PointCollection can be converted to a Path.Data. --- src/DynamoCoreWpf/UI/Converters.cs | 44 +++++++++++++++++++ src/DynamoCoreWpf/UI/GuidedTour/Step.cs | 5 +++ src/DynamoCoreWpf/UI/GuidedTour/Tooltip.cs | 11 +++++ .../UI/Themes/Modern/DynamoModern.xaml | 2 +- .../GuidedTour/PopupWindowViewModel.cs | 15 +++++++ .../Views/GuidedTour/PopupWindow.xaml | 26 ++++++----- 6 files changed, 90 insertions(+), 13 deletions(-) diff --git a/src/DynamoCoreWpf/UI/Converters.cs b/src/DynamoCoreWpf/UI/Converters.cs index 1f2403ad91c..00f6644861b 100644 --- a/src/DynamoCoreWpf/UI/Converters.cs +++ b/src/DynamoCoreWpf/UI/Converters.cs @@ -3294,4 +3294,48 @@ public object ConvertBack(object value, Type targetType, object parameter, Cultu throw new NotImplementedException(); } } + + /// + /// Converts a PointColletion to a Geometry so the points can be drawn using a Path + /// + [ValueConversion(typeof(PointCollection), typeof(Geometry))] + public class PointsToPathConverter : IValueConverter + { + #region IValueConverter Members + + public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + if (value == null) + return null; + + if (value.GetType() != typeof(PointCollection)) + return null; + + PointCollection points = (value as PointCollection); + if (points.Count > 0) + { + Point start = points[0]; + List segments = new List(); + for (int i = 1; i < points.Count; i++) + { + segments.Add(new LineSegment(points[i], true)); + } + PathFigure figure = new PathFigure(start, segments, false); + PathGeometry geometry = new PathGeometry(); + geometry.Figures.Add(figure); + return geometry; + } + else + { + return null; + } + } + + public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) + { + throw new NotSupportedException(); + } + + #endregion + } } \ No newline at end of file diff --git a/src/DynamoCoreWpf/UI/GuidedTour/Step.cs b/src/DynamoCoreWpf/UI/GuidedTour/Step.cs index e934acc2396..b9c454b3fa3 100644 --- a/src/DynamoCoreWpf/UI/GuidedTour/Step.cs +++ b/src/DynamoCoreWpf/UI/GuidedTour/Step.cs @@ -131,6 +131,11 @@ public enum PointerDirection { TOP_RIGHT, TOP_LEFT, BOTTOM_RIGHT, BOTTOM_LEFT, B /// public PointCollection TooltipPointerPoints { get; set; } + /// + /// This will contains the shadow direction in degrees that will be shown in the pointer + /// + public double ShadowTooltipDirection { get; set; } + /// /// This property holds the DynamoViewModel that will be used when executing PreValidation functions /// diff --git a/src/DynamoCoreWpf/UI/GuidedTour/Tooltip.cs b/src/DynamoCoreWpf/UI/GuidedTour/Tooltip.cs index 7430718347d..7ffd4e56427 100644 --- a/src/DynamoCoreWpf/UI/GuidedTour/Tooltip.cs +++ b/src/DynamoCoreWpf/UI/GuidedTour/Tooltip.cs @@ -17,6 +17,7 @@ public class Tooltip : Step double PointerTooltipOverlap = 5; double PointerVerticalOffset; double PointerHorizontalOffset; + enum SHADOW_DIRECTION { LEFT = 180, RIGHT = 0, BOTTOM = 270, TOP = 90}; /// /// The Tooltip constructor @@ -71,6 +72,8 @@ private void DrawPointerDirection(PointerDirection direction) pointX3 = 0; pointY3 = PointerHeight / 2 + PointerVerticalOffset; + //Left Shadow + ShadowTooltipDirection = (double)SHADOW_DIRECTION.LEFT; } else if (direction == PointerDirection.BOTTOM_LEFT) @@ -83,6 +86,8 @@ private void DrawPointerDirection(PointerDirection direction) pointX3 = 0; pointY3 = Height - PointerHeight / 2 - PointerVerticalOffset; + //Left Shadow + ShadowTooltipDirection = (double)SHADOW_DIRECTION.LEFT; } else if (direction == PointerDirection.TOP_RIGHT) { @@ -94,6 +99,8 @@ private void DrawPointerDirection(PointerDirection direction) pointX3 = realWidth; pointY3 = PointerHeight / 2 + PointerVerticalOffset; + //Right Shadow + ShadowTooltipDirection = (double)SHADOW_DIRECTION.RIGHT; } else if (direction == PointerDirection.BOTTOM_RIGHT) @@ -106,6 +113,8 @@ private void DrawPointerDirection(PointerDirection direction) pointX3 = realWidth; pointY3 = Height - PointerHeight / 2 - PointerVerticalOffset; + //Right Shadow + ShadowTooltipDirection = (double)SHADOW_DIRECTION.RIGHT; } else if (direction == PointerDirection.BOTTOM_DOWN) { @@ -117,6 +126,8 @@ private void DrawPointerDirection(PointerDirection direction) pointX3 = PointerDownWidth / 2 + PointerHorizontalOffset; pointY3 = realHeight - PointerHeight; + //Bottom Shadow + ShadowTooltipDirection = (double)SHADOW_DIRECTION.BOTTOM; } TooltipPointerPoints = new PointCollection(new[] { new Point(pointX1, pointY1), diff --git a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml index ea63a460cf8..ac78b09740a 100644 --- a/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml +++ b/src/DynamoCoreWpf/UI/Themes/Modern/DynamoModern.xaml @@ -4075,7 +4075,7 @@ - diff --git a/src/DynamoCoreWpf/ViewModels/GuidedTour/PopupWindowViewModel.cs b/src/DynamoCoreWpf/ViewModels/GuidedTour/PopupWindowViewModel.cs index 5efebfe2bc0..6acf7461a8a 100644 --- a/src/DynamoCoreWpf/ViewModels/GuidedTour/PopupWindowViewModel.cs +++ b/src/DynamoCoreWpf/ViewModels/GuidedTour/PopupWindowViewModel.cs @@ -41,6 +41,21 @@ public PointCollection TooltipPointerPoints } } + /// + /// This will contains the shadow direction in degrees that will be shown in the pointer + /// + public double ShadowTooltipDirection + { + get + { + return Step.ShadowTooltipDirection; + } + set + { + Step.ShadowTooltipDirection = value; + } + } + /// /// Due that some popups doesn't need the pointer then this property hides or show the pointer /// diff --git a/src/DynamoCoreWpf/Views/GuidedTour/PopupWindow.xaml b/src/DynamoCoreWpf/Views/GuidedTour/PopupWindow.xaml index b59752dbaa6..772df77141e 100644 --- a/src/DynamoCoreWpf/Views/GuidedTour/PopupWindow.xaml +++ b/src/DynamoCoreWpf/Views/GuidedTour/PopupWindow.xaml @@ -7,6 +7,7 @@ xmlns:localui="clr-namespace:Dynamo.Wpf.UI.GuidedTour" xmlns:ui="clr-namespace:Dynamo.UI" xmlns:p="clr-namespace:Dynamo.Wpf.Properties;assembly=DynamoCoreWpf" + xmlns:controls="clr-namespace:Dynamo.Controls" mc:Ignorable="d" PopupAnimation="Fade" AllowsTransparency="True" @@ -23,6 +24,7 @@ + @@ -62,18 +64,18 @@ - - - - - - + + + + + Date: Tue, 4 Jan 2022 13:12:37 -0600 Subject: [PATCH 2/2] DYN-4252-Shadow-Under-Pointer Code Review Fixed one comment --- src/DynamoCoreWpf/Views/GuidedTour/PopupWindow.xaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/DynamoCoreWpf/Views/GuidedTour/PopupWindow.xaml b/src/DynamoCoreWpf/Views/GuidedTour/PopupWindow.xaml index 772df77141e..30dfcda51c5 100644 --- a/src/DynamoCoreWpf/Views/GuidedTour/PopupWindow.xaml +++ b/src/DynamoCoreWpf/Views/GuidedTour/PopupWindow.xaml @@ -63,7 +63,7 @@ - +