internal async Task SetStatusToolTipAsync(CancellationToken token) { string toolTip; if (Info.Detailed?.RawStatus is not null) { // Prefer submodule status, shows ahead/behind toolTip = LocalizationHelpers.ProcessSubmoduleStatus( new GitModule(Info.Path), Info.Detailed.RawStatus, moduleIsParent: false, limitOutput: true); } else if (GitStatus is not null) { var changeCount = new ArtificialCommitChangeCount(); changeCount.Update(GitStatus); toolTip = changeCount.GetSummary(); } else { // No data need to be set return; } await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(token); token.ThrowIfCancellationRequested(); TreeViewNode.ToolTipText = toolTip; }
protected override void ApplyStyle() { base.ApplyStyle(); Trace.Assert(TreeViewNode is not null); if (IsCurrent) { TreeViewNode.NodeFont = new Font(AppSettings.Font, FontStyle.Bold); } if (Info.Detailed?.RawStatus is not null) { // Prefer submodule status, shows ahead/behind TreeViewNode.ToolTipText = LocalizationHelpers.ProcessSubmoduleStatus( new GitModule(Info.Path), Info.Detailed.RawStatus, moduleIsParent: false, limitOutput: true); } else if (GitStatus is not null) { var changeCount = new ArtificialCommitChangeCount(); changeCount.Update(GitStatus); TreeViewNode.ToolTipText = changeCount.GetSummary(); } else { TreeViewNode.ToolTipText = DisplayText(); } TreeViewNode.ImageKey = GetSubmoduleItemImage(Info.Detailed); TreeViewNode.SelectedImageKey = TreeViewNode.ImageKey; return; // NOTE: Copied and adapated from FormBrowse.GetSubmoduleItemImage string GetSubmoduleItemImage(DetailedSubmoduleInfo details) { if (details?.Status is null) { return(nameof(Images.FolderSubmodule)); } if (details.Status == SubmoduleStatus.FastForward) { return(details.IsDirty ? nameof(Images.SubmoduleRevisionUpDirty) : nameof(Images.SubmoduleRevisionUp)); } if (details.Status == SubmoduleStatus.Rewind) { return(details.IsDirty ? nameof(Images.SubmoduleRevisionDownDirty) : nameof(Images.SubmoduleRevisionDown)); } if (details.Status == SubmoduleStatus.NewerTime) { return(details.IsDirty ? nameof(Images.SubmoduleRevisionSemiUpDirty) : nameof(Images.SubmoduleRevisionSemiUp)); } if (details.Status == SubmoduleStatus.OlderTime) { return(details.IsDirty ? nameof(Images.SubmoduleRevisionSemiDownDirty) : nameof(Images.SubmoduleRevisionSemiDown)); } // Unknown return(details.IsDirty ? nameof(Images.SubmoduleDirty) : nameof(Images.FileStatusModified)); } }