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); }
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); }
void SetValues(TreeIter parent, TreeIter it, string name, ObjectValue val) { string strval; bool canEdit; string nameColor = null; string valueColor = null; string valueButton = null; if (name == null) { name = val.Name; } bool hasParent = !parent.Equals(TreeIter.Zero); string valPath; if (!hasParent) { valPath = "/" + name; } else { valPath = GetIterPath(parent) + "/" + name; } string oldValue; oldValues.TryGetValue(valPath, out oldValue); if (val.IsUnknown) { strval = GettextCatalog.GetString("The name '{0}' does not exist in the current context.", val.Name); nameColor = disabledColor; canEdit = false; } else if (val.IsError) { strval = val.Value; int i = strval.IndexOf('\n'); if (i != -1) { strval = strval.Substring(0, i); } valueColor = errorColor; canEdit = false; } else if (val.IsNotSupported) { strval = val.Value; valueColor = disabledColor; if (val.CanRefresh) { valueButton = Gtk.Stock.Refresh; } canEdit = false; } else if (val.IsEvaluating) { strval = GettextCatalog.GetString("Evaluating..."); valueColor = disabledColor; if (val.IsEvaluatingGroup) { nameColor = disabledColor; name = val.Name; } canEdit = false; } else { canEdit = val.IsPrimitive && !val.IsReadOnly && allowEditing; strval = val.DisplayValue ?? "(null)"; if (oldValue != null && strval != oldValue) { nameColor = valueColor = modifiedColor; } } strval = strval.Replace(Environment.NewLine, " "); bool showViewerButton = DebuggingService.HasValueVisualizers(val); string icon = GetIcon(val.Flags); store.SetValue(it, NameCol, name); store.SetValue(it, ValueCol, strval); store.SetValue(it, TypeCol, val.TypeName); store.SetValue(it, ObjectCol, val); store.SetValue(it, ExpandedCol, !val.HasChildren); store.SetValue(it, NameEditableCol, !hasParent && allowAdding); store.SetValue(it, ValueEditableCol, canEdit); store.SetValue(it, IconCol, icon); store.SetValue(it, NameColorCol, nameColor); store.SetValue(it, ValueColorCol, valueColor); store.SetValue(it, ValueButtonVisibleCol, valueButton != null); store.SetValue(it, ViewerButtonVisibleCol, showViewerButton); if (!hasParent && PinnedWatch != null) { store.SetValue(it, PinIconCol, "md-pin-down"); if (PinnedWatch.LiveUpdate) { store.SetValue(it, LiveUpdateIconCol, liveIcon); } else { store.SetValue(it, LiveUpdateIconCol, noLiveIcon); } } if (val.HasChildren) { // Add dummy node it = store.AppendValues(it, "", "", "", null, true); } }