Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/monodevelop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Karlaš <david.karlas@xamarin.com>2014-06-22 15:09:26 +0400
committerDavid Karlaš <david.karlas@xamarin.com>2014-06-22 15:46:30 +0400
commit6d520a99f7ea2fee9a6b63e98c42f2b475d50678 (patch)
tree87fd79a16071ba0b1e23ac782bc66d32d9bfa961 /main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters
parentcdf422259e6bf53b946d62a9ee6dfbb34549169b (diff)
[Debugger] new class DebugValueConverter<T> and /MonoDevelop/Debugging/DebugValueConverters for all conversions
Diffstat (limited to 'main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters')
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/ColorsConverters.cs77
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/DebugValueConverter.cs48
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/RectanglesConverters.cs66
-rw-r--r--main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/SizesConverters.cs62
4 files changed, 253 insertions, 0 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/ColorsConverters.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/ColorsConverters.cs
new file mode 100644
index 0000000000..1e4cb5135f
--- /dev/null
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/ColorsConverters.cs
@@ -0,0 +1,77 @@
+//
+// ColorsConverters.cs
+//
+// Author:
+// David Karlaš <david.karlas@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Mono.Debugging.Client;
+using Xwt.Drawing;
+
+namespace MonoDevelop.Debugger.Converters
+{
+ class SystemDrawingColorConverter : DebugValueConverter<Color>
+ {
+ #region ColorConverter implementation
+
+ public override bool CanGetValue (ObjectValue val)
+ {
+ return val.TypeName == "System.Drawing.Color";
+ }
+
+ public override Color GetValue (ObjectValue val)
+ {
+ var ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone ();
+ ops.AllowTargetInvoke = true;
+ var r = (byte)val.GetChild ("R", ops).GetRawValue (ops);
+ var g = (byte)val.GetChild ("G", ops).GetRawValue (ops);
+ var b = (byte)val.GetChild ("B", ops).GetRawValue (ops);
+ var a = (byte)val.GetChild ("A", ops).GetRawValue (ops);
+ return Color.FromBytes (r, g, b, a);
+ }
+
+ #endregion
+ }
+
+ class GdkColorConverter : DebugValueConverter<Color>
+ {
+ #region ColorConverter implementation
+
+ public override bool CanGetValue (ObjectValue val)
+ {
+ return val.TypeName == "Gdk.Color";
+ }
+
+ public override Color GetValue (ObjectValue val)
+ {
+ var ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone ();
+ ops.AllowTargetInvoke = true;
+ return new Color (
+ ((ushort)val.GetChild ("Red", ops).GetRawValue (ops) / 65535.0),
+ ((ushort)val.GetChild ("Green", ops).GetRawValue (ops) / 65535.0),
+ ((ushort)val.GetChild ("Blue", ops).GetRawValue (ops) / 65535.0));
+ }
+
+ #endregion
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/DebugValueConverter.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/DebugValueConverter.cs
new file mode 100644
index 0000000000..d66bfa7f65
--- /dev/null
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/DebugValueConverter.cs
@@ -0,0 +1,48 @@
+//
+// DebugValueConverter.cs
+//
+// Author:
+// David Karlaš <david.karlas@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Mono.Debugging.Client;
+
+namespace MonoDevelop.Debugger
+{
+ public abstract class DebugValueConverter<T>
+ {
+ public abstract bool CanGetValue (ObjectValue val);
+
+ public abstract T GetValue (ObjectValue val);
+
+ public virtual bool CanSetValue (ObjectValue val)
+ {
+ return false;
+ }
+
+ public virtual void SetValue (T value, ObjectValue val)
+ {
+ throw new NotImplementedException ();
+ }
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/RectanglesConverters.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/RectanglesConverters.cs
new file mode 100644
index 0000000000..0a33b1ca2a
--- /dev/null
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/RectanglesConverters.cs
@@ -0,0 +1,66 @@
+//
+// RectanglesConverters.cs
+//
+// Author:
+// David Karlaš <david.karlas@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Xwt;
+using Mono.Debugging.Client;
+
+namespace MonoDevelop.Debugger.Converters
+{
+ class RectanglesConverters : DebugValueConverter<Rectangle>
+ {
+ #region implemented abstract members of DebugValueConverter
+
+ public override bool CanGetValue (ObjectValue val)
+ {
+ return val.TypeName == "System.Drawing.Rectangle" ||
+ val.TypeName == "Gdk.Rectangle" ||
+ val.TypeName == "Xamarin.Forms.Rectangle" ||
+ val.TypeName == "System.Drawing.RectangleF";
+ }
+
+ public override Rectangle GetValue (ObjectValue val)
+ {
+ var ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone ();
+ ops.AllowTargetInvoke = true;
+ var rectangle = new Rectangle ();
+ if (val.TypeName == "System.Drawing.RectangleF") {
+ rectangle.X = (float)val.GetChild ("X", ops).GetRawValue (ops);
+ rectangle.Y = (float)val.GetChild ("Y", ops).GetRawValue (ops);
+ rectangle.Width = (float)val.GetChild ("Width", ops).GetRawValue (ops);
+ rectangle.Height = (float)val.GetChild ("Height", ops).GetRawValue (ops);
+ } else {
+ rectangle.X = (int)val.GetChild ("X", ops).GetRawValue (ops);
+ rectangle.Y = (int)val.GetChild ("Y", ops).GetRawValue (ops);
+ rectangle.Width = (int)val.GetChild ("Width", ops).GetRawValue (ops);
+ rectangle.Height = (int)val.GetChild ("Height", ops).GetRawValue (ops);
+ }
+ return rectangle;
+ }
+
+ #endregion
+ }
+}
+
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/SizesConverters.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/SizesConverters.cs
new file mode 100644
index 0000000000..78801c82a9
--- /dev/null
+++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.Converters/SizesConverters.cs
@@ -0,0 +1,62 @@
+//
+// SizesConverters.cs
+//
+// Author:
+// David Karlaš <david.karlas@xamarin.com>
+//
+// Copyright (c) 2014 Xamarin, Inc (http://www.xamarin.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining a copy
+// of this software and associated documentation files (the "Software"), to deal
+// in the Software without restriction, including without limitation the rights
+// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+// copies of the Software, and to permit persons to whom the Software is
+// furnished to do so, subject to the following conditions:
+//
+// The above copyright notice and this permission notice shall be included in
+// all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+// THE SOFTWARE.
+using System;
+using Xwt;
+using Mono.Debugging.Client;
+
+namespace MonoDevelop.Debugger.Converters
+{
+ class SizesConverters : DebugValueConverter<Size>
+ {
+ #region implemented abstract members of DebugValueConverter
+
+ public override bool CanGetValue (ObjectValue val)
+ {
+ return val.TypeName == "System.Drawing.Size" ||
+ val.TypeName == "Gdk.Size" ||
+ val.TypeName == "Xamarin.Forms.Size" ||
+ val.TypeName == "System.Drawing.SizeF";
+ }
+
+ public override Size GetValue (ObjectValue val)
+ {
+ var ops = DebuggingService.DebuggerSession.EvaluationOptions.Clone ();
+ ops.AllowTargetInvoke = true;
+ var size = new Size ();
+ if (val.TypeName == "System.Drawing.SizeF") {
+ size.Width = (float)val.GetChild ("Width", ops).GetRawValue (ops);
+ size.Height = (float)val.GetChild ("Height", ops).GetRawValue (ops);
+ } else {
+ size.Width = (int)val.GetChild ("Width", ops).GetRawValue (ops);
+ size.Height = (int)val.GetChild ("Height", ops).GetRawValue (ops);
+ }
+ return size;
+ }
+
+ #endregion
+ }
+}
+