예제 #1
0
 public void HandleMouseMove(MouseEvt me)
 {
     this.dragInfo.MatchSome(
         d =>
     {
         Reposition r = new Reposition(d, me);
         Canvas.SetLeft(r.Polygon, r.Left);
         Canvas.SetTop(r.Polygon, r.Top);
     });
 }
예제 #2
0
파일: Classic.cs 프로젝트: Angeldude/sodium
 public void HandleMouseMove(MouseEvt me)
 {
     this.dragInfo.Get().Match(
         d =>
         {
             Reposition r = new Reposition(d, me);
             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();

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

                            EvtDown me = [email protected](this.cts.Token) as EvtDown;
                            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;
                            }
                        }

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

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

                            EvtUp meUp     = me as EvtUp;
                            EvtMove meMove = me as EvtMove;
                            if (meUp != null)
                            {
                                break;
                            }
                            if (meMove != null)
                            {
                                @out.Add(new Reposition(dragInfo, meMove.Me), 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)
                {
                }
            });
        }