I have a font class that I am trying to develop that provides similar editing in the property browser as the way you edit fonts for WebControls. The problem I am having is if in my control I set one instance of font class to handle the font needs of the title in my control and another instance of my font class to handle the font needs of the body content they don?t work properly. The way I understand it is that the designer treats each instance of my font class as a top level property and loads it into memory but it doesn't load sub properties of the font class which is exposed as a property. Ok well great but upon recreation in the type converter if both instance read the sub properties from the class definition rather from an instance then how da-heck can I have 2 separate instances that act independently of each other. The way they act in the designer now is if I change a sub-property for the title which has it's own instance of font class it also changes the sub-properties of the body content which has its own instance of font class. Hope this makes since and any ideas on how this situation is handled. Here is snippet of how I coded the font properties of the control.
public FontInfo UserNameFont{get{return font2;}set{}}
internal FontInfo font2 = new FontInfo();
public FontInfo Font{get{return font1;}set{}}
internal FontInfo font1 = new FontInfo();
//FontInfo class
[TypeConverter(typeof(FontInfoConverter))]
public class FontInfo
{
internal string name = "Verdana";
internal string names = "Verdana";
internal bool italic = false;
internal bool underline = false;
internal bool strikeout = false;
internal bool overline = false;
internal bool bold = false
internal string size = "12px";
[Editor(typeof(System.Drawing.Design.FontNameEditor), typeof(UITypeEditor))]
[TypeConverter(typeof(FontInfoNameConverter)), NotifyParentPropertyAttribute(true)]
[DefaultValue(typeof(System.Drawing.FontFamily),"Verdana")]
public string Name{get{return name;}set{name = value;}}
[NotifyParentPropertyAttribute(true)
public string Names{get{return names;}set{names = value;}}
[DefaultValue(typeof(bool), "false"), NotifyParentPropertyAttribute(true)]
public bool Italic{get{return italic;}set{italic = value;}}
[DefaultValue(typeof(bool), "false"), NotifyParentPropertyAttribute(true)]
public bool Underline{get{return underline;}set{underline = value;}}
[DefaultValue(typeof(bool), "false"), NotifyParentPropertyAttribute(true)]
public bool Strikeout{get{return strikeout;}set{strikeout = value;}}
[DefaultValue(typeof(bool), "false"), NotifyParentPropertyAttribute(true)]
public bool Overline{get{return overline;}set{overline = value;}}
[DefaultValue(typeof(bool), "false"), NotifyParentPropertyAttribute(true)]
public bool Bold{get{return bold;}set{ bold = value;}}
public string Size{get{return size;}set{size = value;}}
}
Then I was planning on the help of the type converter for detecting which instance was being changed and change the sub-properties of each fontinfo for me which in turn are wired to the rendered output respectively. But because each instance depends on the same class definition for sub-property values it will not work independently. Any suggestions other than, duplicating the fontinfo class with a different name and type converter. I was trying to somehow grab the variable name of each instance in the font converter and change that particular instances sub-properties... but again the way I understand it even if I do figure out how to do this it still won't work properly because both instances are sharing the same set of sub-properties even though both where declared as a new instance. Any ideas?
Answering a question increases your knowledge asking a question shows your Intelligence!