diff options
author | David Karlaš <david.karlas@xamarin.com> | 2014-06-22 15:09:26 +0400 |
---|---|---|
committer | David Karlaš <david.karlas@xamarin.com> | 2014-06-22 15:46:30 +0400 |
commit | 6d520a99f7ea2fee9a6b63e98c42f2b475d50678 (patch) | |
tree | 87fd79a16071ba0b1e23ac782bc66d32d9bfa961 /main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers | |
parent | cdf422259e6bf53b946d62a9ee6dfbb34549169b (diff) |
[Debugger] new class DebugValueConverter<T> and /MonoDevelop/Debugging/DebugValueConverters for all conversions
Diffstat (limited to 'main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers')
-rw-r--r-- | main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers/ColorPreviewVisualizer.cs | 6 | ||||
-rw-r--r-- | main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers/SizeAndRectanglePreviewVisualizer.cs (renamed from main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers/SizePreviewVisualizer.cs) | 59 |
2 files changed, 32 insertions, 33 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers/ColorPreviewVisualizer.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers/ColorPreviewVisualizer.cs index 770ad16fcf..f8fc8736f1 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers/ColorPreviewVisualizer.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers/ColorPreviewVisualizer.cs @@ -34,12 +34,12 @@ namespace MonoDevelop.Debugger.PreviewVisualizers { public override bool CanVisualize (ObjectValue val) { - return DebuggingService.HasColorConverter (val); + return DebuggingService.HasGetConverter<Xwt.Drawing.Color> (val); } public override Gtk.Widget GetVisualizerWidget (ObjectValue val) { - var color = DebuggingService.GetColorConverter (val).GetColor (val); + var color = DebuggingService.GetGetConverter<Xwt.Drawing.Color> (val).GetValue (val); var mainBox = new HBox (); var colorBox = new ColorBox { Color = color }; @@ -105,7 +105,7 @@ namespace MonoDevelop.Debugger.PreviewVisualizers cr.RoundedRectangle (2, 2, 42, 42, 2); cr.SetSourceRGB (Color.Red, Color.Green, Color.Blue); cr.FillPreserve (); - var darkColor = Color.WithIncreasedLight (-0.5); + var darkColor = Color.WithIncreasedLight (-0.3); cr.SetSourceRGB (darkColor.Red, darkColor.Green, darkColor.Blue); cr.LineWidth = 1; cr.Stroke (); diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers/SizePreviewVisualizer.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers/SizeAndRectanglePreviewVisualizer.cs index 93a20d95ff..2c61540645 100644 --- a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers/SizePreviewVisualizer.cs +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.PreviewVisualizers/SizeAndRectanglePreviewVisualizer.cs @@ -1,5 +1,5 @@ // -// SizePreviewVisualizer.cs +// SizeAndRectanglePreviewVisualizer.cs // // Author: // David Karlaš <david.karlas@xamarin.com> @@ -29,54 +29,52 @@ using Gtk; namespace MonoDevelop.Debugger.PreviewVisualizers { - class SizePreviewVisualizer : PreviewVisualizer + class SizeAndRectanglePreviewVisualizer : PreviewVisualizer { #region implemented abstract members of PreviewVisualizer public override bool CanVisualize (ObjectValue val) { - return val.TypeName == "System.Drawing.Size" || - val.TypeName == "Gdk.Size" || - val.TypeName == "Xamarin.Forms.Size" || - val.TypeName == "System.Drawing.SizeF"; + return DebuggingService.HasGetConverter<Xwt.Size> (val) || DebuggingService.HasGetConverter<Xwt.Rectangle> (val); } public override Gtk.Widget GetVisualizerWidget (ObjectValue val) { - var ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone (); - ops.AllowTargetInvoke = true; - - double width, height; - - if (val.TypeName == "System.Drawing.SizeF") { - width = (float)val.GetChild ("Width", ops).GetRawValue (ops); - height = (float)val.GetChild ("Height", ops).GetRawValue (ops); - } else { - width = (int)val.GetChild ("Width", ops).GetRawValue (ops); - height = (int)val.GetChild ("Height", ops).GetRawValue (ops); + var sizeConverter = DebuggingService.GetGetConverter<Xwt.Size> (val); + if (sizeConverter != null) { + var size = sizeConverter.GetValue (val); + return new SizeAndRectanglePreviewVisualizerWidget (size); } - return new SizePreviewVisualizerWidget (width, height); + var rectangleConverter = DebuggingService.GetGetConverter<Xwt.Rectangle> (val); + var rectangle = rectangleConverter.GetValue (val); + return new SizeAndRectanglePreviewVisualizerWidget (rectangle); } #endregion } - class SizePreviewVisualizerWidget : Gtk.DrawingArea + class SizeAndRectanglePreviewVisualizerWidget : Gtk.DrawingArea { - double width; - double height; + bool drawLocation; + Xwt.Rectangle rectangle; + + public SizeAndRectanglePreviewVisualizerWidget (Xwt.Size size) + { + rectangle = new Xwt.Rectangle (Xwt.Point.Zero, size); + drawLocation = false; + } - public SizePreviewVisualizerWidget (double width, double height) + public SizeAndRectanglePreviewVisualizerWidget (Xwt.Rectangle rectangle) { - this.width = width; - this.height = height; + this.rectangle = rectangle; + drawLocation = true; } protected override bool OnExposeEvent (Gdk.EventExpose evnt) { using (var ctx = Gdk.CairoHelper.Create (GdkWindow)) { ctx.SetSourceRGB (219 / 256.0, 229 / 256.0, 242 / 256.0); - ctx.Rectangle (10, 10, width, height); + ctx.Rectangle (10, 10, rectangle.Width, rectangle.Height); ctx.FillPreserve (); ctx.SetSourceRGB (74 / 256.0, 144 / 256.0, 226 / 256.0); ctx.Antialias = Cairo.Antialias.None; @@ -84,9 +82,10 @@ namespace MonoDevelop.Debugger.PreviewVisualizers ctx.Stroke (); ctx.Antialias = Cairo.Antialias.Default; - //TODO: Rectangle only dot -// ctx.Arc (10, height + 10, 4, 0, 2 * Math.PI); -// ctx.Fill (); + if (drawLocation) { + ctx.Arc (10, rectangle.Height + 10, 4, 0, 2 * Math.PI); + ctx.Fill (); + } //TODO: Write width and height text(rectangle dot point) // ctx.MoveTo (20, 20); @@ -102,8 +101,8 @@ namespace MonoDevelop.Debugger.PreviewVisualizers protected override void OnSizeRequested (ref Requisition requisition) { requisition = new Requisition () { - Height = (int)height + 20, - Width = (int)width + 20 + Height = (int)rectangle.Height + 20, + Width = (int)rectangle.Width + 20 }; } } |