diff options
author | David Karlaš <david.karlas@xamarin.com> | 2014-06-18 11:04:59 +0400 |
---|---|---|
committer | David Karlaš <david.karlas@xamarin.com> | 2014-06-22 15:36:35 +0400 |
commit | 851ee55397fa27f6ff3c8db16c8707c5587752f3 (patch) | |
tree | 057fe528aff0fa37d146631fa33198bfbece61f2 /main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.InlineVisualizers | |
parent | c628d2c566ade792232999773a7779c31e8c3041 (diff) |
[Debugger] InlineVisualizer, ColorPreview icon & ColorInlineVisualizer
Diffstat (limited to 'main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.InlineVisualizers')
2 files changed, 108 insertions, 0 deletions
diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.InlineVisualizers/ColorInlineVisualizer.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.InlineVisualizers/ColorInlineVisualizer.cs new file mode 100644 index 0000000000..023caa8d62 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.InlineVisualizers/ColorInlineVisualizer.cs @@ -0,0 +1,52 @@ +// +// ColorInlineVisualizer.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.InlineVisualizers +{ + public class ColorInlineVisualizer : InlineVisualizer + { + #region InlineVisualizer implementation + + public override bool CanInlineVisualize (ObjectValue val) + { + return DebuggingService.HasColorConverter (val); + } + + public override string InlineVisualize (ObjectValue val) + { + var color = DebuggingService.GetColorConverter (val).GetColor (val); + return "R=" + ((byte)(color.Red * 255.0)) + ", " + + "G=" + ((byte)(color.Green * 255.0)) + ", " + + "B=" + ((byte)(color.Blue * 255.0)) + ", " + + "A=" + ((byte)(color.Alpha * 255.0)); + } + + #endregion + } +} + diff --git a/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.InlineVisualizers/InlineVisualizer.cs b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.InlineVisualizers/InlineVisualizer.cs new file mode 100644 index 0000000000..88b2de6be9 --- /dev/null +++ b/main/src/addins/MonoDevelop.Debugger/MonoDevelop.Debugger.InlineVisualizers/InlineVisualizer.cs @@ -0,0 +1,56 @@ +// +// InlineVisualizer.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 InlineVisualizer + { + /// <summary> + /// Determines whether this instance can inline visualize the specified value + /// </summary> + /// <returns> + /// <c>true</c> if this instance can inline visualize the specified value; otherwise, <c>false</c>. + /// </returns> + /// <param name='val'> + /// The value + /// </param> + /// <remarks> + /// This method must check the value and return <c>true</c> if it is able to display that value. + /// Typically, this method will check the TypeName of the value. + /// </remarks> + public abstract bool CanInlineVisualize (ObjectValue val); + + /// <summary> + /// Converts specified value into string to be displayed in debugger. + /// </summary> + /// <returns>String value representing value.</returns> + /// <param name="val">Value.</param> + public abstract string InlineVisualize (ObjectValue val); + } +} + |