Пример #1
0
 private void Reposition()
 {
     this.dragInfo.MatchSome(
         d =>
     {
         this.lastMe.MatchSome(
             me =>
         {
             Reposition r = new Reposition(d, me, this.axisLock);
             Canvas.SetLeft(r.Polygon, r.Left);
             Canvas.SetTop(r.Polygon, r.Top);
         });
     });
 }
Пример #2
0
 private void Reposition()
 {
     this.dragInfo.Get().Match(
         d =>
         {
             this.lastMe.Match(
                 me =>
                 {
                     Reposition r = new Reposition(d, me, this.axisLock);
                     Canvas.SetLeft(r.Polygon, r.Left);
                     Canvas.SetTop(r.Polygon, r.Top);
                 },
                 () => { });
         },
         () => { });
 }
Пример #3
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)
                {
                }
            });
        }