public static LocationInfo FromLocation(Location location, string displayName, ImageMoniker imageMoniker) {
     return new LocationInfo {
         Location     = location,
         DisplayName  = displayName,
         ImageMoniker = imageMoniker,
     };
 }
        public bool TryGetImageMoniker(ImmutableArray<string> tags, out ImageMoniker imageMoniker)
        {
            this.AssertIsForeground();

            imageMoniker = GetImageMoniker(tags);
            return !imageMoniker.IsNullImage();
        }
        public IInfoBar AttachInfoBar(Guid toolwindowGuid, string message, string buttonText, ImageMoniker imageMoniker)
        {
            if (string.IsNullOrWhiteSpace(message))
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (string.IsNullOrWhiteSpace(buttonText))
            {
                throw new ArgumentNullException(nameof(buttonText));
            }

            IVsWindowFrame frame = GetToolWindowFrame(this.serviceProvider, toolwindowGuid);

            InfoBarModel model = CreateModel(message, buttonText, imageMoniker);

            IVsInfoBarUIElement uiElement = null;
            if (TryCreateInfoBarUI(this.serviceProvider, model, out uiElement)
                && TryAddInfoBarToFrame(frame, uiElement))
            {
                return new PrivateInfoBarWrapper(frame, uiElement);
            }

            return null;
        }
Esempio n. 4
0
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="displayText">Text shown in the UI</param>
		/// <param name="filterText">Text used to filter out items or null to use <paramref name="displayText"/></param>
		/// <param name="insertionText">Text that gets inserted in the text buffer or null to use <paramref name="displayText"/></param>
		/// <param name="description">Description or null</param>
		/// <param name="iconMoniker">Icon moniker or null</param>
		/// <param name="iconAutomationText">Icon automation text or null</param>
		/// <param name="attributeIcons">Attribute icons shown on the right side</param>
		/// <param name="suffix">Text shown after the normal completion text</param>
		public DsCompletion(string displayText, string filterText = null, string insertionText = null, string description = null, ImageMoniker iconMoniker = default(ImageMoniker), string iconAutomationText = null, IEnumerable<CompletionIcon2> attributeIcons = null, string suffix = null)
			: base(displayText, insertionText, description, default(ImageMoniker), iconAutomationText, attributeIcons, suffix) {
			if (displayText == null)
				throw new ArgumentNullException(nameof(displayText));
			FilterText = filterText ?? displayText;
			InsertionText = insertionText ?? displayText;
			this.iconMoniker = iconMoniker.Id == 0 && iconMoniker.Guid == Guid.Empty ? (ImageMoniker?)null : iconMoniker;
		}
        IInfoBar IInfoBarManager.AttachInfoBar(Guid toolwindowGuid, string message, string buttonText, ImageMoniker imageMoniker)
        {
            Assert.IsFalse(this.attached.ContainsKey(toolwindowGuid), "Info bar is already attached to tool window {0}", toolwindowGuid);

            var infoBar = new ConfigurableInfoBar(message, buttonText, imageMoniker);
            this.attached[toolwindowGuid] = infoBar;
            return infoBar;
        }
        public ConfigurableInfoBar(string message, string buttonText, ImageMoniker imageMoniker)
        {
            Assert.IsNotNull(message, "Message is null");
            Assert.IsNotNull(buttonText, "Button text is null");
            Assert.IsNotNull(imageMoniker, "image moniker is null");

            this.Message = message;
            this.ButtonText = buttonText;
            this.Image = imageMoniker;
        }
 public CustomCommitCompletion(CompletionPresenterSession completionPresenterSession, CompletionItem completionItem, string displayText)
     : base()
 {
     // PERF: Note that the base class contains a constructor taking the displayText string
     // but we're intentionally NOT using that here because it allocates a private CompletionState
     // object. By overriding the public property getters (DisplayText, InsertionText, etc.) the
     // extra allocation is avoided.
     _completionPresenterSession = completionPresenterSession;
     this.CompletionItem = completionItem;
     _displayText = displayText;
     _imageMoniker = CompletionItem.Glyph.HasValue ? CompletionItem.Glyph.Value.GetImageMoniker() : default(ImageMoniker);
 }
Esempio n. 8
0
 /// <summary>
 /// Create an instance of an IntellisenseFilter with the specified attributes.
 /// </summary>
 public IntellisenseFilter(ImageMoniker moniker, string toolTip, string accessKey, string automationText, bool initialIsChecked = false, bool initialIsEnabled = true)
 {
     if (string.IsNullOrEmpty(accessKey))
     {
         throw new ArgumentException("Must not be null or empty", nameof(accessKey));
     }
     this.Moniker = moniker;
     this.ToolTip = toolTip;
     this.AccessKey = accessKey;
     this.AutomationText = automationText;
     this.IsChecked = initialIsChecked;
     this.IsEnabled = initialIsEnabled;
 }
Esempio n. 9
0
 public CustomCommitCompletion(
     CompletionPresenterSession completionPresenterSession, 
     PresentationItem presentationItem)
     : base()
 {
     // PERF: Note that the base class contains a constructor taking the displayText string
     // but we're intentionally NOT using that here because it allocates a private CompletionState
     // object. By overriding the public property getters (DisplayText, InsertionText, etc.) the
     // extra allocation is avoided.
     _completionPresenterSession = completionPresenterSession;
     this.PresentationItem = presentationItem;
     _imageMoniker = ImageMonikers.GetImageMoniker(PresentationItem.Item.Tags, presentationItem.CompletionService.Language);
 }
Esempio n. 10
0
        public bool GetIconForFile(string fullPath, out ImageMoniker imageMoniker, out int priority) {
            if (!string.IsNullOrEmpty(fullPath)) {
                var ext = Path.GetExtension(fullPath);
                if (PythonConstants.FileExtension.Equals(ext, StringComparison.OrdinalIgnoreCase) ||
                    PythonConstants.WindowsFileExtension.Equals(ext, StringComparison.OrdinalIgnoreCase)) {
                    imageMoniker = KnownMonikers.PYFileNode;
                    priority = 1000;
                    return true;
                }
            }

            imageMoniker = default(ImageMoniker);
            priority = 0;

            return false;
        }
        public bool TryGetImageMoniker(ImmutableArray<string> tags, out ImageMoniker imageMoniker)
        {
            var glyph = tags.GetGlyph();

            // We can't do the compositing of these glyphs at the editor layer.  So just map them
            // to the non-add versions.
            switch (glyph)
            {
                case Glyph.AddReference:
                    glyph = Glyph.Reference;
                    break;
            }

            imageMoniker = glyph.GetImageMoniker();
            return !imageMoniker.IsNullImage();
        }
 private ImageCompositionLayer CreateLayer(
     ImageMoniker imageMoniker, 
     int virtualWidth = 16,
     int virtualYOffset = 0,
     int virtualXOffset = 0)
 {
     return new ImageCompositionLayer
     {
         VirtualWidth = virtualWidth,
         VirtualHeight = 16,
         ImageMoniker = imageMoniker,
         HorizontalAlignment = (uint)_UIImageHorizontalAlignment.IHA_Left,
         VerticalAlignment = (uint)_UIImageVerticalAlignment.IVA_Top,
         VirtualXOffset = virtualXOffset,
         VirtualYOffset = virtualYOffset,
     };
 }
Esempio n. 13
0
        /// <summary>
        /// Get the image based on the moniker, backColor and dimensions
        /// </summary>
        public static Bitmap GetImage(ImageMoniker moniker, System.Drawing.Color backColor, int height, int width, bool scalingRequired)
        {
            m_attributes.Background = (uint)backColor.ToArgb();
            m_attributes.LogicalHeight = height;
            m_attributes.LogicalWidth = width;

            if (scalingRequired)
            {
                m_attributes.LogicalHeight = (int)(height * DpiHelper.LogicalToDeviceUnitsScalingFactorY);
                m_attributes.LogicalWidth = (int)(width * DpiHelper.LogicalToDeviceUnitsScalingFactorX);
            }

            IVsUIObject uIObjOK = ImageService.GetImage(moniker, m_attributes);
            Bitmap bitmap = (Bitmap)UIUtilities.GetObjectData(uIObjOK);
            bitmap.MakeTransparent(System.Drawing.Color.Magenta);

            return bitmap;
        }
        public static BitmapSource GetImage(ImageMoniker moniker, int size)
        {
            ImageAttributes imageAttributes = new ImageAttributes();
            imageAttributes.Flags = (uint)_ImageAttributesFlags.IAF_RequiredFlags;
            imageAttributes.ImageType = (uint)_UIImageType.IT_Bitmap;
            imageAttributes.Format = (uint)_UIDataFormat.DF_WPF;
            imageAttributes.LogicalHeight = size;
            imageAttributes.LogicalWidth = size;
            imageAttributes.StructSize = Marshal.SizeOf(typeof(ImageAttributes));

            IVsUIObject result = _imageService.GetImage(moniker, imageAttributes);

            object data;
            result.get_Data(out data);

            if (data == null)
                return null;

            return data as BitmapSource;
        }
Esempio n. 15
0
        public static BitmapSource GetIconForImageMoniker(ImageMoniker? imageMoniker, int sizeX, int sizeY)
        {
            if (imageMoniker == null)
            {
                return null;
            }

            IVsImageService2 vsIconService = ServiceProvider.GlobalProvider.GetService(typeof(SVsImageService)) as IVsImageService2;

            if (vsIconService == null)
            {
                return null;
            }

            ImageAttributes imageAttributes = new ImageAttributes
            {
                Flags = (uint)_ImageAttributesFlags.IAF_RequiredFlags,
                ImageType = (uint)_UIImageType.IT_Bitmap,
                Format = (uint)_UIDataFormat.DF_WPF,
                LogicalHeight = sizeY,
                LogicalWidth = sizeX,
                StructSize = Marshal.SizeOf(typeof(ImageAttributes))
            };

            IVsUIObject result = vsIconService.GetImage(imageMoniker.Value, imageAttributes);

            object data;
            result.get_Data(out data);
            BitmapSource glyph = data as BitmapSource;

            if (glyph != null)
            {
                glyph.Freeze();
            }

            return glyph;
        }
Esempio n. 16
0
        public static ImageSource GetIconForImageMoniker(ImageMoniker imageMoniker) {
            IVsImageService2 imageService = VsAppShell.Current.GetGlobalService<IVsImageService2>(typeof(SVsImageService));
            ImageSource glyph = null;

            ImageAttributes imageAttributes = new ImageAttributes();
            imageAttributes.Flags = (uint)_ImageAttributesFlags.IAF_RequiredFlags;
            imageAttributes.ImageType = (uint)_UIImageType.IT_Bitmap;
            imageAttributes.Format = (uint)_UIDataFormat.DF_WPF;
            imageAttributes.LogicalHeight = 16;// IconHeight,
            imageAttributes.LogicalWidth = 16;// IconWidth,
            imageAttributes.StructSize = Marshal.SizeOf(typeof(ImageAttributes));

            IVsUIObject result = imageService.GetImage(imageMoniker, imageAttributes);

            Object data = null;
            if (result.get_Data(out data) == VSConstants.S_OK) {
                glyph = data as ImageSource;
                if (glyph != null) {
                    glyph.Freeze();
                }
            }

            return glyph;
        }
Esempio n. 17
0
 public SimpleCompletionEntry(string text, string description, ImageMoniker moniker, IIntellisenseSession session)
     : base(text, "\"" + text + "\"", description, WpfUtil.GetIconForImageMoniker(moniker, 16, 16), null, false, session as ICompletionSession)
 { }
        private IInfoBar AttachInfoBarImpl(Guid toolwindowGuid, string message, string buttonText, ImageMoniker imageMoniker)
        {
            IVsUIShell     shell = serviceProvider.GetService <SVsUIShell, IVsUIShell>();
            IVsWindowFrame frame = GetToolWindowFrame(shell, toolwindowGuid);

            InfoBarModel model = CreateModel(message, buttonText, imageMoniker);

            IVsInfoBarUIFactory infoBarUIFactory = serviceProvider.GetService <SVsInfoBarUIFactory, IVsInfoBarUIFactory>();
            IVsInfoBarUIElement uiElement;

            if (TryCreateInfoBarUI(infoBarUIFactory, model, out uiElement) &&
                TryAddInfoBarToFrame(frame, uiElement))
            {
                return(new PrivateInfoBarWrapper(frame, uiElement));
            }

            return(null);
        }
 static string S(ImageMoniker a) => ManagedImageMonikers.ImageMonikerDebugDisplay(a);
 public ViewModel(string label, ImageMoniker moniker)
 {
     Label   = label;
     Moniker = moniker;
 }
 private static InfoBarModel CreateModel(string message, string buttonText, ImageMoniker imageMoniker)
 {
     return new InfoBarModel(message,
         actionItems: new[]
         {
             new InfoBarButton(buttonText)
         },
         image: imageMoniker,
         isCloseButtonVisible: true);
 }
 public HeaderMenuItemViewModel(string displayContent, ImageMoniker imageMoniker, string automationName)
     : base(displayContent, imageMoniker, automationName)
 {
 }
 public bool TryCreateImageContent(int index, string columnName, bool singleColumnView, out ImageMoniker content)
 {
     content = default;
     return(false);
 }
Esempio n. 24
0
 public SimpleCompletionEntry(string text, ImageMoniker moniker, IIntellisenseSession session)
     : this(text, text, null, moniker, session)
 {
 }
Esempio n. 25
0
 public SimpleCompletionEntry(string displayText, string insertionText, ImageMoniker moniker, IIntellisenseSession session)
     : base(displayText, insertionText, null, null, null, false, session as ICompletionSession)
 {
 }
Esempio n. 26
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            if (_disposed)
            {
                return;
            }

            ITextSnapshot snapshot     = _buffer.CurrentSnapshot;
            var           triggerPoint = session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
            {
                return;
            }

            SnapshotSpan extent = FindTokenSpanAtPosition(session).GetSpan(snapshot);
            var          line   = triggerPoint.Value.GetContainingLine().Extent;

            var spans = _classifier.GetClassificationSpans(line);

            List <Intel.Completion> list = new List <Completion>();
            int position = session.TextView.Caret.Position.BufferPosition;

            foreach (var span in spans)
            {
                if (span.ClassificationType.IsOfType("XML Attribute Value"))
                {
                    if (!span.Span.Contains(extent.Start))
                    {
                        continue;
                    }

                    if (!span.Span.Contains(extent))
                    {
                        continue;
                    }

                    var attrs       = spans.Where(s => s.ClassificationType.IsOfType("XML Attribute"));
                    var currentAttr = attrs.Where(s => s.Span.Start <= span.Span.Start).OrderByDescending(s => s.Span.Start.Position).FirstOrDefault();

                    if (currentAttr == null)
                    {
                        return;
                    }

                    string current = currentAttr.Span.GetText();
                    string guid    = null;
                    //string id = null;
                    //string attrName = null;
                    string lineText = line.GetText();

                    //Match idMatch = Regex.Match(lineText, " id=\"(?<id>[^\"]+)\"");

                    //if (idMatch.Success)
                    //    id = idMatch.Groups["id"].Value;

                    Match guidMatch = Regex.Match(lineText, " guid=\"(?<guid>[^\"]+)\"");

                    if (guidMatch.Success)
                    {
                        guid = guidMatch.Groups["guid"].Value;
                    }

                    XmlDocument doc = ReadXmlDocument(snapshot);

                    if (doc == null)
                    {
                        return;
                    }

                    if ((current == "id" || current == "idCommandList"))
                    {
                        if (guid == "guidSHLMainMenu")
                        {
                            foreach (string key in VsctBuiltInCache._dic.Keys)
                            {
                                list.Add(CreateCompletion(key, key, _builtInGlyph, VsctBuiltInCache._dic[key]));
                            }
                        }
                        else if (guid == "ImageCatalogGuid" && _imageService != null)
                        {
                            PropertyInfo[] monikers = typeof(KnownMonikers).GetProperties(BindingFlags.Static | BindingFlags.Public);
                            foreach (var monikerName in monikers)
                            {
                                ImageMoniker moniker = (ImageMoniker)monikerName.GetValue(null, null);
                                var          glyph   = GetImage(moniker);
                                list.Add(CreateCompletion(monikerName.Name, monikerName.Name, glyph));
                            }
                        }
                        else
                        {
                            GetNameValueCompletion(list, doc, "//GuidSymbol[@name='" + guid + "']//IDSymbol");
                        }
                    }
                    else if (current == "guid" || current == "package")
                    {
                        list.Add(CreateCompletion("guidSHLMainMenu", "guidSHLMainMenu", _builtInGlyph, "Guid for Shell's group and menu ids."));
                        GetNameValueCompletion(list, doc, "//GuidSymbol");
                    }
                    else if (current == "editor")
                    {
                        list.Add(CreateCompletion("guidVSStd97", "guidVSStd97", _builtInGlyph));
                        list.Add(CreateCompletion("guidVSStd2K", "guidVSStd2K", _builtInGlyph));
                        GetNameValueCompletion(list, doc, "//GuidSymbol");
                    }
                    else if (current == "usedList")
                    {
                        extent = span.Span;
                        GetUsedListCompletion(list, doc, "//GuidSymbol[@name='" + guid + "']//IDSymbol");
                    }
                    else if (current == "href")
                    {
                        list.Add(CreateCompletion("stdidcmd.h", "stdidcmd.h", _defaultGlyph));
                        list.Add(CreateCompletion("vsshlids.h", "vsshlids.h", _defaultGlyph));
                        list.Add(CreateCompletion("KnownImageIds.vsct", "KnownImageIds.vsct", _defaultGlyph));
                    }
                    else if (current == "context")
                    {
                        list.Add(CreateCompletion("GUID_TextEditorFactory", "GUID_TextEditorFactory", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_CodeWindow", "UICONTEXT_CodeWindow", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_Debugging", "UICONTEXT_Debugging", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_DesignMode", "UICONTEXT_DesignMode", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_Dragging", "UICONTEXT_Dragging", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_EmptySolution", "UICONTEXT_EmptySolution", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_FullScreenMode", "UICONTEXT_FullScreenMode", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_NoSolution", "UICONTEXT_NoSolution", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_NotBuildingAndNotDebugging", "UICONTEXT_NotBuildingAndNotDebugging", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_SolutionBuilding", "UICONTEXT_SolutionBuilding", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_SolutionExists", "UICONTEXT_SolutionExists", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_SolutionExistsAndNotBuildingAndNotDebugging", "UICONTEXT_SolutionExistsAndNotBuildingAndNotDebugging", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_SolutionHasMultipleProjects", "UICONTEXT_SolutionHasMultipleProjects", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_SolutionHasSingleProject", "UICONTEXT_SolutionHasSingleProject", _defaultGlyph));
                        list.Add(CreateCompletion("UICONTEXT_ToolboxInitialized", "UICONTEXT_ToolboxInitialized", _defaultGlyph));
                    }
                }
            }

            if (list.Count > 0)
            {
                var applicableTo = snapshot.CreateTrackingSpan(extent, SpanTrackingMode.EdgeInclusive);
                completionSets.Add(new VsctCompletionSet("All", "All", applicableTo, list, Enumerable.Empty <Intel.Completion>()));
            }
        }
        IInfoBar IInfoBarManager.AttachInfoBarWithButton(Guid toolwindowGuid, string message, string buttonText, ImageMoniker imageMoniker)
        {
            this.attached.Should().NotContainKey(toolwindowGuid, "Info bar is already attached to tool window {0}", toolwindowGuid);

            var infoBar = new ConfigurableInfoBar(message, buttonText, imageMoniker);

            this.attached[toolwindowGuid] = infoBar;
            return(infoBar);
        }
 private static SonarLintImageMoniker CreateFromVsMoniker(ImageMoniker imageMoniker) => new SonarLintImageMoniker(imageMoniker.Guid, imageMoniker.Id);
Esempio n. 29
0
            public async Task UpdateBufferContentsAsync(CancellationToken cancellationToken)
            {
                GeneratedSourceResult?generatedSource = null;
                var project = _workspace.CurrentSolution.GetProject(_projectId);

                // Locals correspond to the equivalently-named fields; we'll assign these and then assign to the fields while on the
                // UI thread to avoid any potential race where we update the InfoBar while this is running.
                string?      windowFrameMessageToShow;
                ImageMoniker windowFrameImageMonikerToShow;

                if (project == null)
                {
                    windowFrameMessageToShow      = "The project no longer exists.";
                    windowFrameImageMonikerToShow = KnownMonikers.StatusError;
                }
                else
                {
                    var generatorDriverRunResults = await project.GetGeneratorDriverRunResultAsync(cancellationToken).ConfigureAwait(false);

                    var generatorRunResult = generatorDriverRunResults?.Results.SingleOrNull(r => r.Generator.GetType().FullName == _generatorTypeName);

                    if (generatorRunResult == null)
                    {
                        windowFrameMessageToShow      = string.Format(ServicesVSResources.The_generator_0_that_generated_this_file_has_been_removed_from_the_project, _generatorTypeName);
                        windowFrameImageMonikerToShow = KnownMonikers.StatusError;
                    }
                    else
                    {
                        generatedSource = generatorRunResult.Value.GeneratedSources.SingleOrNull(r => r.HintName == _generatedSourceHintName);

                        if (generatedSource == null)
                        {
                            windowFrameMessageToShow      = string.Format(ServicesVSResources.The_generator_0_that_generated_this_file_has_stopped_generating_this_file, _generatorTypeName);
                            windowFrameImageMonikerToShow = KnownMonikers.StatusError;
                        }
                        else
                        {
                            windowFrameMessageToShow      = string.Format(ServicesVSResources.This_file_is_autogenerated_by_0_and_cannot_be_edited, _generatorTypeName);
                            windowFrameImageMonikerToShow = default;
                        }
                    }
                }

                await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken);

                _windowFrameMessageToShow      = windowFrameMessageToShow;
                _windowFrameImageMonikerToShow = windowFrameImageMonikerToShow;

                // Update the text if we have new text
                if (generatedSource.HasValue)
                {
                    try
                    {
                        // Allow us to do our own edits
                        _updatingBuffer = true;

                        // Ensure the encoding matches; this is necessary for debugger checksums to match what is in the PDB.
                        if (_fileManager._textDocumentFactoryService.TryGetTextDocument(_textBuffer, out var textDocument))
                        {
                            textDocument.Encoding = generatedSource.Value.SourceText.Encoding;
                        }

                        // We'll ask the editor to do the diffing for us so updates don't refresh the entire buffer
                        using (var edit = _textBuffer.CreateEdit(EditOptions.DefaultMinimalChange, reiteratedVersionNumber: null, editTag: null))
                        {
                            // TODO: make the edit in some nicer way than creating a massive string
                            edit.Replace(startPosition: 0, _textBuffer.CurrentSnapshot.Length, generatedSource.Value.SourceText.ToString());
                            edit.Apply();
                        }
                    }
                    finally
                    {
                        _updatingBuffer = false;
                    }
                }

                // Update the InfoBar either way
                EnsureWindowFrameInfoBarUpdated();
            }
Esempio n. 30
0
 bool IWpfTableEntry.TryCreateImageContent(string columnName, bool singleColumnView, out ImageMoniker content)
 {
     content = default;
     return(false);
 }
        private Mock <IAnalysisIssueLocationVisualization> CreateMockLocation(string filePath, ImageMoniker imageMoniker = default, Exception failsToRetrieveMoniker = null)
        {
            if (failsToRetrieveMoniker != null)
            {
                imageServiceMock
                .Setup(x => x.GetImageMonikerForFile(filePath))
                .Throws(failsToRetrieveMoniker);
            }
            else
            {
                imageServiceMock.Setup(x => x.GetImageMonikerForFile(filePath)).Returns(imageMoniker);
            }

            var locationViz = new Mock <IAnalysisIssueLocationVisualization>();

            locationViz.SetupProperty(x => x.CurrentFilePath);

            locationViz.Object.CurrentFilePath = filePath;

            return(locationViz);
        }
Esempio n. 32
0
 public SimpleCompletionEntry(string displayText, string insertionText, string description, ImageMoniker moniker, ITrackingSpan span, IIntellisenseSession session, int specificVersion = 0)
     : base(displayText, "\"" + insertionText + "\"", description, null, null, false, session as ICompletionSession)
 {
     SetIconMoniker(moniker);
     ApplicableTo     = span;
     _specificVersion = specificVersion;
 }
Esempio n. 33
0
 public VersionCompletion(string displayText, string insertionText, string description, ImageMoniker iconMoniker, string iconAutomationText)
     : base(displayText, insertionText, description, iconMoniker, iconAutomationText)
 {
 }
Esempio n. 34
0
 public VsImageMonikerImageList(ImageMoniker imageMoniker)
 {
     _imageMoniker = imageMoniker;
 }
        // These methods are called by the debugger, as instructed by the DebuggerDisplayAttributes at the top of the file.

        internal static string ImageMonikerDebugDisplay(ImageMoniker moniker) => DebugDisplay(moniker.Guid, moniker.Id);
Esempio n. 36
0
 private static string GetIconStringName(ImageMoniker icon)
 {
     return($"{icon.Guid.ToString()};{icon.Id}");
 }
 private static bool Equals(ImageMoniker a, ImageMoniker b) => a.Id == b.Id && a.Guid == b.Guid;
 public NotificationOptionViewModel(NotificationOption notification, ImageMoniker moniker)
 {
     Notification = notification;
     Name = notification.Name;
     Moniker = moniker;
 }
Esempio n. 39
0
 /// <summary>
 /// Get the image based on moniker using the default dimensions
 /// </summary>
 public static Bitmap GetImage(ImageMoniker moniker)
 {
     System.Drawing.Color backColor = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey);
     return(GetImage(moniker, backColor, DefaultWidth, DefaultHeight, true));
 }
Esempio n. 40
0
 public DependencyIconSet GetOrAddIconSet(ImageMoniker icon, ImageMoniker expandedIcon, ImageMoniker unresolvedIcon, ImageMoniker unresolvedExpandedIcon)
 {
     return(GetOrAddIconSet(new DependencyIconSet(icon, expandedIcon, unresolvedIcon, unresolvedExpandedIcon)));
 }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            ImageMoniker moniker = (ImageMoniker)parameter;

            return(moniker.GetImage());
        }
Esempio n. 42
0
 public SimpleCompletionEntry(string text, string insertionText, string description, ImageMoniker moniker, IIntellisenseSession session, int specificVersion = 0)
     : base(text, "\"" + insertionText + "\"", description, null, null, false, session as ICompletionSession)
 {
     base.SetIconMoniker(moniker);
     _specificVersion = specificVersion;
 }
 public VsImageMonikerImageList(ImageMoniker imageMoniker)
 {
     _imageMoniker = imageMoniker;
 }
Esempio n. 44
0
 public static ImageSource GetImageSource(ImageMoniker imageMoniker)
 {
     return(GetImageSource(GetImage(imageMoniker)));
 }
 public void GetImageMonikers(int firstImageIndex, int imageMonikerCount, ImageMoniker[] imageMonikers) {
     for (int index = 0; index < imageMonikerCount; index++) {
         imageMonikers[index] = _imageMonikers[index + firstImageIndex];
     }
 }
 public ViewModel(string label, ImageMoniker moniker)
 {
     Label = label;
     Moniker = moniker;
 }
Esempio n. 47
0
 public SimpleCompletionEntry(string text, ImageMoniker moniker, IIntellisenseSession session)
     : this(text, null, WpfUtil.GetIconForImageMoniker(moniker, 16, 16), session)
 { }
Esempio n. 48
0
 public EnforcementLevel(string name, DiagnosticSeverity value, ImageMoniker moniker)
 {
     Name = name;
     Value = value;
     Moniker = moniker;
 }
 public IntraTextGoToTag(ILocationInfoProvider provider, ImageMoniker imageMoniker, string toolTip) 
     : base(provider) {
     ImageMoniker = imageMoniker;
     ToolTip      = toolTip;
 }
Esempio n. 50
0
 static string S(ImageMoniker a) => ImageMonikerDebuggerDisplay.FromImageMoniker(a);
Esempio n. 51
0
 public static ImageSource GetImageSource(ImageMoniker imageMoniker)
 {
     return GetImageSource(GetImage(imageMoniker));
 }
Esempio n. 52
0
 public DependencyIconSet(ImageMoniker icon, ImageMoniker expandedIcon, ImageMoniker unresolvedIcon, ImageMoniker unresolvedExpandedIcon)
 {
     Icon                   = icon;
     ExpandedIcon           = expandedIcon;
     UnresolvedIcon         = unresolvedIcon;
     UnresolvedExpandedIcon = unresolvedExpandedIcon;
 }
Esempio n. 53
0
        private static ImageSource GetImage(IVsImageService2 imageService, ImageMoniker imageMoniker) {
            var imageAttributes = new ImageAttributes {
                ImageType = (uint)_UIImageType.IT_Bitmap,
                Flags = (uint)_ImageAttributesFlags.IAF_RequiredFlags,
                Format = (uint)_UIDataFormat.DF_WPF,
                LogicalHeight = 16,
                LogicalWidth = 16,
                StructSize = Marshal.SizeOf(typeof(ImageAttributes))
            };

            IVsUIObject uiObject = imageService.GetImage(imageMoniker, imageAttributes);

            object data;
            if (uiObject.get_Data(out data) != VSConstants.S_OK) {
                return null;
            }

            var imageSource = data as ImageSource;
            imageSource?.Freeze();
            return imageSource;
        }
Esempio n. 54
0
 public NotificationOptionViewModel(NotificationOption notification, ImageMoniker moniker)
 {
     Notification = notification;
     Name         = notification.Name;
     Moniker      = moniker;
 }
Esempio n. 55
0
 public HeaderMenuItemViewModel(string displayContent, ImageMoniker imageMoniker)
     : base(displayContent, imageMoniker)
 {
 }
        public IInfoBar AttachInfoBarWithButton(Guid toolwindowGuid, string message, string buttonText, ImageMoniker imageMoniker)
        {
            if (string.IsNullOrWhiteSpace(message))
            {
                throw new ArgumentNullException(nameof(message));
            }

            if (string.IsNullOrWhiteSpace(buttonText))
            {
                throw new ArgumentNullException(nameof(buttonText));
            }

            return(AttachInfoBarImpl(toolwindowGuid, message, buttonText, imageMoniker));
        }
Esempio n. 57
0
 protected InheritanceMenuItemViewModel(string displayContent, ImageMoniker imageMoniker, string automationName)
 {
     ImageMoniker   = imageMoniker;
     DisplayContent = displayContent;
     AutomationName = automationName;
 }
Esempio n. 58
0
 /// <summary>
 /// Get the image based on moniker using the default dimensions
 /// </summary>
 public static Bitmap GetImage(ImageMoniker moniker)
 {
     System.Drawing.Color backColor = VSColorTheme.GetThemedColor(EnvironmentColors.ToolWindowBackgroundColorKey);
     return GetImage(moniker, backColor, DefaultWidth, DefaultHeight, true);
 }
 public void GetImageMonikers(int firstImageIndex, int imageMonikerCount, ImageMoniker[] imageMonikers)
 {
     if (firstImageIndex == 0 && imageMonikerCount == 1)
     {
         imageMonikers[0] = _imageMoniker;
     }
 }
 public static LocationInfo FromError(LocationNotFoundException ex, ImageMoniker imageMoniker) {
     return new LocationInfo {
         ErrorMessage = ex?.Message,
         ImageMoniker = imageMoniker
     };
 }