コード例 #1
0
        /// <summary>
        /// This method will calculate the Popup location based in a item from the Library
        /// </summary>
        internal static void CalculateLibraryItemLocation(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow)
        {
            CurrentExecutingStep = stepInfo;
            if (uiAutomationData == null)
            {
                return;
            }
            var jsFunctionName = uiAutomationData.JSFunctionName;

            object[] jsParameters = new object[] { uiAutomationData.JSParameters[0] };
            //Create the array for the paramateres that will be sent to the WebBrowser.InvokeScript Method
            object[] parametersInvokeScript = new object[] { jsFunctionName, jsParameters };
            //Execute the JS function with the provided parameters
            var returnedObject = ResourceUtilities.ExecuteJSFunction(CurrentExecutingStep.MainWindow, CurrentExecutingStep.HostPopupInfo, parametersInvokeScript);

            if (returnedObject == null)
            {
                return;
            }
            //Due that the returned object is a json then we get the values from the json
            JObject json   = JObject.Parse(returnedObject.ToString());
            double  top    = Convert.ToDouble(json["client"]["top"].ToString());
            double  bottom = Convert.ToDouble(json["client"]["bottom"].ToString());
            //We calculate the Vertical location taking the average position "(top + bottom) / 2" and the height of the popup
            double verticalPosition = (top + bottom) / 2 - CurrentExecutingStep.Height / 2;

            CurrentExecutingStep.UpdatePopupVerticalPlacement(verticalPosition);
        }
コード例 #2
0
        /// <summary>
        /// This method will be executed when packages search window is opened, so it can identify the close button of the window
        /// </summary>
        /// <param name="stepInfo"></param>
        /// <param name="uiAutomationData"></param>
        /// <param name="enableFunction"></param>
        /// <param name="currentFlow"></param>
        internal static void ExecuteClosePackagesSearch(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow)
        {
            if (enableFunction)
            {
                CurrentExecutingStep = stepInfo;

                if (stepInfo.ExitGuide != null)
                {
                    exitGuide = stepInfo.ExitGuide;
                }

                Window ownedWindow = Guide.FindWindowOwned(stepInfo.HostPopupInfo.WindowName, stepInfo.MainWindow as Window);

                foreach (var handler in uiAutomationData.AutomaticHandlers)
                {
                    if (ownedWindow == null)
                    {
                        return;
                    }

                    CloseButtonSearchPackages        = Guide.FindChild(ownedWindow, handler.HandlerElement) as Button;
                    CloseButtonSearchPackages.Click += CloseButton_Click;
                }
            }
            else
            {
                if (CloseButtonSearchPackages != null)
                {
                    CloseButtonSearchPackages.Click -= CloseButton_Click;
                }
            }
        }
コード例 #3
0
 internal static void EnableNextButton(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow)
 {
     if (searchPackagesLoaded)
     {
         var nextButton = Guide.FindChild((CurrentExecutingStep.StepUIPopup as PopupWindow).mainPopupGrid, uiAutomationData.ElementName) as Button;
         if (nextButton != null)
         {
             nextButton.IsEnabled = true;
         }
     }
 }
コード例 #4
0
        /// <summary>
        /// This method will call a js function that will scroll down until the bottom of the page
        /// </summary>
        internal static void LibraryScrollToBottom(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow)
        {
            CurrentExecutingStep = stepInfo;
            if (uiAutomationData == null)
            {
                return;
            }
            string jsFunctionName = uiAutomationData.JSFunctionName;

            //Create the array for the paramateres that will be sent to the WebBrowser.InvokeScript Method
            object[] parametersInvokeScript = new object[] { jsFunctionName, new object[] { } };
            //Execute the JS function with the provided parameters
            ResourceUtilities.ExecuteJSFunction(CurrentExecutingStep.MainWindow, CurrentExecutingStep.HostPopupInfo, parametersInvokeScript);
        }
コード例 #5
0
        /// <summary>
        /// This method will be executed when passing from Step 2 to Step 3 in the Packages guide, so it will show the TermsOfUse Window in case it was not accepted yet
        /// </summary>
        /// <param name="stepInfo"></param>
        /// <param name="uiAutomationData"></param>
        /// <param name="enableFunction"></param>
        /// <param name="currentFlow"></param>
        internal static void ExecuteTermsOfServiceFlow(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow)
        {
            CurrentExecutingStep = stepInfo;

            if (stepInfo.ExitGuide != null)
            {
                exitGuide = stepInfo.ExitGuide;
            }

            //When enableFunction = true, means we want to show the TermsOfUse Window (this is executed in the UIAutomation step in the Show() method)
            if (enableFunction)
            {
                //If the TermsOfService is not accepted yet it will show the TermsOfUseView otherwise it will show the PackageManagerSearchView
                stepInfo.DynamoViewModelStep.ShowPackageManagerSearch(null);
                Window ownedWindow = Guide.FindWindowOwned(stepInfo.HostPopupInfo.WindowName, stepInfo.MainWindow as Window);

                foreach (var handler in uiAutomationData.AutomaticHandlers)
                {
                    if (ownedWindow == null)
                    {
                        return;
                    }
                    UIElement element = Guide.FindChild(ownedWindow, handler.HandlerElement);

                    //When the Accept button is pressed in the TermsOfUseView then we need to move to the next Step
                    if (element != null)
                    {
                        ManageEventHandler(element, handler.HandlerElementEvent, handler.ExecuteMethod);
                    }
                }
            }
            //When enableFunction = false, means we are hiding (closing) the TermsOfUse Window due that we are moving to the next Step or we are exiting the Guide
            else
            {
                Window ownedWindow = Guide.FindWindowOwned(stepInfo.HostPopupInfo.WindowName, stepInfo.MainWindow as Window);
                if (ownedWindow == null)
                {
                    return;
                }

                //Tries to close the TermsOfUseView or the PackageManagerSearchView if they were opened previously
                Guide.CloseWindowOwned(stepInfo.HostPopupInfo.WindowName, stepInfo.MainWindow as Window);
            }
        }
コード例 #6
0
        /// <summary>
        /// This method will subscribe the Next button from the Step8 Popup for clicking the Package already installed (then it will be expanded).
        /// </summary>
        /// <param name="stepInfo">Information about the Step</param>
        /// <param name="uiAutomationData">Specific UI Automation step that is being executed</param>
        /// <param name="enableFunction">it says if the functionality should be enabled or disabled</param>
        /// <param name="currentFlow">The current flow of the Guide can be FORWARD or BACKWARD</param>
        internal static void SubscribeNextButtonClickEvent(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow)
        {
            CurrentExecutingStep = stepInfo;
            //if there is not handler then the function should return
            if (uiAutomationData.AutomaticHandlers == null || uiAutomationData.AutomaticHandlers.Count == 0)
            {
                return;
            }
            //Due that only one handler was configured we get the first one
            var automaticHandler = uiAutomationData.AutomaticHandlers.FirstOrDefault();
            //Find the NextButton inside the Popup
            var nextbuttonFound = Guide.FindChild((CurrentExecutingStep.StepUIPopup as PopupWindow).mainPopupGrid, automaticHandler.HandlerElement) as Button;

            if (nextbuttonFound == null)
            {
                return;
            }
            //Add or Remove the handler assigned to the Button.Click
            ManageEventHandler(nextbuttonFound, automaticHandler.HandlerElementEvent, automaticHandler.ExecuteMethod, enableFunction);
        }
コード例 #7
0
        /// <summary>
        /// This method will subcribe the menu "Packages->Search for a Package" MenuItem to the Next event so when is pressed we will moved to the next Step
        /// </summary>
        /// <param name="stepInfo">Information about the Step</param>
        /// <param name="uiAutomationData">Information about UI Automation that is being executed</param>
        /// <param name="enableFunction">Variable used to know if we are executing the automation or undoing changes</param>
        /// <param name="currentFlow">Current Guide Flow</param>
        internal static void SubscribeSearchForPackagesOption(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow)
        {
            CurrentExecutingStep = stepInfo;

            //We try to find the WindowElementNameString (in this case the MenuItem) in the DynamoView VisualTree
            var foundUIElement = Guide.FindChild(CurrentExecutingStep.MainWindow, CurrentExecutingStep.HostPopupInfo.HighlightRectArea.WindowElementNameString) as MenuItem;

            if (foundUIElement == null)
            {
                return;
            }
            if (enableFunction)
            {
                //Executed then Showing the Step
                foundUIElement.Click += SearchForPackage_Click;
            }
            else
            {
                //Just executed when exiting the Guide or when passing to the next Step
                foundUIElement.Click -= SearchForPackage_Click;
            }
        }
コード例 #8
0
        /// <summary>
        /// This method will be executed when passing from Step 6 to Step 7 in the Packages guide, so it will subscribe the install button event
        /// </summary>
        /// <param name="stepInfo"></param>
        /// <param name="uiAutomationData"></param>
        /// <param name="enableFunction"></param>
        /// <param name="currentFlow"></param>
        internal static void ExecuteInstallPackagesFlow(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow)
        {
            CurrentExecutingStep = stepInfo;
            Window ownedWindow = Guide.FindWindowOwned(stepInfo.HostPopupInfo.WindowName, stepInfo.MainWindow as Window);


            if (enableFunction)
            {
                if (ownedWindow != null)
                {
                    viewModel = ownedWindow.DataContext as PackageManagerSearchViewModel;
                }

                Button buttonElement = Guide.FindChild(ownedWindow, stepInfo.HostPopupInfo.HostUIElementString) as Button;
                viewModel.PackageManagerClientViewModel.Downloads.CollectionChanged += Downloads_CollectionChanged;
            }
            else
            {
                //Tries to close the TermsOfUseView or the PackageManagerSearchView if they were opened previously
                Guide.CloseWindowOwned(stepInfo.HostPopupInfo.WindowName, stepInfo.MainWindow as Window);
            }
        }
コード例 #9
0
        /// <summary>
        /// This method will be used to subscribe a method to the Button.Click event of the ViewDetails button located in the PackageManagerSearch Window
        /// </summary>
        /// <param name="stepInfo">Information about the Step</param>
        /// <param name="uiAutomationData">Information about UI Automation that is being executed</param>
        /// <param name="enableFunction">Variable used to know if we are executing the automation or undoing changes</param>
        /// <param name="currentFlow">Current Guide Flow</param>
        internal static void SubscribeViewDetailsEvent(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow)
        {
            CurrentExecutingStep = stepInfo;
            PackageManagerSearchView packageManager = Guide.FindWindowOwned(stepInfo.HostPopupInfo.WindowName, stepInfo.MainWindow as Window) as PackageManagerSearchView;

            if (packageManager == null)
            {
                return;
            }
            Button foundElement = Guide.FindChild(packageManager, stepInfo.HostPopupInfo.HighlightRectArea.WindowElementNameString) as Button;

            if (foundElement == null)
            {
                return;
            }
            if (enableFunction)
            {
                foundElement.Click += ViewDetails_Click;
            }
            else
            {
                foundElement.Click -= ViewDetails_Click;
            }
        }
コード例 #10
0
ファイル: Step.cs プロジェクト: reddyashish/Dynamo
        /// <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;
            }
        }
コード例 #11
0
        /// <summary>
        /// This method will be opening the SideBar Package Details (or closing it when enableFunction = false)
        /// </summary>
        /// <param name="stepInfo">Information about the Step</param>
        /// <param name="uiAutomationData">Information about UI Automation that is being executed</param>
        /// <param name="enableFunction">Variable used to know if we are executing the automation or undoing changes</param>
        /// <param name="currentFlow">Current Guide Flow</param>
        internal static void ExecuteViewDetailsSideBar(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow)
        {
            const string packageDetailsName      = "Package Details";
            const string closeButtonName         = "CloseButton";
            const string packageSearchWindowName = "PackageSearch";

            CurrentExecutingStep = stepInfo;
            var stepMainWindow       = stepInfo.MainWindow as Window;
            var packageDetailsWindow = Guide.FindChild(stepMainWindow, stepInfo.HostPopupInfo.HostUIElementString) as UserControl;

            if (enableFunction)
            {
                //This section will open the Package Details Sidebar
                PackageManagerSearchView packageManager = Guide.FindWindowOwned(packageSearchWindowName, stepMainWindow) as PackageManagerSearchView;
                if (packageManager == null)
                {
                    return;
                }
                PackageManagerSearchViewModel packageManagerViewModel = packageManager.DataContext as PackageManagerSearchViewModel;

                //If the results in the PackageManagerSearch are null then we cannot open the Package Detail tab
                if (packageManagerViewModel == null || packageManagerViewModel.SearchResults.Count == 0)
                {
                    return;
                }

                //We take the first result from the PackageManagerSearch
                PackageManagerSearchElementViewModel packageManagerSearchElementViewModel = packageManagerViewModel.SearchResults[0];
                if (packageManagerSearchElementViewModel == null)
                {
                    return;
                }

                if (packageDetailsWindow == null)
                {
                    packageManagerViewModel.ViewPackageDetailsCommand.Execute(packageManagerSearchElementViewModel.Model);
                }

                //The PackageDetails sidebar is using events when is being shown then we need to execute those events before setting the Popup.PlacementTarget.
                //otherwise the sidebar will not be present (and we don't have host for the Popup) and the Popup will be located out of the Dynamo window
                CurrentExecutingStep.MainWindow.Dispatcher.Invoke(DispatcherPriority.Background, new Action(delegate { }));
            }
            else
            {
                //This section will close the Package Details Sidebar (just in case is still opened),
                //due that the sidebar (UserControl) is inserted inside a TabItem the only way to close is by using the method dynamoView.CloseExtensionTab
                var dynamoView = (stepMainWindow as DynamoView);
                if (packageDetailsWindow == null)
                {
                    return;
                }
                //In order to close the Package Details tab we need first to get the Tab, then get the Close button and finally call the event to close it
                TabItem tabitem = dynamoView.ExtensionTabItems.OfType <TabItem>().SingleOrDefault(n => n.Header.ToString() == packageDetailsName);
                if (tabitem == null)
                {
                    return;
                }
                //Get the Close button from the PackageDetailsView
                Button closeButton = Guide.FindChild(tabitem, closeButtonName) as Button;
                if (closeButton == null)
                {
                    return;
                }
                dynamoView.CloseExtensionTab(closeButton, null);
            }
        }
コード例 #12
0
        /// <summary>
        /// This method will be used to open the PackageManagerSearchView and search for a specific Package
        /// </summary>
        /// <param name="stepInfo">Step information</param>
        /// <param name="uiAutomationData">Specific UI Automation step that is being executed</param>
        /// <param name="enableFunction">it says if the functionality should be enabled or disabled</param>
        /// <param name="currentFlow">The current flow of the Guide can be FORWARD or BACKWARD</param>
        internal static void ExecutePackageSearch(Step stepInfo, StepUIAutomation uiAutomationData, bool enableFunction, GuideFlow currentFlow)
        {
            CurrentExecutingStep = stepInfo;
            //We try to find the PackageManagerSearchView window
            Window ownedWindow = Guide.FindWindowOwned(stepInfo.HostPopupInfo.WindowName, stepInfo.MainWindow as Window);

            if (enableFunction)
            {
                //We need to check if the PackageManager search is already open if that is the case we don't need to open it again
                if (ownedWindow != null)
                {
                    return;
                }
                stepInfo.DynamoViewModelStep.ShowPackageManagerSearch(null);

                PackageManagerSearchView packageManager = Guide.FindWindowOwned(stepInfo.HostPopupInfo.WindowName, stepInfo.MainWindow as Window) as PackageManagerSearchView;
                if (packageManager == null)
                {
                    return;
                }
                PackageManagerSearchViewModel packageManagerViewModel = packageManager.DataContext as PackageManagerSearchViewModel;
                if (packageManagerViewModel == null)
                {
                    return;
                }

                //Due that we need to search the Autodesk Sample package after the initial search is completed
                //we need to subscribe to the PropertyChanged event so we will know when the SearchState property is equal to Results (meaning that got results)
                packageManagerViewModel.PropertyChanged += PackageManagerViewModel_PropertyChanged;
            }
            else
            {
                PackageManagerSearchView packageManager = Guide.FindWindowOwned(stepInfo.HostPopupInfo.WindowName, stepInfo.MainWindow as Window) as PackageManagerSearchView;
                if (packageManager == null)
                {
                    return;
                }
                PackageManagerSearchViewModel packageManagerViewModel = packageManager.DataContext as PackageManagerSearchViewModel;
                if (packageManagerViewModel == null)
                {
                    return;
                }

                //Depending of the SetUp done in the Guides Json we will make the Clean Up or not, for example there are several Steps that use the PackageManagerSearchView then we won't close it

                //The Guide is moving to FORWARD and the ExecuteCleanUpForward = false, then we don't need to close the PackageManagerSearchView
                if (uiAutomationData.ExecuteCleanUpForward && currentFlow == GuideFlow.FORWARD)
                {
                    ClosePackageManager(packageManager);
                }

                //The Guide is moving to FORWARD and the ExecuteCleanUpForward = false, then we don't need to close the PackageManagerSearchView
                if (uiAutomationData.ExecuteCleanUpBackward && currentFlow == GuideFlow.BACKWARD)
                {
                    ClosePackageManager(packageManager);
                }

                //The currentFlow = GuideFlow.CURRENT when exiting the Guide
                if (currentFlow == GuideFlow.CURRENT)
                {
                    ClosePackageManager(packageManager);
                }
            }
        }
コード例 #13
0
ファイル: Step.cs プロジェクト: alvpickmans/Dynamo
        /// <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;
            }
        }
コード例 #14
0
        /// <summary>
        /// This method is subscribed to the PropertyChanged event so we will be notified when the SearchState changed
        /// </summary>
        /// <param name="sender">PackageManagerSearchViewModel</param>
        /// <param name="e">PropertyChanged</param>
        private static void PackageManagerViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e, StepUIAutomation uiAutomationData)
        {
            PackageManagerSearchViewModel packageManagerViewModel = sender as PackageManagerSearchViewModel;

            if (packageManagerViewModel == null)
            {
                return;
            }
            if (e.PropertyName == nameof(packageManagerViewModel.SearchState))
            {
                //Let wait until the initial Package Search is completed and we got results then we will search the Autodesk Sample package
                if (packageManagerViewModel.SearchState == PackageSearchState.Results)
                {
                    //Put the name of the Package to be searched in the SearchTextBox
                    packageManagerViewModel.SearchText = AutodeskSamplePackage;

                    searchPackagesLoaded = true;

                    EnableNextButton(null, uiAutomationData, true, GuideFlow.FORWARD);
                    packageManagerViewModel.DisableSearchTextBox();

                    //Unsubscribe from the PropertyChanged event otherwise it will enter everytime the SearchTextBox is updated
                    packageManagerViewModel.PropertyChanged -= searchPackagesPropertyChanged.Invoke;
                }
            }
        }