[Mono-devel-list] Patch for System.Drawing.Design

A - Soft Technologies A-Soft at A-SoftTech.com
Tue Jun 17 05:19:04 EDT 2003


Hi,

anybody please review and commit that patch for the System.Drawing.Design
namespace.

This patch may need my other patches to System.Componentmodel namespace
which are still not commited. Also when commiting this patch you have to
delete the file IDesignerHost.cs in
mcs\class\System.Drawing\System.Drawing.Design for it to work correctly
(that file does not belong there)

A.Nahr

Index: CategoryNameCollection.cs
===================================================================
RCS file:
/mono/mcs/class/System.Drawing/System.Drawing.Design/CategoryNameCollection.
cs,v
retrieving revision 1.1
diff -u -r1.1 CategoryNameCollection.cs
--- CategoryNameCollection.cs 1 Dec 2002 01:17:59 -0000 1.1
+++ CategoryNameCollection.cs 17 Jun 2003 09:12:18 -0000
@@ -1,9 +1,12 @@
+//
 // System.Drawing.Design.CategoryNameCollection.cs
 //
-// Author:
+// Authors:
 //  Alejandro Sánchez Acosta
+//  Andreas Nahr (ClassDevelopment at A-SoftTech.com)
 //
 // (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
 //

 using System.Collections;
@@ -12,46 +15,34 @@
 {
  public sealed class CategoryNameCollection : ReadOnlyCollectionBase
  {
-  private int index;

-  [MonoTODO]
   public CategoryNameCollection (CategoryNameCollection value) {
-   throw new NotImplementedException ();
+   InnerList.AddRange (value);
   }

-  [MonoTODO]
   public CategoryNameCollection(string[] value) {
-   throw new NotImplementedException ();
+   InnerList.AddRange (value);
   }

-  [MonoTODO]
   public string this[int index] {
    get {
-    throw new NotImplementedException ();
-   }
-
-   set {
-    throw new NotImplementedException ();
+    return (string) InnerList[index];
    }
   }

-  [MonoTODO]
   public bool Contains (string value)
   {
-   throw new NotImplementedException ();
+   return InnerList.Contains (value);
   }

-
-  [MonoTODO]
   public void CopyTo (string[] array, int index)
   {
-   throw new NotImplementedException ();
+   InnerList.CopyTo (array, index);
   }

-  [MonoTODO]
   public int IndexOf (string value)
   {
-   throw new NotImplementedException ();
+   return InnerList.IndexOf (value);
   }
  }
 }
Index: ChangeLog
===================================================================
RCS file: /mono/mcs/class/System.Drawing/System.Drawing.Design/ChangeLog,v
retrieving revision 1.3
diff -u -r1.3 ChangeLog
--- ChangeLog 31 Mar 2003 04:33:48 -0000 1.3
+++ ChangeLog 17 Jun 2003 09:12:18 -0000
@@ -1,4 +1,8 @@
-2003-03-31  Alan Tam <Tam at SiuLung.com>

+2003-06-18  Andreas Nahr <ClassDevelopment at A-SoftTech.com>

 * CategoryNameCollection.cs
 * ToolboxItemCollection.cs: Implemented

 * PropertyValueItem.cs: Implemented

+ * IDesignerHost.cs: Deleted (not defined in this namespace)
+
+ * IToolboxService.cs: Fixed missing imports, added missing interface
declarations

+ * ToolboxComponentsCreatingEventArgs.cs: Fixed missing imports

 * ToolboxItem.cs: Fixed missing imports, Partially implemented

 * UITypeEditor.cs: Implemented

 * UITypeEditorEditStyle.cs: Fixed incorrect values

2003-03-31  Alan Tam <Tam at SiuLung.com>



  * UITypeEditor.cs: Added

  * PaintValueEventArgs.cs: Fixed typo in namespace

Index: IToolboxService.cs
===================================================================
RCS file:
/mono/mcs/class/System.Drawing/System.Drawing.Design/IToolboxService.cs,v
retrieving revision 1.1
diff -u -r1.1 IToolboxService.cs
--- IToolboxService.cs 1 Dec 2002 01:17:59 -0000 1.1
+++ IToolboxService.cs 17 Jun 2003 09:12:19 -0000
@@ -1,18 +1,22 @@
+//
 // System.Drawing.Design.IToolboxService.cs
 //
-// Author:
+// Authors:
 // Alejandro Sánchez Acosta  <raciel at es.gnu.org>
+//  Andreas Nahr (ClassDevelopment at A-SoftTech.com)
 //
 // (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
 //

 using System.Collections;
+using System.ComponentModel.Design;
 using System.Runtime.InteropServices;

 namespace System.Drawing.Design
 {
- //[Guid("")]
- [InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
+ [Guid("4BACD258-DE64-4048-BC4E-FEDBEF9ACB76"),
+ InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
  public interface IToolboxService
  {
   CategoryNameCollection CategoryNames {get;}
@@ -27,6 +31,10 @@

   void AddLinkedToolboxItem (ToolboxItem toolboxItem, string category,
IDesignerHost host);

+  void AddToolboxItem (ToolboxItem toolboxItem, String category);
+
+  void AddToolboxItem (ToolboxItem toolboxItem);
+
   ToolboxItem DeserializeToolboxItem (object serializedObject);

   ToolboxItem DeserializeToolboxItem (object serializedObject,
IDesignerHost host);
@@ -34,6 +42,14 @@
   ToolboxItem GetSelectedToolboxItem ();

   ToolboxItem GetSelectedToolboxItem (IDesignerHost host);
+
+  ToolboxItemCollection GetToolboxItems ();
+
+  ToolboxItemCollection GetToolboxItems (IDesignerHost host);
+
+  ToolboxItemCollection GetToolboxItems (String category);
+
+  ToolboxItemCollection GetToolboxItems (String category, IDesignerHost
host);

   bool IsSupported (object serializedObject, ICollection filterAttributes);

Index: PropertyValueItem.cs
===================================================================
RCS file:
/mono/mcs/class/System.Drawing/System.Drawing.Design/PropertyValueItem.cs,v
retrieving revision 1.2
diff -u -r1.2 PropertyValueItem.cs
--- PropertyValueItem.cs 18 Apr 2003 18:05:29 -0000 1.2
+++ PropertyValueItem.cs 17 Jun 2003 09:12:19 -0000
@@ -1,68 +1,60 @@
+//
 // System.Drawing.Design.PropertyValueItem.cs
 //
-// Author:
-//     Alejandro Sánchez Acosta  <raciel at es.gnu.org>
+// Authors:
+//  Alejandro Sánchez Acosta  <raciel at es.gnu.org>
+//  Andreas Nahr (ClassDevelopment at A-SoftTech.com)
 //
 // (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
 //

 using System.Drawing;
-using System.Drawing.Imaging;
-using System.ComponentModel;

 namespace System.Drawing.Design
 {
  public class PropertyValueUIItem
  {
-  [MonoTODO]
+
+  private Image uiItemImage;
+  private PropertyValueUIItemInvokeHandler handler;
+  private string tooltip;
+
   public PropertyValueUIItem (Image uiItemImage,
-          PropertyValueUIItemInvokeHandler handler,
-          string tooltip)
+   PropertyValueUIItemInvokeHandler handler, string tooltip)
   {
-   throw new NotImplementedException ();
+   this.uiItemImage = uiItemImage;
+   this.handler = handler;
+   this.tooltip = tooltip;
   }

-  [MonoTODO]
   public virtual Image Image
   {
    get
    {
-    throw new NotImplementedException ();
+    return uiItemImage;
    }
   }

-  [MonoTODO]
   public virtual PropertyValueUIItemInvokeHandler InvokeHandler
   {
    get
    {
-    throw new NotImplementedException ();
-   }
-
-   set
-   {
-    throw new NotImplementedException ();
+    return handler;
    }
   }

-  [MonoTODO]
   public virtual string ToolTip
   {
    get
    {
-    throw new NotImplementedException ();
-   }
-
-   set
-   {
-    throw new NotImplementedException ();
+    return tooltip;
    }
   }

-  [MonoTODO]
   public virtual void Reset()
   {
-   throw new NotImplementedException ();
+   // To be overriden in child classes
   }
  }
 }
Index: ToolboxComponentsCreatingEventArgs.cs
===================================================================
RCS file:
/mono/mcs/class/System.Drawing/System.Drawing.Design/ToolboxComponentsCreati
ngEventArgs.cs,v
retrieving revision 1.1
diff -u -r1.1 ToolboxComponentsCreatingEventArgs.cs
--- ToolboxComponentsCreatingEventArgs.cs 1 Dec 2002 01:17:59 -0000 1.1
+++ ToolboxComponentsCreatingEventArgs.cs 17 Jun 2003 09:12:19 -0000
@@ -1,3 +1,4 @@
+//
 // System.Drawing.Design.ToolboxComponentsCreatingEventArgs.cs
 //
 // Author:
@@ -5,6 +6,8 @@
 //
 // (C) Alejandro Sánchez Acosta
 //
+
+using System.ComponentModel.Design;

 namespace System.Drawing.Design
 {
Index: ToolboxItem.cs
===================================================================
RCS file:
/mono/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItem.cs,v
retrieving revision 1.1
diff -u -r1.1 ToolboxItem.cs
--- ToolboxItem.cs 1 Dec 2002 01:17:59 -0000 1.1
+++ ToolboxItem.cs 17 Jun 2003 09:12:20 -0000
@@ -1,12 +1,17 @@
+//
 // System.Drawing.Design.ToolboxItem.cs
 //
-// Author:
+// Authors:
 // Alejandro Sánchez Acosta
+//  Andreas Nahr (ClassDevelopment at A-SoftTech.com)
 //
 // (C) Alejandro Sánchez Acosta
+// (C) 2003 Andreas Nahr
+//

 using System.Collections;
 using System.ComponentModel;
+using System.ComponentModel.Design;
 using System.Drawing;
 using System.Reflection;
 using System.Runtime.Serialization;
@@ -19,19 +24,16 @@

   private AssemblyName assembly;
   private Bitmap bitmap;
-  private ICollection filter;
-  private string displayname;
-  private bool locked;
-  private string name;
+  private ICollection filter = new ToolboxItemFilterAttribute[0];
+  private string displayname = "";
+  private bool locked = false;
+  private string name = "";

-  [MonoTODO]
   public ToolboxItem() {
-   throw new NotImplementedException ();
   }

-  [MonoTODO]
   public ToolboxItem (Type toolType) {
-   throw new NotImplementedException ();
+   Initialize (toolType);
   }

   public AssemblyName AssemblyName {
@@ -40,6 +42,7 @@
    }

    set {
+    CheckUnlocked ();
     assembly = value;
    }
   }
@@ -50,6 +53,7 @@
    }

    set {
+    CheckUnlocked ();
     bitmap = value;
    }
   }
@@ -60,6 +64,7 @@
    }

    set {
+    CheckUnlocked ();
     displayname = value;
    }
   }
@@ -70,6 +75,7 @@
    }

    set {
+    CheckUnlocked ();
     filter = value;
    }
   }
@@ -78,10 +84,6 @@
    get {
     return locked;
    }
-
-   set {
-    locked = value;
-   }
   }

   public string TypeName {
@@ -90,26 +92,27 @@
    }

    set {
+    CheckUnlocked ();
     name = value;
    }
   }

-  [MonoTODO]
   protected void CheckUnlocked ()
   {
-   throw new NotImplementedException ();
+   throw new InvalidOperationException ("The ToolboxItem is locked");
   }

-  [MonoTODO]
   public IComponent[] CreateComponents ()
   {
-   throw new NotImplementedException ();
+   return CreateComponents (null);
   }

-  [MonoTODO]
   public IComponent[] CreateComponents (IDesignerHost host)
   {
-   throw new NotImplementedException ();
+   OnComponentsCreating (new ToolboxComponentsCreatingEventArgs (host));
+   IComponent[] Comp = CreateComponentsCore (host);
+   OnComponentsCreated ( new ToolboxComponentsCreatedEventArgs (Comp));
+   return Comp;
   }

   [MonoTODO]
@@ -124,16 +127,24 @@
    throw new NotImplementedException ();
   }

-  [MonoTODO]
   public override bool Equals (object obj)
   {
-   throw new NotImplementedException ();
+   // FIXME: too harsh??
+   if (!(obj is ToolboxItem))
+    return false;
+   if (obj == this)
+    return true;
+   return ((ToolboxItem) obj).AssemblyName.Equals (assembly) &&
+    ((ToolboxItem) obj).Locked.Equals (locked) &&
+    ((ToolboxItem) obj).TypeName.Equals (name) &&
+    ((ToolboxItem) obj).DisplayName.Equals (displayname) &&
+    ((ToolboxItem) obj).Bitmap.Equals (bitmap);
   }

-  [MonoTODO]
   public override int GetHashCode ()
   {
-   throw new NotImplementedException ();
+   // FIXME: other algorithm?
+   return string.Concat (name, displayname).GetHashCode ();
   }

   [MonoTODO]
@@ -145,6 +156,14 @@
   [MonoTODO]
   public virtual void Initialize (Type type)
   {
+   // assembly = // FIXME we need to get the AssemblyName data from
somewhere or create a new one
+   displayname = type.Name;
+   name = type.FullName;
+   // MS also seems to create the bitmap here
+   bitmap = new Bitmap (16, 16); // FIXME set some default bitmap !?
+
+   filter = type.GetCustomAttributes (typeof (ToolboxItemFilterAttribute),
true);
+
    throw new NotImplementedException ();
   }

@@ -154,22 +173,19 @@
    throw new NotImplementedException ();
   }

-  [MonoTODO]
   public void Lock ()
   {
-   throw new NotImplementedException ();
+   locked = true;
   }

-  [MonoTODO]
   protected virtual void OnComponentsCreated
(ToolboxComponentsCreatedEventArgs args)
   {
-   throw new NotImplementedException ();
+   this.ComponentsCreated (this, args);
   }

-  [MonoTODO]
   protected virtual void OnComponentsCreating
(ToolboxComponentsCreatingEventArgs args)
   {
-   throw new NotImplementedException ();
+   this.ComponentsCreating (this, args);
   }

   [MonoTODO]
@@ -178,10 +194,13 @@
    throw new NotImplementedException ();
   }

-  [MonoTODO]
   public override string ToString()
   {
-   throw new NotImplementedException ();
+   return displayname;
   }
+
+  public event ToolboxComponentsCreatedEventHandler ComponentsCreated;
+
+  public event ToolboxComponentsCreatingEventHandler ComponentsCreating;
  }
 }
Index: ToolboxItemCollection.cs
===================================================================
RCS file:
/mono/mcs/class/System.Drawing/System.Drawing.Design/ToolboxItemCollection.c
s,v
retrieving revision 1.1
diff -u -r1.1 ToolboxItemCollection.cs
--- ToolboxItemCollection.cs 31 Mar 2003 12:45:58 -0000 1.1
+++ ToolboxItemCollection.cs 17 Jun 2003 09:12:20 -0000
@@ -1,10 +1,12 @@
 //
-// System.Drawing.Design.ToolboxItemCollection
+// System.Drawing.Design.ToolboxItemCollection.cs
 //
 // Authors:
-//      Martin Willemoes Hansen (mwh at sysrq.dk)
+//  Martin Willemoes Hansen (mwh at sysrq.dk)
+//  Andreas Nahr (ClassDevelopment at A-SoftTech.com)
 //
 // (C) 2003 Martin Willemoes Hansen
+// (C) 2003 Andreas Nahr
 //

 using System.Collections;
@@ -13,42 +15,34 @@
 {
  public sealed class ToolboxItemCollection : ReadOnlyCollectionBase
  {
-  [MonoTODO]
+
   public ToolboxItemCollection (ToolboxItem[] value)
   {
+   InnerList.AddRange (value);
   }

-  [MonoTODO]
   public ToolboxItemCollection (ToolboxItemCollection value)
   {
+   InnerList.AddRange (value);
   }

   public ToolboxItem this [int index] {
-   [MonoTODO]
-   get { throw new NotImplementedException(); }
+   get { return (ToolboxItem) InnerList[index]; }
   }

-  [MonoTODO]
   public bool Contains (ToolboxItem value)
   {
-   throw new NotImplementedException();
+   return InnerList.Contains (value);
   }

-  [MonoTODO]
   public void CopyTo (ToolboxItem[] array, int index)
   {
-   throw new NotImplementedException();
+   InnerList.CopyTo (array, index);
   }

-  [MonoTODO]
   public int IndexOf (ToolboxItem value)
   {
-   throw new NotImplementedException();
-  }
-
-  [MonoTODO]
-  ~ToolboxItemCollection()
-  {
+   return InnerList.IndexOf (value);
   }
  }
 }
Index: UITypeEditor.cs
===================================================================
RCS file:
/mono/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditor.cs,v
retrieving revision 1.1
diff -u -r1.1 UITypeEditor.cs
--- UITypeEditor.cs 31 Mar 2003 04:33:48 -0000 1.1
+++ UITypeEditor.cs 17 Jun 2003 09:12:20 -0000
@@ -1,66 +1,58 @@
-// System.Drawing.Design.UITypeEditor.cs

+//
+// System.Drawing.Design.UITypeEditor.cs
+//
+// Authors:
+//  Alan Tam Siu Lung <Tam at SiuLung.com>
//  Andreas Nahr (ClassDevelopment at A-SoftTech.com)
+//
+// (C) 2003 Alan Tam Siu Lung <Tam at SiuLung.com>
// (C) 2003 Andreas Nahr
 //

-// Author:

-//     Alan Tam Siu Lung <Tam at SiuLung.com>

-//

-// (C) 2003 Alan Tam Siu Lung <Tam at SiuLung.com>

-//

-

-using System;

+using System;
 using System.ComponentModel;

-

 namespace System.Drawing.Design

-{

- /// <summary>

- /// Summary description for UITypeEditor.

- /// </summary>

- public class UITypeEditor

- {

-  [MonoTODO]

-  public UITypeEditor()

-  {

-  }

-

-  [MonoTODO]

-  public virtual object EditValue(ITypeDescriptorContext context,

-      IServiceProvider provider, object value)

-  {

-   throw new NotImplementedException ();

-  }

-

-  public object EditValue(IServiceProvider provider, object value)

-  {

-   throw new NotImplementedException ();

-  }

-

-  [MonoTODO]

-  public virtual UITypeEditorEditStyle GetEditStyle(ITypeDescriptorContext
context)

-  {

-   throw new NotImplementedException ();

-  }

-

-  [MonoTODO]

-  public UITypeEditorEditStyle GetEditStyle()

-  {

-   throw new NotImplementedException ();

-  }

-

-  [MonoTODO]

-  public virtual bool GetPaintValueSupported(ITypeDescriptorContext
context)

-  {

-   throw new NotImplementedException ();

-  }

-

-  [MonoTODO]

-  public void PaintValue(object value, Graphics canvas, Rectangle
rectangle)

-  {

-   throw new NotImplementedException ();

-  }

-

-  [MonoTODO]

-  public virtual void PaintValue(PaintValueEventArgs e)

-  {

-   throw new NotImplementedException ();

-  }

- }

+{
+ public class UITypeEditor
+ {
+
+  public UITypeEditor()
+  {
+  }
+
+  public virtual object EditValue (ITypeDescriptorContext context,
+   IServiceProvider provider, object value)
+  {
+   // We already stated that we can't edit ;)
+   return value;
+  }

+  public object EditValue(IServiceProvider provider, object value)
+  {
+   return EditValue (null, provider, value);
+  }

+  public virtual UITypeEditorEditStyle GetEditStyle (ITypeDescriptorContext
context)
+  {
+   return UITypeEditorEditStyle.None;
+  }

+  public UITypeEditorEditStyle GetEditStyle ()
+  {
+   return GetEditStyle (null);
+  }

+  public bool GetPaintValueSupported ()
+  {
+   return GetPaintValueSupported (null);
+  }

+  public virtual bool GetPaintValueSupported (ITypeDescriptorContext
context)
+  {
+   return false;
+  }

+  public void PaintValue (object value, Graphics canvas, Rectangle
rectangle)
+  {
+   PaintValue (new PaintValueEventArgs (null, value, canvas, rectangle));
+  }

+  public virtual void PaintValue (PaintValueEventArgs e)
+  {
+   // LAMESPEC: Did not find info in the docs if this should do something
here.
+   // Usually you would expect, that this class gets inherited and this
overridden,
+   // but on the other hand the class is not abstract. Could never observe
it did paint anything
+   return;
+  }
+ }
 }

Index: UITypeEditorEditStyle.cs
===================================================================
RCS file:
/mono/mcs/class/System.Drawing/System.Drawing.Design/UITypeEditorEditStyle.c
s,v
retrieving revision 1.1
diff -u -r1.1 UITypeEditorEditStyle.cs
--- UITypeEditorEditStyle.cs 1 Apr 2002 23:27:46 -0000 1.1
+++ UITypeEditorEditStyle.cs 17 Jun 2003 09:12:20 -0000
@@ -8,8 +8,8 @@
 namespace System.Drawing.Design

 {

  public enum  UITypeEditorEditStyle{

-   DropDown=1,

+   DropDown=3,

    Modal=2,

-   None=3

+   None=1

  }

 }




More information about the Mono-devel-list mailing list