예제 #1
0
 //public void DragOver(object sender, DragEventArgs e)
 //{
 //    if (e.Data.GetData("Connect") is Connect obj)
 //    {
 //        obj.EndPoint = ForPoint.Subtraction(e.GetPosition(this), 2);
 //    }
 //}
 protected override void OnDragOver(DragEventArgs e)
 {
     if (e.Data.GetData("Connect") is Connect obj)
     {
         obj.EndPoint = ForPoint.Subtraction(e.GetPosition(this), 2);
     }
     base.OnDragOver(e);
 }
예제 #2
0
        public Node GetNewNode(Point position)
        {
            Node node = new Node("State " + this.nodes.Count.ToString(), this)
            {
                Name = "State" + this.nodes.Count.ToString()
            };

            ForPoint.Equality(node.Manager.translate, ForPoint.Division(position, node.Manager.Zoom));
            nodes.Add(node);
            Panel.SetZIndex(node, nodes.Count());
            return(node);
        }
예제 #3
0
        private void ChangePosition2(Point point)
        {
            Point position1 = ForPoint.GetValueAsPoint(transforms.translate);
            Point size      = ForPoint.Subtraction(point, position1);

            form.Width  = Math.Abs(size.X);
            form.Height = Math.Abs(size.Y);
            //Если нужно отражаем по X
            transforms.scale.ScaleX = (size.X > 0) ? 1 : -1;
            //Если нужно отражаем по Y
            transforms.scale.ScaleY = (size.Y > 0) ? 1 : -1;
        }
예제 #4
0
        public void Move(Point delta)
        {
            delta = ForPoint.DivisionOnScale(delta, scale);
            bool XMax = ((delta.X > 0) && (translate.X > TranslateXMax));
            bool XMin = ((delta.X < 0) && (translate.X < TranslateXMin));
            bool YMax = ((delta.Y > 0) && (translate.Y > TranslateYMax));
            bool YMin = ((delta.Y < 0) && (translate.Y < TranslateXMin));

            if (XMax || XMin || YMax || YMin)
            {
                return;
            }
            ForPoint.Addition(translate, delta);
        }
예제 #5
0
        public void Scale(int Delta)
        {
            bool Delta0   = (Delta == 0);
            bool DeltaMax = ((Delta > 0) && (Zoom > ScaleMax));
            bool DeltaMin = ((Delta < 0) && (Zoom < ScaleMin));

            if (Delta0 || DeltaMax || DeltaMin)
            {
                return;
            }

            Zoom += (Delta > 0) ? Scales : -Scales;
            ForPoint.EqualityScale(scale, Zoom);
        }
예제 #6
0
        public static Point GetPoint2WithScale(FrameworkElement element, Transforms transforms)
        {
            Point point1 = ForPoint.GetPoint1(element, transforms.translate);

            if (transforms.scale.ScaleX > 0)
            {
                point1.X += element.ActualWidth;
            }
            if (transforms.scale.ScaleY > 0)
            {
                point1.Y += element.ActualHeight;
            }
            return(point1);
        }
예제 #7
0
        public int UpdateSeletedNodes()
        {
            Point selectorPoint1 = Selector.Position1;
            Point selectorPoint2 = Selector.Position2;

            if (nodes.Count > 0)
            {
                selectorPoint1 = ForPoint.Division(selectorPoint1, nodes.First().Manager.Zoom);
                selectorPoint2 = ForPoint.Division(selectorPoint2, nodes.First().Manager.Zoom);
            }
            foreach (Node node in nodes)
            {
                node.Selected = Functions.Intersect(node.Point1, node.Point2, selectorPoint1, selectorPoint2);
            }
            return(0);
        }
예제 #8
0
        public Point GetDeltaMove(Point?CurrentPosition = null)
        {
            Point result = new Point();

            if (CurrentPosition == null)
            {
                CurrentPosition = Mouse.GetPosition(parent);
            }

            if (MovePoint != null)
            {
                result = ForPoint.Subtraction(CurrentPosition.Value, MovePoint.Value);
            }
            MovePoint = CurrentPosition;
            return(result);
        }
예제 #9
0
 private void ChangePosition1(Point point)
 {
     //изменяем текущее место положения
     ForPoint.Equality(transforms.translate, point);
     ForPoint.EqualityCenter(transforms.scale, point);
 }
예제 #10
0
 public static Point GetPoint1(FrameworkElement element, System.Windows.Media.TranslateTransform translate)
 {
     return(ForPoint.GetValueAsPoint(translate));
 }