Exemplo n.º 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);

            stepUIPopup.IsOpen = true;
        }
Exemplo n.º 2
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();
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Hide the tooltip in the DynamoUI, first undo highlighting an element, then undo UI Automation
        /// </summary>
        internal void Hide(Guide.GuideFlow currentFlow)
        {
            stepUIPopup.IsOpen = false;

            //Disable the HightlightArea functionality
            SetHighlightSection(false);

            //We need to remove the cutoff section from the Overlay for the current Step (it will be set again for the next Step)
            SetCutOffSectionSize(false);

            //Disable the current action automation that is executed for the Current Step (if there is one)
            if (UIAutomation != null)
            {
                foreach (var automation in UIAutomation)
                {
                    ExecuteUIAutomationStep(automation, false, currentFlow);
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// This method will execute an UIAutomation action over a specific UIElement
        /// </summary>
        /// <param name="uiAutomationData">UIAutomation info read from a json file</param>
        /// <param name="enableUIAutomation">Enable/Disable the automation action for a specific UIElement</param>
        private void ExecuteUIAutomationStep(StepUIAutomation uiAutomationData, bool enableUIAutomation, Guide.GuideFlow currentFlow)
        {
            var popupBorderName = "SubmenuBorder";
            //This section will search the UIElement dynamically in the Dynamo VisualTree in which an automation action will be executed
            UIElement automationUIElement = Guide.FindChild(MainWindow, uiAutomationData.Name);

            if (automationUIElement != null)
            {
                uiAutomationData.UIElementAutomation = automationUIElement;
            }

            switch (uiAutomationData.ControlType)
            {
            case StepUIAutomation.UIControlType.MENUITEM:
                if (uiAutomationData.UIElementAutomation == null)
                {
                    return;
                }
                MenuItem menuEntry = uiAutomationData.UIElementAutomation as MenuItem;
                if (menuEntry == null)
                {
                    return;
                }
                switch (uiAutomationData.Action)
                {
                case StepUIAutomation.UIAction.OPEN:
                    menuEntry.IsSubmenuOpen    = enableUIAutomation;
                    menuEntry.StaysOpenOnClick = enableUIAutomation;
                    break;
                }
                //Means that the Popup location needs to be updated after the MenuItem is opened
                if (uiAutomationData.UpdatePlacementTarget)
                {
                    //We need to find the border inside the MenuItem.Popup so we can get its Width (this template is defined in MenuStyleDictionary.xaml)
                    var menuPopupBorder = menuEntry.Template.FindName(popupBorderName, menuEntry) as Border;
                    if (menuPopupBorder == null)
                    {
                        return;
                    }

                    //We need to do this substraction so the Step Popup wil be located at the end of the MenuItem Popup.
                    stepUIPopup.HorizontalOffset = (menuPopupBorder.ActualWidth - menuEntry.ActualWidth) + HostPopupInfo.HorizontalPopupOffSet;
                    UpdatePopupLocationInvoke(stepUIPopup);
                }
                break;

            //In this case the UI Automation will be done using a Function located in the static class GuidesValidationMethods
            case StepUIAutomation.UIControlType.FUNCTION:
                MethodInfo builderMethod   = typeof(GuidesValidationMethods).GetMethod(uiAutomationData.Name, BindingFlags.Static | BindingFlags.NonPublic);
                object[]   parametersArray = new object[] { this, uiAutomationData, enableUIAutomation, currentFlow };
                builderMethod.Invoke(null, parametersArray);
                //If UpdatePlacementTarget = true then means that a new Window was opened after executing the funtion then we need to update the Popup.PlacementTarget
                if (uiAutomationData.UpdatePlacementTarget)
                {
                    UpdatePlacementTarget();
                }
                break;

            //In this case the UI Automation will be done over a WPF Button
            case StepUIAutomation.UIControlType.BUTTON:
                if (string.IsNullOrEmpty(uiAutomationData.WindowName))
                {
                    return;
                }

                //This means that the Button is in a PopupWindow (instead of the DynamoView) so we need to find the button and then apply the automation
                if (uiAutomationData.WindowName.Equals(WindowNamePopup))
                {
                    //Finds the Button inside the PopupWindow
                    var buttonFound = Guide.FindChild((stepUIPopup as PopupWindow).mainPopupGrid, uiAutomationData.Name) as Button;
                    if (buttonFound == null)
                    {
                        return;
                    }

                    switch (uiAutomationData.Action)
                    {
                    case StepUIAutomation.UIAction.DISABLE:
                        if (enableUIAutomation)
                        {
                            buttonFound.IsEnabled = false;
                        }
                        else
                        {
                            buttonFound.IsEnabled = true;
                        }
                        break;
                    }
                }
                break;

            case StepUIAutomation.UIControlType.JSFUNCTION:
                if (string.IsNullOrEmpty(uiAutomationData.JSFunctionName))
                {
                    return;
                }
                //We need to create a new list for the parameters due that we will be adding the enableUIAutomation boolean value
                var parametersJSFunction = new List <object>(uiAutomationData.JSParameters);
                parametersJSFunction.Add(enableUIAutomation);
                //Create the array for the parameters that will be sent to the JS Function
                object[] jsParameters = parametersJSFunction.ToArray();
                //Create the array for the paramateres that will be sent to the WebBrowser.InvokeScript Method
                object[] parametersInvokeScript = new object[] { uiAutomationData.JSFunctionName, jsParameters };
                //Execute the JS function with the provided parameters
                ResourceUtilities.ExecuteJSFunction(MainWindow, HostPopupInfo, parametersInvokeScript);
                break;
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// This method will execute an UIAutomation action over a specific UIElement
        /// </summary>
        /// <param name="uiAutomationData">UIAutomation info read from a json file</param>
        /// <param name="enableUIAutomation">Enable/Disable the automation action for a specific UIElement</param>
        private void ExecuteUIAutomationStep(StepUIAutomation uiAutomationData, bool enableUIAutomation, Guide.GuideFlow currentFlow)
        {
            //This section will search the UIElement dynamically in the Dynamo VisualTree in which an automation action will be executed
            UIElement automationUIElement = Guide.FindChild(MainWindow, uiAutomationData.Name);

            if (automationUIElement != null)
            {
                uiAutomationData.UIElementAutomation = automationUIElement;
            }

            switch (uiAutomationData.ControlType)
            {
            case StepUIAutomation.UIControlType.MENUITEM:
                if (uiAutomationData.UIElementAutomation == null)
                {
                    return;
                }
                MenuItem menuEntry = uiAutomationData.UIElementAutomation as MenuItem;
                if (menuEntry == null)
                {
                    return;
                }
                switch (uiAutomationData.Action)
                {
                case StepUIAutomation.UIAction.OPEN:
                    menuEntry.IsSubmenuOpen    = enableUIAutomation;
                    menuEntry.StaysOpenOnClick = enableUIAutomation;
                    break;
                }
                break;

            //In this case the UI Automation will be done using a Function located in the static class GuidesValidationMethods
            case StepUIAutomation.UIControlType.FUNCTION:
                MethodInfo builderMethod   = typeof(GuidesValidationMethods).GetMethod(uiAutomationData.Name, BindingFlags.Static | BindingFlags.NonPublic);
                object[]   parametersArray = new object[] { this, uiAutomationData, enableUIAutomation, currentFlow };
                builderMethod.Invoke(null, parametersArray);
                //If UpdatePlacementTarget = true then means that a new Window was opened after executing the funtion then we need to update the Popup.PlacementTarget
                if (uiAutomationData.UpdatePlacementTarget)
                {
                    UpdatePlacementTarget();
                }
                break;

            //In this case the UI Automation will be done over a WPF Button
            case StepUIAutomation.UIControlType.BUTTON:
                if (string.IsNullOrEmpty(uiAutomationData.WindowName))
                {
                    return;
                }

                //This means that the Button is in a PopupWindow (instead of the DynamoView) so we need to find the button and then apply the automation
                if (uiAutomationData.WindowName.Equals(WindowNamePopup))
                {
                    //Finds the Button inside the PopupWindow
                    var buttonFound = Guide.FindChild((stepUIPopup as PopupWindow).mainPopupGrid, uiAutomationData.Name) as Button;
                    if (buttonFound == null)
                    {
                        return;
                    }

                    switch (uiAutomationData.Action)
                    {
                    case StepUIAutomation.UIAction.DISABLE:
                        if (enableUIAutomation)
                        {
                            buttonFound.IsEnabled = false;
                        }
                        else
                        {
                            buttonFound.IsEnabled = true;
                        }
                        break;
                    }
                }
                break;
            }
        }