/// <summary> /// This method will update the CutOff rectangle size everytime that the step change /// </summary> /// <param name="bVisible">It will say if the CutOff Area will be disabled or enabled</param> private void SetCutOffSectionSize(bool bVisible) { if (HostPopupInfo.CutOffRectArea == null) { return; } if (bVisible) { //This will validate that HostPopupInfo.HostUIElement is in the MainWindow VisualTree otherwise the TransformToAncestor() will crash var foundUIElement = Guide.FindChild(MainWindow, HostPopupInfo.HostUIElementString); if (foundUIElement == null) { return; } Point relativePoint = HostPopupInfo.HostUIElement.TransformToAncestor(MainWindow) .Transform(new Point(0, 0)); var holeWidth = HostPopupInfo.HostUIElement.DesiredSize.Width + HostPopupInfo.CutOffRectArea.WidthBoxDelta; var holeHeight = HostPopupInfo.HostUIElement.DesiredSize.Height + HostPopupInfo.CutOffRectArea.HeightBoxDelta; if (StepGuideBackground.CutOffBackgroundArea != null) { StepGuideBackground.CutOffBackgroundArea.CutOffRect = new Rect(relativePoint.X, relativePoint.Y, holeWidth, holeHeight); } } else { StepGuideBackground.ClearCutOffSection(); } }
/// <summary> /// This method will set the highlight rectangle color if there is any configured in the json file /// </summary> /// <param name="bVisible">It will say if the Highlight Area will be disabled or enabled</param> private void SetHighlightSection(bool bVisible) { if (HostPopupInfo.HighlightRectArea == null) { return; } if (bVisible) { if (!string.IsNullOrEmpty(HostPopupInfo.HighlightRectArea.UIElementTypeString)) { HighlightWindowElement(bVisible); } else { //If is not empty means that the HighlightRectArea.WindowElementNameString doesn't belong to the DynamoView then another way for hightlighting the element will be applied if (!string.IsNullOrEmpty(HostPopupInfo.HighlightRectArea.WindowName)) { return; } string highlightColor = HostPopupInfo.HighlightRectArea.HighlightColor; //This section will get the X,Y coordinates of the HostUIElement based in the Ancestor UI Element so we can put the highlight rectangle Point relativePoint = HostPopupInfo.HostUIElement.TransformToAncestor(MainWindow) .Transform(new Point(0, 0)); var holeWidth = HostPopupInfo.HostUIElement.DesiredSize.Width + HostPopupInfo.HighlightRectArea.WidthBoxDelta; var holeHeight = HostPopupInfo.HostUIElement.DesiredSize.Height + HostPopupInfo.HighlightRectArea.HeightBoxDelta; StepGuideBackground.HighlightBackgroundArea.SetHighlighRectSize(relativePoint.Y, relativePoint.X, holeWidth, holeHeight); if (string.IsNullOrEmpty(highlightColor)) { StepGuideBackground.GuideHighlightRectangle.Stroke = Brushes.Transparent; } else { var converter = new BrushConverter(); var brush = (Brush)converter.ConvertFromString(highlightColor); StepGuideBackground.GuideHighlightRectangle.Stroke = brush; } } } else { HighlightWindowElement(bVisible); StepGuideBackground.ClearHighlightSection(); } }