Пример #1
0
        public PreviewVisualizerWindow(ObjectValue val, Gtk.Widget invokingWidget) : base(Gtk.WindowType.Toplevel)
        {
            this.TypeHint  = WindowTypeHint.PopupMenu;
            this.Decorated = false;
            TransientFor   = (Gtk.Window)invokingWidget.Toplevel;

            Theme.SetFlatColor(new Cairo.Color(245 / 256.0, 245 / 256.0, 245 / 256.0));
            Theme.Padding = 3;
            ShowArrow     = true;
            var mainBox     = new VBox();
            var headerTable = new Table(1, 3, false);

            headerTable.ColumnSpacing = 5;
            var closeButton = new ImageButton()
            {
                InactiveImage = ImageService.GetIcon("md-popup-close", IconSize.Menu),
                Image         = ImageService.GetIcon("md-popup-close-hover", IconSize.Menu)
            };

            closeButton.Clicked += delegate {
                this.Destroy();
            };
            var hb = new HBox();
            var vb = new VBox();

            hb.PackStart(vb, false, false, 0);
            vb.PackStart(closeButton, false, false, 0);
            headerTable.Attach(hb, 0, 1, 0, 1);

            var headerTitle = new Label();

            headerTitle.ModifyFg(StateType.Normal, new Color(36, 36, 36));
            var font = headerTitle.Style.FontDescription.Copy();

            font.Weight = Pango.Weight.Bold;
            headerTitle.ModifyFont(font);
            headerTitle.Text = val.TypeName;
            var vbTitle = new VBox();

            vbTitle.PackStart(headerTitle, false, false, 3);
            headerTable.Attach(vbTitle, 1, 2, 0, 1);

            if (DebuggingService.HasValueVisualizers(val))
            {
                var openButton = new Button();
                openButton.Label    = "Open";
                openButton.Relief   = ReliefStyle.Half;
                openButton.Clicked += delegate {
                    PreviewWindowManager.DestroyWindow();
                    DebuggingService.ShowValueVisualizer(val);
                };
                var hbox = new HBox();
                hbox.PackEnd(openButton, false, false, 2);
                headerTable.Attach(hbox, 2, 3, 0, 1);
            }
            else
            {
                headerTable.Attach(new Label(), 2, 3, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill | AttachOptions.Expand, 10, 0);
            }
            mainBox.PackStart(headerTable);
            mainBox.ShowAll();

            var previewVisualizer = DebuggingService.GetPreviewVisualizer(val);

            if (previewVisualizer == null)
            {
                previewVisualizer = new GenericPreviewVisualizer();
            }
            Control widget = null;

            try {
                widget = previewVisualizer.GetVisualizerWidget(val);
            } catch (Exception e) {
                DebuggingService.DebuggerSession.LogWriter(true, "Exception during preview widget creation: " + e.Message);
            }
            if (widget == null)
            {
                widget = new GenericPreviewVisualizer().GetVisualizerWidget(val);
            }
            var alignment = new Alignment(0, 0, 1, 1);

            alignment.SetPadding(3, 5, 5, 5);
            alignment.Show();
            alignment.Add(widget);
            mainBox.PackStart(alignment);
            ContentBox.Add(mainBox);
        }
Пример #2
0
        public PreviewVisualizerWindow(ObjectValue val, Gtk.Widget invokingWidget) : base(Gtk.WindowType.Toplevel)
        {
            this.TypeHint  = WindowTypeHint.PopupMenu;
            this.Decorated = false;
            if (((Gtk.Window)invokingWidget.Toplevel).Modal)
            {
                this.Modal = true;
            }
            TransientFor = (Gtk.Window)invokingWidget.Toplevel;

            Theme.SetBackgroundColor(Styles.PreviewVisualizerBackgroundColor.ToCairoColor());
            Theme.Padding = 3;
            ShowArrow     = true;
            var mainBox     = new VBox();
            var headerTable = new Table(1, 3, false);

            headerTable.ColumnSpacing = 5;
            var closeButton = new ImageButton()
            {
                InactiveImage = ImageService.GetIcon("md-popup-close", IconSize.Menu),
                Image         = ImageService.GetIcon("md-popup-close-hover", IconSize.Menu)
            };

            closeButton.SetCommonAccessibilityAttributes("Preview visualizer close button", GettextCatalog.GetString("Close"), null);
            closeButton.Clicked += delegate {
                this.Destroy();
            };
            var hb = new HBox();
            var vb = new VBox();

            hb.PackStart(vb, false, false, 0);
            vb.PackStart(closeButton, false, false, 0);
            headerTable.Attach(hb, 0, 1, 0, 1);

            var headerTitle = new Label();

            headerTitle.ModifyFg(StateType.Normal, Styles.PreviewVisualizerHeaderTextColor.ToGdkColor());
            var font = FontService.SansFont.CopyModified(Ide.Gui.Styles.FontScale12);

            font.Weight = Pango.Weight.Bold;
            headerTitle.ModifyFont(font);
            headerTitle.Text = val.TypeName;
            var vbTitle = new VBox();

            vbTitle.PackStart(headerTitle, false, false, 3);
            headerTable.Attach(vbTitle, 1, 2, 0, 1);

            if (DebuggingService.HasValueVisualizers(val))
            {
                var openButton = new Button();
                openButton.Label    = "Open";
                openButton.Relief   = ReliefStyle.Half;
                openButton.Clicked += delegate {
                    PreviewWindowManager.DestroyWindow();
                    DebuggingService.ShowValueVisualizer(val);
                };
                var hbox = new HBox();
                hbox.PackEnd(openButton, false, false, 2);
                headerTable.Attach(hbox, 2, 3, 0, 1);
            }
            else
            {
                headerTable.Attach(new Label(), 2, 3, 0, 1, AttachOptions.Fill | AttachOptions.Expand, AttachOptions.Fill | AttachOptions.Expand, 10, 0);
            }
            mainBox.PackStart(headerTable);
            mainBox.ShowAll();

            var     previewVisualizer = DebuggingService.GetPreviewVisualizer(val);
            Control widget            = null;

            try {
                widget = previewVisualizer?.GetVisualizerWidget(val);
            } catch (Exception e) {
                DebuggingService.DebuggerSession.LogWriter(true, "Exception during preview widget creation: " + e.Message);
            }
            if (widget == null)
            {
                genericPreview = new GenericPreviewVisualizer();
                widget         = genericPreview.GetVisualizerWidget(val);
            }
            var alignment = new Alignment(0, 0, 1, 1);

            alignment.SetPadding(3, 5, 5, 5);
            alignment.Show();
            alignment.Add(widget);
            mainBox.PackStart(alignment);
            ContentBox.Add(mainBox);
        }
        protected override bool OnButtonPressEvent(Gdk.EventButton evnt)
        {
            allowStoreColumnSizes = true;
            bool           res = base.OnButtonPressEvent(evnt);
            TreePath       path;
            TreeViewColumn col;
            CellRenderer   cr;

            if (evnt.Button == 1 && GetCellAtPos((int)evnt.X, (int)evnt.Y, out path, out col, out cr))
            {
                TreeIter it;
                store.GetIter(out it, path);
                if (cr == crpViewer)
                {
                    ObjectValue val = (ObjectValue)store.GetValue(it, ObjectCol);
                    DebuggingService.ShowValueVisualizer(val);
                }
                else if (!editing)
                {
                    if (cr == crpButton)
                    {
                        RefreshRow(it);
                    }
                    else if (cr == crpPin)
                    {
                        TreeIter pi;
                        if (PinnedWatch != null && !store.IterParent(out pi, it))
                        {
                            RemovePinnedWatch(it);
                        }
                        else
                        {
                            CreatePinnedWatch(it);
                        }
                    }
                    else if (cr == crpLiveUpdate)
                    {
                        TreeIter pi;
                        if (PinnedWatch != null && !store.IterParent(out pi, it))
                        {
                            DebuggingService.SetLiveUpdateMode(PinnedWatch, !PinnedWatch.LiveUpdate);
                            if (PinnedWatch.LiveUpdate)
                            {
                                store.SetValue(it, LiveUpdateIconCol, liveIcon);
                            }
                            else
                            {
                                store.SetValue(it, LiveUpdateIconCol, noLiveIcon);
                            }
                        }
                    }
                }
            }

            if (evnt.Button == 3)
            {
                ShowPopup();
            }

            return(res);
        }