Ejemplo n.º 1
0
        public static API_GitHub gitClone(this API_GitHub gitHub, string url, string targetDir, string privateKeyFile)
        {
            if (targetDir.inValid())
            {
                targetDir = "".tempDir();
            }
            var guiAutomation = new API_GuiAutomation();

            if (guiAutomation.desktopWindow("Git clone").isNull())              // see if there is already an 'Git clone' window
            {
                //Create a form window with a webbrowser that will open a local folder
                var windowName = "This is Git Clone target folder  (id:{0})".format(3.randomNumbers());
                var topPanel   = O2Gui.open <Panel>(windowName, 600, 200);
                var webBrowser = topPanel.add_WebBrowser_Control();
                webBrowser.open(targetDir);
                webBrowser.mouse_MoveTo_WinForm();

                // get the form and right click on it
                var window = guiAutomation.desktopWindow(windowName);
                guiAutomation.mouse().click().rightClick();

                // get the context menu and click on the 'Git Clone...' menu button
                var contextMenu = guiAutomation.getContextMenu();
                contextMenu.menu("Git Clone...").mouse().click();
            }
            // get the Git Clone window
            var gitClone = guiAutomation.desktopWindow("Git clone", 10);

            gitClone.bringToFront();
            // get a reference to the textboxes we will need to populate
            var url_TextBox       = gitClone.textBox("Url: ");
            var directory_TextBox = gitClone.textBox("Directory:");
            var puttyKey_TextBox  = gitClone.textBoxes().id(1571);

            if (url.valid())
            {
                url_TextBox.set_Text(url);
            }
            if (privateKeyFile.valid() && privateKeyFile.fileExists())
            {
                puttyKey_TextBox.set_Text(privateKeyFile);
            }
            //directory_TextBox.set_Text(targetDir);   // no need to do this since it is added when we use the context menu

            // Click button
            gitClone.button("OK").mouse().click();

            return(gitHub);
        }