Author: miguel
Date: 2007-06-09 12:08:28 -0400 (Sat, 09 Jun 2007)
New Revision: 79057
Modified:
trunk/olive/class/agclr/Mono/NativeMethods.cs
trunk/olive/class/agclr/System.Windows.Media/Color.cs
trunk/olive/class/agclr/System.Windows.Media/SolidColorBrush.cs
trunk/olive/class/agclr/System.Windows/DependencyObject.cs
Log:
Make SolidBrush work
Modified: trunk/olive/class/agclr/Mono/NativeMethods.cs
===================================================================
--- trunk/olive/class/agclr/Mono/NativeMethods.cs 2007-06-09 15:51:59 UTC
(rev 79056)
+++ trunk/olive/class/agclr/Mono/NativeMethods.cs 2007-06-09 16:08:28 UTC
(rev 79057)
@@ -58,8 +58,10 @@
[DllImport("moon")]
internal extern static IntPtr xaml_create_from_str (string
xaml, out Kind kind);
-
-
+
+ [DllImport("moon")]
+ internal extern static Value value_color_from_argb (uint c);
+
#region Items
[DllImport("moon")]
internal extern static IntPtr item_get_surface (IntPtr item);
@@ -79,19 +81,20 @@
internal extern static IntPtr panel_get_children_collection
(IntPtr panel);
#endregion
-#region Canvas
- [DllImport("moon")]
- internal extern static IntPtr canvas_new ();
-#endregion
-
#region Collections
[DllImport("moon")]
internal extern static IntPtr collection_add (IntPtr
collection, IntPtr value);
#endregion
-#region Shapes
+#region Constructors
[DllImport("moon")]
internal extern static IntPtr rectangle_new ();
+
+ [DllImport("moon")]
+ internal extern static IntPtr solid_color_brush_new ();
+
+ [DllImport("moon")]
+ internal extern static IntPtr canvas_new ();
#endregion
}
}
Modified: trunk/olive/class/agclr/System.Windows/DependencyObject.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows/DependencyObject.cs 2007-06-09
15:51:59 UTC (rev 79056)
+++ trunk/olive/class/agclr/System.Windows/DependencyObject.cs 2007-06-09
16:08:28 UTC (rev 79057)
@@ -259,8 +259,11 @@
String.Format ("Class {0}
does not implement GetKind", x));
}
*((IntPtr *) p) = x.native;
+ } else if (v is Color){
+ value =
NativeMethods.value_color_from_argb (((Color) v).argb);
} else
- throw new NotImplementedException
(String.Format ("Do not know how to encode {0} yet", v.GetType ()));
+ throw new NotImplementedException (
+ String.Format ("Do not know how
to encode {0} yet", v.GetType ()));
}
return value;
}
@@ -277,6 +280,11 @@
if (property == null)
throw new ArgumentNullException ("property");
+ if (native == IntPtr.Zero){
+ throw new Exception (
+ "Uninitialized object: this object has
not set its native handle or overwritten SetValue");
+ }
+
if (obj == null){
NativeMethods.dependency_object_set_value
(native, property.native, IntPtr.Zero);
return;
Modified: trunk/olive/class/agclr/System.Windows.Media/Color.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows.Media/Color.cs 2007-06-09
15:51:59 UTC (rev 79056)
+++ trunk/olive/class/agclr/System.Windows.Media/Color.cs 2007-06-09
16:08:28 UTC (rev 79057)
@@ -32,9 +32,15 @@
// maybe we should keep the 4 floats value and compute the argb
on them
// but that would require 4 times the memory
- private uint argb;
+ // Its internal for now, but we should turn Color into a binary
+ // compatible format so we can pass that directly to Value,
right
+ // now we are using a hack that creates the value out of the
argb
+ // to be able to call C++'s uint32 constructor, but we should be
+ // passing all doubles instead.
+ internal uint argb;
+
private Color (uint value)
{
argb = value;
Modified: trunk/olive/class/agclr/System.Windows.Media/SolidColorBrush.cs
===================================================================
--- trunk/olive/class/agclr/System.Windows.Media/SolidColorBrush.cs
2007-06-09 15:51:59 UTC (rev 79056)
+++ trunk/olive/class/agclr/System.Windows.Media/SolidColorBrush.cs
2007-06-09 16:08:28 UTC (rev 79057)
@@ -31,14 +31,18 @@
public class SolidColorBrush : Brush {
- public static readonly DependencyProperty ColorProperty =
DependencyProperty.Register ("Color", typeof (Color), typeof (SolidColorBrush));
+ public static readonly DependencyProperty ColorProperty =
DependencyProperty.Lookup (Kind.SOLIDCOLORBRUSH, "Color");
-
public SolidColorBrush ()
{
+ native = NativeMethods.solid_color_brush_new ();
}
-
+ public SolidColorBrush (Color c) : this ()
+ {
+ SetValue (ColorProperty, c);
+ }
+
public Color Color {
get { return (Color) GetValue (ColorProperty); }
set { SetValue (ColorProperty, value); }
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches