void CodeToolWindow_WindowShow(object sender, EventArgs e)
        {
            if (shutting_down)
            {
                return;
            }
            if (OnAir == false && CodeRush.TextViews.Active != null)
            {
                EnvDTE.Window wnd = null;
                try
                {
                    wnd = this.Window; // CodeRush.ToolWindows.Show(typeof(CodeToolWindow));
                    if (wnd != null && wnd.IsFloating)
                    {
                        //wnd.Visible = true;
                        //wnd.IsFloating = true;
                        EnvDTE.Window prop_wnd = CodeRush.ApplicationObject.Windows.Item(EnvDTE.Constants.vsWindowKindProperties);
                        if (prop_wnd == null)
                        {
                            return;
                        }

                        wnd.Width  = 60;
                        wnd.Top    = prop_wnd.Top;    // ea.TextView.ScreenBounds.Top;
                        wnd.Height = prop_wnd.Height; // ea.TextView.ScreenBounds.Height;
                        wnd.Left   = prop_wnd.Left;   // +code_wnd.Width + 1; // ea.TextView.ScreenBounds.Right - wnd.Width;

                        //wnd.IsFloating = false;
                        if (false) //(prop_wnd != null && prop_wnd.Linkable && prop_wnd.LinkedWindowFrame != null && prop_wnd.LinkedWindowFrame.LinkedWindows != null)
                        {
                            //var frame = wnd.DTE.Windows.CreateLinkedWindowFrame(wnd, prop_wnd, EnvDTE.vsLinkedWindowType.vsLinkedWindowTypeVertical);
                            prop_wnd.LinkedWindowFrame.LinkedWindows.Add(wnd);
                        }
                        else
                        {
                            int width  = prop_wnd.Width + 60;
                            int height = prop_wnd.Height;
                            prop_wnd.LinkedWindowFrame.LinkedWindows.Remove(prop_wnd);
                            //prop_wnd.IsFloating = true;
                            EnvDTE80.Window2 Frame = (EnvDTE80.Window2)CodeRush.ApplicationObject.Windows.CreateLinkedWindowFrame(wnd, prop_wnd,
                                                                                                                                  EnvDTE.vsLinkedWindowType.vsLinkedWindowTypeVertical);
                            Frame.Caption = "Properties && Code";

                            Frame.SetKind(EnvDTE.vsWindowType.vsWindowTypeToolWindow);
                            Frame.Width  = width;
                            Frame.Height = height;
                            EnvDTE.Window main_wnd = ((EnvDTE80.DTE2)CodeRush.ApplicationObject).MainWindow;
                            //EnvDTE.Window main_wnd = CodeRush.ApplicationObject.Windows.Item(EnvDTE.Constants.vsWindowKindDocumentOutline);
                            //main_wnd.LinkedWindowFrame.LinkedWindows.Add(Frame);
                            main_wnd.LinkedWindows.Add(Frame);
                        }

                        OnAir = true;
                    }
                }
                catch
                {
                }
            }
        }
Ejemplo n.º 2
0
        public void ResolveConflictsPerTF(string rootPath)
        {
            try
            {
                _attachedFrames.Clear();
                string pathToTools = Environment.GetEnvironmentVariable("VS160COMNTOOLS");
                if (String.IsNullOrEmpty(pathToTools))
                {
                    pathToTools = Environment.GetEnvironmentVariable("VS140COMNTOOLS");
                }
                if (String.IsNullOrEmpty(pathToTools))
                {
                    pathToTools = Environment.GetEnvironmentVariable("VS150COMNTOOLS");
                }
                if (String.IsNullOrEmpty(pathToTools))
                {
                    pathToTools = Environment.GetEnvironmentVariable("VS130COMNTOOLS");
                }
                if (String.IsNullOrEmpty(pathToTools))
                {
                    pathToTools = Environment.GetEnvironmentVariable("VS100COMNTOOLS");
                }
                if (String.IsNullOrEmpty(pathToTools))
                {
                    throw new Exception("VS1X0COMNTOOLS not found");
                }
                string pathToTF = Path.GetFullPath(Path.Combine(pathToTools, "..\\IDE\\TF.exe"));

                ProcessStartInfo psi = new ProcessStartInfo();
                psi.WorkingDirectory = rootPath;
                psi.Arguments        = "resolve /recursive /prompt";
                psi.FileName         = pathToTF;
                psi.CreateNoWindow   = true;
                psi.UseShellExecute  = false;
                Process p      = Process.Start(psi);
                bool    hasSet = false;

                while (!p.WaitForExit(10))
                {
                    SetMergeDiffWindowsToFloatOnly();

                    bool setForeground = true;
                    foreach (EnvDTE.Window w1 in Dte.Windows)
                    {
                        EnvDTE80.Window2 window = w1 as EnvDTE80.Window2;
                        if (window.Caption.StartsWith("Merge - ") || window.Caption.StartsWith("Diff - "))
                        {
                            if (!hasSet || window.WindowState != EnvDTE.vsWindowState.vsWindowStateMaximize)
                            {
                                hasSet             = true;
                                window.IsFloating  = true;
                                window.WindowState = EnvDTE.vsWindowState.vsWindowStateMaximize;
                            }
                            setForeground = false;
                        }
                    }
                    if (setForeground)
                    {
                        var  foregroundWindow  = GetForegroundWindow();
                        var  mainWindowHandle  = Process.GetCurrentProcess().MainWindowHandle;
                        uint foregroundProcess = 0;
                        uint mainWindowProcess = 0;
                        GetWindowThreadProcessId(foregroundWindow, out foregroundProcess);
                        GetWindowThreadProcessId(mainWindowHandle, out mainWindowProcess);

                        if (foregroundProcess == mainWindowProcess)
                        {
                            SetForegroundWindow(p.MainWindowHandle);
                        }
                    }
                    Application.DoEvents();
                }

                foreach (var frame in _attachedFrames.Keys)
                {
                    frame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, null);
                }
                _attachedFrames.Clear();
            }
            catch (Exception ex)
            {
                SimpleLogger.Log(ex, true);
            }
        }
Ejemplo n.º 3
0
        public bool ShowDifferencesPerTF(string rootPath, string sourcePath, string targetPath)
        {
            try
            {
                _attachedFrames.Clear();
                string pathToTools = Environment.GetEnvironmentVariable("VS120COMNTOOLS");
                string pathToTF    = Path.GetFullPath(Path.Combine(pathToTools, "..\\IDE\\TF.exe"));

                ProcessStartInfo psi = new ProcessStartInfo();
                psi.WorkingDirectory = rootPath;
                psi.Arguments        = String.Format("diff \"{0}\" \"{1}\"", sourcePath, targetPath);
                psi.FileName         = pathToTF;
                psi.CreateNoWindow   = true;
                psi.UseShellExecute  = false;
                Process p      = Process.Start(psi);
                bool    hasSet = false;

                while (!p.WaitForExit(10))
                {
                    SetMergeDiffWindowsToFloatOnly();

                    bool setForeground = true;
                    foreach (EnvDTE.Window w1 in Dte.Windows)
                    {
                        EnvDTE80.Window2 window = w1 as EnvDTE80.Window2;
                        if (window.Caption.StartsWith("Merge - ") || window.Caption.StartsWith("Diff - "))
                        {
                            if (!hasSet || window.WindowState != EnvDTE.vsWindowState.vsWindowStateMaximize)
                            {
                                hasSet             = true;
                                window.IsFloating  = true;
                                window.WindowState = EnvDTE.vsWindowState.vsWindowStateMaximize;
                            }
                            setForeground = false;
                        }
                    }
                    if (setForeground)
                    {
                        var  foregroundWindow  = GetForegroundWindow();
                        var  mainWindowHandle  = Process.GetCurrentProcess().MainWindowHandle;
                        uint foregroundProcess = 0;
                        uint mainWindowProcess = 0;
                        GetWindowThreadProcessId(foregroundWindow, out foregroundProcess);
                        GetWindowThreadProcessId(mainWindowHandle, out mainWindowProcess);

                        if (foregroundProcess == mainWindowProcess)
                        {
                            SetForegroundWindow(p.MainWindowHandle);
                        }
                    }
                    Application.DoEvents();
                }

                foreach (var frame in _attachedFrames.Keys)
                {
                    frame.SetProperty((int)__VSFPROPID.VSFPROPID_ViewHelper, null);
                }
                _attachedFrames.Clear();

                if (p.ExitCode == 100)
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                SimpleLogger.Log(ex, true);
            }
            return(true);
        }