コード例 #1
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;
                }
            }
        }
コード例 #2
0
ファイル: Step.cs プロジェクト: reddyashish/Dynamo
        /// <summary>
        /// This method will update the Target in case the UI Automation was executed and the Popup was waiting for a specific Window to be opened
        /// </summary>
        internal void UpdatePlacementTarget()
        {
            if (stepUIPopup == null)
            {
                return;
            }
            //This means that the HostPopupInfo.HostUIElementString is in a different Window than DynamoView
            if (!string.IsNullOrEmpty(HostPopupInfo.WindowName))
            {
                Window ownedWindow = Guide.FindWindowOwned(HostPopupInfo.WindowName, MainWindow as Window);
                if (ownedWindow == null)
                {
                    return;
                }
                HostPopupInfo.HostUIElement = ownedWindow;
                stepUIPopup.PlacementTarget = ownedWindow;
                UpdateLocation();
            }
            //This case will be used for UIElements that are in the Dynamo VisualTree but they are shown until there is a user interaction (like the SideBar cases)
            var hostUIElement = Guide.FindChild(MainWindow, HostPopupInfo.HostUIElementString);

            if (hostUIElement == null)
            {
                return;
            }
            HostPopupInfo.HostUIElement = hostUIElement;
            stepUIPopup.PlacementTarget = hostUIElement;
            UpdateLocation();
        }
コード例 #3
0
ファイル: Step.cs プロジェクト: reddyashish/Dynamo
        /// <summary>
        /// This method will execute the PreValidation action/method for this Step.
        /// </summary>
        internal void ExecutePreValidation()
        {
            object[] parametersArray;
            Window   ownedWindow = Guide.FindWindowOwned(HostPopupInfo.WindowName, MainWindow as Window);

            if (PreValidationInfo != null)
            {
                if (PreValidationInfo.ControlType.Equals("visibility"))
                {
                    if (!string.IsNullOrEmpty(PreValidationInfo.FuncName))
                    {
                        MethodInfo builderMethod = typeof(GuidesValidationMethods).GetMethod(PreValidationInfo.FuncName, BindingFlags.Static | BindingFlags.NonPublic);

                        //Checks if needs to execute 'IsPackageInstalled' method to include the right parameters
                        if (PreValidationInfo.FuncName.Equals("IsPackageInstalled"))
                        {
                            PackageManager.PackageManagerSearchViewModel viewModel = null;

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

                            parametersArray = new object[] { viewModel };
                        }
                        else
                        {
                            parametersArray = new object[] { DynamoViewModelStep };
                        }

                        var validationResult = (bool)builderMethod.Invoke(null, parametersArray);

                        bool expectedValue = bool.Parse(PreValidationInfo.ExpectedValue);

                        //Once the execution of the PreValidation method was done we compare the result against the expected (also described in the json) so we set a flag
                        if (validationResult == expectedValue)
                        {
                            PreValidationIsOpenFlag = true;
                        }
                        else
                        {
                            PreValidationIsOpenFlag = false;
                        }
                    }
                }
            }
        }
コード例 #4
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);
            }
        }
コード例 #5
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);
            }
        }
コード例 #6
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;
            }
        }
コード例 #7
0
ファイル: Step.cs プロジェクト: reddyashish/Dynamo
        /// <summary>
        /// This function will highlight a Window element (the element can be located in DynamoView or another Window or can be a MenuItem
        /// <param name="bVisible">Indicates if the highlight should be applied or removed</param>
        internal void HighlightWindowElement(bool bVisible)
        {
            //Check if the HighlightRectArea was provided in the json file and the HostUIElement was found in the DynamoView VisualTree
            if (HostPopupInfo.HighlightRectArea == null || HostPopupInfo.HostUIElement == null)
            {
                return;
            }
            //Check if the WindowElementNameString was provided in the json and is not empty
            if (string.IsNullOrEmpty(HostPopupInfo.HighlightRectArea.WindowElementNameString))
            {
                return;
            }

            //If is MenuItem type means that the Popup.TargetPlacement will be calculated dinamically
            if (HostPopupInfo.HighlightRectArea.UIElementTypeString.Equals(typeof(MenuItem).Name))
            {
                //We try to find the WindowElementNameString (in this case the MenuItem) in the DynamoView VisualTree
                var foundUIElement = Guide.FindChild(HostPopupInfo.HostUIElement, HostPopupInfo.HighlightRectArea.WindowElementNameString);

                if (foundUIElement != null)
                {
                    var subMenuItem = foundUIElement as MenuItem;

                    //If the HighlightRectArea.WindowElementNameString described is a MenuItem (Dynamo menu) then we need to add the Rectangle dynamically to the Template
                    HighlightMenuItem(subMenuItem, bVisible);
                }
            }
            //The HighlightRectArea.UIElementTypeString was provided but the type is DynamoView then we will search the element in the DynamoView VisualTree
            else if (HostPopupInfo.HighlightRectArea.UIElementTypeString.Equals(typeof(DynamoView).Name))
            {
                string highlightColor = HostPopupInfo.HighlightRectArea.HighlightColor;

                //Find the in the DynamoView VisualTree the specified Element (WindowElementNameString)
                var hostUIElement = Guide.FindChild(MainWindow, HostPopupInfo.HighlightRectArea.WindowElementNameString);

                if (hostUIElement == null)
                {
                    return;
                }

                //If the Element was found we need to calculate the X,Y coordinates based in the UIElement Ancestor
                Point relativePoint = hostUIElement.TransformToAncestor(MainWindow)
                                      .Transform(new Point(0, 0));

                var holeWidth  = hostUIElement.DesiredSize.Width + HostPopupInfo.HighlightRectArea.WidthBoxDelta;
                var holeHeight = hostUIElement.DesiredSize.Height + HostPopupInfo.HighlightRectArea.HeightBoxDelta;

                //Activate the Highlight rectangle from the GuideBackground
                StepGuideBackground.HighlightBackgroundArea.SetHighlighRectSize(relativePoint.Y, relativePoint.X, holeWidth, holeHeight);

                if (string.IsNullOrEmpty(highlightColor))
                {
                    StepGuideBackground.GuideHighlightRectangle.Stroke = Brushes.Transparent;
                }
                else
                {
                    //This section will put the desired color in the Highlight rectangle (read from the json file)
                    var converter = new BrushConverter();
                    var brush     = (Brush)converter.ConvertFromString(highlightColor);
                    StepGuideBackground.GuideHighlightRectangle.Stroke = brush;
                }
            }
            //This case is for when the item to be highlighted is inside the LibraryView (WebBrowser component)
            else if (HostPopupInfo.HighlightRectArea.UIElementTypeString.Equals(typeof(WebBrowser).Name))
            {
                //We need to access the WebBrowser instance and call a js function to highlight the html div border of the item
                HighlightLibraryItem(bVisible);
            }
            //If the UIElementTypeString is not a MenuItem and also not a DynamoView we need to find the Window in the OwnedWindows and search the element inside it
            else
            {
                string highlightColor = HostPopupInfo.HighlightRectArea.HighlightColor;
                Window ownedWindow    = Guide.FindWindowOwned(HostPopupInfo.HighlightRectArea.WindowName, MainWindow as Window);
                if (ownedWindow == null)
                {
                    return;
                }
                UIElement foundElement = Guide.FindChild(ownedWindow, HostPopupInfo.HighlightRectArea.WindowElementNameString);
                switch (HostPopupInfo.HighlightRectArea.UIElementTypeString.ToUpper())
                {
                //We need to highlight a Button (if the Button template doesn't have a grid then the template needs to be updated)
                case "BUTTON":
                    var buttonElement = foundElement as Button;
                    if (buttonElement == null)
                    {
                        return;
                    }

                    //We will be searching for the Grid name provided in the json file and then add the Highlight Rectangle
                    var bordersGrid = buttonElement.Template.FindName(HostPopupInfo.HighlightRectArea.UIElementGridContainer, buttonElement) as Grid;
                    if (bordersGrid == null)
                    {
                        return;
                    }

                    if (bVisible)
                    {
                        var buttonRectangle = CreateRectangle(bordersGrid, HostPopupInfo.HighlightRectArea.HighlightColor);
                        //The Rectangle will be added dynamically in a specific step and then when passing to next step we will remove it
                        bordersGrid.Children.Add(buttonRectangle);
                    }
                    else
                    {
                        //When we need to undo the highlight we find the Rectangle and remove it
                        var buttonRectangle = bordersGrid.Children.OfType <Rectangle>().Where(rect => rect.Name.Equals("HighlightRectangle")).FirstOrDefault();
                        if (buttonRectangle != null)
                        {
                            bordersGrid.Children.Remove(buttonRectangle);
                        }
                    }
                    break;
                }
            }
        }
コード例 #8
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);
            }
        }
コード例 #9
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);
                }
            }
        }