Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

C#
Posted

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?

C#
Posted

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#

.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?
Posted

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

.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?
Posted

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.

C#
  • *Gurus*
Posted
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.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted (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 by aewarnick
C#
Posted

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();}
			}

C#
  • 2 weeks later...
Posted

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?

C#

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...