private void DesignerControl_MouseUp(object sender, System.Windows.Forms.MouseEventArgs e) { if (ObjectType == null) { DragObjectFinished(); } else if (DragObject != null) { BaseObject ob = DragObject.Object; if (ObjectSteps == 0) { if (DragObject.ControlPoints.Length > 1) { PointF pf1 = ob.ToPointF(ob.ControlPoints[1]); PointF pf0 = ob.ToPointF(ob.ControlPoints[0]); if (Math.Sqrt((pf1.X - pf0.X) * (pf1.X - pf0.X) + (pf1.Y - pf0.Y) * (pf1.Y - pf0.Y)) > 20) { ObjectSteps++; } } } if (ObjectSteps != 0) { DragObject.ControlPointIndex = ObjectSteps + 1; } ObjectSteps++; if (ObjectSteps == ob.InitNum || ob.InitNum == 0) { DragObjectFinished(); } } }
private void DesignerControl_MouseUp(object sender, MouseEventArgs e) { if (this.ObjectType == null) { this.DragObjectFinished(); } else if (this.DragObject != null) { BaseObject obj2 = this.DragObject.Object; if ((this.ObjectSteps == 0) && (this.DragObject.ControlPoints.Length > 1)) { PointF tf = obj2.ToPointF(obj2.ControlPoints[1]); PointF tf2 = obj2.ToPointF(obj2.ControlPoints[0]); if (Math.Sqrt((double)(((tf.X - tf2.X) * (tf.X - tf2.X)) + ((tf.Y - tf2.Y) * (tf.Y - tf2.Y)))) > 20.0) { this.ObjectSteps++; } } if (this.ObjectSteps != 0) { this.DragObject.ControlPointIndex = this.ObjectSteps + 1; } this.ObjectSteps++; if (this.ObjectSteps == obj2.InitNum) { this.DragObjectFinished(); } } }
private void DesignerControl_MouseMove(object sender, MouseEventArgs e) { if (this.DragObject != null) { FormulaArea fa = this.DragObject.Object.Area; float num = e.X - this.DragObject.StartPoint.X; float num2 = e.Y - this.DragObject.StartPoint.Y; this.InvalidateObject(this.DragObject.Object); if (this.DragObject.ControlPointIndex < 0) { for (int i = 0; i < this.DragObject.Object.ControlPoints.Length; i++) { PointF tf = this.DragObject.Object.ToPointF(this.DragObject.ControlPoints[i]); this.DragObject.Object.ControlPoints[i] = this.GetValueFromPos(tf.X + num, tf.Y + num2, ref fa); } } else { BaseObject obj2 = this.DragObject.Object; obj2.ControlPoints[this.DragObject.ControlPointIndex] = this.GetValueFromPos((float)e.X, (float)e.Y, ref fa); if (((obj2.InitNum > 0) && (obj2.InitPoints != null)) && (obj2.InSetup && (this.DragObject.ControlPoints.Length > 1))) { PointF tf2 = obj2.ToPointF(obj2.ControlPoints[1]); PointF tf3 = obj2.ToPointF(obj2.ControlPoints[0]); float num4 = (tf2.X - tf3.X) / obj2.InitPoints[1].X; float num5 = (tf2.Y - tf3.Y) / obj2.InitPoints[1].Y; for (int j = 2; j < obj2.ControlPoints.Length; j++) { obj2.ControlPoints[j] = this.GetValueFromPos(tf3.X + (num4 * obj2.InitPoints[j].X), tf3.Y + (num5 * obj2.InitPoints[j].Y), ref fa); } } } this.InvalidateObject(this.DragObject.Object); } else { Cursor cursor = this.Designer.Cursor; if (this.GetPointIndex(e.X, e.Y) >= 0) { this.Designer.Cursor = Cursors.SizeAll; } else if (this.GetObjectAt(e.X, e.Y) != null) { this.Designer.Cursor = Cursors.Hand; } else if (this.ObjectType == null) { this.Designer.Cursor = cursor; } else { this.Designer.Cursor = Cursors.Cross; } } }
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 { } }
private void DesignerControl_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { try { CurrentMouseX = e.X; CurrentMouseY = e.Y; if (DragObject != null) { FormulaArea fa = DragObject.Object.Area; float DeltaX = e.X - DragObject.StartPoint.X; float DeltaY = e.Y - DragObject.StartPoint.Y; InvalidateObject(DragObject.Object); BaseObject ob = DragObject.Object; if (ob.ControlPointNum == 0) { return; } Changed = true; if (DragObject.ControlPointIndex < 0) { for (int i = 0; i < DragObject.Object.ControlPoints.Length; i++) { PointF pf = DragObject.Object.ToPointF(DragObject.ControlPoints[i]); DragObject.Object.ControlPoints[i] = GetValueFromPos(pf.X + DeltaX, pf.Y + DeltaY, ref fa); } } else { ob.ControlPoints[DragObject.ControlPointIndex] = GetValueFromPos(e.X, e.Y, ref fa); if (ob.InitNum > 0 && ob.InitPoints != null && ob.InSetup) { if (DragObject.ControlPoints.Length > 1) { PointF pf1 = ob.ToPointF(ob.ControlPoints[1]); PointF pf0 = ob.ToPointF(ob.ControlPoints[0]); float FactorX = (pf1.X - pf0.X) / ob.InitPoints[1].X; float FactorY = (pf1.Y - pf0.Y) / ob.InitPoints[1].Y; for (int i = 2; i < ob.ControlPoints.Length; i++) { ob.ControlPoints[i] = GetValueFromPos( pf0.X + FactorX * ob.InitPoints[i].X, pf0.Y + FactorY * ob.InitPoints[i].Y, ref fa); } } } } InvalidateObject(DragObject.Object); } else { Cursor OldCursor = Designer.Cursor; bool b = GetPointIndex(e.X, e.Y) >= 0; if (b) { Designer.Cursor = Cursors.SizeAll; } else { BaseObject ob = GetObjectAt(e.X, e.Y); if (ob != null) { Designer.Cursor = Cursors.Hand; } else if (ObjectType == null) { Designer.Cursor = OldCursor; } else { Designer.Cursor = Cursors.Cross; } } } } catch { } }