public void Paste() { try { IDataObject ido = Clipboard.GetDataObject(); string s = (string)ido.GetData(typeof(string)); if (s != null) { byte[] bs = Encoding.UTF8.GetBytes(s); MemoryStream ms = new MemoryStream(bs); StreamReader sr = new StreamReader(ms); string t = sr.ReadLine(); Type T = Type.GetType(t); if (T != null) { XmlSerializer xs = new XmlSerializer(T); object o = xs.Deserialize(sr); if (o is BaseObject) { BaseObject bo = o as BaseObject; bo.SetObjectManager(this); FormulaHitInfo fhi = Canvas.Chart.GetHitInfo(CurrentMouseX, CurrentMouseY); FormulaArea fa = fhi.Area; if (fhi.HitType == FormulaHitType.htArea && fa != null) { PointF pf0 = bo.ToPointF(bo.ControlPoints[0]); float DeltaX = CurrentMouseX - pf0.X; float DeltaY = CurrentMouseY - pf0.Y; for (int i = 0; i < bo.ControlPoints.Length; i++) { PointF pf = bo.ToPointF(bo.ControlPoints[i]); bo.ControlPoints[i] = GetValueFromPos(pf.X + DeltaX, pf.Y + DeltaY, ref fa); } AddObject(bo); Invalidate(); } } } } } catch { } }
public ChartDragInfo(FormulaChart Chart, FormulaHitInfo HitInfo) { this.HitInfo = HitInfo; this.AreaHeight = new int[Chart.Areas.Count]; FormulaAxisY axisY = HitInfo.AxisY; if ((axisY == null) && (HitInfo.Area != null)) { axisY = HitInfo.Area.AxisY; } if (axisY != null) { this.AreaMinY = axisY.MinY; this.AreaMaxY = axisY.MaxY; } for (int i = 0; i < Chart.Areas.Count; i++) { FormulaArea area = Chart.Areas[i]; this.AreaHeight[i] = area.Rect.Height; } this.StartTime = Chart.StartTime; this.EndTime = Chart.EndTime; }
/// <summary> /// Constructor of ChartDragInfo /// </summary> /// <param name="Chart">FormulaChart instance</param> /// <param name="HitInfo">The Hit information of the dragging start point</param> public ChartDragInfo(FormulaChart Chart, FormulaHitInfo HitInfo) { this.HitInfo = HitInfo; AreaHeight = new int[Chart.Areas.Count]; FormulaAxisY fay = HitInfo.AxisY; if (fay == null && HitInfo.Area != null) { fay = HitInfo.Area.AxisY; } if (fay != null) { AreaMinY = fay.MinY; AreaMaxY = fay.MaxY; } for (int i = 0; i < Chart.Areas.Count; i++) { FormulaArea fa = Chart.Areas[i]; AreaHeight[i] = fa.Rect.Height; } StartTime = Chart.StartTime; EndTime = Chart.EndTime; }