aewarnick Posted June 7, 2003 Posted June 7, 2003 class BackgrdBrsh : Brush { Color color1= SystemColors.Control; Color color2= SystemColors.Control; int degree=20; public Color Color1 { get{return color1;} set{color1 = value;} } public Color Color2 { get{return color2;} set{color2 = value;} } public int Degree { get{return degree;} set{degree = value;} } } BackgrdBrsh does not implement inherited abstract member 'System.Drawing.Brush.Clone()' I am not trying to clone the brush, just inherit from it to make my own custom Brush object. Just like the LinearGradientBrush did, apparently. Quote C#
aewarnick Posted June 7, 2003 Author Posted June 7, 2003 I am guessing that it is impossible so I am just creating my own new class without inheritance. The problem is that I cannot get the properties of the class to show up in the designer like Size's properties - Width and Height. And Font has a whole bunch of properties in the designer. How would I go about doing that? Quote C#
AndreRyan Posted June 7, 2003 Posted June 7, 2003 Brushes don't show up in the designer, their code classes. I think the Brush class is marked as uninheritable. You just declare a public property, no idea how in C# Quote .Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
aewarnick Posted June 7, 2003 Author Posted June 7, 2003 Yep, figured that out. Thank you. Does anyone know the answer to the question above? Quote C#
AndreRyan Posted June 8, 2003 Posted June 8, 2003 To display the font sub settings just have a Font Get/Set, the designer will place a drop+ next to it automatically Public Properties will appear in the designer even if you don't want them to(unless theres a DoNotShowInDesigner Attribute) just Inherit Windows.Forms.Control to use it as a control Quote .Net allows software to be written for any version of Windows and not break like Unmanaged applications unless using Unmanaged procedures like APIs. If your program uses large amounts of memory but releases it when something else needs it, then what's the problem?
aewarnick Posted June 8, 2003 Author Posted June 8, 2003 I don't want the Font properties. They are there. This is my class: public class aBrush { Color color1= SystemColors.Control; Color color2= SystemColors.Control; int rotation=20; //----------------------------- public aBrush(Color c1, Color c2, int rot) { Color1= c1; Color2= c2; Rotation= rot; } public aBrush(Color c1) { Color1= c1; } public aBrush() { } //----------------------------- public Color Color1 { get{return color1;} set{color1=value;} } //----------------------------- public Color Color2 { get{return color2;} set{color2=value;} } //----------------------------- public int Rotation { get{return rotation;} set{rotation=value;} } } //end class aBrush That class is inside another class that shows up in the designer along with it's properties. But the above class only displays in the designer as the class name. There is no "+ node" there to set the properties of this class. That is what I need. Quote C#
*Gurus* divil Posted June 8, 2003 *Gurus* Posted June 8, 2003 You need to specify a typeconverter for that class using the TypeConverter attribute. Make a very simple typeconverter class that just inherits from ExpandableObjectConverter. I gave someone an example of doing what you're trying to do before, try searching the forum for ExpandableObjectConverter. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted June 8, 2003 Author Posted June 8, 2003 (edited) I had to look for TypeConverter to find it but I'll post back with the results of my efforts. It is here: http://www.xtremedotnettalk.com/showthread.php?s=&threadid=70895&highlight=TypeConverter What is this line in C# *this one*<TypeConverter(GetType(ExpandableObjectConverter))> _ Public Class ExpandyClass I am assuming: [ TypeConverter(typeof(ExpandableObjectConverter)) ] If I am not right please correct. Edited June 8, 2003 by aewarnick Quote C#
*Gurus* divil Posted June 9, 2003 *Gurus* Posted June 9, 2003 That is correct. Does it work? Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted June 9, 2003 Author Posted June 9, 2003 No because I don't understand what the first class is for that creates an instance of the second class and then returns it. Public Class ClassWithProperty Private _Expandy As ExpandyClass Public Sub New() _Expandy = New ExpandyClass() End Sub Public Property Expandy() As ExpandyClass Get Return _Expandy End Get Set(ByVal Value As ExpandyClass) _Expandy = Value End Set End Property End Class Here is my code public class FormBrushClass { FormBrush FB=new FormBrush(); public FormBrush FormBr { get{return FB;} set{FB=value;} } } /// <summary> /// Colors the BackGround of the Form. /// </summary> [ TypeConverter(typeof(ExpandableObjectConverter)) ] public class FormBrush { Color c1= SystemColors.Control; Color c2= SystemColors.Control; Rectangle fiStartEndArea=new Rectangle(0,0,100,100); int rot=20; //----------------------------- public FormBrush(Color color1, Color color2, Rectangle fillStartEndArea, int rotation) { Color1= color1; Color2= color2; FillStartEndArea= fillStartEndArea; Rotation= rotation; } public FormBrush(Color color1) { Color1= color1; } public FormBrush() { } //----------------------------- public Color Color1 { get{return c1;} set{c1=value;} } //----------------------------- public Color Color2 { get{return c2;} set{c2=value;} } //----------------------------- public Rectangle FillStartEndArea { get{return fiStartEndArea;} set{fiStartEndArea=value;} } //----------------------------- public int Rotation { get{return rot;} set{rot=value;} } } //end class FormBrush //---------------------------- FormBrush backgrdBrush=null; /// <summary> /// A brush to paint the background any color you want. Will always be behind the image. /// </summary> public FormBrush BackgrdBrush { get{return backgrdBrush;} set{backgrdBrush=value; this.Invalidate();} } Quote C#
*Gurus* divil Posted June 9, 2003 *Gurus* Posted June 9, 2003 So what happens when the propertygrid is pointed at the first class? Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted June 20, 2003 Author Posted June 20, 2003 I don't understand why I need that first class: FormBrushClass. Can you explain why I need it and how to point the property grid to that class? Quote C#
*Gurus* divil Posted June 20, 2003 *Gurus* Posted June 20, 2003 You said you wanted to make your class exandable in the propertygrid, which indicates it's going to be exposed as a member of another class. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted June 20, 2003 Author Posted June 20, 2003 Ok I understand that. It is exposed as a MEMBER of another class. Now how can I point the compiler to the first class when my code uses the second class and not the first at all? Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.