コード例 #1
0
		public override Control GetVisualizerWidget (ObjectValue val)
		{
			var ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone ();
			ops.AllowTargetInvoke = true;
			ops.ChunkRawStrings = true;
			ops.EllipsizedLength = 5000;//Preview window can hold aprox. 4700 chars
			val.Refresh (ops);//Refresh DebuggerDisplay/String value with full length instead of ellipsized
			string value = val.Value;
			Gdk.Color col = Styles.PreviewVisualizerTextColor.ToGdkColor ();

			if (DebuggingService.HasInlineVisualizer (val))
				value = DebuggingService.GetInlineVisualizer (val).InlineVisualize (val);

			var label = new Gtk.Label ();
			label.Text = value;
			label.ModifyFont (FontService.SansFont.CopyModified (Ide.Gui.Styles.FontScale11));
			label.ModifyFg (StateType.Normal, col);
			label.SetPadding (4, 4);

			if (label.SizeRequest ().Width > 500) {
				label.WidthRequest = 500;
				label.Wrap = true;
				label.LineWrapMode = Pango.WrapMode.WordChar;
			} else {
				label.Justify = Gtk.Justification.Center;
			}

			if (label.Layout.GetLine (1) != null) {
				label.Justify = Gtk.Justification.Left;
				var trimmedLine = label.Layout.GetLine (50);
				if (trimmedLine != null) {
					label.Text = value.Substring (0, trimmedLine.StartIndex).TrimEnd ('\r', '\n') + "\n…";
				}
			}

			label.Show ();

			return label;
		}