Exemplo n.º 1
0
        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;
                    }
                }
            }
        }
Exemplo n.º 2
0
 public DrawRectangle(MyCapture cap)
     : base(cap)
 {
     MyCapture = cap;
 }
Exemplo n.º 3
0
 public DrawFont(MyCapture cap)
     : base(cap)
 {
     MyCapture = cap;
 }
Exemplo n.º 4
0
 public DrawCopy(MyCapture cap)
     : base(cap)
 {
     MyCapture = cap;
 }
Exemplo n.º 5
0
 public DrawSelected(MyCapture cap)
     : base(cap)
 {
     MyCapture = cap;
 }
Exemplo n.º 6
0
 public DrawEllipse(MyCapture cap)
     : base(cap)
 {
     MyCapture = cap;
 }
Exemplo n.º 7
0
 public DrawLine(MyCapture cap)
     : base(cap)
 {
     MyCapture = cap;
 }
Exemplo n.º 8
0
 public DrawBase(MyCapture cap)
 {
 }
Exemplo n.º 9
0
 public DrawGroup(MyCapture cap)
     : base(cap)
 {
     MyCapture = cap;
 }
Exemplo n.º 10
0
        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;
            }
        }