using System; using System.Collections.Generic; using System.Linq; using System.Text; using Orvid.Graphics; namespace OForms { #region OButton /// /// This class is a button. /// public class OButton : OControl { /// /// The bounding box for this control. /// public BoundingBox Bounds; private static Vec2 DefaultSize = new Vec2(75, 20); //public event Mouse MouseClick = new Mouse(None); //private static void None(object o, MouseArgs e) { } //public OButton() // : base() //{ // MouseClick += new Mouse(CheckMouseClick); //} //private void CheckMouseClick(object o, MouseArgs e) //{ // if (Bounds.IsInBounds(new Vec2(e.X, e.Y))) // { // MouseClick.Invoke(o, e); // } //} #region Draw /// /// Draws the button. /// public override void Draw(Image i) { float xScale = Size.X / DefaultSize.X; float yScale = Size.Y / DefaultSize.Y; // Center fill. //(0,4), (75, 4), (75, 17), (0,17) i.DrawRectangle( new Vec2(Location.X, (Location.Y - (Int32)(yScale * 4))), new Vec2(Location.X + (Int32)(xScale * 75), (Location.Y - (Int32)(yScale * 4))), new Vec2(Location.X + (Int32)(xScale * 75), (Location.Y - (Int32)(yScale * 17))), new Vec2(Location.X, (Location.Y - (Int32)(yScale * 17))), Color); // Top left corner. // (5, 4), 4, 4 i.DrawElipse( new Vec2(Location.X + (Int32)(xScale * 5), (Location.Y - (Int32)(yScale * 4))), (Int32)(yScale * 4), (Int32)(xScale * 4), Color); // Top right corner. // (71, 4), 4, 4 i.DrawElipse( new Vec2(Location.X + (Int32)(xScale * 71), Location.Y - (Int32)(yScale * 4)), (Int32)(yScale * 4), (Int32)(xScale * 4), Color); // Bottom left corner // (5, 16), 4, 4 i.DrawElipse( new Vec2(Location.X + (Int32)(xScale * 5), (Location.Y - (Int32)(yScale * 16))), (Int32)(yScale * 4), (Int32)(xScale * 4), Color); // Bottom right corner // (71, 16), 4, 4 i.DrawElipse( new Vec2(Location.X + (Int32)(xScale * 71), (Location.Y - (Int32)(yScale * 16))), (Int32)(yScale * 4), (Int32)(xScale * 4), Color); // The rest of the fill //(5,0), (71, 0), (71, 20), (5,20) i.DrawRectangle( new Vec2(Location.X + (Int32)(xScale * 5), Location.Y), new Vec2(Location.X + (Int32)(xScale * 71), Location.Y), new Vec2(Location.X + (Int32)(xScale * 71), (Location.Y - (Int32)(yScale * 20))), new Vec2(Location.X + (Int32)(xScale * 5), (Location.Y - (Int32)(yScale * 20))), Color); // Set the bounding box. Bounds = new BoundingBox( Location.X, Location.X + (Int32)(xScale * 75), Location.Y, Location.Y - (Int32)(yScale * 20) ); } #endregion } #endregion #region Mouse Event Delegates ///// ///// The enum that describes the various types of actions ///// that a mouse event can send. ///// //public enum MouseButton //{ // /// // /// This type means the mouse was released. // /// // MouseUp, // /// // /// This type means the left mouse button was, // /// and still is, pressed down. // /// // MouseDown, // /// // /// This means that the left mouse button was clicked. // /// // MouseClick, // /// // /// This means the right mouse button was, // /// and still is, pressed down. // /// // MouseRightDown, // /// // /// This means that the right mouse button was clicked. // /// // MouseRightClick, // /// // /// This means that the middle mouse button was, // /// and still is, pressed down. // /// // MouseMiddleDown, // /// // /// This means that the middle mouse button was clicked. // /// // MouseMiddleClick, // /// // /// This means the mouse was moved. // /// // MouseMove //} ///// ///// The class that describes a mouse event. ///// //public class MouseArgs //{ // /// // /// The X position of the mouse. // /// // public int X; // /// // /// The Y position of the mouse. // /// // public int Y; // /// // /// The type of event that occurred. // /// // public MouseButton Type; //} //public delegate void Mouse(object o, MouseArgs e); #endregion }