Navigation

Search

Categories

On this page

Custom Control Design Time Attributes
ColorButton Control v1.7

Archive

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 12
This Year: 0
This Month: 0
This Week: 0
Comments: 0

Sign In

 Friday, June 01, 2007
Friday, June 01, 2007 2:01:07 PM UTC (  |  )
I was just asked a question by a recent ColorButton Source code customer about how the design time .dll (ColorButton.PocketPC.asmmeta.dll) is created for the ColorButton Control and seeing how it is not obvious in code (there is not a seperate project), I thought I had better explain what is going on.

Within the ColorButton source, there is a file called 'DTAColorButton.xmta'. The DTA part is an abbreviation for Design Time Attributes, by no means a naming convention standard, but something that I have become comfortable with.

The .xmta file simply contains an .xml format definition of the public properties within the ColorButton class. The compiler (magic really) recognises the existance of the .xmta file and creates the ColorButton.PocketPC.asmmeta.dll file, or one appropriate for the project target.

Further, the ColorButton solution shares the one set of source code across all projects in the solution:
ColorButton.Desktop
ColorButton.PocketPC
ColorButton.Smartphone
ColorButton.WindowsCE

Apart from the Desktop compile which has alot of #'s in the code which takes care of the desktop design time attributes:

#if Desktop
  [Description("Gets or sets the position information for button content"), Category("Appearance")]
#endif

The rest of the projects compile an asmmeta.dll to suit the device:
ColorButton.PocketPC.asmmeta.dll
ColorButton.WindowsCE.asmmeta.dll
ColorButton.Smartphone.asmmeta.dll

I hope this explains a bit about the source provided by Pocket PC Controls.com and may even give you some insight into creating your own controls.

If you need more info, feel free to add comment.

 Sunday, May 20, 2007
Sunday, May 20, 2007 10:32:03 AM UTC (  |  )
It was brought to my attention that the ColorButton control had no way of determining that it had focus!!!
We stuck with the standard button behavior of thickening the border of the button when focused.
The DrawColorButton method looks like this now:

private void DrawColorButton()
{    
  CollectColors();

  // draw the button to the screen
  switch (_ButtonShape)
  {        
    case ButtonShape.Ellipse :

      if (_ShowGradient)
        Draw.Gradient(_Graphics, this.Bounds, _BackDownColor, BackColor, (int)_GradientDirection, (int)_ButtonShape);
      else
        _Graphics.FillEllipse(_Brush, 0, 0, Width-1, Height-1);
    
      _Graphics.DrawEllipse(_Pen, 0, 0, Width-1, Height-1);

      if (base.Focused)
        _Graphics.DrawEllipse(_Pen, 1, 1, Width - 3, Height - 3);

      break;

    case ButtonShape.Rectangle :               

      if (_ShowGradient)
        Draw.Gradient(_Graphics, this.Bounds, _BackDownColor, BackColor, (int)_GradientDirection, (int)_ButtonShape);
      else
        _Graphics.FillRectangle(_Brush, 0, 0, Width, Height);
                    
      _Graphics.DrawRectangle(_Pen, 0, 0, Width-1, Height-1);

      if(base.Focused)
        _Graphics.DrawRectangle(_Pen, 1, 1, Width - 3, Height - 3);

      break;
    }

    DrawStringToButton();
    DrawIconToButton();

}

Those of you who purchased the control in the last 6 months would like the update please send me an email.
There is still no way of determining if the ColorButton has focus when using images and we will add this functionality in the near future. If there are any of you who would like to see a new image property added to cater for the focused state, please let me know and we can push that along.

You can see here that colorButton2 has focus: