protected override void OnUICommandsSourceChanged(object sender, IGitUICommandsSource newSource) { base.OnUICommandsSourceChanged(sender, newSource); DragDrops(); AddTree(new BranchTree( new TreeNode("Branches" //Strings.branches.Text ), newSource)); /* AddTreeSet(new TreeNode(Strings.stashes.Text) { ContextMenuStrip = menuStashes, ImageKey = stashesKey }, () => Module.GetStashes().Select(stash => new StashNode(stash, UICommands)).ToList(), OnReloadStashes, OnAddStash );*/ /* AddTreeSet(new TreeNode(Strings.remotes.Text) { ContextMenuStrip = menuRemotes, ImageKey = remotesKey }, () => Module.GetRemotesInfo().Select(remote => new RemoteNode(remote, UICommands)).ToList(), OnReloadRemotes, OnAddRemote ); */ }
/// <summary>Searches up the <see cref="UserControl"/>'s parent tree until it finds a <see cref="IGitUICommandsSource"/>.</summary> void SearchForUICommandsSource() { if (!UICommandsSourceParentSearch) { return; } lock (_lock) { if (_uiCommandsSource != null) { return; } IGitUICommandsSource cmdsSrc = null; Control parent = Parent; while (parent != null && cmdsSrc == null) { if (parent is IGitUICommandsSource) { cmdsSrc = parent as IGitUICommandsSource; } else { parent = parent.Parent; } } if (cmdsSrc == null) { throw new InvalidOperationException("The UI Command Source is not available for this control. Are you calling methods before adding it to the parent control?"); } UICommandsSource = cmdsSrc; } }
private void SearchForUICommandsSource() { if (!UICommandsSourceParentSearch) { return; } lock (this) { if (_uiCommandsSource != null) { return; } IGitUICommandsSource cs = null; Control p = Parent; while (p != null && cs == null) { if (p is IGitUICommandsSource) { cs = p as IGitUICommandsSource; } else { p = p.Parent; } } UICommandsSource = cs; } }
protected Tree(TreeNode treeNode, IGitUICommandsSource uiCommands) { Nodes = new Nodes(this); _uiCommandsSource = uiCommands; TreeViewNode = treeNode; treeNode.Tag = this; uiCommands.UICommandsChanged += (a, e) => { // When GitModule has changed, clear selected node if (TreeViewNode?.TreeView != null) { TreeViewNode.TreeView.SelectedNode = null; } // Certain operations need to happen the first time after we change modules. For example, // we don't want to use the expanded/collapsed state of existing nodes in the tree, but at // the same time, we don't want to remove them from the tree as this is visible to the user, // as well as less efficient. _firstReloadNodesSinceModuleChanged = true; // Rebind callbacks e.OldCommands.PostRepositoryChanged -= UICommands_PostRepositoryChanged; uiCommands.UICommands.PostRepositoryChanged += UICommands_PostRepositoryChanged; }; uiCommands.UICommands.PostRepositoryChanged += UICommands_PostRepositoryChanged; }
protected Tree(TreeNode treeNode, IGitUICommandsSource uiCommands) { Nodes = new Nodes(this); _uiCommandsSource = uiCommands; TreeViewNode = treeNode; uiCommands.UICommandsChanged += (a, e) => { // When GitModule has changed, clear selected node if (TreeViewNode?.TreeView != null) { TreeViewNode.TreeView.SelectedNode = null; } // Also clear treeview nodes so that any previous state is flushed // (e.g. expanded/collapsed state, etc.) if (TreeViewNode != null) { TreeViewNode.Nodes.Clear(); } e.OldCommands.PostRepositoryChanged -= UICommands_PostRepositoryChanged; uiCommands.UICommands.PostRepositoryChanged += UICommands_PostRepositoryChanged; }; uiCommands.UICommands.PostRepositoryChanged += UICommands_PostRepositoryChanged; }
protected override void OnUICommandsSourceChanged(object sender, IGitUICommandsSource newSource) { base.OnUICommandsSourceChanged(sender, newSource); DragDrops(); var localBranchesRootNode = new TreeNode(Strings.branches.Text) { ImageKey = "RemoteRepo.png", }; localBranchesRootNode.SelectedImageKey = localBranchesRootNode.ImageKey; AddTree(new BranchTree(localBranchesRootNode, newSource)); var remoteBranchesRootNode = new TreeNode(Strings.remotes.Text) { ImageKey = "RemoteMirror.png", }; remoteBranchesRootNode.SelectedImageKey = remoteBranchesRootNode.ImageKey; _remoteTree = new RemoteBranchTree(remoteBranchesRootNode, newSource) { TreeViewNode = { ContextMenuStrip = menuRemotes } }; AddTree(_remoteTree); if (showTagsToolStripMenuItem.Checked) { AddTags(); } }
protected override void OnUICommandsSourceChanged(object sender, IGitUICommandsSource newSource) { base.OnUICommandsSourceChanged(sender, newSource); CancelBackgroundTasks(); var localBranchesRootNode = new TreeNode(Strings.BranchesText.Text) { ImageKey = nameof(MsVsImages.Repository_16x), }; localBranchesRootNode.SelectedImageKey = localBranchesRootNode.ImageKey; AddTree(new BranchTree(localBranchesRootNode, newSource)); var remoteBranchesRootNode = new TreeNode(Strings.RemotesText.Text) { ImageKey = nameof(MsVsImages.Repository_16x), }; remoteBranchesRootNode.SelectedImageKey = remoteBranchesRootNode.ImageKey; _remoteTree = new RemoteBranchTree(remoteBranchesRootNode, newSource) { TreeViewNode = { ContextMenuStrip = menuRemotes } }; AddTree(_remoteTree); if (showTagsToolStripMenuItem.Checked) { AddTags(); } }
protected override void OnUICommandsSourceSet(IGitUICommandsSource source) { base.OnUICommandsSourceSet(source); CancelBackgroundTasks(); var localBranchesRootNode = new TreeNode(Strings.Branches) { ImageKey = nameof(Images.BranchLocalRoot), SelectedImageKey = nameof(Images.BranchLocalRoot), }; AddTree(new BranchTree(localBranchesRootNode, source)); var remoteBranchesRootNode = new TreeNode(Strings.Remotes) { ImageKey = nameof(Images.BranchRemoteRoot), SelectedImageKey = nameof(Images.BranchRemoteRoot), }; _remoteTree = new RemoteBranchTree(remoteBranchesRootNode, source) { TreeViewNode = { ContextMenuStrip = menuRemotes } }; AddTree(_remoteTree); if (showTagsToolStripMenuItem.Checked) { AddTags(); } }
/// <summary>Searches up the <see cref="UserControl"/>'s parent tree until it finds a <see cref="IGitUICommandsSource"/>.</summary> void SearchForUICommandsSource() { if (!UICommandsSourceParentSearch) { return; } lock (this) { if (_uiCommandsSource != null) { return; } IGitUICommandsSource cmdsSrc = null; Control parent = Parent; while (parent != null && cmdsSrc == null) { if (parent is IGitUICommandsSource) { cmdsSrc = parent as IGitUICommandsSource; } else { parent = parent.Parent; } } UICommandsSource = cmdsSrc; } }
public void Init(IGitUICommandsSource commandsSource) { UICommandsSource = commandsSource ?? throw new ArgumentNullException(nameof(commandsSource)); UICommandsSource.UICommandsChanged += commandsSource_GitUICommandsChanged; commandsSource_activate(commandsSource); return; void commandsSource_GitUICommandsChanged(object sender, GitUICommandsChangedEventArgs e) { var oldCommands = e.OldCommands; if (oldCommands != null) { oldCommands.PreCheckoutBranch -= GitUICommands_PreCheckout; oldCommands.PreCheckoutRevision -= GitUICommands_PreCheckout; oldCommands.PostCheckoutBranch -= GitUICommands_PostCheckout; oldCommands.PostCheckoutRevision -= GitUICommands_PostCheckout; oldCommands.PostEditGitIgnore -= GitUICommands_PostEditGitIgnore; } commandsSource_activate(sender as IGitUICommandsSource); } void commandsSource_activate(IGitUICommandsSource sender) { var newCommands = sender.UICommands; if (newCommands != null) { newCommands.PreCheckoutBranch += GitUICommands_PreCheckout; newCommands.PreCheckoutRevision += GitUICommands_PreCheckout; newCommands.PostCheckoutBranch += GitUICommands_PostCheckout; newCommands.PostCheckoutRevision += GitUICommands_PostCheckout; newCommands.PostEditGitIgnore += GitUICommands_PostEditGitIgnore; var module = newCommands.Module; StartWatchingChanges(module.WorkingDir, module.WorkingDirGitDir); } } void GitUICommands_PreCheckout(object sender, GitUIEventArgs e) { CurrentStatus = GitStatusMonitorState.Paused; } void GitUICommands_PostCheckout(object sender, GitUIPostActionEventArgs e) { CurrentStatus = GitStatusMonitorState.Running; } void GitUICommands_PostEditGitIgnore(object sender, GitUIEventArgs e) { _ignoredFiles = new HashSet <string>(); _ignoredFilesAreStale = true; } }
/// <summary>Raises the <see cref="GitUICommandsSourceSet"/> event.</summary> protected virtual void OnUICommandsSourceChanged(object sender, IGitUICommandsSource newSource) { var handler = GitUICommandsSourceSet; if (handler != null) { handler(this, new GitUICommandsSourceEventArgs(newSource)); } }
public void Init(IGitUICommandsSource commandsSource) { if (commandsSource == null) { throw new ArgumentNullException(nameof(commandsSource)); } UICommandsSource = commandsSource; UICommandsSource.GitUICommandsChanged += commandsSource_GitUICommandsChanged; commandsSource_activate(commandsSource); }
protected override void OnUICommandsSourceSet(IGitUICommandsSource source) { base.OnUICommandsSourceSet(source); CreateBranches(); CreateRemotes(); CreateTags(); CreateSubmodules(); ShowEnabledTrees(); }
/// <summary>Subscribes to a git UI commands source's notifications.</summary> void Subscribe(IGitUICommandsSource iGitUICommandsSource) { if (subscription != null) { subscription.Dispose(); } if (iGitUICommandsSource.UICommands != null) { subscription = iGitUICommandsSource.UICommands.Notifications.Notifications.Subscribe(OnNewNotification); } }
public IndexWatcher(IGitUICommandsSource aUICommandsSource) { UICommandsSource = aUICommandsSource; UICommandsSource.GitUICommandsChanged += UICommandsSource_GitUICommandsChanged; GitIndexWatcher = new FileSystemWatcher(); RefsWatcher = new FileSystemWatcher(); SetFileSystemWatcher(); IndexChanged = true; GitIndexWatcher.Changed += fileSystemWatcher_Changed; RefsWatcher.Changed += fileSystemWatcher_Changed; }
/// <summary>Initalizes a new control which holds notifications, with most recent items first.</summary> public NotificationFeed(IGitUICommandsSource uiCommandsSource) { //TextAlign = ContentAlignment.MiddleRight; //TextImageRelation = TextImageRelation.ImageBeforeText; //Dock = DockStyle.Left; Image = Resources.Information; this.uiCommandsSource = uiCommandsSource; uiCommandsSource.GitUICommandsChanged += OnGitUICommandsChanged; Subscribe(uiCommandsSource); }
public IndexWatcher(IGitUICommandsSource uiCommandsSource) { _uICommandsSource = uiCommandsSource; _uICommandsSource.UICommandsChanged += OnUICommandsChanged; GitIndexWatcher = new FileSystemWatcher(); RefsWatcher = new FileSystemWatcher(); SetFileSystemWatcher(); IndexChanged = true; GitIndexWatcher.Changed += fileSystemWatcher_Changed; RefsWatcher.Changed += fileSystemWatcher_Changed; }
protected override void OnUICommandsSourceSet(IGitUICommandsSource source) { base.OnUICommandsSourceSet(source); CreateBranches(); CreateRemotes(); CreateTags(); CreateSubmodules(); FixInvalidTreeToPositionIndices(); ShowEnabledTrees(); RebuildMenuSettings(); }
private void commandsSource_activate(IGitUICommandsSource sender) { var newCommands = sender.UICommands; if (newCommands != null) { newCommands.PreCheckoutBranch += GitUICommands_PreCheckout; newCommands.PreCheckoutRevision += GitUICommands_PreCheckout; newCommands.PostCheckoutBranch += GitUICommands_PostCheckout; newCommands.PostCheckoutRevision += GitUICommands_PostCheckout; newCommands.PostEditGitIgnore += GitUICommands_PostEditGitIgnore; var module = newCommands.Module; StartWatchingChanges(module.WorkingDir, module.WorkingDirGitDir); } }
protected override void OnUICommandsSourceSet(IGitUICommandsSource source) { base.OnUICommandsSourceSet(source); if (tsmiShowBranches.Checked) { AddBranches(); } if (tsmiShowRemotes.Checked) { AddRemotes(); } if (tsmiShowTags.Checked) { AddTags(); } }
private static Panel CreateViewRules(FormSparseWorkingCopyViewModel sparse, ToolTip tooltip, IGitUICommandsSource commandsSource) { // Label Label label1 = new() { AutoSize = true, Text = Globalized.Strings.SpecifyTheRulesForIncludingOrExcludingFilesAndDirectories.Text, Dock = DockStyle.Top, Padding = new Padding(10, 5, 10, 0) }; Label label2 = new() { AutoSize = true, Text = Globalized.Strings.SpecifyTheRulesForIncludingOrExcludingFilesAndDirectoriesLine2.Text, Dock = DockStyle.Top, Padding = new Padding(25, 3, 10, 3), ForeColor = SystemColors.GrayText }; sparse.PropertyChanged += delegate { label1.Visible = label2.Visible = sparse.IsSparseCheckoutEnabled; }; // Text editor FileViewer editor = new() { Dock = DockStyle.Fill, UICommandsSource = commandsSource, IsReadOnly = false }; editor.TextLoaded += (sender, args) => sparse.SetRulesTextAsOnDisk(editor.GetText()); try { FileInfo sparseFile = sparse.GetPathToSparseCheckoutFile(); if (sparseFile.Exists) { editor.ViewFileAsync(sparseFile.FullName); } } catch (Exception ex) { MessageBox.Show(ActiveForm, Globalized.Strings.CannotLoadTheTextOfTheSparseFile.Text + "\n\n" + ex.Message, Globalized.Strings.SparseWorkingCopy.Text + " – " + Globalized.Strings.LoadFile.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } editor.TextChanged += (sender, args) => sparse.RulesText = editor.GetText() ?? ""; tooltip.SetToolTip(editor, Globalized.Strings.EditsTheContentsOfTheGitInfoSparseCheckoutFile.Text); Control separator = CreateViewSeparator(DockStyle.Top); sparse.PropertyChanged += delegate { editor.Visible = separator.Visible = sparse.IsSparseCheckoutEnabled; }; Panel panel = new() { Margin = Padding.Empty, Padding = Padding.Empty, Controls = { editor, separator, label2, label1 }, AutoSize = true, Dock = DockStyle.Fill }; return(panel); } private static Control CreateViewSeparator([Optional] DockStyle?dock) { return(new Control { Height = 2, BackColor = SystemColors.ControlDark, Dock = dock ?? DockStyle.Fill, Padding = Padding.Empty, Margin = Padding.Empty }); }
protected override void OnUICommandsSourceChanged(object sender, IGitUICommandsSource newSource) { base.OnUICommandsSourceChanged(sender, newSource); DragDrops(); AddRootNode(new BranchesNode( new TreeNode(Strings.branches.Text) { ContextMenuStrip = menuBranches, ImageKey = branchesKey }, UICommands, () => { var branchNames = Module.GetBranchNames().ToArray(); return(BranchesNode.GetBranchTree(UICommands, branchNames)); }, OnAddBranchNode )); AddTreeSet(new TreeNode(Strings.stashes.Text) { ContextMenuStrip = menuStashes, ImageKey = stashesKey }, () => Module.GetStashes().Select(stash => new StashNode(stash, UICommands)).ToList(), OnReloadStashes, OnAddStash ); //AddTreeSet(nodeTags, ...); if (isFirst) {// bypass reloading twice // (once from initial UICommandsSource being set) // (once from FormBrowse Initialize()) isFirst = false; } else { RepoChanged(); } }
private void SearchForUICommandsSource() { if (UICommandsSourceParentSearch) { IGitUICommandsSource cs = null; Control p = Parent; while (p != null && cs == null) { if (p is IGitUICommandsSource) { cs = p as IGitUICommandsSource; } else { p = p.Parent; } } UICommandsSource = cs; } }
private void GitUICommandsChanged(IGitUICommandsSource source, GitUICommands oldCommands) { if (oldCommands != null) { oldCommands.PreCheckoutBranch -= GitUICommands_PreCheckout; oldCommands.PreCheckoutRevision -= GitUICommands_PreCheckout; oldCommands.PostCheckoutBranch -= GitUICommands_PostCheckout; oldCommands.PostCheckoutRevision -= GitUICommands_PostCheckout; oldCommands.PostEditGitIgnore -= GitUICommands_PostEditGitIgnore; } if (UICommands != null) { UICommands.PreCheckoutBranch += GitUICommands_PreCheckout; UICommands.PreCheckoutRevision += GitUICommands_PreCheckout; UICommands.PostCheckoutBranch += GitUICommands_PostCheckout; UICommands.PostCheckoutRevision += GitUICommands_PostCheckout; UICommands.PostEditGitIgnore += GitUICommands_PostEditGitIgnore; TryStartWatchingChanges(Module.WorkingDir, Module.GetGitDirectory()); } }
public GitUICommandsSourceEventArgs([NotNull] IGitUICommandsSource gitUiCommandsSource) { GitUICommandsSource = gitUiCommandsSource; }
/// <summary>Raises the <see cref="UICommandsSourceSet"/> event.</summary> protected virtual void OnUICommandsSourceSet([NotNull] IGitUICommandsSource source) { UICommandsSourceSet?.Invoke(this, new GitUICommandsSourceEventArgs(source)); }
protected override void OnUICommandsSourceChanged(object sender, IGitUICommandsSource newSource) { base.OnUICommandsSourceChanged(sender, newSource); txtBranchFilter.AutoCompleteCustomSource = null; _branchFilterAutoCompletionSrc.Clear(); DragDrops(); var localBranchesRootNode = new TreeNode(Strings.branches.Text) { ImageKey = "RemoteRepo.png", }; localBranchesRootNode.SelectedImageKey = localBranchesRootNode.ImageKey; AddTree(new BranchTree(localBranchesRootNode, newSource)); var remoteBranchesRootNode = new TreeNode(Strings.remotes.Text) { ImageKey = "RemoteMirror.png", }; remoteBranchesRootNode.SelectedImageKey = remoteBranchesRootNode.ImageKey; _remoteTree = new RemoteBranchTree(remoteBranchesRootNode, newSource) { TreeViewNode = {ContextMenuStrip = menuRemotes} }; AddTree(_remoteTree); if (showTagsToolStripMenuItem.Checked) { AddTags(); } }
void UICommandsSource_GitUICommandsChanged(IGitUICommandsSource sender, GitUICommands oldCommands) { Clear(); }
/// <summary>Occurs when the <see cref="UICommandsSource"/> is disposed.</summary> protected virtual void DisposeUICommandsSource() { _uiCommandsSource = null; }
void FileViewer_GitUICommandsSourceSet(object sender, IGitUICommandsSource uiCommandsSource) { UICommandsSource.GitUICommandsChanged += WorkingDirChanged; WorkingDirChanged(UICommandsSource, null); }
public void SetUp() { _uiCommandsSource = Substitute.For <IGitUICommandsSource>(); _fileViewer = new FileViewer(); }
public SubmoduleTree(TreeNode treeNode, IGitUICommandsSource uiCommands) : base(treeNode, uiCommands) { SubmoduleStatusProvider.Default.StatusUpdating += Provider_StatusUpdating; SubmoduleStatusProvider.Default.StatusUpdated += Provider_StatusUpdated; }
public BranchTree(TreeNode aTreeNode, IGitUICommandsSource uiCommands) : base(aTreeNode, uiCommands) { uiCommands.GitUICommandsChanged += uiCommands_GitUICommandsChanged; }
private void WorkingDirChanged(IGitUICommandsSource source, GitUICommands old) { this.Encoding = null; }
public GitUICommandsSourceEventArgs(IGitUICommandsSource gitUiCommandsSource) { GitUICommandsSource = gitUiCommandsSource; }
/// <summary>Raises the <see cref="GitUICommandsSourceSet"/> event.</summary> protected virtual void OnUICommandsSourceChanged(object sender, IGitUICommandsSource newSource) { var handler = GitUICommandsSourceSet; if (handler != null) handler(this, newSource); }
public TagTree(TreeNode aTreeNode, IGitUICommandsSource uiCommands) : base(aTreeNode, uiCommands) { uiCommands.GitUICommandsChanged += uiCommands_GitUICommandsChanged; }