예제 #1
0
파일: ui.cs 프로젝트: dotnet/wpf-test
        /// <summary>
        /// Executes requested action
        /// </summary>
        private void DoRequestedAction(object o)
        {
            EventQueueItem item = (EventQueueItem)o;

            switch (item.Command)
            {
            case Command.MouseRightDown:
                MTI.Input.SendMouseInput(0, 0, 0, MTI.SendMouseInputFlags.RightDown);
                break;

            case Command.MouseRightUp:
                MTI.Input.SendMouseInput(0, 0, 0, MTI.SendMouseInputFlags.RightUp);
                break;

            case Command.MouseLeftDown:
                MTI.Input.SendMouseInput(0, 0, 0, MTI.SendMouseInputFlags.LeftDown);
                break;

            case Command.MouseLeftUp:
                MTI.Input.SendMouseInput(0, 0, 0, MTI.SendMouseInputFlags.LeftUp);
                break;

            case Command.MouseMove:
                Rect  r      = AvalonHelper.GetBoundingRectangle(item.Parameter as UIElement);
                Point center = RectUtils.Center(r);
                MTI.Input.MoveTo(center);
                break;

            default:
                break;
            }
        }
예제 #2
0
파일: ui.cs 프로젝트: dotnet/wpf-test
        /// <summary>
        /// Methods that gets called by the dispatcher to 1) execute an item and then 2) post next item in the dispatcher's queue
        /// </summary>
        private object Post(object o)
        {
            // if called with a non-null object, it means that an item must be execute
            if (o != null)
            {
                DoRequestedAction(o);
            }

            // take next item
            if (this.Count > 0)
            {
                // get next item
                EventQueueItem item = (EventQueueItem)Dequeue();

                // post it
                Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(Post), item);
            }

            return(null);
        }