private void RemoveProcess(Process p, bool killProcess)
        {
            LOG.DebugFormat("RemoveProcess - PID: {0} - Kill Process: {1}", p.Id, killProcess);

            lock ( _tags )
            {
                if (!this.OwnsProcess(p))
                {
                    LOG.ErrorFormat("Attempting to remove process not under control - Process ID: {0}", p.Id);
                    return;
                }

                TabControllerTag tag = _tags[p.Id];

                _tags.Remove(p.Id);

                tag.Tab.Parent = null;

                if (killProcess)
                {
                    KeyboardShortcutsManager.Instance.RemoveHandle(p.MainWindowHandle);

                    tag.Close();
                }
            }
        }
        internal async Task AddNewProcess(Process p)
        {
            TabControllerTag tag;

            lock ( _tags )
            {
                LOG.DebugFormat("AddNewProcess - PID: {0}", p.Id);
                if (this.OwnsProcess(p))
                {
                    LOG.DebugFormat("AddNewProcess - Process already under control - PID: {0}", p.Id);
                    return;
                }

                tag = TabControllerTag.CreateController(p);
                _tags.Add(tag.Process.Id, tag);
            }

            await tag.WaitForStartup();

            KeyboardShortcutsManager.Instance.AddHandle(tag.Process.MainWindowHandle);

            ProcessTabs.Tabs.Add(tag.Tab);
            ProcessTabs.SelectedTab = tag.Tab;

            ShowMe();
        }
        private void CloseTab(Tab tab)
        {
            TabControllerTag t = tab.Controller();

            LOG.DebugFormat("Close Tab - ID: {0}", t.Process.Id);

            RemoveProcess(t.Process, true);

            CheckIfLastTab();
        }
Exemple #4
0
        public static TabControllerTag CreateController(Process p)
        {
            Tab t = new Tab(Native.GetWindowText(p.MainWindowHandle));

            TabControllerTag tag = new TabControllerTag(t, p);

            t.Tag = tag;

            return(tag);
        }
        protected override bool ProcessCmdKey(ref Message msg, Keys keyData)
        {
            if (FORWARD_KEYS.Any(k => keyData == k))
            {
                TabControllerTag tag = ProcessTabs.SelectedTab?.Controller();
                if (tag != null)
                {
                    Native.SetForegroundWindow(tag.Process.MainWindowHandle);
                    Native.SendKeyDown(tag.Process.MainWindowHandle, keyData);
                    return(true);
                }
            }

            return(base.ProcessCmdKey(ref msg, keyData));
        }
        internal void AddExistingTab(Tab tab)
        {
            LOG.DebugFormat("AddExistingTab - Tab: {0}", tab);

            TabControllerTag tag = tab.Controller();

            if (this.OwnsProcess(tag.Process))
            {
                LOG.ErrorFormat("AddExistingTab - Already own process - PID: {0}", tag.Process.Id);
                return;
            }

            ProcessTabs.Tabs.Add(tab);
            ProcessTabs.SelectedTab = tab;
        }
        private void RegisterExistingTab(Tab tab)
        {
            LOG.DebugFormat("RegisterExistingTab - Tab: {0}", tab);

            TabControllerTag tag = tab.Controller();

            if (this.OwnsProcess(tag.Process))
            {
                LOG.ErrorFormat("RegisterExistingTab - Already own process - PID: {0}", tag.Process.Id);
                return;
            }

            lock ( _tags )
            {
                _tags.Add(tag.Process.Id, tag);
            }

            ShowMe();
        }