/*============================================================================= Project: SharpImage Module: siRenderer.cs Language: C# Author: Dan Mueller Date: $Date: 2007-07-27 03:48:36 +1000 (Fri, 27 Jul 2007) $ Revision: $Revision: 9 $ Copyright (c) Queensland University of Technology (QUT) 2007. All rights reserved. This software is distributed WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the above copyright notices for more information. =============================================================================*/ using System; using System.IO; using System.Collections.Generic; using System.Text; using System.Drawing; using System.Drawing.Drawing2D; using System.Drawing.Imaging; using System.Windows.Forms; using System.Diagnostics; using SharpImage.Main; using SharpImage.Properties; namespace SharpImage.Rendering { #region siRenderer Class //========================================================================= public abstract class siRenderer : IDisposable { #region Instance Variables //===================================================================== protected delegate void VoidMethodCallback(); protected delegate void FormArgCallback(Form form); bool m_FormHasBeenClosed = false; private string m_TempPath = null; private int m_NextFile = 0; itk.itkMatrixOffsetTransform m_DirectionTransform = null; itk.itkMatrixOffsetTransform m_DirectionTransformInverse = null; //========================================================================= #endregion #region Construction and Disposal //===================================================================== /// /// Protected constuctor. /// NOTE: By default the form is not visible. /// /// The type of the Renderer. eg. "GDI Viewer". /// The parenting application. /// The form to draw the Renderer. protected siRenderer(string typename, IApplication parent, siRendererForm form) { // Setup member variables this.m_Form = form; this.m_TypeName = typename; this.m_ParentApplication = parent; this.TitleText = string.Empty; // Setup the form this.Form.Icon = Resources.Image; // Watch form events this.Form.Paint += new PaintEventHandler(Form_Paint); this.Form.Resize += new EventHandler(Form_Resize); this.Form.KeyDown += new KeyEventHandler(Form_KeyDown); this.Form.KeyUp += new KeyEventHandler(Form_KeyUp); this.Form.KeyPress += new KeyPressEventHandler(Form_KeyPress); this.Form.MouseDown += new MouseEventHandler(Form_MouseDown); this.Form.MouseUp += new MouseEventHandler(Form_MouseUp); this.Form.MouseMove += new MouseEventHandler(Form_MouseMove); this.Form.MouseWheel += new MouseEventHandler(Form_MouseWheel); this.Form.GotFocus += new EventHandler(Form_GotFocus); this.Form.LostFocus += new EventHandler(Form_LostFocus); this.Form.FormClosed += new FormClosedEventHandler(Form_FormClosed); } //===================================================================== #endregion #region Properties //===================================================================== #region Public: TypeName //===================================================================== private string m_TypeName = string.Empty; /// /// Gets a name representing the type of Renderer. /// [System.ComponentModel.Browsable(true)] [System.ComponentModel.Category("(Information)")] [System.ComponentModel.ParenthesizePropertyName(false)] [System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.All)] public string TypeName { get { return this.m_TypeName; } } //===================================================================== #endregion #region Public: Parent //===================================================================== private IApplication m_ParentApplication = null; /// /// Gets a parenting application. /// [System.ComponentModel.Browsable(false)] public IApplication ParentApplication { get { return this.m_ParentApplication; } } //===================================================================== #endregion #region Public: TitleText //===================================================================== private string m_TitleText = string.Empty; /// /// Gets/sets the text displayed in the title. /// The actual title text is "TypeName: TitleText". /// [System.ComponentModel.Browsable(false)] public string TitleText { get { return this.m_TitleText; } set { this.m_TitleText = value; this.Form.Text = this.FormTitleText; } } //===================================================================== #endregion #region Public: ViewportSize //===================================================================== /// /// Gets the size of the Renderer. /// [System.ComponentModel.Browsable(true)] [System.ComponentModel.Category("Size and Transform")] [System.ComponentModel.ParenthesizePropertyName(false)] [System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.All)] public Size ViewportSize { get { return this.Form.ViewportSize; } set { this.Form.ViewportSize = value; } } //===================================================================== #endregion #region Public: ViewportRectangle //===================================================================== /// /// Gets the rectangle of the Renderer in screen space. /// [System.ComponentModel.Browsable(false)] public Rectangle ViewportRectangle { get { return this.Form.ViewportRectangle; } } //===================================================================== #endregion #region Public: BackColor //===================================================================== /// /// Gets/sets the background color of the Renderer window. /// [System.ComponentModel.Browsable(true)] [System.ComponentModel.Category("Color")] [System.ComponentModel.ParenthesizePropertyName(false)] [System.ComponentModel.RefreshProperties(System.ComponentModel.RefreshProperties.All)] public virtual Color BackColor { get { return this.Form.BackColor; } set { this.Form.BackColor = value; this.Metadata["BackColor"] = value; } } //===================================================================== #endregion #region Public: Visible //===================================================================== /// /// Gets/sets if the Renderer Window/Form is visible. /// [System.ComponentModel.Browsable(false)] public bool Visible { get { return this.Form.Visible; } set { this.Form.Visible = value; } } //===================================================================== #endregion #region Public: IsModified //===================================================================== private bool m_IsModified = false; /// /// Gets/sets if the Renderer has been modified and needs repainting. /// Setting this property does NOT cause the Modified event to be /// raised: call the RaiseModified() method to do that. /// [System.ComponentModel.Browsable(false)] public bool IsModified { get { return this.m_IsModified; } set { this.m_IsModified = value; } } //===================================================================== #endregion #region Public: Metadata //===================================================================== private Dictionary m_Metadata = new Dictionary(); /// /// Gets the Metadata variable list. /// [System.ComponentModel.Browsable(false)] public Dictionary Metadata { get { return this.m_Metadata; } } //===================================================================== #endregion #region Public: Inputs //===================================================================== private List m_Inputs = new List(); /// /// Gets a list of the input data objects. /// [System.ComponentModel.Browsable(false)] public List Inputs { get { return m_Inputs; } } //===================================================================== #endregion #region Public: Form //===================================================================== private siRendererForm m_Form = null; /// /// Gets/sets the form to show the Renderer. /// [System.ComponentModel.Browsable(false)] public siRendererForm Form { get { return this.m_Form; } } //===================================================================== #endregion #region Protected: Cursor //===================================================================== /// /// Gets/sets the cusor to display when over the Renderer. /// protected Cursor Cursor { get { return this.Form.Cursor; } set { this.Form.Cursor = value; } } //===================================================================== #endregion #region Protected: Actors //===================================================================== private List> m_Actors = new List>(); /// /// Gets the current list of actors. /// protected List> Actors { get { return this.m_Actors; } } //===================================================================== #endregion #region Private: FormTitleText //===================================================================== /// /// Gets the text to display in the Form title. /// private string FormTitleText { get { if (this.TitleText == null || this.TitleText.Length == 0) return this.TypeName; else return this.TypeName + ": " + this.TitleText; } } //===================================================================== #endregion //===================================================================== #endregion #region Events and Delegates //===================================================================== #region Delegates //===================================================================== /// /// EventArg delegate for allowing listeners access to the /// RendererBase which rasied the event. /// /// public delegate void siRendererHandler(siRenderer renderer, EventArgs e); /// /// KeyEventArg delegate for allowing listeners access to the /// RendererBase which rasied the event. /// /// public delegate void siRendererKeyEventHandler(siRenderer renderer, KeyEventArgs e); /// /// KeyPressEventArgs delegate for allowing listeners access to the /// RendererBase which rasied the event. /// /// public delegate void siRendererKeyPressEventHandler(siRenderer renderer, KeyPressEventArgs e); //===================================================================== #endregion #region Modified //===================================================================== private siRendererHandler m_EventStorage_Modified; /// /// An event raised when the Renderer is modified. /// public event siRendererHandler Modified { add { this.m_EventStorage_Modified += value; } remove { this.m_EventStorage_Modified -= value; } } /// /// Raises the Modified event. /// public void RaiseModified() { this.IsModified = true; if (this.m_EventStorage_Modified != null) this.m_EventStorage_Modified(this, new EventArgs()); } //===================================================================== #endregion #region KeyDown //===================================================================== private siRendererKeyEventHandler m_EventStorage_KeyDown; /// /// An event raised when a key has been pressed down. /// public event siRendererKeyEventHandler KeyDown { add { this.m_EventStorage_KeyDown += value; } remove { this.m_EventStorage_KeyDown -= value; } } /// /// Raise the KeyDown event. /// protected void RaiseKeyDown(KeyEventArgs e) { //Fire event if (this.m_EventStorage_KeyDown != null) this.m_EventStorage_KeyDown(this, e); } //===================================================================== #endregion #region KeyUp //===================================================================== private siRendererKeyEventHandler m_EventStorage_KeyUp; /// /// An event raised when a key has been pressed and released. /// public event siRendererKeyEventHandler KeyUp { add { this.m_EventStorage_KeyUp += value; } remove { this.m_EventStorage_KeyUp -= value; } } /// /// Raise the KeyUp event. /// protected void RaiseKeyUp(KeyEventArgs e) { // Fire event if (this.m_EventStorage_KeyUp != null) this.m_EventStorage_KeyUp(this, e); } //===================================================================== #endregion #region KeyPress //===================================================================== private siRendererKeyPressEventHandler m_EventStorage_KeyPress; /// /// An event raised when a key has been pressed. /// public event siRendererKeyPressEventHandler KeyPress { add { this.m_EventStorage_KeyPress += value; } remove { this.m_EventStorage_KeyPress -= value; } } /// /// Raise the KeyPress event. /// protected void RaiseKeyPress(KeyPressEventArgs e) { // Fire event if (this.m_EventStorage_KeyPress != null) this.m_EventStorage_KeyPress(this, e); } //===================================================================== #endregion #region MouseDown //===================================================================== private MouseEventHandler m_EventStorage_MouseDown; /// /// An event raised when a mouse button has been pressed down. /// public event MouseEventHandler MouseDown { add { this.m_EventStorage_MouseDown += value; } remove { this.m_EventStorage_MouseDown -= value; } } /// /// Raise the MouseDown event. /// protected void RaiseMouseDown(MouseEventArgs e) { // Fire event if (this.m_EventStorage_MouseDown != null) this.m_EventStorage_MouseDown(this, e); } //===================================================================== #endregion #region MouseUp //===================================================================== private MouseEventHandler m_EventStorage_MouseUp; /// /// An event raised when a mouse button has been released. /// public event MouseEventHandler MouseUp { add { this.m_EventStorage_MouseUp += value; } remove { this.m_EventStorage_MouseUp -= value; } } /// /// Raise the MouseUp event. /// protected void RaiseMouseUp(MouseEventArgs e) { // Fire event if (this.m_EventStorage_MouseUp != null) this.m_EventStorage_MouseUp(this, e); } //===================================================================== #endregion #region MouseMove //===================================================================== private MouseEventHandler m_EventStorage_MouseMove; /// /// An event raised when the mouse is moved over the Renderer. /// public event MouseEventHandler MouseMove { add { this.m_EventStorage_MouseMove += value; } remove { this.m_EventStorage_MouseMove -= value; } } /// /// Raise the MouseMove event. /// protected void RaiseMouseMove(MouseEventArgs e) { // Fire event if (this.m_EventStorage_MouseMove != null) this.m_EventStorage_MouseMove(this, e); } //===================================================================== #endregion #region MouseWheel //===================================================================== private MouseEventHandler m_EventStorage_MouseWheel; /// /// An event raised when the mouse wheel is moved. /// public event MouseEventHandler MouseWheel { add { this.m_EventStorage_MouseWheel += value; } remove { this.m_EventStorage_MouseWheel -= value; } } /// /// Raise the MouseWheel event. /// protected void RaiseMouseWheel(MouseEventArgs e) { //Fire event if (this.m_EventStorage_MouseWheel != null) this.m_EventStorage_MouseWheel(this, e); } //===================================================================== #endregion #region GotFocus //===================================================================== private siRendererHandler m_EventStorage_GotFocus; /// /// An event raised after the Renderer has received the focus. /// public event siRendererHandler GotFocus { add { this.m_EventStorage_GotFocus += value; } remove { this.m_EventStorage_GotFocus -= value; } } /// /// Raise the GotFocus event. /// protected void RaiseGotFocus() { // Fire event if (this.m_EventStorage_GotFocus != null) this.m_EventStorage_GotFocus(this, new EventArgs()); } //===================================================================== #endregion #region LostFocus //===================================================================== private siRendererHandler m_EventStorage_LostFocus; /// /// An event raised after the Renderer has lost the focus. /// public event siRendererHandler LostFocus { add { this.m_EventStorage_LostFocus += value; } remove { this.m_EventStorage_LostFocus -= value; } } /// /// Raise the LostFocus event. /// protected void RaiseLostFocus() { // Fire event if (this.m_EventStorage_LostFocus != null) this.m_EventStorage_LostFocus(this, new EventArgs()); } //===================================================================== #endregion #region Closed //===================================================================== private siRendererHandler m_EventStorage_Closed; /// /// An event raised after the Renderer has been closed. /// public event siRendererHandler Closed { add { this.m_EventStorage_Closed += value; } remove { this.m_EventStorage_Closed -= value; } } /// /// Raise the Closed event. /// protected void RaiseClosed() { // Fire event if (this.m_EventStorage_Closed != null) this.m_EventStorage_Closed(this, new EventArgs()); } //===================================================================== #endregion //===================================================================== #endregion #region Public Methods //===================================================================== /// /// Initialises the Renderer. /// At this point the Renderer can assume that the inputs /// are valid. /// public virtual void Initialise() { if (this.Inputs == null || this.Inputs.Count == 0) throw new ApplicationException("At least one itkDataObject must be input into the Renderer."); } /// /// Forces the Renderer to repaint itself. /// Subclasses must override this, but still call this base class method. /// public virtual void Repaint() { this.RaiseModified(); } /// /// Shows the Renderer. /// /// This method is thread-safe. public void Show(Form mdiParent) { // Make the call thread-safe if (this.Form.InvokeRequired) { this.Form.Invoke(new FormArgCallback(this.Show), mdiParent); return; } // Show this.Form.MdiParent = mdiParent; this.Form.Show(); } /// /// Hides the Renderer. /// /// This method is thread-safe. public void Hide() { // Make the call thread-safe if (this.Form.InvokeRequired) { this.Form.Invoke(new VoidMethodCallback(this.Hide)); return; } this.Form.Hide(); } /// /// Close the Renderer and dispose of all resources. /// /// This method is thread-safe. public virtual void Close() { // Make the call thread-safe if (this.Form.InvokeRequired) { this.Form.Invoke(new VoidMethodCallback(this.Close)); return; } // Fire the event before we start disposing of things this.RaiseClosed(); // Check the form is still valid if (this.Form != null && !this.m_FormHasBeenClosed) { // Close the form // NOTE: We must remove the closed event handler to ensure it // is not fired when closing the form this.m_FormHasBeenClosed = true; this.Form.FormClosed -= new FormClosedEventHandler(Form_FormClosed); this.Form.Close(); } } /// /// Give focus to the Renderer. /// /// This method is thread-safe. public virtual void Focus() { // Make the call thread-safe if (this.Form.InvokeRequired) { this.Form.Invoke(new VoidMethodCallback(this.Focus)); return; } // Focus the form if (this.Form != null) { this.Form.Focus(); this.Form.BringToFront(); } } /// /// Create a handle to the GDI+ graphics object associated with the /// Renderer form. /// /// public virtual Graphics GetFormGraphics() { return this.Form.CreateGraphics(); } /// /// Get the image currently displayed by the screen. /// /// public virtual Bitmap GetScreenCapture() { throw new NotSupportedException("Screen capture is not supported by this renderer."); } /// /// Returns if the Renderer has non-null values for all of the /// given Metadata variable names. /// /// The list of keys to test. /// true AND all the variables in MetadataVars are valid OR /// false AND one or all of the variables in MetadataVars /// were invalid (was null or did not exist). public bool ContainsMetadata(params string[] keys) { foreach (string key in keys) { if (!this.Metadata.ContainsKey(key)) return false; else if (this.Metadata[key] == null) return false; } return true; } /// /// Returns a string representation of the Renderer. /// /// public override string ToString() { return this.FormTitleText; } /// /// Pass the given point through the direction transform /// of the first input image. /// WARNING: This method assumes that the first input is an image. /// /// /// public itk.itkPoint DirectionTransformPoint(itk.itkPoint point) { if (m_DirectionTransform == null) { // Create the transform m_DirectionTransform = itk.itkAffineTransform.New(point.Dimension); // Set the transform matrix, translation (zeros), and center (zeros) m_DirectionTransform.Matrix = (this.Inputs[0] as itk.itkImageBase).Direction; itk.itkVector translation = new itk.itkVector(point.Dimension); // Zeros itk.itkPoint center = new itk.itkPoint(point.Dimension); // Zeros m_DirectionTransform.Translation = translation; m_DirectionTransform.Center = center; } // Transform the vector, and return return m_DirectionTransform.TransformPoint(point); } /// /// Pass the given point through the inverse direction transform /// of the first input image. /// WARNING: This method assumes that the first input is an image. /// /// /// public itk.itkPoint DirectionTransformInversePoint(itk.itkPoint point) { if (m_DirectionTransform == null || m_DirectionTransformInverse == null) { // Create the transforms m_DirectionTransform = itk.itkAffineTransform.New(point.Dimension); m_DirectionTransformInverse = itk.itkAffineTransform.New(point.Dimension); // Set the transform matrix, translation (zeros), and center (zeros) m_DirectionTransform.Matrix = (this.Inputs[0] as itk.itkImageBase).Direction; itk.itkVector translation = new itk.itkVector(point.Dimension); // Zeros itk.itkPoint center = new itk.itkPoint(point.Dimension); // Zeros m_DirectionTransform.Translation = translation; m_DirectionTransform.Center = center; // Compute the inverse m_DirectionTransform.GetInverse(m_DirectionTransformInverse); } // Transform the point, and return return m_DirectionTransformInverse.TransformPoint(point); } /// /// Pass the given vector through the direction transform /// of the first input image. /// WARNING: This method assumes that the first input is an image. /// /// /// public itk.itkVector DirectionTransformVector(itk.itkVector vector) { if (m_DirectionTransform == null) { // Create the transform m_DirectionTransform = itk.itkAffineTransform.New(vector.Dimension); // Set the transform matrix, translation (zeros), and center (zeros) m_DirectionTransform.Matrix = (this.Inputs[0] as itk.itkImageBase).Direction; itk.itkVector translation = new itk.itkVector(vector.Dimension); // Zeros itk.itkPoint center = new itk.itkPoint(vector.Dimension); // Zeros m_DirectionTransform.Translation = translation; m_DirectionTransform.Center = center; } // Transform the vector, and return return m_DirectionTransform.TransformVector(vector); } /// /// Pass the given vector through the inverse direction transform /// of the first input image. /// WARNING: This method assumes that the first input is an image. /// /// /// public itk.itkVector DirectionTransformInverseVector(itk.itkVector vector) { if (m_DirectionTransform == null || m_DirectionTransformInverse == null) { // Create the transforms m_DirectionTransform = itk.itkAffineTransform.New(vector.Dimension); m_DirectionTransformInverse = itk.itkAffineTransform.New(vector.Dimension); // Set the transform matrix, translation (zeros), and center (zeros) m_DirectionTransform.Matrix = (this.Inputs[0] as itk.itkImageBase).Direction; itk.itkVector translation = new itk.itkVector(vector.Dimension); // Zeros itk.itkPoint center = new itk.itkPoint(vector.Dimension); // Zeros m_DirectionTransform.Translation = translation; m_DirectionTransform.Center = center; // Compute the inverse m_DirectionTransform.GetInverse(m_DirectionTransformInverse); } // Transform the vector, and return return m_DirectionTransformInverse.TransformVector(vector); } //===================================================================== #endregion #region Actor Methods //===================================================================== /// /// Adds the given actor to the renderer at the back of the list. /// The Actor is renderered /// /// public void AddActor(siActor actor) { if (actor != null) this.AddActorToBack(actor); } /// /// Adds the given actor to the front of the list. /// /// public void AddActorToFront(siActor actor) { if (actor != null) { this.Actors.Insert(0, actor); actor.Modified += new siActor.siActorModifiedHandler(Actor_Modified); this.Repaint(); } } /// /// Adds the given actor to the back of the list. /// /// public void AddActorToBack(siActor actor) { if (actor != null) { this.Actors.Add(actor); actor.Modified += new siActor.siActorModifiedHandler(Actor_Modified); this.Repaint(); } } /// /// Removes all instances of the given actor from the list. /// /// public void RemoveActor(siActor actor) { if (actor != null) { this.Actors.RemoveAll(new Predicate>(this.RemoveAllActors)); actor.Modified -= new siActor.siActorModifiedHandler(Actor_Modified); if (this.Metadata != null) this.Metadata.Remove("Cursor"); this.Repaint(); } } private bool RemoveAllActors(siActor actor) { return this.Actors.Contains(actor); } /// /// Sends the given actor to the back of the list. /// /// public void SendActorToBack(siActor actor) { if (actor != null) { this.Actors.Remove(actor); this.Actors.Add(actor); this.Repaint(); } } /// /// Sends the given actor the front of the list. /// /// public void BringActorToFront(siActor actor) { if (actor != null) { this.Actors.Remove(actor); this.Actors.Insert(0, actor); this.Repaint(); } } /// /// An event handler for whenever an actor is modified. /// /// void Actor_Modified(siActor sender, bool partial) { // Force a repaint to refresh the actor this.Repaint(); } //===================================================================== #endregion #region Event Methods //===================================================================== protected virtual void OnPaint(PaintEventArgs e) { // Render the actors in reverse order, sto that those at // the front are rendered on top of those at the back for (int i = this.Actors.Count-1; i>=0; i--) this.Actors[i].Paint(this, e); } protected virtual void OnResize() { // Force a repaint this.RaiseModified(); this.Repaint(); } protected virtual void OnClosed() { // Raise event this.RaiseClosed(); } protected virtual void OnMouseDown(MouseEventArgs e) { // Raise event this.RaiseMouseDown(e); // Force a repaint this.Repaint(); } protected virtual void OnMouseUp(MouseEventArgs e) { // Raise event this.RaiseMouseUp(e); // Force a repaint this.Repaint(); } protected virtual void OnMouseMove(MouseEventArgs e) { //Raise event this.RaiseMouseMove(e); // We don't want to force a total repaint (that takes too much // time) but we do want to inform the form that parts have // been invalidated by the mouse move. This invalidate forces // the form to update the mouse cursor (among other things). this.Form.Invalidate(); } protected virtual void OnMouseWheel(MouseEventArgs e) { // Raise event this.RaiseMouseWheel(e); // Force a repaint this.Repaint(); } protected virtual void OnKeyDown(KeyEventArgs e) { // Raise event this.Metadata["KeyDown"] = e; this.Metadata["CurrentKey"] = e; this.RaiseKeyDown(e); // Check for copy to clipboard shortcut (Ctrl+C) if (e.Control && e.KeyCode == Keys.C) Clipboard.SetImage(this.GetScreenCapture()); // Check for copy to temp folder shortcut (Ctrl+T) if (e.Control && e.KeyCode == Keys.T) { // Get the temporary path to write the image to if (this.m_TempPath == null || this.m_TempPath.Length == 0 || !Directory.Exists(this.m_TempPath)) { FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Please browse for the temporary images folder:"; fbd.RootFolder = Environment.SpecialFolder.MyComputer; fbd.ShowNewFolderButton = true; if (fbd.ShowDialog(this.ParentApplication as IWin32Window) == DialogResult.OK) this.m_TempPath = Path.Combine(fbd.SelectedPath, DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss-ff")); else return; } // Get a unique filename Directory.CreateDirectory(this.m_TempPath); string tempFile = Path.GetFileNameWithoutExtension(this.Inputs[0].Name) + "_" + this.m_NextFile.ToString("000") + ".png"; this.m_NextFile++; this.GetScreenCapture().Save(Path.Combine(this.m_TempPath, tempFile)); } } protected virtual void OnKeyUp(KeyEventArgs e) { // Raise event this.Metadata["KeyDown"] = null; this.Metadata["CurrentKey"] = e; this.RaiseKeyUp(e); } protected virtual void OnKeyPress(KeyPressEventArgs e) { // Raise event this.RaiseKeyPress(e); } protected virtual void OnGotFocus() { // Raise event this.RaiseGotFocus(); } protected virtual void OnLostFocus() { // Raise event this.RaiseLostFocus(); } //===================================================================== #endregion #region IDisposable Members //===================================================================== public virtual void Dispose() { this.Form.Dispose(); this.m_Form = null; this.Metadata.Clear(); this.m_Metadata = null; this.Inputs.Clear(); this.m_Inputs = null; } //===================================================================== #endregion #region Form Event Handlers //===================================================================== void Form_Paint(object sender, PaintEventArgs e) { this.OnPaint(e); } void Form_Resize(object sender, EventArgs e) { this.OnResize(); } void Form_MouseUp(object sender, MouseEventArgs e) { this.OnMouseUp(e); // Allow the Actors to consume the event bool eventWasConsumed = false; foreach (siActor actor in this.Actors) { eventWasConsumed = actor.MouseUp(this, e); if (eventWasConsumed) return; } } void Form_MouseDown(object sender, MouseEventArgs e) { this.OnMouseDown(e); // Allow the Actors to consume the event bool eventWasConsumed = false; foreach (siActor actor in this.Actors) { eventWasConsumed = actor.MouseDown(this, e); if (eventWasConsumed) return; } } void Form_MouseMove(object sender, MouseEventArgs e) { this.OnMouseMove(e); // Allow the Actors to consume the event bool eventWasConsumed = false; foreach (siActor actor in this.Actors) { eventWasConsumed = actor.MouseMove(this, e); if (eventWasConsumed) return; } } void Form_MouseWheel(object sender, MouseEventArgs e) { this.OnMouseWheel(e); } void Form_KeyDown(object sender, KeyEventArgs e) { this.OnKeyDown(e); } void Form_KeyUp(object sender, KeyEventArgs e) { this.OnKeyUp(e); } void Form_KeyPress(object sender, KeyPressEventArgs e) { this.OnKeyPress(e); } void Form_GotFocus(object sender, EventArgs e) { this.OnGotFocus(); } void Form_LostFocus(object sender, EventArgs e) { this.OnLostFocus(); } void Form_FormClosed(object sender, FormClosedEventArgs e) { this.Close(); } //===================================================================== #endregion } //========================================================================= #endregion }