To make it easy for KryptonRibbon developers to use the new color menu item I have added a couple of new elements. One is used inside the button cluster and the other within the triple and lines containers. Here you can see examples of both in action….
There are several points to note. First of all the color button is just an extension of the existing button element and so everything you can do with buttons you can also do with color buttons. So you can make the button a Push, Check, DropDown or Split type depending on your application requirements.
Use the SelectedColor property to define the current color of the element. You can see in the above image that a portion of the element image has a solid block of color drawn to indicate the selected color. This is drawn automatically for you. As the user selects new colors, or you programmatically alter the selection, this block will be updated.
Of course, you might decide this default block size and position are not appropriate for you. No problem, just alter the SelectedRect property to indicate where you would prefer it to be drawn. This image shows the top entry with the default rectangle but the ones below have been modified to different values…
Note that the color block is drawn over the top of the image so you will want to synchronize the image and block position so they complement each other.
There are some cases where you might want to allow the specification of no color at all. In this case you just assign the Color.Empty value to the SelectedColor property. The user can do this using the ‘No Color’ entry in the context menu as seen in the first image above. A Color.Empty value is not drawn as a solid block because it would result in nothing being drawn! Instead a border is drawn around the color area using the EmptyBorderColor. This picture shows just this scenario for two of the color buttons.
There are various other properties for controlling which entries are shown in the context menu but I will not list them all here. Suffice it to say that you can customize the look using just design time properties to work in a reasonable way for most application needs. If that is still not enough you can hook into the DropDown event and completely alter the context menu contents as you please.