Example #1
0
        private void MotionButton_TouchEnter(object sender, TouchEventArgs e)
        {
            StartTimer();
            _lastTouchDevice = e.Device;

            ScaleDown();
        }
Example #2
0
    private static Vector DraggedDelta(InputDevice inputDevice, Window window, UIElement relativeTo)
    {
      /*
      MouseDevice mouse = inputDevice as MouseDevice;
      Contact contact = inputDevice as Contact;

      // get the current position
      Point currentPosition = (mouse == null) ? contact.GetPosition(window) : mouse.GetPosition(window);

      // get the down state
      if (!deviceStateDictionary.ContainsKey(inputDevice))
      {
        return ZeroVector;
      }

      // translate to the relativeTo elementToDrag
      Point downPosition = deviceStateDictionary[inputDevice].Position;

      if (relativeTo != window)
      {
        currentPosition = window.TranslatePoint(currentPosition, relativeTo);
        downPosition = window.TranslatePoint(downPosition, relativeTo);
      }

      return (currentPosition - downPosition);
       */
      return new Vector(0,0);
    }
Example #3
0
        /// <summary>
        ///     Initializes a new instance of the InputEventArgs class.
        /// </summary>
        /// <param name="inputDevice">
        ///     The input device to associate with this event.
        /// </param>
        /// <param name="timestamp">
        ///     The time when the input occured. 
        /// </param>
        public InputEventArgs(InputDevice inputDevice, int timestamp)
        {
            /* inputDevice parameter being null is valid*/
	    /* timestamp parameter is valuetype, need not be checked */
            _inputDevice = inputDevice;
            _timestamp = timestamp;
        }
        /// <summary>
        ///     Initializes a new instance of the InputReportEventArgs class.
        /// </summary>
        /// <param name="inputDevice">
        ///     The input device to associate this input with.
        /// </param>
        /// <param name="report">
        ///     The input report being processed.
        /// </param>
        public InputReportEventArgs(InputDevice inputDevice, 
                                    InputReport report) : base(inputDevice, ((report != null) ? report.Timestamp : -1))
        {
            if (report == null)
                throw new ArgumentNullException("report");

            _report = report;
        }
        /// <summary> 
        ///     Constructs an instance of the TextInputEventArgs class.
        /// </summary> 
        /// <param name="inputDevice"> 
        ///     The input device to associate with this event.
        /// </param> 
        /// <param name="composition">
        ///     The TextComposition object that contains the composition text and the composition state.
        /// </param>
        public TextCompositionEventArgs(InputDevice inputDevice, TextComposition composition) : base(inputDevice, Environment.TickCount) 
        {
            if (composition == null) 
            { 
                throw new ArgumentNullException("composition");
            } 

            _composition = composition;
        }
Example #6
0
        public static void ClearDeviceState(InputDevice device)
        {
            if (device == null)
            {
                return;
            }

            deviceStateDictionary.Remove(device);
        }
Example #7
0
 private void FillSymbolDown(object sender, InputDevice device, Point pos)
 {
     var db = ((FrameworkElement)sender).DataContext as DataBinding;
     if (db == null) return;
     var pl = db.Attributes["Layer"] as dsLayer;
     if (pl == null) return;
     var p = db.Attributes["PoI"] as PoI;
     UpdateCircularMenu(p, db, pl, pos);
 }
Example #8
0
        /// <summary>
        /// Returns the Source the input device was placed at.
        /// </summary>
        public static DependencyObject GetDragSource(InputDevice inputDevice)
        {
            if (inputDevice == null)
            {
                throw new ArgumentNullException("inputDevice");
            }

            if (deviceStateDictionary.ContainsKey(inputDevice))
            {
                return deviceStateDictionary[inputDevice].Source;
            }

            return null;
        }
Example #9
0
        /// <summary>
        /// Returns delta between current input device position and where the input device was placed
        /// relative to the given elementToDrag.
        /// </summary>
        /// <param name="inputDevice"></param>
        /// <param name="relativeTo"></param>
        /// <returns></returns>
        public static Vector DraggedDelta(InputDevice inputDevice, UIElement relativeTo)
        {
            if (inputDevice == null)
            {
                throw new ArgumentNullException("inputDevice");
            }

            if (relativeTo == null)
            {
                throw new ArgumentNullException("relativeTo");
            }

            Window window = inputDevice.ActiveSource.RootVisual as Window;
            if (window != null)
            {
                return DraggedDelta(inputDevice, window, relativeTo);
            }

            return ZeroVector;
        }
Example #10
0
        public static void InitializeDeviceState(InputDevice device)
        {
            if (device == null || deviceStateDictionary.ContainsKey(device))
            {
                return;
            }

            Window window = device.ActiveSource.RootVisual as Window;
            if (window == null)
            {
                return;
            }

            MouseDevice mouse = device as MouseDevice;
            Contact contact = device as Contact;

            Point position = (mouse == null) ? contact.GetPosition(window) : mouse.GetPosition(window);
            DependencyObject directlyOver = (mouse == null) ? contact.DirectlyOver as DependencyObject: mouse.DirectlyOver as DependencyObject;

            deviceStateDictionary.Add(device, new DragState(position, directlyOver));
        }
        /// <summary>
        /// Determines whether this visualization matches the specified input device.
        /// </summary>
        /// <param name="inputDevice"></param>
        /// <returns></returns>
        public override bool Matches(InputDevice inputDevice)
        {
            // We match a given InputDevice if it's tag value is present
            // in our item data.

            if (itemData == null)
            {
                return false;
            }

            // Has to be a valid tag
            if (!IsTagValid(inputDevice.GetTagData()))
            {
                return false;
            }

            // Look for a match in our item data
            Items.Item matchingItem = itemData.Find((byte)inputDevice.GetTagData().Value);

            return matchingItem != null;
        }
        private static Vector DraggedDelta(InputDevice inputDevice, Window window, UIElement relativeTo)
        {
            // get the current position
            Point currentPosition = inputDevice.GetPosition(window);

            // get the down state
            if (!deviceStateDictionary.ContainsKey(inputDevice))
            {
                return ZeroVector;
            }

            // translate to the relativeTo elementToDrag
            Point downPosition = deviceStateDictionary[inputDevice].Position;

            if (relativeTo != window)
            {
                currentPosition = window.TranslatePoint(currentPosition, relativeTo);
                downPosition = window.TranslatePoint(downPosition, relativeTo);
            }

            return (currentPosition - downPosition);
        }
Example #13
0
        public void StartDragDrop(object sender, InputDevice device, object src)
        {
            var mf = sender;

            // Check whether the input device is in the ignore list.
            if (ignoredDeviceList.Contains(device)) return;

            InputDeviceHelper.InitializeDeviceState(device);

            // try to start drag-and-drop,
            // verify that the cursor the contact was placed at is a ListBoxItem
            //                DependencyObject downSource = sender as DependencyObject;
            //                FrameworkElement parrent = mf.Parent as FrameworkElement;
            //                var source = GetVisualAncestor<FrameworkElement>(downSource);

            var findSource = src as FrameworkElement;

            //var parrent = GetVisualAncestor<FrameworkElement>(downSource);

            //                var cursorVisual = new ucDocument(){Document = new Document(){Location = mf.Location}};
            //                var cursorVisual = new ListFeatureView() { CanBeDragged = false };
            var cursorVisual = new Border {
                                              Background = Brushes.Black,
                                              DataContext = mf,
                                              Width = 30,
                                              Height = 30
                                          };


            IEnumerable<InputDevice> devices = new List<InputDevice>(new[] {device});

            SurfaceDragDrop.BeginDragDrop(view, findSource, cursorVisual, mf, devices, DragDropEffects.Copy);

            // Reset the input device's state.
            InputDeviceHelper.ClearDeviceState(device);
            ignoredDeviceList.Remove(device);
        }
 public TextCompositionEventArgs(InputDevice inputDevice, TextComposition composition)
     : base(inputDevice, /* XXX */ 0)
 {
 }
 public BeginDragEventArgs(InputDevice device, Point dragOrigin, Point currentPosition)
 {
     Device = device;
     DragOrigin = dragOrigin;
     CurrentPosition = currentPosition;
 }
Example #16
0
 private void AbortExistingEngineIfAny(InputDevice device)
 {
   if (!engineStatuses.ContainsKey(device))
     return;
   var engine = engineStatuses[device];
   engine.AbortGesture();
   engineStatuses.Remove(device);
 }
Example #17
0
		public ArgsPoker (InputDevice device, int timestamp)
			: base (device, timestamp)
		{
		}
Example #18
0
 public ItemNavigateArgs(InputDevice deviceUsed, ModifierKeys modifierKeys)
 {
     _deviceUsed = deviceUsed;
     _modifierKeys = modifierKeys;
 }
Example #19
0
		public InputEventArgs (InputDevice inputDevice, int timestamp)
		{
			this.inputDevice = inputDevice;
			this.timestamp = timestamp;
		}
Example #20
0
 private void SurfaceButton1_TouchEnter(object sender, TouchEventArgs e)
 {
     StartTimer();
     lastTouchDevice = e.Device;
 }
        /// <summary>
        /// A static helper method to raise the BeginDrag event on a target element.
        /// </summary>
        /// <param name="target">UIElement or ContentElement on which to raise the event</param>
        /// <param name="device">The input device that owns the drag operation.</param>
        /// <param name="dragOrigin">The origin of the drag operation relative to the input element raising the event.</param>
        /// <param name="currentPosition">The current position of the input device relative to the input element raising the event.</param>
        internal static BeginDragEventArgs RaiseBeginDragEvent(DependencyObject target, InputDevice device, Point dragOrigin, Point currentPosition)
        {
            if (target == null) return null;

            BeginDragEventArgs args = new BeginDragEventArgs(device, dragOrigin, currentPosition);
            args.RoutedEvent = BeginDragEvent;
            RoutedEventHelper.RaiseEvent(target, args);
            return args;
        }
Example #22
0
        internal TextComposition(InputManager inputManager, IInputElement source, string resultText, TextCompositionAutoComplete autoComplete, InputDevice inputDevice)
        { 
            _inputManager = inputManager; 

            _inputDevice = inputDevice; 

            if (resultText == null)
            {
                throw new ArgumentException(SR.Get(SRID.TextComposition_NullResultText)); 
            }
 
            _resultText = resultText; 
            _compositionText = "";
            _systemText = ""; 
            _systemCompositionText = "";
            _controlText = "";

            _autoComplete = autoComplete; 

            _stage = TextCompositionStage.None; 
 
            // source of this text composition.
            _source = source; 
        }
 /// <summary>
 /// A helper method to raise the BeginDrag event.
 /// </summary>
 /// <param name="device">The input device that owns the drag operation.</param>
 /// <param name="dragOrigin">The origin of the drag operation relative to the input element raising the event.</param>
 /// <param name="currentPosition">The current position of the input device relative to the input element raising the event.</param>
 protected BeginDragEventArgs RaiseBeginDragEvent(InputDevice device, Point dragOrigin, Point currentPosition)
 {
     return RaiseBeginDragEvent(this, device, dragOrigin, currentPosition);
 }
 public TextCompositionEventArgs(InputDevice inputDevice, TextComposition composition) : base (default(InputDevice), default(int))
 {
 }
Example #25
0
        /// <summary>
        /// The start drag drop.
        /// </summary>
        /// <param name="sender">
        /// The sender.
        /// </param>
        /// <param name="device">
        /// The device.
        /// </param>
        /// <param name="src">
        /// The src.
        /// </param>
        public void StartDragDrop(object sender, InputDevice device, object src)
        {
            // if (!layer.Service.Settings.CanEdit) return;
            var p = sender as PoI;

            if (p == null)
            {
                return;
            }

            if (!p.IsVisible)
            {
                return;
            }

            this.SelectedPoiType = p;
            p.Data["layer"] = this.layer; // Needed for drag drop handler
            bool iconDragEnabled = this.AppState.Config.GetBool(CreatePoiByDraggingIconIsEnabled, true);
            if (iconDragEnabled && (this.view != null) && (this.ActiveEditMode == EditMode.Icon))
            {
                var mf = sender;

                // Check whether the input device is in the ignore list.
                if (this.ignoredDeviceList.Contains(device))
                {
                    return;
                }

                InputDeviceHelper.InitializeDeviceState(device);

                // try to start drag-and-drop,
                // verify that the cursor the contact was placed at is a ListBoxItem
                // DependencyObject downSource = sender as DependencyObject;
                // FrameworkElement parrent = mf.Parent as FrameworkElement;
                // var source = GetVisualAncestor<FrameworkElement>(downSource);
                var findSource = src as FrameworkElement;

                // var parrent = GetVisualAncestor<FrameworkElement>(downSource);

                // var cursorVisual = new ucDocument(){Document = new Document(){Location = mf.Location}};
                // var cursorVisual = new ListFeatureView() { CanBeDragged = false };
                var cursorVisual = new ucPoiPreview { PoI = mf as PoI, DataContext = mf, Width = 40, Height = 40 };

                var devices = new List<InputDevice>(new[] { device });

                SurfaceDragDrop.BeginDragDrop(this.view, findSource, cursorVisual, mf, devices, DragDropEffects.Copy);

                // Reset the input device's state.
                InputDeviceHelper.ClearDeviceState(device);
                this.ignoredDeviceList.Remove(device);
            }
        }
Example #26
0
        public void StartDragDrop(object sender, InputDevice device, object src) {
            //if (!layer.Service.Settings.CanEdit) return;

            var mf = sender;

            // Check whether the input device is in the ignore list.
            if (ignoredDeviceList.Contains(device)) return;

            InputDeviceHelper.InitializeDeviceState(device);

            // try to start drag-and-drop,
            // verify that the cursor the contact was placed at is a ListBoxItem
            //                DependencyObject downSource = sender as DependencyObject;
            //                FrameworkElement parrent = mf.Parent as FrameworkElement;
            //                var source = GetVisualAncestor<FrameworkElement>(downSource);

            var findSource = src as FrameworkElement;

            //var parrent = GetVisualAncestor<FrameworkElement>(downSource);

            //                var cursorVisual = new ucDocument(){Document = new Document(){Location = mf.Location}};
            //                var cursorVisual = new ListFeatureView() { CanBeDragged = false };
            var cursorVisual = new TaskDragItem {
                Task = Task,
                IsDragging = true,
                Plugin = Plugin,
                DataContext = mf,
                Width = 75,
                Height = 75
            };


            var devices = new List<InputDevice>(new[] {device});

            SurfaceDragDrop.BeginDragDrop(this, findSource, cursorVisual, mf, devices, DragDropEffects.Copy);

            // Reset the input device's state.
            InputDeviceHelper.ClearDeviceState(device);
            ignoredDeviceList.Remove(device);
        }
		public TextCompositionEventArgs (InputDevice inputDevice, TextComposition composition)
			: base (inputDevice, /* XXX */ 0)
		{
		}
Example #28
0
 internal DeadCharTextComposition(InputManager inputManager, IInputElement source, string text, TextCompositionAutoComplete autoComplete, InputDevice inputDevice) : base(inputManager, source, text, autoComplete, inputDevice)
 {
 }
		public InputReportEventArgs (InputDevice inputDevice, InputReport report)
		{
		}
        protected virtual bool BeginDragOperation(InputDevice deviceToCapture, Point initialDragPosition)
        {
            // This is a helper method that provides for easy dragging of the 
            // LoopPanel's Offset using the Mouse. It can be overridden to provide 
            // support for other input devices like a Surface Contact.
            bool result = false;
            if (CapturedDevice == null)
            {
                _lastDragPosition = initialDragPosition;
                if (deviceToCapture is MouseDevice)
                {
                    MouseDevice md = deviceToCapture as MouseDevice;

                    if (md.Captured != null) md.Captured.ReleaseMouseCapture();

                    // By default, we support dragging via the left mouse button.  
                    // If another button is required for dragging, this method should be overridden.
                    if (md.Captured == null && md.LeftButton == MouseButtonState.Pressed)
                    {
                        CapturedDevice = md;
                        md.Capture(this);
                        result = true;
                    }
                }
                else if (deviceToCapture is TouchDevice)
                {
                    TouchDevice td = deviceToCapture as TouchDevice;

                    if (td.Captured != null) this.ReleaseTouchCapture(td);

                    // By default, we support dragging via the left touch button.  
                    // If another button is required for dragging, this method should be overridden.
                    if (td.Captured == null)
                    {
                        CapturedDevice = td;
                        td.Capture(this);
                        result = true;
                    }

                }
            }
            return result;
        }
Example #31
0
        private System.Windows.Media.Color GetPixelColor(InputDevice inputDevice)
        {
            // Translate the input point to bitmap coordinates
            double transformFactor = ColorWheel.Source.Width / ColorWheel.ActualWidth;
            Point inputPoint = inputDevice.GetPosition(ColorWheel);
            Point bitmapPoint = new Point(inputPoint.X * transformFactor, inputPoint.Y * transformFactor);

            // The point is outside the color wheel. Return black.
            if (bitmapPoint.X < 0 || bitmapPoint.X >= ColorWheel.Source.Width ||
                bitmapPoint.Y < 0 || bitmapPoint.Y >= ColorWheel.Source.Height)
            {
                return Colors.Black;
            }

            // The point is inside the color wheel. Find the color at the point.
            CroppedBitmap cb = new CroppedBitmap(ColorWheel.Source as BitmapSource, new Int32Rect((int)bitmapPoint.X, (int)bitmapPoint.Y, 1, 1));
            byte[] pixels = new byte[4];
            cb.CopyPixels(pixels, 4, 0);
            return Color.FromRgb(pixels[2], pixels[1], pixels[0]);
        }