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 RichText GetDisplayText(OccurrencePresentationOptions options, RangeOccurrence rangeOccurrence)
        {
            var processor = rangeOccurrence.GetSolution().NotNull("rangeOccurrence.GetSolution() != null")
                            .GetComponent <UnitySceneDataLocalCache>();
            var occurrence = (rangeOccurrence as UnityEditorOccurrence).NotNull("rangeOccurrence as UnityEditorOccurrence != null");
            var reference  = (occurrence.PrimaryReference as IUnityYamlReference).NotNull("occurrence.PrimaryReference as IUnityYamlReference != null");


            return(GetAttachedGameObjectName(processor, reference.ComponentDocument));
        }
        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);
        }
Esempio n. 4
0
        protected override RichText GetDisplayText(OccurrencePresentationOptions options, RangeOccurrence rangeOccurrence)
        {
            // false to show full scene path. Very expensive
            var unityPathSceneConsumer = new UnityPathSceneConsumer(true);
            var processor = rangeOccurrence.GetSolution().NotNull("rangeOccurrence.GetSolution() != null")
                            .GetComponent <UnitySceneProcessor>();
            var occurrence = (rangeOccurrence as UnityEditorOccurrence).NotNull("rangeOccurrence as UnityEditorOccurrence != null");
            var reference  = (occurrence.PrimaryReference as IUnityYamlReference).NotNull("occurrence.PrimaryReference as IUnityYamlReference != null");

            processor.ProcessSceneHierarchyFromComponentToRoot(reference.ComponentDocument, unityPathSceneConsumer);


            return(unityPathSceneConsumer.NameParts.FirstOrDefault() ?? "Unknown");
        }
        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 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);
        }
Esempio n. 7
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);
     }
 }