Example #1
0
        /// <summary>
        /// Show the tooltip in the DynamoUI, first execute UI Automation, then Prevalidation, then calculate target host and finally highlight an element
        /// </summary>
        internal void Show(Guide.GuideFlow currentFlow)
        {
            //In case the UIAutomation info is set for the Step we execute all the UI Automation actions when the Next button is pressed
            if (UIAutomation != null)
            {
                foreach (var automation in UIAutomation)
                {
                    ExecuteUIAutomationStep(automation, true, currentFlow);
                }
            }

            //If the PreValidation info was read from the json file then is executed and it will decide which Step should be shown and which not
            if (PreValidationInfo != null)
            {
                ExecutePreValidation();
            }

            //After the UI Automation is done we need to calculate the Target (if is not in DynamoView)
            CalculateTargetHost();

            //After the Popup.PlacementTarget was recalculated (or calculated) then we proceed to put the cut off section
            SetCutOffSectionSize(true);

            //After UI Automation and calculate the target we need to highlight the element (otherwise probably won't exist)
            SetHighlightSection(true);

            if (HostPopupInfo.WindowName != null && HostPopupInfo.WindowName.Equals(nameof(LibraryView)))
            {
                var automationStep = (from automation in UIAutomation
                                      where automation.Name.Equals(calculateLibraryFuncName)
                                      select automation).FirstOrDefault();
                GuidesValidationMethods.CalculateLibraryItemLocation(this, automationStep, true, Guide.GuideFlow.CURRENT);
            }


            stepUIPopup.IsOpen = true;

            if (this.StepUIPopup is PopupWindow popupWindow)
            {
                if (Guide.FindChild((popupWindow).mainPopupGrid, NextButton) is Button nextbuttonFound)
                {
                    nextbuttonFound.Focus();
                }
            }
        }
        /// <summary>
        /// This methos subscribes and unsubscribes an event by setting the method and the event dynamically
        /// </summary>
        /// <param name="element">The element to subscribe the method I.E: Button</param>
        /// <param name="eventname">The event name that will be subscribed I.E: Click</param>
        /// <param name="methodname">The method that will listen the event I.E: AcceptButton_Click
        /// The method need to have Access Modifier internal and return void
        /// </param>
        /// <param name="addEvent">A flag that will check if it's to subscribe or unsubscribe</param>
        internal static void ManageEventHandler(object element, string eventname, string methodname, bool addEvent = true)
        {
            EventInfo eventInfo = element.GetType().GetEvent(eventname);

            var validationMethods = new GuidesValidationMethods();

            var eventHandlerMethod = validationMethods.GetType().GetMethod(methodname, BindingFlags.NonPublic | BindingFlags.Instance);

            Delegate del = Delegate.CreateDelegate(eventInfo.EventHandlerType, validationMethods, eventHandlerMethod);

            if (addEvent)
            {
                eventInfo.AddEventHandler(element, del);
            }
            else
            {
                eventInfo.RemoveEventHandler(element, del);
            }
        }
Example #3
0
        /// <summary>
        /// Update the Location of Popups only when they are located over the Library (HostPopupInfo.WindowName = LibraryView)
        /// </summary>
        public void UpdateLibraryPopupsLocation()
        {
            if (HostPopupInfo.WindowName != null && HostPopupInfo.WindowName.Equals(nameof(LibraryView)))
            {
                var automationScrollDownStep = (from automation in UIAutomation
                                                where automation.Name.Equals(libraryScrollToBottomFuncName)
                                                select automation).FirstOrDefault();
                if (automationScrollDownStep == null)
                {
                    return;
                }
                GuidesValidationMethods.LibraryScrollToBottom(this, automationScrollDownStep, true, Guide.GuideFlow.CURRENT);

                var automationCalculateStep = (from automation in UIAutomation
                                               where automation.Name.Equals(calculateLibraryFuncName)
                                               select automation).FirstOrDefault();
                if (automationCalculateStep == null)
                {
                    return;
                }
                GuidesValidationMethods.CalculateLibraryItemLocation(this, automationCalculateStep, true, Guide.GuideFlow.CURRENT);
            }
        }