Пример #1
0
 public Reposition(DragInfo dragInfo, MouseEvt me, bool axisLock)
 {
     double tx = me.Pt.X - dragInfo.Me.Pt.X;
     double ty = me.Pt.Y - dragInfo.Me.Pt.Y;
     if (axisLock)
     {
         if (Math.Abs(tx) < Math.Abs(ty))
         {
             tx = 0;
         }
         else
         {
             ty = 0;
         }
     }
     this.output = new Lazy<Tuple<Polygon, Point>>(() => Tuple.Create(dragInfo.Me.Element.Polygon, new Point(dragInfo.OriginalLeft + tx, dragInfo.OriginalTop + ty)));
 }
Пример #2
0
        public Reposition(DragInfo dragInfo, MouseEvt me, bool axisLock)
        {
            double tx = me.Pt.X - dragInfo.Me.Pt.X;
            double ty = me.Pt.Y - dragInfo.Me.Pt.Y;

            if (axisLock)
            {
                if (Math.Abs(tx) < Math.Abs(ty))
                {
                    tx = 0;
                }
                else
                {
                    ty = 0;
                }
            }
            this.output = new Lazy <Tuple <Polygon, Point> >(() => Tuple.Create(dragInfo.Me.Element.Polygon, new Point(dragInfo.OriginalLeft + tx, dragInfo.OriginalTop + ty)));
        }
Пример #3
0
 public void HandleMouseUp(MouseEvt me)
 {
     this.dragInfo.Reset();
 }
Пример #4
0
 public void HandleMouseMove(MouseEvt me)
 {
     this.lastMe = Maybe.Just(me);
     this.Reposition();
 }
Пример #5
0
 protected EvtBase(MouseEvt me)
 {
     this.Me = me;
 }
Пример #6
0
        public Actor(Action <string> addMessage, Dispatcher dispatcher)
        {
            this.addMessage = addMessage;

            BlockingCollection <Reposition> @out = new BlockingCollection <Reposition>(1);

            Task.Run(() =>
            {
                try
                {
                    while (true)
                    {
                        this.cts.Token.ThrowIfCancellationRequested();

                        bool axisLock = false;

                        DragInfo dragInfo;
                        while (true)
                        {
                            this.cts.Token.ThrowIfCancellationRequested();

                            object e    = [email protected](this.cts.Token);
                            EvtDown me  = e as EvtDown;
                            ShiftEvt se = e as ShiftEvt;
                            if (me != null)
                            {
                                dragInfo = dispatcher.Invoke(() => new DragInfo(me.Me, Canvas.GetLeft(me.Me.Element.Polygon).ZeroIfNaN(), Canvas.GetTop(me.Me.Element.Polygon).ZeroIfNaN()));
                                break;
                            }
                            if (se != null)
                            {
                                axisLock = se.IsDown;
                            }
                        }

                        dispatcher.Invoke(() => this.addMessage("actor dragging " + dragInfo.Me.Element.Name));
                        MouseEvt lastMe = dragInfo.Me;
                        while (true)
                        {
                            this.cts.Token.ThrowIfCancellationRequested();

                            object me = [email protected](this.cts.Token);

                            EvtUp meUp     = me as EvtUp;
                            EvtMove meMove = me as EvtMove;
                            ShiftEvt se    = me as ShiftEvt;
                            if (meUp != null)
                            {
                                break;
                            }
                            if (meMove != null)
                            {
                                lastMe = meMove.Me;
                                @out.Add(new Reposition(dragInfo, lastMe, axisLock), this.cts.Token);
                            }
                            else if (se != null)
                            {
                                axisLock = se.IsDown;
                                @out.Add(new Reposition(dragInfo, lastMe, axisLock), this.cts.Token);
                            }
                        }
                    }
                }
                catch (OperationCanceledException)
                {
                }
            });

            Task.Run(() =>
            {
                try
                {
                    while (true)
                    {
                        this.cts.Token.ThrowIfCancellationRequested();

                        Reposition r = @out.Take(this.cts.Token);
                        dispatcher.Invoke(() =>
                        {
                            Canvas.SetLeft(r.Polygon, r.Left);
                            Canvas.SetTop(r.Polygon, r.Top);
                        });
                    }
                }
                catch (OperationCanceledException)
                {
                }
            });
        }
Пример #7
0
 public EvtUp(MouseEvt me)
     : base(me)
 {
 }
Пример #8
0
 protected EvtBase(MouseEvt me)
 {
     this.Me = me;
 }
Пример #9
0
 public void HandleMouseMove(MouseEvt me)
 {
     this.lastMe = Maybe.Just(me);
     this.Reposition();
 }
Пример #10
0
 public void HandleMouseUp(MouseEvt me) => this.sMouseUp.Send(me);
Пример #11
0
 public void HandleMouseUp(MouseEvt me)
 {
     this.dragInfo = Maybe.None;
 }
Пример #12
0
 public void HandleMouseMove(MouseEvt me) => this.sMouseMove.Send(me);
Пример #13
0
 public EvtUp(MouseEvt me)
     : base(me)
 {
 }
Пример #14
0
 public EvtMove(MouseEvt me)
     : base(me)
 {
 }
Пример #15
0
 public void HandleMouseMove(MouseEvt me) => this.sMouseMove.Send(me);
Пример #16
0
 public void HandleMouseUp(MouseEvt me)
 {
     Task.Run(() => [email protected](new EvtUp(me), this.cts.Token));
 }
Пример #17
0
 public void HandleMouseUp(MouseEvt me) => this.sMouseUp.Send(me);
Пример #18
0
 public EvtMove(MouseEvt me)
     : base(me)
 {
 }
Пример #19
0
 public void HandleMouseUp(MouseEvt me)
 {
     this.dragInfo.Reset();
 }
Пример #20
0
 public void HandleMouseUp(MouseEvt me)
 {
     Task.Run(() => [email protected](new EvtUp(me), this.cts.Token));
 }