using System; using System.Drawing; using System.Windows.Forms; using SMath.Controls; using SMath.Math; using SMath.Manager; using SMath.Drawing; namespace Regions { public class Control: RegionEvaluable { #region Private fields private bool _enabled; private IBitmap _image; private ContextMenuStrip _contextMenuStrip; private delegate void PaintEventHandler( PaintEventOptions e ); private event PaintEventHandler Paint; #endregion public bool DesignMode { get { return false; } } public bool Enabled { get { return _enabled; } set { _enabled = value; } } public int Width { get { return Size.Width; } set { Size = new Size( value, Size.Height ); } } public int Height { get { return Size.Height; } set { Size = new Size( Size.Width, value ); } } public object Tag { get; set; } public virtual string Text { get; set; } public Rectangle ClientRectangle { get { return new Rectangle( new Point( 0, 0 ), new Size( Width - 8, Height - 8 ) ); } } public ContextMenuStrip ContextMenuStrip { get { return _contextMenuStrip; } set { _contextMenuStrip = value; } } public Control( SessionProfile sessionProfile ) : base( sessionProfile ) { Size = new Size( 200, 200 ); _image = SMath.Drawing.Graphics.Specifics.CreateBitmap( Size.Width, Size.Height ); SMath.Drawing.Graphics.Specifics.GraphicsFromBitmap( _image ); Paint += OnPaint; _contextMenuStrip = new ContextMenuStrip(); } public Control( Control region ) : base( region ) { Size = new Size( region.Size.Width, region.Size.Height ); _image = SMath.Drawing.Graphics.Specifics.CloneBitmap( region._image ); SMath.Drawing.Graphics.Specifics.GraphicsFromBitmap( _image ); Paint += OnPaint; _contextMenuStrip = new ContextMenuStrip(); } public override RegionBase Clone() { return new Control( this ); } public void SuspendLayout() { } public void ResumeLayout( bool performLayout ) { } public Point PointToClient( Point p ) { return new Point( p.X, p.Y ); } public virtual bool ProcessDialogKey( Keys keyData ) { return false; } public virtual void SetBoundsCore( int x, int y, int width, int height, BoundsSpecified specified ) { } public override void OnEvaluation( Store store ) { } public void SetStyle( ControlStyles style, bool b ) { } public void Refresh() { base.Invalidate(); } public void Invalidate( Rectangle thumbRectangle ) { //Paint.Invoke( new PaintEventArgs( canvas, thumbRectangle ) ); base.Invalidate(); } public void Focus() { Focused = true; } public override void OnPaint( PaintEventOptions e ) { //if ( InEvaluation ) return; base.OnPaint(e); if ( _image != null ) { e.Graphics.DrawImage( _image, e.ClipRectangle.Location.X, e.ClipRectangle.Location.Y ); } } public virtual void OnScroll( ScrollEventArgs e ) { } public virtual void OnSizeChanged( EventArgs e ) { } public virtual void OnEnabledChanged( EventArgs e ) { } } }