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); }
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); }