<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet type='text/xsl' href='http://badcorporatelogo.spaces.live.com/mmm2008-07-24_12.50/rsspretty.aspx?rssquery=en-US;http%3a%2f%2fbadcorporatelogo.spaces.live.com%2fcategory%2fProgramming%2ffeed.rss' version='1.0'?><rss version="2.0" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:msn="http://schemas.microsoft.com/msn/spaces/2005/rss" xmlns:live="http://schemas.microsoft.com/live/spaces/2006/rss" xmlns:dcterms="http://purl.org/dc/terms/" xmlns:cf="http://www.microsoft.com/schemas/rss/core/2005" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>BadCorporateLogo: Programming</title><description /><link>http://badcorporatelogo.spaces.live.com/?_c11_BlogPart_BlogPart=blogview&amp;_c=BlogPart&amp;partqs=catProgramming</link><language>en-US</language><pubDate>Mon, 06 Oct 2008 01:13:06 GMT</pubDate><lastBuildDate>Mon, 06 Oct 2008 01:13:06 GMT</lastBuildDate><generator>Microsoft Spaces v1.1</generator><docs>http://www.rssboard.org/rss-specification</docs><ttl>60</ttl><cf:parentRSS>http://badcorporatelogo.spaces.live.com/blog/feed.rss</cf:parentRSS><live:type>blogcategory</live:type><live:identity><live:id>4894130425169106705</live:id><live:alias>badcorporatelogo</live:alias></live:identity><cf:listinfo><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="typelabel" label="Type" /><cf:group ns="http://schemas.microsoft.com/live/spaces/2006/rss" element="tag" label="Tag" /><cf:group element="category" label="Category" /><cf:sort element="pubDate" label="Date" data-type="date" default="true" /><cf:sort element="title" label="Title" data-type="string" /><cf:sort ns="http://purl.org/rss/1.0/modules/slash/" element="comments" label="Comments" data-type="number" /></cf:listinfo><item><title>Managed Designer Resources: The Restaurant Supply Store</title><link>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!301.entry</link><description>&lt;p&gt;Recently, I've been pretty swamped by work. Nights, weekends, holidays... I've been in the office so long, my wife has forgotten my name! This year, crunch time is like the playoffs - I'm not shaving and my beard is growing out. It's my first time with a beard, really. Honestly, it drives me nuts. I hate having food or drinks touch my my moustache and leave a lasting flavor. So besides working all the time, I'm also constantly wiping my mouth. Bleah! &lt;p&gt;Anyway, I've gotten a few messages from people asking for more about designers. Well, I still don't have time to put into writing. I did a couple weeks ago, but a hardware failure destroyed several hours of work and I didn't feel like starting again right away. Then I got too busy. &lt;p&gt;So instead of writing my own article on designers, I'm going to post a number of links where you can get information from the source: MSDN. &lt;p&gt;If I'd found the second link earlier, I probably wouldn't have written one of my posts since it covers the same stuff. I think I remember reading it several years ago, but I didn't find it when I looked again. &lt;p&gt;Here's a topic on developing components: &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/51sc2s5c(VS.71).aspx"&gt;http://msdn.microsoft.com/en-us/library/51sc2s5c(VS.71).aspx&lt;/a&gt; &lt;p&gt;This specific sub-topic discusses design-time attributes: &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/tk67c2t8(VS.71).aspx"&gt;http://msdn.microsoft.com/en-us/library/tk67c2t8(VS.71).aspx&lt;/a&gt; &lt;p&gt;That page links to the docs on customizing the design-time, which is what I'm writing about: &lt;p&gt;&lt;a href="http://msdn.microsoft.com/en-us/library/37899azc(VS.71).aspx"&gt;http://msdn.microsoft.com/en-us/library/37899azc(VS.71).aspx&lt;/a&gt; &lt;p&gt;The set of topics above actually provides a great deal of information and several samples. I think that's the best set of documentation for this kind of stuff. &lt;p&gt;After having posted these links, I'll try to focus on XNA Framework-specific customizations from now on. It'll probably be another week before my schedule is back to normal. After that, I'll be back to writing.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4894130425169106705&amp;page=RSS%3a+Managed+Designer+Resources%3a+The+Restaurant+Supply+Store&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=badcorporatelogo.spaces.live.com&amp;amp;GT1=badcorporatelogo"&gt;</description><comments>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!301.entry#comment</comments><guid isPermaLink="true">http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!301.entry</guid><pubDate>Sun, 13 Jul 2008 02:26:54 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://badcorporatelogo.spaces.live.com/blog/cns!43EB71B104A2D711!301/comments/feed.rss</wfw:commentRss><wfw:comment>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!301.entry#comment</wfw:comment><dcterms:modified>2008-07-13T02:26:54Z</dcterms:modified></item><item><title>Making a Designer of Your Own - House Salad</title><link>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!286.entry</link><description>&lt;p&gt;Last time, I started to write about the managed designer infrastructure in Visual Studio. This infrastructure is all part of the .NET Framework's &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.aspx"&gt;System.ComponentModel&lt;/a&gt; namespace, and so it naturally deals with components (things that implement &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.icomponent.aspx"&gt;System.ComponentModel.IComponent&lt;/a&gt;) as the base unit. The component model is meant to provide a generic framework for any kind of designer, but in Visual Studio it was implemented specifically to support Windows Forms and source code generation. It was later made more generic, with the intention of supporting any components, but there is still a lot of implementation that works only with Controls. &lt;p&gt;So what does the Control designer have to do with making a designer for XNA Framework game components? Nothing, except that in order to re-use the existing infrastructure, you'll need to know a bit about Control designers. &lt;p&gt;Combining all the ingredients available in the Component Model to create a visual programming experience for XNA game components takes a fair bit of background knowledge. As I said in &lt;a href="http://badcorporatelogo.spaces.live.com/blog/cns!43EB71B104A2D711!283.entry"&gt;my last post&lt;/a&gt;, you can't just look at my recipe for a Game State designer and know how to build your own Input designer. The bulk of the implementation isn't in my code - it's in the designer infrastructure. If you want to make your own dishes, you need to know what's in the pantry, and how to combine certain things to get the desired flavor. &lt;p&gt;Last time, I showed how any class deriving from Component will support a design view in Visual Studio. This design view is based on the concept of &lt;a href="http://en.wikipedia.org/wiki/Object_composition"&gt;composition&lt;/a&gt;. You add objects to the class by dragging them from the Toolbox onto the design surface. Doing so results in a field being declared for the new object instance, and code to instantiate and initialize it. The designer lets you select and name objects on the design surface so that you can further edit them in the Properties Window. After making these changes, the entire design surface is serialized to code so that the composite class can be compiled and then re-created at runtime. &lt;p&gt;When you design a Control, the objects on the design surface are usually represented at design time by the same objects you'll use at runtime. So when you add a Button to the Form designer, a real Button instance is created on the design surface to represent the Button instance you'll get at runtime. When you change the Text property on the Button in the Properties Window, the text on the button changes on the design surface because you've actually changed the Text property of that Button instance. &lt;p&gt;You can change the BackColor and ForeColor properties for more visual evidence that the Properties Window is letting you edit the actual control instance on the design surface. At first glance, you might imagine that the Properties Window is using &lt;a href="http://msdn.microsoft.com/en-us/library/system.reflection.aspx"&gt;reflection&lt;/a&gt; to enumerate the properties of the selected object, get their values, and allow you to set them. &lt;p&gt;That makes sense and might even seem pretty obvious at first... But if you change the Visible property to false, suddenly things are not so obvious. The button is still visible on the design surface! (If you aren't sure what Visible is intended to do, you can run the project at this point to see that the button isn't visible at runtime.) &lt;p&gt;&lt;a href="http://rxdrja.bay.livefilestore.com/y1poZxlZcsmKwioAFePnPGQQTcqPYaY_RJxVYaQXvsf-k9ITEJdn9fR7z15os_d3qIy6eYio6N6bvXeiTgO5R7_BA?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=161 alt=image src="http://byfiles.storage.msn.com/y1p49FnH5vGVi6A_NreCB-s__-aF0txWy08RTlxZwtO-KTr8UT_JxeGMpR299D18JuyUCrfIUziCOOwTJw5UKT6BeAHOfjLGU8x?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Figure 1&lt;/strong&gt; - Something invisible is revealed when you set the Visible property to false. &lt;p&gt;The reason the Button didn't disappear is because the Visible property in the Properties Window doesn't belong to the Button the way the Text, BackColor, and ForeColor properties do. Instead, it belongs to the Button's &lt;em&gt;designer&lt;/em&gt;. :-) &lt;p&gt;At this point, things are undoubtedly going to get confusing. The term &amp;quot;designer&amp;quot; is overloaded, and I need to use it to mean something other than the visually-oriented composition editor we've been discussing until now. &lt;p&gt;Every component created on the design surface has a designer associated with it. The designer is another class that modifies the design-time appearance and behavior of the component. One role of the component designer is to filter or enhance an object's metadata. To put it another way, it can change the attributes on a component or its properties, and can remove, replace, or add properties. A designer can do this to change both the appearance and behavior of a control at design-time. &lt;p&gt;As an example, the Button's &lt;em&gt;designer&lt;/em&gt; replaces the Visible property with a different property that comes from the designer instance. In designer-speak, this is called &lt;em&gt;shadowing&lt;/em&gt;. In the Properties Window, the Visible property appears to belong to the Button, but in fact it belongs to the Button's designer. When you change the Visible property value, it's the designer's property that is changed (you don't see the effect because the designer was never visible in the first place). This prevents the Button instance from becoming invisible, which would make it hard to select or reposition it on the design surface. &lt;p&gt;If you look more closely at the properties of the Button instance, you'll notice there are a few listed that aren't actually properties of the Button class. To pick out just a few, in the Design category, you'll find &amp;quot;GenerateMember&amp;quot;, &amp;quot;Locked&amp;quot;, and &amp;quot;Modifiers&amp;quot;. These control whether the instance will be declared as a field of the class or a local variable, whether the control can be moved or resized on the design surface, and the visibility modifier of the field declaration (if there is one), respectively. Changing these properties affects the code generated for the Button instance, but they don't represent actual properties of any object on the design surface. &lt;p&gt;A basic designer implementation is provided by &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.design.componentdesigner.aspx"&gt;System.ComponentModel.Design.ComponentDesigner&lt;/a&gt;. This class makes it easy to override just the parts you want to modify. As the documentation says, you associate a designer with a component through the &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.designerattribute.aspx"&gt;DesignerAttribute&lt;/a&gt;. &lt;p&gt;Now, a word of caution when using the DesignerAttribute. Its constructor has overloads to use System.Type or System.String arguments to specify the designer's type. If you implement the designer in the same assembly as the component, you can use the System.Type constructor. However, if you implement the designer in a separate assembly, it is almost always a good idea to use the System.String constructor. The reason is that the designer is always given a reference to the component instance, and if you want the designer to be able to reference that component by its proper type, it will be dependent on the component's assembly. That precludes having a reference to the designer assembly from the component assembly, because then you have a circular dependency. So the way to avoid it is to allow you component to be ignorant of its designer, except for its name. &lt;p&gt;A very good reason to have the designer in a different assembly is because the designer will often depend on a bunch of assemblies that you don't ever need at runtime, or that maybe aren't redistributable. In fact, the designer class itself is not needed at runtime! So if you keep it in a separate assembly, then you can keep your runtime libraries lightweight and your redist small. Your customers will appreciate that! &lt;p&gt;I think I'll wrap it up here. Next time, I'll write more about how designers affect the behavior of controls on the design surface. At this point, it's also appropriate to start using code samples to illustrate, and I don't have anything ready right now.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4894130425169106705&amp;page=RSS%3a+Making+a+Designer+of+Your+Own+-+House+Salad&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=badcorporatelogo.spaces.live.com&amp;amp;GT1=badcorporatelogo"&gt;</description><comments>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!286.entry#comment</comments><guid isPermaLink="true">http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!286.entry</guid><pubDate>Wed, 11 Jun 2008 06:36:47 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://badcorporatelogo.spaces.live.com/blog/cns!43EB71B104A2D711!286/comments/feed.rss</wfw:commentRss><wfw:comment>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!286.entry#comment</wfw:comment><dcterms:modified>2008-06-11T06:36:47Z</dcterms:modified></item><item><title>Making a Designer of Your Own - A Starter Course</title><link>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!283.entry</link><description>&lt;p&gt;A couple people have e-mailed me recently about my &amp;quot;teaser&amp;quot; screen shots, because they want to know how I did it. As much as I'd like to explain the menu designer I'm working on, it's complicated. Writing long blog entries just isn't as interesting as writing code (for me, at least), so in all honesty, I'd rather work on the designer than try to explain what I'm doing. The easiest way to explain it is, I'm using the Windows Forms designer framework. It's reasonably well-documented, but not all in one place. You can't read it like a book. &lt;p&gt;Someone &lt;strike&gt;demanded&lt;/strike&gt; asked me for my source code today because he wants to build his own designer. Source code isn't the place to start in this case. That would be like looking at a big turkey dinner I just prepared, and then asking me for the recipe because you want to grill a salmon. What you really want to know is how to cook. &lt;p&gt;For that reason, I'm not going to share my recipe -- not yet, at least. Instead, I'll try to focus on explaining how to cook. Let's start with an appetizer, and work our way up to the entree. &lt;p&gt;In Visual Studio, there is already an extensible designer infrastructure for components (types that implement &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.icomponent.aspx"&gt;System.ComponentModel.IComponent&lt;/a&gt;). This infrastructure has further specialization to support Components (types that derive from &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.component.aspx"&gt;System.ComponentModel.Component&lt;/a&gt;) and Controls (types that derive from &lt;a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.control.aspx"&gt;System.Windows.Forms.Control&lt;/a&gt;). Note that the general infrastructure is for the &lt;strong&gt;IComponent&lt;/strong&gt; interface, while there is extra stuff for the &lt;strong&gt;Component&lt;/strong&gt; class, which is a default implementation of the &lt;strong&gt;IComponent &lt;/strong&gt;interface. There is even more extra stuff for &lt;strong&gt;Control&lt;/strong&gt;s and various specialized subclasses, like &lt;strong&gt;Form&lt;/strong&gt;. &lt;p&gt;The extra stuff is the interesting part. Windows Forms has an editor registered in Visual Studio that will handle any code file in a code project that contains a class declaration for a class that derives from &lt;strong&gt;Component&lt;/strong&gt;. The IDE determines this by asking the language service (the thing that gives you Intellisense) for the first class declaration in a code file. Then it uses another service (probably &lt;a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.design.ityperesolutionservice.aspx"&gt;ITypeResolutionService&lt;/a&gt;, but I forget, and it doesn't matter enough to check), to determine whether the base class of the type declaration derives from &lt;strong&gt;Component&lt;/strong&gt;. If so, then the file is treated as a &amp;quot;component&amp;quot; file. &lt;p&gt;Let's take a look at an example. &lt;h4&gt;&lt;/h4&gt; &lt;p&gt;&lt;a href="http://rxdrja.bay.livefilestore.com/y1poZxlZcsmKwhsvq0YW9f3-0IkILJRLnymJ2qVbUQwx2zZhAcMKeg4ckAf5iu1rph5-F50Gjdz0gauLwtUWieacg?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=152 alt=image src="http://by1.storage.msn.com/y1p49FnH5vGVi665VxoqNBbNaK0qZ96yWZrk_fZJvCKLWxjN03fXcxtkLzN1_61_41ViwZxrVRGjD2t5JhuNSJ0CpInXQs4vjx5?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Figure 1&lt;/strong&gt; shows a regular Class Library project in VC# Express. Look what happens when I edit the declaration for &lt;strong&gt;Class1&lt;/strong&gt; to derive from &lt;strong&gt;Component&lt;/strong&gt;. &lt;p&gt;&lt;a href="http://rxdrja.bay.livefilestore.com/y1p7jJzD1bA9ntyzN2BehoOTUjqMxC3QH1q8kp2Ze1-GyA-hmqzneEFlKgM9vv78bFrxlFwjPcBQ1q-p4ryuqwwhCFctSj20B-V?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=152 alt=image src="http://by1.storage.msn.com/y1p49FnH5vGVi5DZfNpa9oNtTNPAh5tvEOMLDusMJ0D7tTKfpwZhP3bI8B_XFF7g3H6fQOxdZNNMe6C1RjWOIX3BDhW89_vTMPU?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Figure 2&lt;/strong&gt; shows the subtle change. In the Solution Explorer, the icon next to the &lt;strong&gt;Class1.cs&lt;/strong&gt; file is the &amp;quot;component file&amp;quot; icon. Even though the file is already open in the code editor, now when you double-click on the file in Solution Explorer, it will open the Component Designer. &lt;p&gt;&lt;a href="http://rxdrja.bay.livefilestore.com/y1p7jJzD1bA9ntXGAD4W3TsNtKShcTu6jcQiXzDefMdmjkOP0mjSkWgsFO-IL8ilObSYqd-70R-vT6i8Y6ydICzfL82kzKqOxoK?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=152 alt=image src="http://by1.storage.msn.com/y1p49FnH5vGVi6-97Ql3yrmSUzI0ON8knQXomTO8eWOai8tjhjDaUyEXPAO8FYFOOUsJST8LCF156K9wVkLk3sfwIXQAZ47DMYO?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt;  &lt;p&gt;&lt;strong&gt;Figure 3&lt;/strong&gt; shows the &lt;strong&gt;Class1&lt;/strong&gt; class in the the Component Designer. &lt;p&gt;The Component Designer provides a basic, visual code editing experience. You can drag and drop components onto the &lt;strong&gt;Class1&lt;/strong&gt; design view from the Toolbox, and edit those objects in the Properties Window. The changes you make will be serialized to code in a method called &lt;strong&gt;InitializeComponent&lt;/strong&gt; in the &lt;strong&gt;Class1&lt;/strong&gt; class declaration. &lt;p&gt;After some experimentation, an observant person will note several things. First, the generated code appears in &lt;strong&gt;InitializeComponent&lt;/strong&gt;, but that function is never called. This is because the designer generally ignores everything else in the class except that function. The standard practice is to define a default constructor that calls &lt;strong&gt;InitializeComponent&lt;/strong&gt;. Since &lt;strong&gt;Class1&lt;/strong&gt; was not created from a Component template, I'll need to add that code myself. &lt;p&gt;Second, the name of &lt;strong&gt;Class1&lt;/strong&gt; in the Properties Window refers to the name of the &lt;em&gt;type&lt;/em&gt; &lt;strong&gt;Class1&lt;/strong&gt;. Every other component dropped onto the design surface has a name that refers to the name of the &lt;em&gt;member variable&lt;/em&gt; that the component is assigned to. &lt;p&gt;Third, the properties in the Properties Window aren't the properties of &lt;strong&gt;Class1&lt;/strong&gt;. If you add a new property to the class definition in &lt;strong&gt;Class1.cs&lt;/strong&gt;, it won't appear in the Properties Window at all. &lt;p&gt;For example, let's add a string property to &lt;strong&gt;Class1&lt;/strong&gt;.&lt;pre&gt;    &lt;span&gt;public&lt;/span&gt; &lt;span&gt;class&lt;/span&gt; Class1 : Component
    {
        &lt;span&gt;private&lt;/span&gt; &lt;span&gt;string&lt;/span&gt; myProperty;

        &lt;span&gt;public&lt;/span&gt; &lt;span&gt;string&lt;/span&gt; MyProperty
        {
            get { &lt;span&gt;return&lt;/span&gt; myProperty; }
            set { myProperty = &lt;span&gt;value&lt;/span&gt;; }
        }
    }&lt;/pre&gt;


&lt;p&gt;Going back to the design view, &lt;strong&gt;MyProperty&lt;/strong&gt; is nowhere to be seen. If you look closely at the Properties Window, you'll see the reason why. It shows &lt;strong&gt;Class1&lt;/strong&gt; to be an instance of System.ComponentModel.&lt;strong&gt;Component&lt;/strong&gt;. This is important -- the designer creates an instance of the component's &lt;em&gt;base class&lt;/em&gt; at design time. The same goes for editing &lt;strong&gt;Form&lt;/strong&gt;s or &lt;strong&gt;Control&lt;/strong&gt;s.
&lt;p&gt;This only applies to the &lt;em&gt;root&lt;/em&gt; component, however -- the type being designed -- and not for components that are dragged onto the design surface. Part of the reason for this is because you are changing the source code for the type as you edit it in the designer -- making it difficult to keep a compiled instance of the type-being-edited up to date with the latest changes.
&lt;p&gt;Now that you know the designer creates an instance of the base type instead of the actual type, you might already have guessed what I will do next. I'm going to add another class to the project in its own file, &lt;strong&gt;Class2.cs&lt;/strong&gt;, and declare a new class &lt;strong&gt;Class2&lt;/strong&gt; that derives from &lt;strong&gt;Class1&lt;/strong&gt;.
&lt;p&gt;Now, as long as I've compiled the project first, I can double-click on &lt;strong&gt;Class2.cs&lt;/strong&gt; and have it open up in the designer. This happens because &lt;strong&gt;Class2&lt;/strong&gt; derives from &lt;strong&gt;Component&lt;/strong&gt;. Except this time, the instance on the design surface is an instance of &lt;strong&gt;Class1&lt;/strong&gt;! See how the Properties Window shows &lt;strong&gt;MyProperty&lt;/strong&gt;?
&lt;p&gt;&lt;a href="http://rxdrja.bay.livefilestore.com/y1p7jJzD1bA9nuZWCqnLnASKbq7CbiO0RcYyxAUdxqyeHUU0UI6PBQ9ODK4yCB0X6eeVIQpFK3Ssuuac6copzt_lKrZL4ZzugFG?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=152 alt=image src="http://by1.storage.msn.com/y1p49FnH5vGVi6SJ0TsOVAHiKw2CBCRxz8AiBllFOAtdTY8X3EB6rngdvpNN38e8PJDUxVX3sZFUIuFQxXzM1GKrH7hXCnZ9F0u?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt; 
&lt;p&gt;&lt;strong&gt;Figure 4&lt;/strong&gt; shows that you can design your own types in the Component Designer.
&lt;p&gt;Getting your own class into the Component Designer is the first step. Now it's time to customize!
&lt;p&gt;There are a lot of ways to customize the design-time experience for particular components. Most of it is driven through metadata, or custom attributes.
&lt;p&gt;For example, using attributes, I can change the way MyProperty appears in the Properties Window.&lt;pre&gt;    &lt;span&gt;public&lt;/span&gt; &lt;span&gt;class&lt;/span&gt; Class1 : Component
    {
        &lt;span&gt;private&lt;/span&gt; &lt;span&gt;string&lt;/span&gt; myProperty = &lt;span&gt;&amp;quot;elephant&amp;quot;&lt;/span&gt;;

        [DefaultValue(&lt;span&gt;&amp;quot;elephant&amp;quot;&lt;/span&gt;)]
        [Category(&lt;span&gt;&amp;quot;Animals&amp;quot;&lt;/span&gt;)]
        [DisplayName(&lt;span&gt;&amp;quot;My Property&amp;quot;&lt;/span&gt;)]
        [Description(&lt;span&gt;&amp;quot;Set this property to the first thing that comes to mind.&amp;quot;&lt;/span&gt;)]
        &lt;span&gt;public&lt;/span&gt; &lt;span&gt;string&lt;/span&gt; MyProperty
        {
            get { &lt;span&gt;return&lt;/span&gt; myProperty; }
            set { myProperty = &lt;span&gt;value&lt;/span&gt;; }
        }
    }&lt;/pre&gt;


&lt;p&gt;After rebuilding the project, the Properties Window for Class2 reflects the changes.
&lt;p&gt;&lt;a href="http://rxdrja.bay.livefilestore.com/y1p7jJzD1bA9nuYLesqqg-eyL9xeJf8FnJ6VSraLZH3Sy2ygjRLhjWwPM93J8-4ryYIpMDCKNhsIudHg6KOSeS3301OWjDJU7Ux?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=152 alt=image src="http://by1.storage.msn.com/y1p49FnH5vGVi6AV6zLd4PhxV9FxIbTkKRKtow-2tRAXth5hkfvjYTzUb1Jn_v-cMc3q1rErfIfDb9uJzsaGlQoPXRH9O03g_eK?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt; 
&lt;p&gt;&lt;strong&gt;Figure 5&lt;/strong&gt; provides an example of how you can customize the design-time behavior of your components. The &lt;strong&gt;MyProperty&lt;/strong&gt; property is now displayed as &lt;strong&gt;My Property&lt;/strong&gt; (note the space), it is in the Animals category instead of Misc, and it has a description at the bottom of the Properties Window. The value of the property is &amp;quot;elephant&amp;quot;, which is the default value. This is important to the designer because when a property has its default value, it is not serialized to code. Imagine having a component with two hundred properties, and all but one is set to its default value (the value it has when constructed from a default constructor). You would want the code generated for that component to only set the one property that was different from its default, not all 200 values. Otherwise, such a class would initialize 199 of its properties twice!
&lt;p&gt;It's important to note here that the &lt;strong&gt;DefaultValueAttribute&lt;/strong&gt; custom attribute is used as a hint to the designer, and doesn't actually set the property to anything. It's purpose is to tell the designer what the default value is, so the designer can compare the property's actual value against it when it's time to generate code. The Properties Window also uses it to visually indicate which properties need to be serialized -- that is, if a property's value is anything but the default, then that value will appear in &lt;strong&gt;bold&lt;/strong&gt; in the Properties Window. If you specify the wrong value in the attribute, the designer will behave incorrectly -- so be careful!
&lt;p&gt;There are a bunch of attributes in System.ComponentModel that are interesting. A few noteworthy attributes in terms of editing properties are:
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;BrowsableAttribute&lt;/strong&gt; -- use Browsable(false) to prevent a property from appearing in the Properties Window.
&lt;li&gt;&lt;strong&gt;DesignerSerializationVisibilityAttribute&lt;/strong&gt; -- choose not to generate code for a property (often used in combination with Browsable(false)), or serialize only the object returned by the property (like a read-only property that returns an editable collection).
&lt;li&gt;&lt;strong&gt;ReadOnlyAttribute&lt;/strong&gt; -- make a read/write property appear read-only in the Properties Window.
&lt;li&gt;&lt;strong&gt;TypeConverterAttribute&lt;/strong&gt; -- allows you to specify a custom type converter (hint: this is where you can do neat stuff!). Usually, you want to convert between a custom type and its string representation. This way, your custom type can both be displayed in the Properties Windows, and be edited by a user typing in a new value.
&lt;li&gt;&lt;strong&gt;EditorAttribute&lt;/strong&gt; -- allows you to specify a custom editor for the property (hint: this is another place to do neat stuff!). By creating a custom &lt;strong&gt;UITypeEditor&lt;/strong&gt;, you can make rich design-time experiences for your properties, like the color picker for System.Drawing.&lt;strong&gt;Color&lt;/strong&gt; properties on &lt;strong&gt;Control&lt;/strong&gt; classes.&lt;/ul&gt;
&lt;p&gt;In my menu designer, I've been getting a lot of mileage out of creating custom type converters. I created one to enumerate all types that derive from &lt;strong&gt;GameScreen&lt;/strong&gt; to assign to a System.&lt;strong&gt;Type&lt;/strong&gt; property, I created one to enumerate the names of all &lt;strong&gt;SpriteFont&lt;/strong&gt;s in the nested Content project to assign to a string property, and I created another to enumerate the names of all &lt;strong&gt;Texture2D&lt;/strong&gt; content to assign to another string property.
&lt;p&gt;Okay, that's as far as I'm going to get in one sitting. Our starter course is looking pretty modest -- more like cheese and crackers than shrimp cocktail -- but at least there's something on the plate!&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4894130425169106705&amp;page=RSS%3a+Making+a+Designer+of+Your+Own+-+A+Starter+Course&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=badcorporatelogo.spaces.live.com&amp;amp;GT1=badcorporatelogo"&gt;</description><comments>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!283.entry#comment</comments><guid isPermaLink="true">http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!283.entry</guid><pubDate>Tue, 03 Jun 2008 06:41:31 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://badcorporatelogo.spaces.live.com/blog/cns!43EB71B104A2D711!283/comments/feed.rss</wfw:commentRss><wfw:comment>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!283.entry#comment</wfw:comment><dcterms:modified>2008-06-03T06:41:31Z</dcterms:modified></item><item><title>Going Somewhere? Menu Navigation Woes.</title><link>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!261.entry</link><description>&lt;p&gt;There have been about a billion views of my blog since I posted screen shots of the menu designer I started working on &lt;a href="http://badcorporatelogo.spaces.live.com/blog/cns!43EB71B104A2D711!253.entry"&gt;last week&lt;/a&gt;. For those of you who are keenly interested in that particular topic, I am still working on it. I mean you, &lt;a href="http://blogs.msdn.com/etayrien/"&gt;Eli&lt;/a&gt;! ;-) &lt;p&gt;Getting a design surface going took some technical trickery, but I've done it before so it was no big deal. The real difficult part is making a set of classes that are intuitively designable. What does that mean? Well, I guess I'm trying to figure out the right set of classes to support, the right properties to put on all the classes, and the right set of toolbox items to have available. I want something that is both simple enough to get people started right away, and easy enough to customize that not every game &lt;em&gt;looks &lt;/em&gt;like it came from the same designer. &lt;p&gt;I've been building this designer and its components in Visual C# 2005 Express Edition. A few of you might be surprised at that, mainly because you can't use the VS SDK to build customizations for VC# Express (except for some very special cases like XNA Game Studio, but my personal projects are no exception). The fact is, a visual designer doesn't require customizations to the IDE. There's already a powerful designer infrastructure built-in to VC# Express -- the very same one used by Windows Forms! To create custom design-time experiences, you don't need to modify anything in the IDE. All you need is the right metadata on your classes, and you can take control of that infrastructure for yourself. &lt;p&gt;Anyway, tonight I am trying to make sense of the mess I made with respect to navigation items. I've created an item that you can drop onto the menu and then specify what type of screen it navigates to. Selecting this menu item when the menu is running will transition to the next screen. I also gave it the option of specifying a custom background for the next screen, and for loading it on a separate thread with a load screen. The trouble is that if you use the load screen, you can't &amp;quot;cancel&amp;quot; back to the previous screen. If you don't use it, then you can. I'm having trouble figuring out what to call the properties so the resulting behavior will be obvious. &lt;p&gt;Clearly, this one navigation item is too complex. The best thing to do is probably to have more than one navigation item -- say, one that pushes new screens onto the screen manager's stack (allowing back-button navigation), and another that clears the stack to start from scratch (like a gameplay or level screen). That would definitely be easier to understand, but what do I call them? Argh! &lt;p&gt;The thing I like about the navigation items is that it gives you an easy way to build a complex menu system without writing any code. &lt;p&gt;&lt;a href="http://rxdrja.bay.livefilestore.com/y1poZxlZcsmKwivd5YyoP6OlETUpsOWdVQGk0bnJ81w3UUjEsE4RoHGVHtYgwAb42aeC9VTi1lDxvmSsbkB8iqvpA?PARTNER=WRITER"&gt;&lt;img style="border-right:0px;border-top:0px;border-left:0px;border-bottom:0px" height=174 alt=image src="http://by1.storage.msn.com/y1p49FnH5vGVi7MAMyN2tOsN6K2VNV_N13_Hl5-Kb9szqZ0oPwZFwpejlHQj9YHe6YcD88b0aX2veAfYoMbUBEaClMZa8JDShIJ?PARTNER=WRITER" width=244 border=0&gt;&lt;/a&gt;  &lt;p&gt;This screen clipping above shows how the NextScreen property has a dropdown combobox to select the type of the next screen. The combobox will list all the game screens in your project (or referenced by it). It's neat and easy, but the resulting behavior is not yet intuitive. &lt;p&gt;Coming up with good names is hard. It reminds me of a quote from Knuth: &lt;blockquote&gt; &lt;p&gt;The most important thing in the programming language is the name. A language will not succeed without a good name. I have recently invented a very good name and now I am looking for a suitable language.&lt;br&gt;&lt;a href="http://www.brainyquote.com/quotes/quotes/d/donaldknut181626.html"&gt;Donald Knuth&lt;/a&gt;&lt;/blockquote&gt; &lt;p&gt;Once again, it's time for bed.&lt;img src="http://c.services.spaces.live.com/CollectionWebService/c.gif?cid=4894130425169106705&amp;page=RSS%3a+Going+Somewhere%3f+Menu+Navigation+Woes.&amp;referrer=" width="1px" height="1px" border="0" alt=""&gt;&lt;img style="position:absolute" alt="" width="0px" height="0px" src="http://c.live.com/c.gif?NC=31263&amp;amp;NA=1149&amp;amp;PI=73329&amp;amp;RF=&amp;amp;DI=3919&amp;amp;PS=85545&amp;amp;TP=badcorporatelogo.spaces.live.com&amp;amp;GT1=badcorporatelogo"&gt;</description><comments>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!261.entry#comment</comments><guid isPermaLink="true">http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!261.entry</guid><pubDate>Tue, 20 May 2008 08:37:40 GMT</pubDate><slash:comments>0</slash:comments><msn:type>blogentry</msn:type><live:type>blogentry</live:type><live:typelabel>Blog entry</live:typelabel><wfw:commentRss>http://badcorporatelogo.spaces.live.com/blog/cns!43EB71B104A2D711!261/comments/feed.rss</wfw:commentRss><wfw:comment>http://badcorporatelogo.spaces.live.com/Blog/cns!43EB71B104A2D711!261.entry#comment</wfw:comment><dcterms:modified>2008-05-20T08:37:40Z</dcterms:modified></item></channel></rss>