First of all we should realize that we are writing for pocketPC and not for PC platform. What the differences? Well despite interfaces and forms there is one big problem - limited memory! This means whatever we do and create - it must not "eat" to much memory. Adding graphics to a sudoku in C# can be a bit treaky. Of course we can always use C++ lagnguage and create a more low level code and more optimized compiled source but let's do some work and use C# to do that.
First - lets create some nice interface - buttons. it is not that difficult to do if you are familiar with user controls and event handling. We will use both since our button must responce to a click.
The definition of colorbutton class in in colorbutton.cs file of sources. Initially this class was created for a PC, but since compact environment does not support some of its features they were just disabled but main feature remains - a button is better than a regular one in compact framework - we can real-time change its shape and colors!
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace ColorButton
{
public class ColorButton : System.Windows.Forms.Control
{
private enum _States
{
Normal,
MouseOver,
Clicked
}
public enum ButtonStyles
{
Rectangle,
Ellipse
}
// default values
private bool _Active = true;
private _States _State = _States.Normal;
private ButtonStyles _ButtonStyle = ButtonStyles.Rectangle;
private int handle = 0;
private Color _NormalBorderColor = Color.Green;
private Color _NormalColorA = Color.Green;
private Color _NormalColorB = Color.Honeydew;
private Color _HoverBorderColor = Color.MediumVioletRed;
private Color _HoverColorA = Color.MediumVioletRed;
private Color _HoverColorB = Color.White;
public ColorButton(int ihandle)
{
// initiate button size and font
base.Size = new Size(200, 40);
base.Font = new Font("Verdana", 10, FontStyle.Bold);
this.handle = ihandle;
}
public int getHandle()
{
return this.handle;
}
public ButtonStyles ButtonStyle
{
get
{
return _ButtonStyle;
}
set
{
_ButtonStyle = value;
this.Invalidate();
}
}
public Color NormalBorderColor
{
get
{
return _NormalBorderColor;
}
set
{
_NormalBorderColor = value;
this.Invalidate();
}
}
public Color HoverBorderColor
{
get
{
return _HoverBorderColor;
}
set
{
_HoverBorderColor = value;
this.Invalidate();
}
}
public Color NormalColorA
{
get
{
return _NormalColorA;
}
set
{
_NormalColorA = value;
this.Invalidate();
}
}
public Color NormalColorB
{
get
{
return _NormalColorB;
}
set
{
_NormalColorB = value;
this.Invalidate();
}
}
public Color HoverColorA
{
get
{
return _HoverColorA;
}
set
{
_HoverColorA = value;
this.Invalidate();
}
}
public Color HoverColorB
{
get
{


Join the conversation! Your thoughts help the community grow.