[2768] | 1 | using System;
|
---|
| 2 | using System.Windows.Forms;
|
---|
[4068] | 3 | namespace Netron.Diagramming.Core {
|
---|
| 4 | /// <summary>
|
---|
| 5 | /// Clickable icon shape material
|
---|
| 6 | /// </summary>
|
---|
| 7 | public partial class ClickableIconMaterial : IconMaterial, IMouseListener, IHoverListener {
|
---|
| 8 | #region Fields
|
---|
| 9 |
|
---|
| 10 | // ------------------------------------------------------------------
|
---|
[2768] | 11 | /// <summary>
|
---|
[4068] | 12 | /// Implementation of IVersion - the current version of
|
---|
| 13 | /// ClickableIconMaterial.
|
---|
[2768] | 14 | /// </summary>
|
---|
[4068] | 15 | // ------------------------------------------------------------------
|
---|
| 16 | protected double clickableIconMaterialVersion = 1.0;
|
---|
[2768] | 17 |
|
---|
[4068] | 18 | #endregion
|
---|
[2768] | 19 |
|
---|
[4068] | 20 | #region Properties
|
---|
[2768] | 21 |
|
---|
[4068] | 22 | // ------------------------------------------------------------------
|
---|
| 23 | /// <summary>
|
---|
| 24 | /// Gets the current version.
|
---|
| 25 | /// </summary>
|
---|
| 26 | // ------------------------------------------------------------------
|
---|
| 27 | public override double Version {
|
---|
| 28 | get {
|
---|
| 29 | return clickableIconMaterialVersion;
|
---|
| 30 | }
|
---|
| 31 | }
|
---|
[2768] | 32 |
|
---|
[4068] | 33 | #endregion
|
---|
[2768] | 34 |
|
---|
[4068] | 35 | #region Constructor
|
---|
| 36 | /// <summary>
|
---|
| 37 | /// Initializes a new instance of the <see cref="T:ClickableIconMaterial"/> class.
|
---|
| 38 | /// </summary>
|
---|
| 39 | /// <param name="resourceLocation">The resource location.</param>
|
---|
| 40 | public ClickableIconMaterial(string resourceLocation)
|
---|
| 41 | : base(resourceLocation) {
|
---|
| 42 | Resizable = false;
|
---|
| 43 | }
|
---|
| 44 | /// <summary>
|
---|
| 45 | /// Initializes a new instance of the <see cref="T:ClickableIconMaterial"/> class.
|
---|
| 46 | /// </summary>
|
---|
| 47 | public ClickableIconMaterial()
|
---|
| 48 | : base() {
|
---|
| 49 | Resizable = false;
|
---|
| 50 | }
|
---|
| 51 | #endregion
|
---|
[2768] | 52 |
|
---|
[4068] | 53 | #region Methods
|
---|
| 54 | /// <summary>
|
---|
| 55 | /// Gets the service object of the specified type.
|
---|
| 56 | /// </summary>
|
---|
| 57 | /// <param name="serviceType">An object that specifies the type of service object to get.</param>
|
---|
| 58 | /// <returns>
|
---|
| 59 | /// A service object of type serviceType.-or- null if there is no service object of type serviceType.
|
---|
| 60 | /// </returns>
|
---|
| 61 | public override object GetService(Type serviceType) {
|
---|
| 62 | if (serviceType.Equals(typeof(IMouseListener)))
|
---|
| 63 | return this;
|
---|
| 64 | else if (serviceType.Equals(typeof(IHoverListener)))
|
---|
| 65 | return this;
|
---|
| 66 | else
|
---|
| 67 | return null;
|
---|
| 68 | }
|
---|
[2768] | 69 |
|
---|
[4068] | 70 | /// <summary>
|
---|
| 71 | /// Handles the mouse-down event
|
---|
| 72 | /// </summary>
|
---|
| 73 | /// <param name="e">The <see cref="T:MouseEventArgs"/> instance containing the event data.</param>
|
---|
| 74 | public virtual bool MouseDown(MouseEventArgs e) {
|
---|
| 75 | //if(this.Rectangle.Contains(e.Location))
|
---|
| 76 | // this.Shape.ShapeColor = Color.Yellow;
|
---|
| 77 | return false;
|
---|
| 78 | }
|
---|
[2768] | 79 |
|
---|
[4068] | 80 | /// <summary>
|
---|
| 81 | /// Handles the mouse-move event
|
---|
| 82 | /// </summary>
|
---|
| 83 | /// <param name="e">The <see cref="T:MouseEventArgs"/> instance containing the event data.</param>
|
---|
| 84 | public void MouseMove(MouseEventArgs e) {
|
---|
| 85 | System.Diagnostics.Trace.WriteLine(e.Location.ToString());
|
---|
| 86 | }
|
---|
[2768] | 87 |
|
---|
[4068] | 88 | /// <summary>
|
---|
| 89 | /// Handles the mouse-up event
|
---|
| 90 | /// </summary>
|
---|
| 91 | /// <param name="e">The <see cref="T:MouseEventArgs"/> instance containing the event data.</param>
|
---|
| 92 | public virtual void MouseUp(MouseEventArgs e) {
|
---|
[2768] | 93 |
|
---|
[4068] | 94 | }
|
---|
| 95 | #endregion
|
---|
[2768] | 96 |
|
---|
| 97 |
|
---|
| 98 |
|
---|
[4068] | 99 | #region IHoverListener Members
|
---|
| 100 | /// <summary>
|
---|
| 101 | /// Handles the <see cref="OnMouseHover"/> event.
|
---|
| 102 | /// </summary>
|
---|
| 103 | /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
|
---|
| 104 | public void MouseHover(MouseEventArgs e) {
|
---|
[2768] | 105 |
|
---|
| 106 | }
|
---|
[4068] | 107 | private Cursor previousCursor;
|
---|
| 108 | /// <summary>
|
---|
| 109 | /// Handles the OnMouseEnter event.
|
---|
| 110 | /// </summary>
|
---|
| 111 | /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
|
---|
| 112 | public void MouseEnter(MouseEventArgs e) {
|
---|
| 113 | previousCursor = Cursor.Current;
|
---|
| 114 | this.Shape.Model.RaiseOnCursorChange(Cursors.Hand);
|
---|
| 115 | }
|
---|
| 116 |
|
---|
| 117 | /// <summary>
|
---|
| 118 | /// Handles the OnMouseLeave event.
|
---|
| 119 | /// </summary>
|
---|
| 120 | /// <param name="e">The <see cref="T:System.Windows.Forms.MouseEventArgs"/> instance containing the event data.</param>
|
---|
| 121 | public void MouseLeave(MouseEventArgs e) {
|
---|
| 122 | this.Shape.Model.RaiseOnCursorChange(previousCursor);
|
---|
| 123 | }
|
---|
| 124 |
|
---|
| 125 | #endregion
|
---|
| 126 | }
|
---|
[2768] | 127 | }
|
---|