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);
        }
コード例 #2
0
 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);
     }
 }
コード例 #3
0
        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;
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #8
0
        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));
        }
コード例 #9
0
        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;
    }