private void RemoveLogProcess(Process p, bool killProcess)
        {
            LOG.Debug($"{nameof( RemoveLogProcess )} - PID: {p.Id} - Kill Process: {killProcess}");

            lock ( _tags )
            {
                if (!this.OwnsLogProcess(p))
                {
                    LOG.Error($"Attempting to remove log not under control - Process ID: {p.Id}");
                    return;
                }

                TabControllerTag tag = _tags[p.Id];

                _tags.Remove(p.Id);

                tag.Tab.Parent = null;

                if (killProcess)
                {
                    _closedRepos.Push(tag.RepoItem);

                    KeyboardShortcutsManager.Instance.RemoveHandle(p.MainWindowHandle);

                    tag.Close();
                }
            }
        }
        internal async Task AddNewLogProcess(Process p, String path)
        {
            TabControllerTag tag;

            lock ( _tags )
            {
                LOG.Debug($"{nameof( AddNewLogProcess )} - Path: {path} - PID: {p.Id}");
                if (this.OwnsLogProcess(p))
                {
                    LOG.Debug($"{nameof( AddNewLogProcess )} - Process already under control - Path: {path} - PID: {p.Id}");
                    return;
                }

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

            await tag.WaitForStartup();

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

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

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

            LOG.Debug($"{nameof( CloseTab )} - Repo: {t.RepoItem} - ID: {t.Process.Id}");

            RemoveLogProcess(t.Process, true);

            CheckIfLastTab();
        }
示例#4
0
        private async void OpenWithReferencesRepoTabMenuItem_Click(object?sender, EventArgs e)
        {
            TabControllerTag tag  = LogTabs.SelectedTab !.Controller();
            String           repo = Git.GetBaseRepoDirectoryOrError(tag.RepoItem);

            using ReferencesDialog dialog = new ReferencesDialog(repo);
            if (dialog.ShowDialog() == DialogResult.OK)
            {
                await OpenLog(tag.RepoItem, dialog.SelectedReferences);
            }
        }
示例#5
0
        private async void CustomActionTabMenuItem_Click(object?sender, EventArgs e)
        {
            if (sender is not ToolStripItem c ||
                c.Tag is not CustomAction customAction)
            {
                return;
            }

            TabControllerTag tag = LogTabs.SelectedTab !.Controller();

            await RunCustomAction(tag, customAction, tag.RepoItem);
        }
示例#6
0
        private async void GitCommandTabMenuItem_Click(object?sender, EventArgs e)
        {
            if (sender is not ToolStripItem c ||
                c.Tag is not GitActionFunc gitActionFunc)
            {
                return;
            }

            TabControllerTag tag = LogTabs.SelectedTab !.Controller();

            await RunGitAction(tag, gitActionFunc);
        }
        public static TabControllerTag CreateController(Process p, String repo)
        {
            Tab t = new Tab(repo);

            TabControllerTag tag = new TabControllerTag(t, p, repo);

            t.Tag = tag;

            tag.UpdateTabDisplay();
            tag.UpdateIcon();

            return(tag);
        }
        internal void AddExistingTab(Tab tab)
        {
            LOG.Debug($"{nameof( AddExistingTab )} - Tab: {tab}");

            TabControllerTag tag = tab.Controller();

            if (this.OwnsLogProcess(tag.Process))
            {
                LOG.Error($"{nameof( AddExistingTab )} - Already own process - PID: {tag.Process.Id}");
                return;
            }

            LogTabs.Tabs.Add(tab);
            LogTabs.SelectedTab = tab;
        }
        private void RegisterExistingTab(Tab tab)
        {
            LOG.Debug($"{nameof( RegisterExistingTab )} - Tab: {tab}");

            TabControllerTag tag = tab.Controller();

            if (this.OwnsLogProcess(tag.Process))
            {
                LOG.Error($"{nameof( RegisterExistingTab )} - Already own process - PID: {tag.Process.Id}");
                return;
            }

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

            ShowMe();
        }
示例#10
0
        private async void ModifiedRepoCheckBackgroundWorker_DoWork(object?sender, DoWorkEventArgs e)
        {
            while (true)
            {
                for (int i = 0; i < LogTabs.TabCount; i++)
                {
                    if (!Settings.Default.IndicateModifiedTabs)
                    {
                        return;
                    }

                    TabControllerTag tag = LogTabs.Tabs[i].Controller();

                    tag.Modified = await Git.IsModified(tag.RepoItem);
                }

                if (!Settings.Default.IndicateModifiedTabs)
                {
                    return;
                }

                Thread.Sleep(Settings.Default.CheckForModifiedTabsInterval);
            }
        }
        private async Task DuplicateTab(Tab tab)
        {
            TabControllerTag tag = tab.Controller();

            await OpenLog(tag.RepoItem);
        }
示例#12
0
        private void AddToFavoritesRepoTabMenuItem_Click(object?sender, EventArgs e)
        {
            TabControllerTag tag = LogTabs.SelectedTab !.Controller();

            AddFavoriteRepo(tag.RepoItem);
        }