/// <summary> /// Initializes a new instance of the <see cref="CurveItem"/> class. /// Constructor for deserializing objects /// </summary> /// <param name="info"> /// A <see cref="SerializationInfo"/> instance that defines the serialized data /// </param> /// <param name="context"> /// A <see cref="StreamingContext"/> instance that contains the serialized data /// </param> protected CurveItem(SerializationInfo info, StreamingContext context) { // The schema value is just a file version parameter. You can use it to make future versions // backwards compatible as new member variables are added to classes int sch = info.GetInt32("schema"); this._label = (Label)info.GetValue("label", typeof(Label)); this._isY2Axis = info.GetBoolean("isY2Axis"); if (sch >= 11) { this._isX2Axis = info.GetBoolean("isX2Axis"); } else { this._isX2Axis = false; } this._isVisible = info.GetBoolean("isVisible"); this._isOverrideOrdinal = info.GetBoolean("isOverrideOrdinal"); // Data Points are always stored as a PointPairList, regardless of the // actual original type (which could be anything that supports IPointList). this._points = (PointPairList)info.GetValue("points", typeof(PointPairList)); this.Tag = info.GetValue("Tag", typeof(object)); this._yAxisIndex = info.GetInt32("yAxisIndex"); this._link = (Link)info.GetValue("link", typeof(Link)); }
/// <summary> /// Internal initialization routine thats sets some initial values to defaults. /// </summary> /// <param name="label"> /// A string label (legend entry) for this curve /// </param> private void Init(string label) { this._label = new Label(label, null); this._isY2Axis = false; this._isX2Axis = false; this._isVisible = true; this._isOverrideOrdinal = false; this.Tag = null; this._yAxisIndex = 0; this._link = new Link(); }
/// <summary> /// Initializes a new instance of the <see cref="CurveItem"/> class. /// The Copy Constructor /// </summary> /// <param name="rhs"> /// The CurveItem object from which to copy /// </param> public CurveItem(CurveItem rhs) { this._label = rhs._label.Clone(); this._isY2Axis = rhs.IsY2Axis; this._isX2Axis = rhs.IsX2Axis; this._isVisible = rhs.IsVisible; this._isOverrideOrdinal = rhs._isOverrideOrdinal; this._yAxisIndex = rhs._yAxisIndex; if (rhs.Tag is ICloneable) { this.Tag = ((ICloneable)rhs.Tag).Clone(); } else { this.Tag = rhs.Tag; } this._points = (IPointList)rhs.Points.Clone(); this._link = rhs._link.Clone(); }
/// <summary> /// Search through the <see cref="GraphObjList"/> and <see cref="CurveList"/> for items that contain active <see cref="Link"/> objects. /// </summary> /// <param name="mousePt"> /// The mouse location where the click occurred /// </param> /// <param name="g"> /// An appropriate <see cref="Graphics"/> instance /// </param> /// <param name="scaleFactor"> /// The current scaling factor for drawing operations. /// </param> /// <param name="source"> /// The clickable object that was found. Typically a type of /// <see cref="GraphObj"/> or a type of <see cref="CurveItem"/>. /// </param> /// <param name="link"> /// The <see cref="Link"/> instance that is contained within the <see paramref="source"/> object. /// </param> /// <param name="index"> /// An index value, indicating which point was clicked for /// <see cref="CurveItem"/> type objects. /// </param> /// <returns> /// returns true if a clickable link was found under the /// <see paramref="mousePt"/>, or false otherwise. /// </returns> public bool FindLinkableObject(PointF mousePt, Graphics g, float scaleFactor, out object source, out Link link, out int index) { index = -1; // First look for graph objects that lie in front of the data points foreach (GraphObj graphObj in this._graphObjList) { link = graphObj._link; bool inFront = graphObj.IsInFrontOfData; if (link.IsActive) { if (graphObj.PointInBox(mousePt, this, g, scaleFactor)) { source = graphObj; return true; } } } // Second, look at the curve data points foreach (CurveItem curve in this._curveList) { link = curve._link; if (link.IsActive) { CurveItem nearestCurve; if (this.FindNearestPoint(mousePt, curve, out nearestCurve, out index)) { source = curve; return true; } } } // Third, look for graph objects that lie behind the data points foreach (GraphObj graphObj in this._graphObjList) { link = graphObj._link; bool inFront = graphObj.IsInFrontOfData; if (link.IsActive) { if (graphObj.PointInBox(mousePt, this, g, scaleFactor)) { source = graphObj; return true; } } } source = null; link = null; index = -1; return false; }
/// <summary> /// Initializes a new instance of the <see cref="Link"/> class. /// The Copy Constructor /// </summary> /// <param name="rhs"> /// The <see cref="Link"/> object from which to copy /// </param> public Link(Link rhs) { // Copy value types this._title = rhs._title; this._url = rhs._url; this._target = rhs._target; this._isEnabled = false; // copy reference types by cloning if (rhs.Tag is ICloneable) { this.Tag = ((ICloneable)rhs.Tag).Clone(); } else { this.Tag = rhs.Tag; } }
/// <summary> /// Initializes a new instance of the <see cref="GraphObj"/> class. /// Constructor for deserializing objects /// </summary> /// <param name="info"> /// A <see cref="SerializationInfo"/> instance that defines the serialized data /// </param> /// <param name="context"> /// A <see cref="StreamingContext"/> instance that contains the serialized data /// </param> protected GraphObj(SerializationInfo info, StreamingContext context) { // The schema value is just a file version parameter. You can use it to make future versions // backwards compatible as new member variables are added to classes int sch = info.GetInt32("schema"); this._location = (Location)info.GetValue("location", typeof(Location)); this._isVisible = info.GetBoolean("isVisible"); this.Tag = info.GetValue("Tag", typeof(object)); this._zOrder = (ZOrder)info.GetValue("zOrder", typeof(ZOrder)); this._isClippedToChartRect = info.GetBoolean("isClippedToChartRect"); this._link = (Link)info.GetValue("link", typeof(Link)); }
/// <summary> /// Initializes a new instance of the <see cref="GraphObj"/> class. /// The Copy Constructor /// </summary> /// <param name="rhs"> /// The <see cref="GraphObj"/> object from which to copy /// </param> public GraphObj(GraphObj rhs) { // Copy value types this._isVisible = rhs.IsVisible; this._isClippedToChartRect = rhs._isClippedToChartRect; this._zOrder = rhs.ZOrder; // copy reference types by cloning if (rhs.Tag is ICloneable) { this.Tag = ((ICloneable)rhs.Tag).Clone(); } else { this.Tag = rhs.Tag; } this._location = rhs.Location.Clone(); this._link = rhs._link.Clone(); }
/// <summary> /// Initializes a new instance of the <see cref="GraphObj"/> class. /// Constructor that creates a <see cref="GraphObj"/> with the specified position, <see cref="CoordType"/>, <see cref="AlignH"/>, and /// <see cref="AlignV"/>. Other properties are set to default values as defined in the <see cref="Default"/> class. /// </summary> /// <remarks> /// The four coordinates define the starting point and ending point for /// <see cref="ArrowObj"/>'s, or the topleft and bottomright points for /// <see cref="ImageObj"/>'s. For <see cref="GraphObj"/>'s that only require one point, the <see paramref="x2"/> and <see paramref="y2"/> values /// will be ignored. The units of the coordinates are specified by the /// <see cref="Graph.Location.CoordinateFrame"/> property. /// </remarks> /// <param name="x"> /// The x position of the item. /// </param> /// <param name="y"> /// The y position of the item. /// </param> /// <param name="x2"> /// The x2 position of the item. /// </param> /// <param name="y2"> /// The x2 position of the item. /// </param> /// <param name="coordType"> /// The <see cref="CoordType"/> enum value that indicates what type of coordinate system the x and y parameters are referenced /// to. /// </param> /// <param name="alignH"> /// The <see cref="AlignH"/> enum that specifies the horizontal alignment of the object with respect to the (x,y) location /// </param> /// <param name="alignV"> /// The <see cref="AlignV"/> enum that specifies the vertical alignment of the object with respect to the (x,y) location /// </param> public GraphObj(double x, double y, double x2, double y2, CoordType coordType, AlignH alignH, AlignV alignV) { this._isVisible = true; this._isClippedToChartRect = Default.IsClippedToChartRect; this.Tag = null; this._zOrder = ZOrder.A_InFront; this._location = new Location(x, y, x2, y2, coordType, alignH, alignV); this._link = new Link(); }