Esempio n. 1
0
 public GitSvnCloneWindow(GitSvnClient client)
 {
     if (client == null)
     {
         throw new NullReferenceException(nameof(client));
     }
     this.client = client;
     InitializeComponent();
 }
        private void IncludeGitBashInGUI(Window w)
        {
            var windowHandle = new WindowInteropHelper(w).Handle;
            var hWndParent   = IntPtr.Zero;
            //TODO
            var fileName = @"C:\Program Files\Git\git-bash.exe";
            var info     = new ProcessStartInfo(fileName)
            {
                UseShellExecute = false,
                CreateNoWindow  = true,
                WindowStyle     = ProcessWindowStyle.Minimized
            };

            consoleProcess = Process.Start(fileName);
            consoleHandle  = IntPtr.Zero;
            while (consoleHandle == IntPtr.Zero)
            {
                consoleProcess.WaitForInputIdle(100); //wait for the window to be ready for input;
                System.Threading.Thread.Sleep(100);
                consoleProcess.Refresh();             //update process info
                if (consoleProcess.HasExited)
                {
                    return; //abort if the process finished before we got a handle.
                }
                //https://stackoverflow.com/questions/1277563/how-do-i-get-the-handle-of-a-console-applications-window
                //TODO
                consoleHandle = GetGitBashWindowName();
            }
            client = new GitSvnClient(WorkingDir, consoleHandle);
            const int GWL_STYLE  = -16;
            const int WS_VISIBLE = 0x10000000;

            WinAPI.SetWindowLong(consoleHandle, GWL_STYLE, WS_VISIBLE);
            //Windows API call to change the parent of the target window.
            //It returns the hWnd of the window's parent prior to this call.
            hWndOriginalParent = WinAPI.SetParent(consoleHandle, windowHandle);

            //Wire up the event to keep the window sized to match the control
            mainWindow.SizeChanged += WindowResize;
            //Perform an initial call to set the size.
            WindowResize(new object(), new EventArgs());
        }