public bool Present( IMenuItemDescriptor descriptor, IOccurrence occurrence, OccurrencePresentationOptions occurrencePresentationOptions) { var generatorOccurrence = (GeneratorOccurrence)occurrence; var generator = (IFileGenerator)generatorOccurrence.Generator; descriptor.Text = generator.Name; descriptor.Style = MenuItemStyle.Enabled; descriptor.Icon = UnitTestingThemedIcons.NewSession.Id; string assemblyName = generator.GetType().Assembly.GetName().Name; descriptor.ShortcutText = new RichText(assemblyName, TextStyle.FromForeColor(SystemColors.GrayText)); descriptor.Tooltip = new RichText(); if (!string.IsNullOrWhiteSpace(generator.Description)) { descriptor.Tooltip.Append(generator.Description); descriptor.Tooltip.Append(Environment.NewLine); } descriptor.Tooltip.Append(new RichText("Output: ", new TextStyle(FontStyle.Bold))); descriptor.Tooltip.Append(new RichText(generator.GetFileName(), TextStyle.Default)); return(true); }
protected override void DisplayMainText(IMenuItemDescriptor descriptor, IOccurrence occurrence, OccurrencePresentationOptions options, IDeclaredElement declaredElement) { base.DisplayMainText(descriptor, occurrence, options, declaredElement); if (occurrence is LinkedTypesOccurrence linkedTypeOccurrence && linkedTypeOccurrence.HasNameDerived) { descriptor.Text.SetStyle(FontStyle.Bold); } }
public bool Present(IMenuItemDescriptor descriptor, IOccurence occurence, OccurencePresentationOptions occurencePresentationOptions) { var o = ((YouTrackIssueOccurence) occurence); descriptor.Text = o.IssueId; descriptor.Text.Append(" - "); descriptor.Text.Append(o.IssueDescription); descriptor.Style = MenuItemStyle.Enabled; return true; }
public bool Present(IMenuItemDescriptor descriptor, IOccurence occurence, OccurencePresentationOptions occurencePresentationOptions) { var o = ((YouTrackIssueOccurence)occurence); descriptor.Text = o.IssueId; descriptor.Text.Append(" - "); descriptor.Text.Append(o.IssueDescription); descriptor.Style = MenuItemStyle.Enabled; return(true); }
public bool Present(IMenuItemDescriptor descriptor, IOccurrence occurrence, OccurrencePresentationOptions occurrencePresentationOptions) { var unityOccurrence = (occurrence as UnityAssetOccurrence).NotNull("occurrence as UnityAssetOccurrence != null"); var displayText = GetDisplayText(unityOccurrence) + OccurrencePresentationUtil.TextContainerDelimiter; descriptor.Text = displayText; OccurrencePresentationUtil.AppendRelatedFile(descriptor, unityOccurrence.SourceFile.DisplayName.Replace('\\', '/')); descriptor.Icon = UnityFileTypeThemedIcons.FileUnity.Id; return(true); }
private IEnumerable <IMenuItemDescriptor> InternalGetChildrenMenuItems(IMenuItemDescriptor item, Func <IMenuItemDescriptor, bool> predicate) { if (item is ListItemDescriptor) { return ((item as ListItemDescriptor).Items.Select(menuItem => InternalGetChildrenMenuItems(menuItem, predicate)) .Aggregate((enum1, enum2) => enum1.Concat(enum2))); } if (predicate(item)) { return new[] { item } } ; return(Enumerable.Empty <IMenuItemDescriptor>()); }
public bool Present( IMenuItemDescriptor descriptor, IOccurrence occurrence, OccurrencePresentationOptions occurrencePresentationOptions) { var generatorOccurrence = (GeneratorOccurrence)occurrence; var generator = (IInPlaceGenerator)generatorOccurrence.Generator; descriptor.Text = generator.Name; descriptor.Style = MenuItemStyle.Enabled; descriptor.Icon = OptionsThemedIcons.ImportLayer.Id; descriptor.Tooltip = generator.Description; string assemblyName = generator.GetType().Assembly.GetName().Name; descriptor.ShortcutText = new RichText(assemblyName, TextStyle.FromForeColor(SystemColors.GrayText)); return(true); }
public static void AppendRelatedFile(IMenuItemDescriptor descriptor, string relatedFilePresentation, string relatedFolderPresentation) { var sb = new StringBuilder(); if (relatedFilePresentation != null) { sb.Append($"{relatedFilePresentation}"); } if (relatedFolderPresentation != null) { if (relatedFilePresentation != null) { sb.Append(" "); } sb.Append($"in {relatedFolderPresentation}"); } descriptor.ShortcutText = new RichText(sb.ToString(), TextStyle.FromForeColor(Color.DarkGray)); }
public bool Present(IMenuItemDescriptor descriptor, IOccurrence occurrence, OccurrencePresentationOptions occurrencePresentationOptions) { var unityOccurrence = (occurrence as UnityAssetOccurrence).NotNull("occurrence as UnityAssetOccurrence != null"); var declaredElement = unityOccurrence.DeclaredElementPointer.FindDeclaredElement(); if (declaredElement == null) { return(false); } var displayText = unityOccurrence.GetDisplayText() + OccurrencePresentationUtil.TextContainerDelimiter; descriptor.Text = displayText; AppendRelatedFile(descriptor, unityOccurrence.GetRelatedFilePresentation(), unityOccurrence.GetRelatedFolderPresentation()); descriptor.Icon = unityOccurrence.GetIcon(); return(true); }
/// <summary> /// Presents the specified descriptor. /// </summary> /// <param name="descriptor">The descriptor.</param> /// <param name="occurence">The occurence.</param> /// <param name="occurencePresentationOptions">The occurence presentation options.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> public bool Present(IMenuItemDescriptor descriptor, IOccurence occurence, OccurencePresentationOptions occurencePresentationOptions) { var itemOccurence = occurence as ItemOccurence; if (itemOccurence == null) { return false; } var greyTextStyle = TextStyle.FromForeColor(SystemColors.GrayText); var richText = new RichText(itemOccurence.ItemName, TextStyle.FromForeColor(Color.Tomato)); if (!string.IsNullOrEmpty(itemOccurence.ParentPath)) { richText.Append(string.Format(" (in {0})", itemOccurence.ParentPath), greyTextStyle); } descriptor.Text = richText; descriptor.Style = MenuItemStyle.Enabled; descriptor.ShortcutText = new RichText(itemOccurence.ItemUri.Site.Name + "/" + itemOccurence.ItemUri.DatabaseName, greyTextStyle); return true; }