public virtual void SetTranslate(UIElement path) { TranslateTransform pathTranslate = MyCapture.GetTranslate(); ScaleTransform pathScale = MyCapture.GetScale(); TransformGroup tfGroup = path.RenderTransform as TransformGroup; if (tfGroup == null) { tfGroup = new TransformGroup(); tfGroup.Children.Add(pathTranslate); tfGroup.Children.Add(pathScale); path.RenderTransform = tfGroup; } else { TranslateTransform tempTranslate = null; foreach (var item in tfGroup.Children) { tempTranslate = item as TranslateTransform; if (tempTranslate != null) { tempTranslate.X = pathTranslate.X; tempTranslate.Y = pathTranslate.Y; //break; } ScaleTransform tempScale = item as ScaleTransform; if (tempScale != null) { tempScale.CenterX = pathScale.CenterX; tempScale.CenterY = pathScale.CenterY; tempScale.ScaleX = pathScale.ScaleX; tempScale.ScaleY = pathScale.ScaleY; } } } }
public DrawRectangle(MyCapture cap) : base(cap) { MyCapture = cap; }
public DrawFont(MyCapture cap) : base(cap) { MyCapture = cap; }
public DrawCopy(MyCapture cap) : base(cap) { MyCapture = cap; }
public DrawSelected(MyCapture cap) : base(cap) { MyCapture = cap; }
public DrawEllipse(MyCapture cap) : base(cap) { MyCapture = cap; }
public DrawLine(MyCapture cap) : base(cap) { MyCapture = cap; }
public DrawBase(MyCapture cap) { }
public DrawGroup(MyCapture cap) : base(cap) { MyCapture = cap; }
public virtual void MouseMove(object sender, Point point, MyCapture cap, double scale) { if (isMove && moveStep == 1) { Point pm2 = point; Canvas cmain = sender as Canvas; //Console.WriteLine(string.Format("p1(x:{0},y:{1})", pm1.X, pm1.Y)); //Console.WriteLine(string.Format("p2(x:{0},y:{1})", pm2.X, pm2.Y)); double mx = (pm2.X - pm1.X) / scale; double my = (pm2.Y - pm1.Y) / scale; TranslateTransform tempTranslate = cap.SetTranslate(mx, my); //Console.WriteLine(string.Format("t(x:{0},y:{1})", tempTranslate.X, tempTranslate.Y)); //btext.Content = string.Format("{0},{1}", tempTranslate.X, tempTranslate.Y); foreach (var item in cmain.Children) { if (item is TextBlock) { TextBlock tb = item as TextBlock; if (tb.Tag != null && tb.Tag.ToString() == "sp_bz") { continue; } } UIElement path = item as UIElement; TransformGroup tfGroup = path.RenderTransform as TransformGroup; if (tfGroup == null) { TranslateTransform pathTranslate = new TranslateTransform(); pathTranslate.X = tempTranslate.X; pathTranslate.Y = tempTranslate.Y; tfGroup = new TransformGroup(); tfGroup.Children.Add(pathTranslate); path.RenderTransform = tfGroup; } else { TranslateTransform pathTranslate = null; foreach (var tran in tfGroup.Children) { pathTranslate = tran as TranslateTransform; if (pathTranslate != null) { pathTranslate.X = tempTranslate.X; pathTranslate.Y = tempTranslate.Y; break; } } if (pathTranslate == null) { pathTranslate = new TranslateTransform(); pathTranslate.X = tempTranslate.X; pathTranslate.Y = tempTranslate.Y; tfGroup.Children.Add(pathTranslate); } //TranslateTransform pathTranslate = tfGroup.Children[0] as TranslateTransform; } } pm1 = pm2; } }