Пример #1
0
        public void DragAndDropProjectExplorerItemOntoAnotherOne(string pathItemToMove, string pathItemDestination, RepoItemInfo rootNodeInfo)
        {
            pathItemToMove      = pathItemToMove.ReplacePathAliases();
            pathItemDestination = pathItemDestination.ReplacePathAliases();
            TreeItem treeitemToMove      = TreeItemHelpers.FindNodeInTree(pathItemToMove, rootNodeInfo, (ti) => {});
            TreeItem treeItemDestination = TreeItemHelpers.FindNodeInTree(pathItemDestination, rootNodeInfo, (ti) => {});

            Delay.Duration(Duration.FromMilliseconds(1000));
            Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Down item 'treeitemToMove' at Center.");
            treeitemToMove.MoveTo();
            Mouse.ButtonDown(System.Windows.Forms.MouseButtons.Left);
            Report.Log(ReportLevel.Info, "Mouse", "Mouse Left Up item 'treeItemDestination' at Center.");
            treeItemDestination.MoveTo(Duration.FromMilliseconds(1000));
            Mouse.ButtonUp(System.Windows.Forms.MouseButtons.Left);
        }
        /// <summary>
        ///     Search and returns a tree item behind a specified path.
        /// </summary>
        /// <param name="strPath">Item (menu / parameter) to search for.</param>
        /// <returns>
        ///     <br>TreeItem: If call worked fine</br>
        ///     <br>Null: If an error occurred</br>
        /// </returns>
        private TreeItem GetTreeItemByPath(string strPath)
        {
            string[] seperator = { "//" };
            string[] pathParts = strPath.Split(seperator, StringSplitOptions.None);

            int      counter = 0;
            int      lastFoundTreeItemChildIndex = -1;
            TreeItem lastFoundTreeItem           = null;
            TreeItem treeItem = null;

            try
            {
                for (counter = 0; counter < pathParts.Length; counter++)
                {
                    // Get treeitem if it is visible at current GUI
                    treeItem = NavigationElements.GetTreeItem(pathParts[counter], lastFoundTreeItemChildIndex);

                    if (counter == pathParts.Length - 2 && treeItem != null)
                    {
                        treeItem.Click();
                        Parameter parameter = new Application().GetParameterStateFast(pathParts[pathParts.Length - 1]);
                        if (parameter.ParameterState != ParameterState.NotRecognized)
                        {
                            return(treeItem);
                        }
                    }

                    if (treeItem == null)
                    {
                        // If scrollbar active and not null
                        if (NavigationElements.VerticalScrollbar != null && NavigationElements.VerticalScrollbar.Enabled)
                        {
                            if (NavigationElements.PageUpButton.ScreenRectangle.Size.Height == 0)
                            {
                                // If scrollbar is on top
                                // Scroll down
                                treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageDownButton, pathParts[counter], lastFoundTreeItemChildIndex);
                            }
                            else if (NavigationElements.PageDownButton.ScreenRectangle.Size.Height == 0)
                            {
                                // If scrollbar is on bottom
                                // Scroll up
                                treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageUpButton, pathParts[counter], lastFoundTreeItemChildIndex);
                            }
                            else if (NavigationElements.PageUpButton.ScreenRectangle.Size.Height <=
                                     NavigationElements.PageDownButton.ScreenRectangle.Size.Height)
                            {
                                // If scrollbar is nearly on top
                                // Scroll down first
                                treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageDownButton, pathParts[counter], lastFoundTreeItemChildIndex);

                                // Scroll up as next if treeItem noch found
                                if (treeItem == null)
                                {
                                    treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageUpButton, pathParts[counter], lastFoundTreeItemChildIndex);
                                }
                            }
                            else if (NavigationElements.PageUpButton.ScreenRectangle.Size.Height >
                                     NavigationElements.PageDownButton.ScreenRectangle.Size.Height)
                            {
                                // If scrollbar is nearly on bottom
                                // Scroll down first
                                treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageDownButton, pathParts[counter], lastFoundTreeItemChildIndex);

                                // Scroll up as next if treeItem noch found
                                if (treeItem == null)
                                {
                                    treeItem = this.ScrollAndSearchTreeItem(NavigationElements.PageUpButton, pathParts[counter], lastFoundTreeItemChildIndex);
                                }
                            }
                            else
                            {
                                Log.Error(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Impossible path at if-then-else structure.");
                            }
                        }
                        else
                        {
                            // if Scrollbar not active search for treeitem with index greater than last found
                            Log.Info(LogInfo.Namespace(MethodBase.GetCurrentMethod()), "Treeitem " + "[" + pathParts[counter] + "]" + " not found");
                        }
                    }

                    if (treeItem != null)
                    {
                        treeItem.MoveTo();
                        lastFoundTreeItemChildIndex = treeItem.Element.ChildIndex;
                        lastFoundTreeItem           = treeItem;
                    }

                    if (counter >= (pathParts.Length - 1))
                    {
                        continue;
                    }

                    if (treeItem != null)
                    {
                        treeItem.Expand();
                    }
                }

                return(lastFoundTreeItem);
            }
            catch (Exception exception)
            {
                Log.Error("Navigation.GetTreeItemByPath@" + pathParts[counter], exception.Message);
                return(null);
            }
        }