Esempio n. 1
0
        static object CreateImageUIObject(CompletionIcon icon, IImageMonikerService imageMonikerService)
        {
            var icon2 = icon as CompletionIcon2;

            if (icon2 == null)
            {
                var iconSource = icon.IconSource;
                if (iconSource == null)
                {
                    return(null);
                }
                return(new Image {
                    Width = 16,
                    Height = 16,
                    Source = iconSource,
                });
            }

            var imageReference = imageMonikerService.ToImageReference(icon2.IconMoniker);

            if (imageReference.IsDefault)
            {
                return(null);
            }
            var image = new DsImage {
                ImageReference = imageReference
            };

            if (!((icon as IDsCompletionIcon)?.ThemeImage ?? false))
            {
                DsImage.SetBackgroundColor(image, null);
                DsImage.SetBackgroundBrush(image, null);
            }
            return(image);
        }
        public UIElement GenerateGlyph(IWpfTextViewLine line, GlyphTextMarkerGlyphTag glyphTag)
        {
            if (line == null)
            {
                throw new ArgumentNullException(nameof(line));
            }
            if (glyphTag == null)
            {
                throw new ArgumentNullException(nameof(glyphTag));
            }
            Debug.Assert(!glyphTag.ImageReference.IsDefault);
            if (glyphTag.ImageReference.IsDefault)
            {
                return(null);
            }

            const double DEFAULT_IMAGE_LENGTH = 16;
            const double EXTRA_LENGTH         = 2;
            double       imageLength          = Math.Min(DEFAULT_IMAGE_LENGTH, line.Height + EXTRA_LENGTH);

            var image = new DsImage {
                Width          = imageLength,
                Height         = imageLength,
                ImageReference = glyphTag.ImageReference,
            };

            Panel.SetZIndex(image, glyphTag.ZIndex);
            return(image);
        }
Esempio n. 3
0
        static object CreateImageUIObject(CompletionIcon icon)
        {
            var dsIcon = icon as DsCompletionIcon;

            if (dsIcon == null)
            {
                var iconSource = icon.IconSource;
                if (iconSource == null)
                {
                    return(null);
                }
                return(new Image {
                    Width = 16,
                    Height = 16,
                    Source = iconSource,
                });
            }

            var imageReference = dsIcon.ImageReference;

            if (imageReference.IsDefault)
            {
                return(null);
            }
            var image = new DsImage {
                ImageReference = imageReference
            };

            if (!dsIcon.ThemeImage)
            {
                DsImage.SetBackgroundColor(image, null);
                DsImage.SetBackgroundBrush(image, null);
            }
            return(image);
        }
Esempio n. 4
0
        internal bool?ShowContextMenu(object evArgs, FrameworkElement ctxMenuElem, Guid topLevelMenuGuid, Guid ownerMenuGuid, GuidObject creatorObject, IGuidObjectsProvider?provider, IContextMenuInitializer?initCtxMenu, bool openedFromKeyboard)
        {
            InitializeMenuItemObjects();
            Debug2.Assert(guidToGroups is not null);

            // There could be nested context menu handler calls, eg. first text editor followed by
            // the TabControl. We don't wan't the TabControl to disable the text editor's ctx menu.
            if (prevEventArgs.Target == evArgs)
            {
                return(null);
            }

            var ctx = new MenuItemContext(topLevelMenuGuid, openedFromKeyboard, creatorObject, provider?.GetGuidObjects(new GuidObjectsProviderArgs(creatorObject, openedFromKeyboard)));

            bool b = guidToGroups.TryGetValue(ownerMenuGuid, out var groups);

            if (!b)
            {
                return(false);
            }
            Debug2.Assert(groups is not null);

            var menu = new ContextMenu();

            BindBackgroundBrush(menu, isCtxMenu: true);

            // The owner control could be zoomed (eg. text editor) but the context menu isn't, so make
            // sure we use 100% zoom here (same as the context menu).
            double defaultZoom = 1.0;

            DsImage.SetZoom(menu, defaultZoom);
            // Also make sure we use Display mode. Let MetroWindow handle it since it has some extra checks
            var window = Window.GetWindow(ctxMenuElem) as MetroWindow;

            window?.SetScaleTransform(menu, defaultZoom);

            var allItems = CreateMenuItems(ctx, groups, null, null, true);

            if (allItems.Count == 0)
            {
                return(false);
            }
            foreach (var i in allItems)
            {
                menu.Items.Add(i);
            }

            menu.Closed += (s, e) => {
                ctx.Dispose();
                ctxMenuElem.ContextMenu = new ContextMenu();
            };
            if (initCtxMenu is not null)
            {
                initCtxMenu.Initialize(ctx, menu);
            }
            ctxMenuElem.ContextMenu = menu;
            prevEventArgs.Target    = evArgs;
            return(true);
        }
Esempio n. 5
0
        void AddScaleTransform()
        {
            var mwin = GetWindow();

            if (mwin != null)
            {
                mwin.SetScaleTransform(zoomElement, currentZoomValue);
                DsImage.SetZoom(zoomElement, currentZoomValue);
            }
        }
Esempio n. 6
0
        static void Add16x16Image(MenuItem menuItem, ImageReference imageReference, bool?enable = null)
        {
            var image = new DsImage {
                ImageReference = imageReference
            };

            menuItem.Icon = image;
            if (enable == false)
            {
                image.Opacity = 0.3;
            }
        }
Esempio n. 7
0
        public override object Create(HexToolTipContent content)
        {
            if (content == null)
            {
                throw new ArgumentNullException(nameof(content));
            }

            var res = new StackPanel {
                Orientation = Orientation.Vertical,
            };
            var sigGrid = new Grid();

            sigGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = GridLength.Auto
            });
            sigGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            res.Children.Add(sigGrid);
            for (int i = 1; i < content.Text.Length; i++)
            {
                var text = content.Text[i];
                if (text.Count == 0)
                {
                    continue;
                }
                res.Children.Add(CreateTextElement(text));
            }
            var imgRef = content.Image as ImageReference?;

            if (imgRef != null)
            {
                var img = new DsImage {
                    ImageReference      = imgRef.Value,
                    Margin              = new Thickness(0, 0, 4, 0),
                    VerticalAlignment   = VerticalAlignment.Top,
                    HorizontalAlignment = HorizontalAlignment.Left,
                };
                Grid.SetColumn(img, 0);
                sigGrid.Children.Add(img);
            }
            if (content.Text.Length > 0)
            {
                var sig = CreateTextElement(content.Text[0]);
                Grid.SetColumn(sig, 1);
                sigGrid.Children.Add(sig);
            }
            return(res);
        }
Esempio n. 8
0
        void InitializeChildrens()
        {
            if (expander != null)
            {
                return;
            }

            ToolTip = toolTipDummy;

            expander = new ToggleButton {
                Style = (Style)FindResource("ExpandCollapseToggleStyle")
            };
            icon = new DsImage {
                Width             = 16,
                Height            = 16,
                Margin            = new Thickness(0, 0, 5, 1),
                VerticalAlignment = VerticalAlignment.Center,
                Focusable         = false
            };
            content = new ContentPresenter {
                Margin            = new Thickness(2, 0, 6, 0),
                VerticalAlignment = VerticalAlignment.Center,
                Focusable         = false
            };

            expander.Checked += (sender, e) => { if (Node != null)
                                                 {
                                                     Node.IsExpanded = true;
                                                 }
            };
            expander.Unchecked += (sender, e) => { if (Node != null)
                                                   {
                                                       Node.IsExpanded = false;
                                                   }
            };

            AddVisualChild(expander);
            AddVisualChild(icon);
            AddVisualChild(content);

            UpdateChildren(Node);
        }
Esempio n. 9
0
        public object Create()
        {
            var res = new StackPanel {
                Orientation = Orientation.Vertical,
            };
            var sigGrid = new Grid();

            sigGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = GridLength.Auto
            });
            sigGrid.ColumnDefinitions.Add(new ColumnDefinition {
                Width = new GridLength(1, GridUnitType.Star)
            });
            res.Children.Add(sigGrid);
            for (int i = 1; i < writers.Count; i++)
            {
                var output = writers[i];
                if (!output.IsEmpty)
                {
                    res.Children.Add(output.Create());
                }
            }
            if (Image != null)
            {
                var img = new DsImage {
                    ImageReference      = Image.Value,
                    Margin              = new Thickness(0, 0, 4, 0),
                    VerticalAlignment   = VerticalAlignment.Top,
                    HorizontalAlignment = HorizontalAlignment.Left,
                };
                Grid.SetColumn(img, 0);
                sigGrid.Children.Add(img);
            }
            var sig = writers[0].Create();

            Grid.SetColumn(sig, 1);
            sigGrid.Children.Add(sig);
            return(res);
        }
        public override UIElement GenerateGlyph(WpfHexViewLine line, HexGlyphTag tag)
        {
            var glyphTag = tag as HexImageReferenceTag;

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

            const double DEFAULT_IMAGE_LENGTH = 16;
            const double EXTRA_LENGTH         = 2;
            double       imageLength          = Math.Min(DEFAULT_IMAGE_LENGTH, line.Height + EXTRA_LENGTH);

            var image = new DsImage {
                Width          = imageLength,
                Height         = imageLength,
                ImageReference = glyphTag.ImageReference,
            };

            Panel.SetZIndex(image, glyphTag.ZIndex);
            return(image);
        }
Esempio n. 11
0
 void TextView_ZoomLevelChanged(object?sender, ZoomLevelChangedEventArgs e)
 {
     LayoutTransform = e.ZoomTransform;
     DsImage.SetZoom(this, e.NewZoomLevel / 100);
 }
Esempio n. 12
0
 void HexView_ZoomLevelChanged(object sender, VSTE.ZoomLevelChangedEventArgs e)
 {
     canvas.LayoutTransform = e.ZoomTransform;
     DsImage.SetZoom(canvas, e.NewZoomLevel / 100);
 }