private static Keys[] GetKeys(IInputElement focusElement)
		{
			// the buffer must be exactly 256 bytes long as per API definition
			var keyStates = new byte[256];

			if (!NativeGetKeyboardState(keyStates))
				throw new Win32Exception(Marshal.GetLastWin32Error());

			var pressedKeys = new List<Keys>();
			if (focusElement.IsKeyboardFocused)
			{
				// skip the first 8 entries as they are actually mouse events and not keyboard keys
				const int skipMouseKeys = 8;
				for (int i = skipMouseKeys; i < keyStates.Length; i++)
				{
					byte key = keyStates[i];

					//Logical 'and' so we can drop the low-order bit for toggled keys, else that key will appear with the value 1!
					if ((key & 0x80) != 0)
					{

						//This is just for a short demo, you may want this to return
						//multiple keys!
						if (key != 0)
							pressedKeys.Add((Keys)i);
					}
				}
			}
			return pressedKeys.ToArray();
		}
		/// <summary>
		/// Creates a new instance of the keyboard helper.
		/// </summary>
		/// <param name="focusElement">The element that will be used as the focus point. Provide your implementation of <see cref="WpfGame"/> here.</param>
		public WpfKeyboard(IInputElement focusElement)
		{
			if (focusElement == null)
				throw new ArgumentNullException(nameof(focusElement));

			_focusElement = focusElement;
		}
        public override TouchPointCollection GetIntermediateTouchPoints(IInputElement relativeTo)
        {
            TouchPointCollection collection = new TouchPointCollection();
            UIElement element = relativeTo as UIElement;

            if (element == null)
                return collection;

            foreach (HandPointEventArgs e in intermediateEvents)
            {
                Point point = screen.MapPositionToScreen(e.Session);
                if (relativeTo != null)
                {
                    point = this.ActiveSource.RootVisual.TransformToDescendant((Visual)relativeTo).Transform(point);
                }

                //Rect rect = e.BoundingRect;
                Rect rect = new Rect(screen.MapPositionToScreen(e.Session),
                                 new Size(1, 1));

                TouchAction action = TouchAction.Move;
                if (lastEventArgs.Status == HandPointStatus.Down)
                {
                    action = TouchAction.Down;
                }
                else if (lastEventArgs.Status == HandPointStatus.Up)
                {
                    action = TouchAction.Up;
                }
                collection.Add(new TouchPoint(this, point, rect, action));
            }
            return collection;
        }
예제 #4
0
 /// <summary>
 /// 提交树型表格内部某元素引发的修改。
 /// </summary>
 public static void ExecuteCommitEdit(IInputElement target)
 {
     if (TreeGrid.CommitEditCommand.CanExecute(null, target))
     {
         TreeGrid.CommitEditCommand.Execute(null, target);
     }
 }
        public static bool TryFindFocusedControl(IInputElement focusedElement, out DataEntryControl focusedControl)
        {
            if (focusedElement is FrameworkElement)
            {
                FrameworkElement focusedFrameworkElement = (FrameworkElement)focusedElement;
                focusedControl = (DataEntryControl)focusedFrameworkElement.Tag;
                if (focusedControl != null)
                {
                    return true;
                }

                // for complex controls which dynamic generate child controls, such as date time pickers, the tag of the focused element can't be set
                // so try to locate a parent of the focused element with a tag indicating the control
                FrameworkElement parent = null;
                if (focusedFrameworkElement.Parent != null && focusedFrameworkElement.Parent is FrameworkElement)
                {
                    parent = (FrameworkElement)focusedFrameworkElement.Parent;
                }
                else if (focusedFrameworkElement.TemplatedParent != null && focusedFrameworkElement.TemplatedParent is FrameworkElement)
                {
                    parent = (FrameworkElement)focusedFrameworkElement.TemplatedParent;
                }

                if (parent != null)
                {
                    return DataEntryHandler.TryFindFocusedControl(parent, out focusedControl);
                }
            }

            focusedControl = null;
            return false;
        }
예제 #6
0
		public void Focus(IInputElement element) {
			Debug.Assert(element != null && element.Focusable);
			if (element == null || !element.Focusable)
				return;
			if (CanFocus)
				element.Focus();
		}
예제 #7
0
        public void SetFocusedElement(
            IInputElement element, 
            NavigationMethod method,
            InputModifiers modifiers)
        {
            if (element != FocusedElement)
            {
                var interactive = FocusedElement as IInteractive;

                interactive?.RaiseEvent(new RoutedEventArgs
                {
                    RoutedEvent = InputElement.LostFocusEvent,
                });

                FocusedElement = element;
                interactive = element as IInteractive;

                interactive?.RaiseEvent(new GotFocusEventArgs
                {
                    RoutedEvent = InputElement.GotFocusEvent,
                    NavigationMethod = method,
                    InputModifiers = modifiers,
                });
            }
        }
예제 #8
0
		public bool Capture(Contact contact, IInputElement element, CaptureMode captureMode)
		{
			if(element == null)
				captureMode = CaptureMode.None;
			if(captureMode == CaptureMode.None)
				element = null;

			DependencyObject oldCaptured = contact.InputArgs.Captured;
			if(oldCaptured == element)
				return true;

			using (dispatcher.DisableProcessing())
			{
				long timestamp = Stopwatch.GetTimestamp();
				if (contact.InputArgs.Captured != null)
					RaiseCaptureEvent(contact, MultitouchScreen.LostContactCaptureEvent, contact.InputArgs.Captured, timestamp);


				contact.InputArgs.Captured = (DependencyObject)element;
				contact.InputArgs.CaptureState = captureMode;

				if (contact.InputArgs.Captured != null)
					RaiseCaptureEvent(contact, MultitouchScreen.GotContactCaptureEvent, contact.InputArgs.Captured, timestamp);
			}
			return true;
		}
예제 #9
0
        public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
        {
            OpenFileDialog dlg = new OpenFileDialog();

            var filename = FileName;
            if (!String.IsNullOrWhiteSpace(filename))
            {
                dlg.FileName = filename;
            }

            var dialogtitle = DialogTitle;
            if (!String.IsNullOrWhiteSpace(dialogtitle))
            {
                dlg.Title = dialogtitle;
            }

            var filter = Filter;
            if (!String.IsNullOrWhiteSpace(filter))
            {
                dlg.Filter = filter;
            }

            dlg.FilterIndex = 0;
            dlg.Multiselect = false;
            dlg.FileOk += this.BeforeFileOk;

            if (dlg.ShowDialog() == true)
            {
                this.OnFileOk(dlg.FileName, propertyValue, commandSource);
            }
        }
        public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
        {
            ModelPropertyEntryToOwnerActivityConverter ownerActivityConverter = new ModelPropertyEntryToOwnerActivityConverter();
            ModelItem activityItem =
                ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null) as ModelItem;
            EditingContext context = activityItem.GetEditingContext();

            ModelItem parentModelItem =
                ownerActivityConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), true, null) as ModelItem;
            ModelItemDictionary arguments = parentModelItem.Properties[propertyValue.ParentProperty.PropertyName].Dictionary;

            DynamicArgumentDesignerOptions options = new DynamicArgumentDesignerOptions
            {
                Title = propertyValue.ParentProperty.DisplayName
            };

            using (ModelEditingScope change = arguments.BeginEdit("PowerShellParameterEditing"))
            {
                if (DynamicArgumentDialog.ShowDialog(activityItem, arguments, context, activityItem.View, options))
                {
                    change.Complete();
                }
                else
                {
                    change.Revert();
                }
            }
        }
예제 #11
0
        /// <summary>
        /// Focuses a control.
        /// </summary>
        /// <param name="control">The control to focus.</param>
        /// <param name="method">The method by which focus was changed.</param>
        /// <param name="modifiers">Any input modifiers active at the time of focus.</param>
        public void Focus(
            IInputElement control, 
            NavigationMethod method = NavigationMethod.Unspecified,
            InputModifiers modifiers = InputModifiers.None)
        {
            if (control != null)
            {
                var scope = GetFocusScopeAncestors(control)
                    .FirstOrDefault();

                if (scope != null)
                {
                    Scope = scope;
                    SetFocusedElement(scope, control, method, modifiers);
                }
            }
            else if (Current != null)
            {
                // If control is null, set focus to the topmost focus scope.
                foreach (var scope in GetFocusScopeAncestors(Current).Reverse().ToList())
                {
                    IInputElement element;

                    if (_focusScopes.TryGetValue(scope, out element))
                    {
                        Focus(element, method);
                        break;
                    }
                }
            }
        }
        public override void ShowDialog(PropertyValue propertyValue, IInputElement commandSource)
        {
            ModelPropertyEntryToOwnerActivityConverter propertyEntryConverter =
                new ModelPropertyEntryToOwnerActivityConverter();

            ModelItem activityModelItem =
                (ModelItem)propertyEntryConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), false, null);

            ModelItem parentModelItem =
                (ModelItem)propertyEntryConverter.Convert(propertyValue.ParentProperty, typeof(ModelItem), true, null);

            EditingContext context = ((IModelTreeItem)activityModelItem).ModelTreeManager.Context;

            var inputData = parentModelItem.Properties[propertyValue.ParentProperty.PropertyName].Collection;            

            DynamicArgumentDesignerOptions options = new DynamicArgumentDesignerOptions
            { 
                Title = propertyValue.ParentProperty.DisplayName, 
            };

            using (EditingScope scope = context.Services.GetRequiredService<ModelTreeManager>().CreateEditingScope(StringResourceDictionary.Instance.GetString("InvokeMethodParameterEditing"), true))
            {
                if (DynamicArgumentDialog.ShowDialog(activityModelItem, inputData, context, activityModelItem.View, options))
                {
                    scope.Complete();
                }
            }
        }
 public WpfUIResizeOperationHandleConnector(ICanvasItem canvasItem, IInputElement parent, IEdgeSnappingEngine snappingEngine)
 {
     CanvasItem = canvasItem;
     Parent = parent;
     SnappingEngine = snappingEngine;
     Handles = new Dictionary<IInputElement, IPoint>();
 }
예제 #14
0
        /// <summary>
        /// Unregister one key bound to a particular element
        /// </summary>
        /// <param name="key"></param>
        /// <param name="element"></param>
        public static void Unregister(string key, IInputElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            key = NormalizeKey(key);

            AccessKeyManager akm = AccessKeyManager.Current;

            lock (akm._keyToElements)
            {
                // Get all elements bound to this key and remove this element
                ArrayList elements = (ArrayList)akm._keyToElements[key];

                if (elements != null)
                {
                    PurgeDead(elements, element);
                    if (elements.Count == 0)
                    {
                        akm._keyToElements.Remove(key);
                    }
                }
            }
        }
예제 #15
0
        /// <summary>
        ///   Register the access key binding to the element that is the accesskey.
        /// </summary>
        /// <param name="key">When the key is pressed the element OnAccessKey method is called</param>
        /// <param name="element">The registration element</param>
        public static void Register(string key, IInputElement element)
        {
            if (element == null)
            {
                throw new ArgumentNullException("element");
            }
            key = NormalizeKey(key);

            AccessKeyManager akm = AccessKeyManager.Current;

            lock (akm._keyToElements)
            {
                ArrayList elements = (ArrayList)akm._keyToElements[key];

                if (elements == null)
                {
                    elements = new ArrayList(1);
                    akm._keyToElements[key] = elements;
                }
                else
                {
                    // There were some elements there, remove dead ones
                    PurgeDead(elements, null);
                }

                elements.Add(new WeakReference(element));
            }
        }
예제 #16
0
        private Rect GetBounds(StylusPoint stylusPoint, 
            Point position,
            IInputElement relativeTo, 
            GeneralTransform elementToRoot,
            GeneralTransform rootToElement)
        {
            // Get width and heith in pixel value 
            double width = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ true);
            double height = GetStylusPointWidthOrHeight(stylusPoint, /*isWidth*/ false); 
 
            // Get the position with respect to root
            Point rootPoint; 
            if (elementToRoot == null ||
                !elementToRoot.TryTransform(position, out rootPoint))
            {
                rootPoint = position; 
            }
 
            // Create a Rect with respect to root and transform it to element coordinate space 
            Rect rectBounds = new Rect(rootPoint.X - width * 0.5, rootPoint.Y - height * 0.5, width, height);
            if (rootToElement != null) 
            {
                rectBounds = rootToElement.TransformBounds(rectBounds);
            }
            return rectBounds; 
        }
예제 #17
0
 private Rect GetBounds(StylusPoint stylusPoint, Point position, IInputElement relativeTo)
 { 
     GeneralTransform elementToRoot;
     GeneralTransform rootToElement;
     GetRootTransforms(relativeTo, out elementToRoot, out rootToElement);
     return GetBounds(stylusPoint, position, relativeTo, elementToRoot, rootToElement); 
 }
예제 #18
0
        public void SetFocusedElement(IInputElement element, bool keyboardNavigated)
        {
            if (element != this.FocusedElement)
            {
                var interactive = this.FocusedElement as IInteractive;

                if (interactive != null)
                {
                    interactive.RaiseEvent(new RoutedEventArgs
                    {
                        RoutedEvent = InputElement.LostFocusEvent,
                    });
                }

                this.FocusedElement = element;
                interactive = element as IInteractive;

                if (interactive != null)
                {
                    interactive.RaiseEvent(new GotFocusEventArgs
                    {
                        RoutedEvent = InputElement.GotFocusEvent,
                        KeyboardNavigated = keyboardNavigated,
                    });
                }
            }
        }
예제 #19
0
        public void SetFocusedElement(IInputElement element, NavigationMethod method)
        {
            if (element != FocusedElement)
            {
                var interactive = FocusedElement as IInteractive;

                if (interactive != null)
                {
                    interactive.RaiseEvent(new RoutedEventArgs
                    {
                        RoutedEvent = InputElement.LostFocusEvent,
                    });
                }

                FocusedElement = element;
                interactive = element as IInteractive;

                if (interactive != null)
                {
                    interactive.RaiseEvent(new GotFocusEventArgs
                    {
                        RoutedEvent = InputElement.GotFocusEvent,
                        NavigationMethod = method,
                    });
                }
            }
        }
예제 #20
0
        /// <summary>
        /// Focuses a control.
        /// </summary>
        /// <param name="control">The control to focus.</param>
        /// <param name="keyboardNavigated">
        /// Whether the control was focused by a keypress (e.g. the Tab key).
        /// </param>
        public void Focus(IInputElement control, bool keyboardNavigated = false)
        {
            if (control != null)
            {
                var scope = GetFocusScopeAncestors(control)
                    .FirstOrDefault();

                if (scope != null)
                {
                    this.Scope = scope;
                    this.SetFocusedElement(scope, control, keyboardNavigated);
                    System.Diagnostics.Debug.WriteLine("Focused " + control.GetType().Name);
                }
            }
            else if (this.Current != null)
            {
                // If control is null, set focus to the topmost focus scope.
                foreach (var scope in GetFocusScopeAncestors(this.Current).Reverse().ToList())
                {
                    IInputElement element;

                    if (this.focusScopes.TryGetValue(scope, out element))
                    {
                        this.Focus(element, keyboardNavigated);
                        break;
                    }
                }
            }
        }
예제 #21
0
		public ToolBarButtonVM(ICommand command, IInputElement commandTarget, string header, string toolTip, ImageReference? imageReference) {
			Command = command;
			CommandTarget = commandTarget;
			Header = string.IsNullOrEmpty(header) ? null : header;
			ToolTip = string.IsNullOrEmpty(toolTip) ? null : toolTip;
			ImageReference = imageReference ?? default(ImageReference);
		}
		private void OnPaste(IInputElement container)
		{
			using (new WaitWrapper())
			using (new TimeCounter("Command.Paste: {0}"))
				if (this.FitsCanvas(this.clipboard.Buffer))
				{
					DesignerCanvas.Toolbox.SetDefault();
					DesignerCanvas.DeselectAll();

					var newElements = this.clipboard.Buffer
						.Select(element =>
						{
							var newElement = element.Clone();
							newElement.UID = Guid.NewGuid();
							return newElement;
						})
						.ToList();

					this.NormalizeBuffer(container, newElements);
					var newItems = newElements.Select(element => DesignerCanvas.CreateElement(element)).ToList();

					newItems.ForEach(item => item.IsSelected = true);
					ServiceFactoryBase.Events.GetEvent<ElementAddedEvent>().Publish(DesignerCanvas.SelectedElements.ToList());
					newItems.ForEach(item => item.IsSelected = true);
					MoveToFrontCommand.Execute();
					DesignerCanvas.DesignerChanged();
					if (this.clipboard.SourceAction == ClipboardSourceAction.Cut)
						this.clipboard.Clear();
				}
		}
 public new void Execute(object parameter, IInputElement element)
 {
     if (_func != null)
         _func(parameter, element);
     else if (_funcObj != null)
         _funcObj(parameter);
 }
        /// <summary>
        /// Gets the next element in tab order.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <returns>The next element in tab order.</returns>
        public static IInputElement GetPreviousInTabOrder(IInputElement element)
        {
            Contract.Requires<ArgumentNullException>(element != null);

            var container = element.GetVisualParent<IInputElement>();

            if (container != null)
            {
                var mode = KeyboardNavigation.GetTabNavigation((InputElement)container);

                switch (mode)
                {
                    case KeyboardNavigationMode.Continue:
                        return GetPreviousInContainer(element, container) ??
                               GetLastInPreviousContainer(element);
                    case KeyboardNavigationMode.Cycle:
                        return GetPreviousInContainer(element, container) ??
                               GetDescendents(container).LastOrDefault();
                    default:
                        return GetLastInPreviousContainer(container);
                }
            }
            else
            {
                return GetDescendents(element).LastOrDefault();
            }
        }
예제 #25
0
 /// <summary>
 /// Unregisters the access keys associated with the input element.
 /// </summary>
 /// <param name="element">The input element.</param>
 public void Unregister(IInputElement element)
 {
     foreach (var i in _registered.Where(x => x.Item2 == element).ToList())
     {
         _registered.Remove(i);
     }
 }
        /// <summary>
        ///     Instantiates a new instance of this class.
        /// </summary>
        internal ManipulationCompletedEventArgs(
            ManipulationDevice manipulationDevice,
            int timestamp, 
            IInputElement manipulationContainer,
            Point origin, 
            ManipulationDelta total,
            ManipulationVelocities velocities,
            bool isInertial)
            : base(manipulationDevice, timestamp)
        {
            if (total == null)
            {
                throw new ArgumentNullException("total");
            }

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

            RoutedEvent = Manipulation.ManipulationCompletedEvent;

            ManipulationContainer = manipulationContainer;
            ManipulationOrigin = origin;
            TotalManipulation = total;
            FinalVelocities = velocities;
            IsInertial = isInertial;
        }
예제 #27
0
        /// <summary>
        /// Gets the next control in the specified navigation direction.
        /// </summary>
        /// <param name="element">The element.</param>
        /// <param name="direction">The navigation direction.</param>
        /// <returns>
        /// The next element in the specified direction, or null if <paramref name="element"/>
        /// was the last in the requested direction.
        /// </returns>
        public static IInputElement GetNext(
            IInputElement element,
            FocusNavigationDirection direction)
        {
            Contract.Requires<ArgumentNullException>(element != null);
            Contract.Requires<ArgumentException>(
                direction != FocusNavigationDirection.Next &&
                direction != FocusNavigationDirection.Previous);

            var container = element.GetVisualParent<IInputElement>();

            if (container != null)
            {
                var isForward = IsForward(direction);
                var mode = KeyboardNavigation.GetDirectionalNavigation((InputElement)container);

                switch (mode)
                {
                    case KeyboardNavigationMode.Continue:
                        return GetNextInContainer(element, container, direction) ??
                               GetFirstInNextContainer(element, direction);
                    case KeyboardNavigationMode.Cycle:
                        return GetNextInContainer(element, container, direction) ??
                               GetFocusableDescendent(container, direction);
                    case KeyboardNavigationMode.Contained:
                        return GetNextInContainer(element, container, direction);
                    default:
                        return null;
                }
            }
            else
            {
                return GetFocusableDescendents(element).FirstOrDefault();
            }
        }
        /// <summary>
        ///     Instantiates a new instance of this class.
        /// </summary> 
        internal ManipulationDeltaEventArgs(
            ManipulationDevice manipulationDevice, 
            int timestamp, 
            IInputElement manipulationContainer,
            Point origin, 
            ManipulationDelta delta,
            ManipulationDelta cumulative,
            ManipulationVelocities velocities,
            bool isInertial) 
            : base(manipulationDevice, timestamp)
        { 
            if (delta == null) 
            {
                throw new ArgumentNullException("delta"); 
            }

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

            RoutedEvent = Manipulation.ManipulationDeltaEvent; 

            ManipulationContainer = manipulationContainer; 
            ManipulationOrigin = origin; 
            DeltaManipulation = delta;
            CumulativeManipulation = cumulative; 
            Velocities = velocities;
            IsInertial = isInertial;
        }
예제 #29
0
 public ToolBarButtonVM(ICommand command, IInputElement commandTarget, string header, string toolTip, object image)
 {
     this.command = command;
     this.commandTarget = commandTarget;
     this.header = string.IsNullOrEmpty(header) ? null : header;
     this.toolTip = string.IsNullOrEmpty(toolTip) ? null : toolTip;
     this.image = image;
 }
예제 #30
0
        public DragListener(IInputElement target)
        {
            Target = target;

            Target.PreviewMouseLeftButtonDown += Target_MouseDown;
            Target.PreviewMouseMove += Target_MouseMove;
            Target.PreviewMouseLeftButtonUp += Target_MouseUp;
        }
예제 #31
0
 public override TouchPointCollection GetIntermediateTouchPoints(IInputElement relativeTo)
 {
     return(new TouchPointCollection());
 }
예제 #32
0
        /// <summary>
        /// Executes a given command if its <see cref="ICommand.CanExecute"/> method
        /// indicates it can run.
        /// </summary>
        /// <param name="command">The command to be executed, or a null reference.</param>
        /// <param name="commandParameter">An optional parameter that is associated with
        /// the command.</param>
        /// <param name="target">The target element on which to raise the command.</param>
        public static void ExecuteIfEnabled(this ICommand command, object commandParameter, IInputElement target)
        {
            if (command == null)
            {
                return;
            }

            RoutedCommand rc = command as RoutedCommand;

            if (rc != null)
            {
                //routed commands work on a target
                if (rc.CanExecute(commandParameter, target))
                {
                    rc.Execute(commandParameter, target);
                }
            }
            else if (command.CanExecute(commandParameter))
            {
                command.Execute(commandParameter);
            }
        }
예제 #33
0
 public DrawLineMouseGesture(LineHandlerExtension l, IInputElement relativeTo, ChangeGroup changeGroup)
 {
     this.l = l;
     this.positionRelativeTo = relativeTo;
     this.changeGroup        = changeGroup;
 }
예제 #34
0
        //------------------------------------------------------
        //
        //  Constructors
        //
        //------------------------------------------------------

        #region Constructors

        /// <summary>
        ///     The constrcutor of TextComposition class.
        /// </summary>
        public TextComposition(InputManager inputManager, IInputElement source, string resultText) : this(inputManager, source, resultText, TextCompositionAutoComplete.On)
        {
        }
예제 #35
0
        /// <summary>
        /// マウスドラッグ中の移動差分量を流す
        /// </summary>
        /// <param name="control">対象コントロール</param>
        /// <param name="originControl">マウス移動量の原点コントロール</param>
        /// <returns>移動差分量</returns>
        //public static IObservable<Vector> MouseLeftDragVectorAsObservable(this UIElement control, bool handled = false, IInputElement originControl = null)
        //{
        //    if (originControl is null) originControl = control;

        //    var mouseDown = control.MouseLeftButtonDownAsObservable(handled).ToUnit();
        //    var mouseUp = control.MouseLeftButtonUpAsObservable(handled).ToUnit();

        //    return control.MouseMoveAsObservable(handled)
        //        .Select(e => e.GetPosition(originControl))
        //        .Pairwise()     // クリック前からPairwiseしておく
        //        .Select(x => x.NewItem - x.OldItem)
        //        .SkipUntil(mouseDown)
        //        .TakeUntil(mouseUp)
        //        .Repeat();
        //}

        /// <summary>
        /// マウスドラッグ中の絶対座標と移動差分量を流す
        /// </summary>
        /// <param name="control">対象コントロール</param>
        /// <param name="originControl">マウス移動量の原点コントロール</param>
        /// <returns>絶対座標と移動差分量</returns>
        public static IObservable <(Point point, Vector vector)> MouseLeftDragPointVectorAsObservable(this UIElement control, bool handled = false, IInputElement originControl = null)
        {
            if (originControl is null)
            {
                originControl = control;
            }

            var mouseDown = control.MouseLeftButtonDownAsObservable(handled).ToUnit();
            var mouseUp   = control.MouseLeftButtonUpAsObservable(handled).ToUnit();

            return(control.MouseMoveAsObservable(handled)
                   .Select(e => e.GetPosition(originControl))
                   .Pairwise()  // クリック前からPairwiseしておく
                   .Select(x => (point: x.NewItem, vector: x.NewItem - x.OldItem))
                   .SkipUntil(mouseDown)
                   .TakeUntil(mouseUp)
                   .Repeat());
        }
예제 #36
0
파일: Button.cs 프로젝트: alimbada/Perspex
 /// <summary>
 /// Starts listening for the Enter key when the button <see cref="IsDefault"/>.
 /// </summary>
 /// <param name="root">The input root.</param>
 private void ListenForDefault(IInputElement root)
 {
     root.AddHandler(KeyDownEvent, RootKeyDown);
 }
예제 #37
0
파일: Notify.cs 프로젝트: metatool/metatool
        public static MessageToken <TipItem> ShowMessage(FrameworkElement balloon,
                                                         ObservableCollection <TipItem> data, int?timeout,
                                                         NotifyPosition position = NotifyPosition.ActiveScreen, PopupAnimation animation = PopupAnimation.None)
        {
            var dispatcher = balloon.Dispatcher;

            if (!dispatcher.CheckAccess())
            {
                return(dispatcher.Invoke(DispatcherPriority.Normal,
                                         (Func <MessageToken <TipItem> >)(() =>
                                                                          ShowMessage(balloon, data, timeout, position, animation))) as
                       MessageToken <TipItem>);
            }

            if (balloon == null)
            {
                throw new ArgumentNullException("balloon");
            }
            if (timeout.HasValue && timeout < 500)
            {
                var msg = "Invalid timeout of {0} milliseconds. Timeout must be at least 500 ms";
                msg = String.Format(msg, timeout);
                throw new ArgumentOutOfRangeException("timeout", msg);
            }

            if (LogicalTreeHelper.GetParent(balloon) is Popup parent)
            {
                parent.Child = null;
                var msg =
                    "Cannot display control [{0}] in a new balloon popup - that control already has a parent. You may consider creating new balloons every time you want to show one.";
                msg = String.Format(msg, balloon);
                throw new InvalidOperationException(msg);
            }

            var popup = new Popup();

            popup.AllowsTransparency = true;
            popup.PopupAnimation     = animation;
            popup.Placement          = PlacementMode.AbsolutePoint;
            popup.StaysOpen          = true;
            popup.DataContext        = data;

            Point point;

            switch (position)
            {
            case NotifyPosition.Caret:
            {
                var rect = WindowManager.CurrentWindow.CaretPosition;
                var X    = (rect.Left + rect.Width / 2 - balloon.ActualWidth / 2);
                var Y    = (rect.Bottom + rect.Height / 2 - balloon.ActualHeight / 2);
                if (X == 0 && Y == 0)
                {
                    goto case NotifyPosition.ActiveWindowCenter;
                }

                point = new Point(X, Y);
                break;
            }

            case NotifyPosition.ActiveWindowCenter:
            {
                var rect = WindowManager.CurrentWindow.Rect;
                var X    = (rect.X + rect.Width / 2 - balloon.ActualWidth / 2);
                var Y    = (rect.Y + rect.Height / 2 - balloon.ActualHeight / 2);
                point = new Point(X, Y);
                break;
            }

            case NotifyPosition.ActiveScreen:
            {
                var screen = Screen.FromHandle(WindowManager.CurrentWindow.Handle);
                if (screen.Equals(Screen.PrimaryScreen))
                {
                    var p = TrayInfo.GetTrayLocation();
                    point = new Point(p.X, p.Y);
                    break;
                }

                var bounds = screen.Bounds;
                var X      = bounds.X + bounds.Width;
                var Y      = bounds.Y + bounds.Height;
                point = new Point(X, Y);
                break;
            }

            case NotifyPosition.Default:
            {
                var p = TrayInfo.GetTrayLocation();
                point = new Point(p.X, p.Y);
                break;
            }


            default:
                throw new ArgumentOutOfRangeException(nameof(position) + " not supported", position, null);
            }


            popup.Child            = balloon;
            popup.HorizontalOffset = point.X + 1;
            popup.VerticalOffset   = point.Y - 2;
            balloon.Focusable      = true;

            IInputElement element = null;

            popup.Opened += (s, a) =>
            {
                element = Keyboard.FocusedElement;
                var source = (HwndSource)PresentationSource.FromVisual(balloon);
                var handle = source.Handle;
                PInvokes.SetForegroundWindow(handle);
                Keyboard.Focus(balloon);
            };

            popup.IsOpen = true;
            popup.Focus();

            var r = new MessageToken <TipItem>(popup);

            popup.Closed += (s, a) =>
            {
                Keyboard.Focus(element);
                r.Close();
            };

            void TimerTick(object sender, EventArgs e)
            {
                r.Timer.Tick -= TimerTick;
                r.Close();
            }

            if (timeout.HasValue)
            {
                r.Timer = new DispatcherTimer {
                    Interval = TimeSpan.FromMilliseconds(timeout.Value)
                };
                r.Timer.Tick += TimerTick;
                r.Timer.Start();
            }

            return(r);
        }
예제 #38
0
 /// <summary>
 ///     Retrieves the current touch point for ever touch device that is currently active.
 /// </summary>
 /// <param name="relativeTo">Defines the coordinate space of the touch point.</param>
 /// <returns>A collection of touch points.</returns>
 public TouchPointCollection GetTouchPoints(IInputElement relativeTo)
 {
     return(TouchDevice.GetTouchPoints(relativeTo));
 }
        private bool RaiseContextMenuOpeningEvent(IInputElement source, double x, double y, bool userInitiated)
        {
            // Fire the event
            ContextMenuEventArgs args     = new ContextMenuEventArgs(source, true /* opening */, x, y);
            DependencyObject     sourceDO = source as DependencyObject;

            if (userInitiated && sourceDO != null)
            {
                if (InputElement.IsUIElement(sourceDO))
                {
                    ((UIElement)sourceDO).RaiseEvent(args, userInitiated);
                }
                else if (InputElement.IsContentElement(sourceDO))
                {
                    ((ContentElement)sourceDO).RaiseEvent(args, userInitiated);
                }
                else if (InputElement.IsUIElement3D(sourceDO))
                {
                    ((UIElement3D)sourceDO).RaiseEvent(args, userInitiated);
                }
                else
                {
                    source.RaiseEvent(args);
                }
            }
            else
            {
                source.RaiseEvent(args);
            }


            if (!args.Handled)
            {
                // No one handled the event, auto show any available ContextMenus

                // Saved from the bubble up the tree where we looked for a set ContextMenu property
                DependencyObject o = args.TargetElement;
                if ((o != null) && ContextMenuService.ContextMenuIsEnabled(o))
                {
                    // Retrieve the value
                    object      menu = ContextMenuService.GetContextMenu(o);
                    ContextMenu cm   = menu as ContextMenu;
                    cm.SetValue(OwnerProperty, o);
                    cm.Closed += new RoutedEventHandler(OnContextMenuClosed);

                    if ((x == -1.0) && (y == -1.0))
                    {
                        // We infer this to mean that the ContextMenu was opened with the keyboard
                        cm.Placement = PlacementMode.Center;
                    }
                    else
                    {
                        // If there is a CursorLeft and CursorTop, it was opened with the mouse.
                        cm.Placement = PlacementMode.MousePoint;
                    }

                    // Clear any open tooltips
                    RaiseToolTipClosingEvent(true /*reset */);

                    cm.SetCurrentValueInternal(ContextMenu.IsOpenProperty, BooleanBoxes.TrueBox);

                    return(true); // A menu was opened
                }

                return(false); // There was no menu to open
            }

            // Clear any open tooltips since someone else opened one
            RaiseToolTipClosingEvent(true /*reset */);

            return(true); // The event was handled by someone else
        }
        private void OnPostProcessInput(object sender, ProcessInputEventArgs e)
        {
            if (e.StagingItem.Input.RoutedEvent == InputManager.InputReportEvent)
            {
                InputReportEventArgs report = (InputReportEventArgs)e.StagingItem.Input;
                if (!report.Handled)
                {
                    if (report.Report.Type == InputType.Mouse)
                    {
                        RawMouseInputReport mouseReport = (RawMouseInputReport)report.Report;
                        if ((mouseReport.Actions & RawMouseActions.AbsoluteMove) == RawMouseActions.AbsoluteMove)
                        {
                            if ((Mouse.LeftButton == MouseButtonState.Pressed) ||
                                (Mouse.RightButton == MouseButtonState.Pressed))
                            {
                                RaiseToolTipClosingEvent(true /* reset */);
                            }
                            else
                            {
                                IInputElement directlyOver = Mouse.PrimaryDevice.RawDirectlyOver;
                                if (directlyOver != null)
                                {
                                    Point pt = Mouse.PrimaryDevice.GetPosition(directlyOver);

                                    // If possible, check that the mouse position is within the render bounds
                                    // (avoids mouse capture confusion).
                                    if (Mouse.CapturedMode != CaptureMode.None)
                                    {
                                        // Get the root visual
                                        PresentationSource source          = PresentationSource.CriticalFromVisual((DependencyObject)directlyOver);
                                        UIElement          rootAsUIElement = source != null ? source.RootVisual as UIElement : null;
                                        if (rootAsUIElement != null)
                                        {
                                            // Get mouse position wrt to root
                                            pt = Mouse.PrimaryDevice.GetPosition(rootAsUIElement);

                                            // Hittest to find the element the mouse is over
                                            IInputElement enabledHit;
                                            rootAsUIElement.InputHitTest(pt, out enabledHit, out directlyOver);

                                            // Find the position of the mouse relative the element that the mouse is over
                                            pt = Mouse.PrimaryDevice.GetPosition(directlyOver);
                                        }
                                        else
                                        {
                                            directlyOver = null;
                                        }
                                    }

                                    if (directlyOver != null)
                                    {
                                        // Process the mouse move
                                        OnMouseMove(directlyOver, pt);
                                    }
                                }
                            }
                        }
                        else if ((mouseReport.Actions & RawMouseActions.Deactivate) == RawMouseActions.Deactivate)
                        {
                            if (LastMouseDirectlyOver != null)
                            {
                                LastMouseDirectlyOver = null;
                                if (LastMouseOverWithToolTip != null)
                                {
                                    RaiseToolTipClosingEvent(true /* reset */);

                                    // When the user moves the cursor outside of the window,
                                    // clear the LastMouseOverWithToolTip property so if the user returns
                                    // the mouse to the same item, the tooltip will reappear.  If
                                    // the deactivation is coming from a window grabbing capture
                                    // (such as Drag and Drop) do not clear the property.
                                    if (MS.Win32.SafeNativeMethods.GetCapture() == IntPtr.Zero)
                                    {
                                        LastMouseOverWithToolTip = null;
                                    }
                                }
                            }
                        }
                    }
                }
            }
            else if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyDownEvent)
            {
                ProcessKeyDown(sender, (KeyEventArgs)e.StagingItem.Input);
            }
            else if (e.StagingItem.Input.RoutedEvent == Keyboard.KeyUpEvent)
            {
                ProcessKeyUp(sender, (KeyEventArgs)e.StagingItem.Input);
            }
            else if (e.StagingItem.Input.RoutedEvent == Mouse.MouseUpEvent)
            {
                ProcessMouseUp(sender, (MouseButtonEventArgs)e.StagingItem.Input);
            }
            else if (e.StagingItem.Input.RoutedEvent == Mouse.MouseDownEvent)
            {
                RaiseToolTipClosingEvent(true /* reset */);
            }
        }
예제 #41
0
        /// <inheritdoc/>
        protected override void OnLostKeyboardFocus(KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, RoutedEventData data)
        {
            Ultraviolet.GetInput().HideSoftwareKeyboard();

            if (PART_Editor != null)
            {
                PART_Editor.HandleLostKeyboardFocus();
            }

            UpdateIsSelectionActive();

            base.OnLostKeyboardFocus(device, oldFocus, newFocus, data);
        }
예제 #42
0
 /// <summary>
 ///     Retrieves the current touch point of the primary touch device, if one exists.
 /// </summary>
 /// <param name="relativeTo">Defines the coordinate space of the touch point.</param>
 /// <returns>The touch point of the primary device or null if no device is a primary device.</returns>
 public TouchPoint GetPrimaryTouchPoint(IInputElement relativeTo)
 {
     return(TouchDevice.GetPrimaryTouchPoint(relativeTo));
 }
예제 #43
0
 protected override void OnCapture(IInputElement element, CaptureMode captureMode)
 {
     Mouse.PrimaryDevice.Capture(element, captureMode);
 }
예제 #44
0
 /// <summary>
 ///     Calculates the position of the stylus relative to a particular element.
 /// </summary>
 internal abstract Point GetPosition(IInputElement relativeTo);
예제 #45
0
 public void Deactivate(IInputElement e)
 {
     e.KeyUp -= E_KeyUp;
     _obj.DeattachCommand();
 }
예제 #46
0
 /// <summary>
 ///     Returns a StylusPointCollection object for processing the data in the packet.
 ///     This method creates a new StylusPointCollection and copies the data.
 /// </summary>
 internal abstract StylusPointCollection GetStylusPoints(IInputElement relativeTo, StylusPointDescription subsetToReformatTo);
예제 #47
0
파일: Button.cs 프로젝트: alimbada/Perspex
 /// <summary>
 /// Stops listening for the Enter key when the button is no longer <see cref="IsDefault"/>.
 /// </summary>
 /// <param name="root">The input root.</param>
 private void StopListeningForDefault(IInputElement root)
 {
     root.RemoveHandler(KeyDownEvent, RootKeyDown);
 }
예제 #48
0
 /// <summary>
 ///     Returns a StylusPointCollection object for processing the data in the packet.
 ///     This method creates a new StylusPointCollection and copies the data.
 /// </summary>
 internal abstract StylusPointCollection GetStylusPoints(IInputElement relativeTo);
예제 #49
0
        /// <summary>
        /// マウスドラッグ中の絶対座標を流す
        /// </summary>
        /// <param name="control">対象コントロール</param>
        /// <param name="originControl">マウス移動量の原点コントロール</param>
        /// <returns>絶対座標</returns>
        public static IObservable <Point> MouseLeftDragPointAsObservable(this UIElement control, bool handled = false, IInputElement originControl = null)
        {
            if (originControl is null)
            {
                originControl = control;
            }

            var mouseDown = control.MouseLeftButtonDownAsObservable(handled).ToUnit();
            var mouseUp   = control.MouseLeftButtonUpAsObservable(handled).ToUnit();

            return(control.MouseMoveAsObservable(handled)
                   .Select(e => e.GetPosition(originControl))
                   .SkipUntil(mouseDown)
                   .TakeUntil(mouseUp)
                   .Repeat());
        }
예제 #50
0
 /// <summary>
 ///     Captures the stylus to a particular element.
 /// </summary>
 internal abstract bool Capture(IInputElement element);
예제 #51
0
 private void WindowOnDeactivated(object sender, EventArgs eventArgs)
 {
     _restoreFocusWindowReactivation = _popup != null?FocusManager.GetFocusedElement((Window)sender) : null;
 }
예제 #52
0
 /// <summary>
 ///     Captures the stylus to a particular element.
 /// </summary>
 internal abstract bool Capture(IInputElement element, CaptureMode captureMode);
예제 #53
0
 public virtual void Close(IInputElement inputElement = null)
 {
     DialogHost.CloseDialogCommand.Execute(null, inputElement ?? (this as IDialog).InputElement);
 }
예제 #54
0
파일: Stylus.cs 프로젝트: ash2005/z
 /////////////////////////////////////////////////////////////////////
 /// <summary>
 ///     Captures the stylus to a particular element.
 /// </summary>
 /// <param name="element">
 ///     The element to capture the stylus to.
 /// </param>
 public static bool Capture(IInputElement element)
 {
     return(Capture(element, CaptureMode.Element));
 }
예제 #55
0
        /// <summary>
        ///     Whether the command can be executed with the given parameter on the given target.
        /// </summary>
        /// <param name="parameter">Parameter to be passed to any command handlers.</param>
        /// <param name="target">The target element on which to begin looking for command handlers.</param>
        /// <returns>true if the command can be executed, false otherwise.</returns>
        public bool CanExecute(object parameter, IInputElement target)
        {
            bool unused;

            return(CriticalCanExecute(parameter, target, false, out unused));
        }
예제 #56
0
 /// <summary>
 /// Checks if descendents of the specified element can be focused.
 /// </summary>
 /// <param name="e">The element.</param>
 /// <returns>True if descendents of the element can be focused.</returns>
 public static bool CanFocusDescendents(this IInputElement e) => e.IsEnabledCore && e.IsVisible;
        /// <summary>
        ///     Initiates the process of opening the tooltip popup.
        /// </summary>
        /// <param name="fromKeyboard">
        ///     Whether this particular event is caused by keyboard focus.
        ///     This is passed down to the tooltip and the popup to determine its placement.
        /// </param>
        private void RaiseToolTipOpeningEvent(bool fromKeyboard = false)
        {
            ResetToolTipTimer();

            if (_forceCloseTimer != null)
            {
                OnForceClose(null, EventArgs.Empty);
            }

            DependencyObject o = LastObjectWithToolTip;

            if (o != null)
            {
                bool show = true;

                IInputElement element = o as IInputElement;
                if (element != null)
                {
                    ToolTipEventArgs args = new ToolTipEventArgs(true);
                    element.RaiseEvent(args);

                    show = !args.Handled;
                }

                if (show)
                {
                    object  tooltip = ToolTipService.GetToolTip(o);
                    ToolTip tip     = tooltip as ToolTip;
                    if (tip != null)
                    {
                        _currentToolTip = tip;
                        _ownToolTip     = false;
                    }
                    else if ((_currentToolTip == null) || !_ownToolTip)
                    {
                        _currentToolTip = new ToolTip();
                        _ownToolTip     = true;
                        _currentToolTip.SetValue(ServiceOwnedProperty, BooleanBoxes.TrueBox);

                        // Bind the content of the tooltip to the ToolTip attached property
                        Binding binding = new Binding();
                        binding.Path   = new PropertyPath(ToolTipService.ToolTipProperty);
                        binding.Mode   = BindingMode.OneWay;
                        binding.Source = o;
                        _currentToolTip.SetBinding(ToolTip.ContentProperty, binding);
                    }

                    if (!_currentToolTip.StaysOpen)
                    {
                        // The popup takes capture in this case, which causes us to hit test to the wrong window.
                        // We do not support this scenario. Cleanup and then throw and exception.
                        throw new NotSupportedException(SR.Get(SRID.ToolTipStaysOpenFalseNotAllowed));
                    }

                    _currentToolTip.SetValue(OwnerProperty, o);
                    _currentToolTip.Opened      += OnToolTipOpened;
                    _currentToolTip.Closed      += OnToolTipClosed;
                    _currentToolTip.FromKeyboard = fromKeyboard;
                    _currentToolTip.IsOpen       = true;

                    ToolTipTimer          = new DispatcherTimer(DispatcherPriority.Normal);
                    ToolTipTimer.Interval = TimeSpan.FromMilliseconds(ToolTipService.GetShowDuration(o));
                    ToolTipTimer.Tick    += new EventHandler(OnRaiseToolTipClosingEvent);
                    ToolTipTimer.Start();
                }
            }
        }
        /// <summary>
        ///     Closes the current tooltip, firing a Closing event if necessary.
        /// </summary>
        /// <param name="reset">
        ///     When false, will continue to treat input as if the tooltip were open so that
        ///     the tooltip of the current element won't re-open. Example: Clicking on a button
        ///     will hide the tooltip, but when the mouse is released, the tooltip should not
        ///     appear unless the mouse is moved off and then back on the button.
        /// </param>
        private void RaiseToolTipClosingEvent(bool reset)
        {
            ResetToolTipTimer();

            if (reset)
            {
                LastChecked = null;
            }

            DependencyObject o = LastObjectWithToolTip;

            if (o != null)
            {
                if (_currentToolTip != null)
                {
                    bool isOpen = _currentToolTip.IsOpen;

                    try
                    {
                        if (isOpen)
                        {
                            IInputElement element = o as IInputElement;
                            if (element != null)
                            {
                                element.RaiseEvent(new ToolTipEventArgs(false));
                            }
                        }
                    }
                    finally
                    {
                        if (isOpen)
                        {
                            _currentToolTip.IsOpen = false;

                            // Setting IsOpen makes call outs to app code. So it is possible that
                            // the _currentToolTip is ----d as a result of an action there. If that
                            // were the case we do not need to set off the timer to close the tooltip.
                            if (_currentToolTip != null)
                            {
                                // Keep references and owner set for the fade out or slide animation
                                // Owner is released when animation completes
                                _forceCloseTimer          = new DispatcherTimer(DispatcherPriority.Normal);
                                _forceCloseTimer.Interval = Popup.AnimationDelayTime;
                                _forceCloseTimer.Tick    += new EventHandler(OnForceClose);
                                _forceCloseTimer.Tag      = _currentToolTip;
                                _forceCloseTimer.Start();
                            }

                            _quickShow            = true;
                            ToolTipTimer          = new DispatcherTimer(DispatcherPriority.Normal);
                            ToolTipTimer.Interval = TimeSpan.FromMilliseconds(ToolTipService.GetBetweenShowDelay(o));
                            ToolTipTimer.Tick    += new EventHandler(OnBetweenShowDelay);
                            ToolTipTimer.Start();
                        }
                        else
                        {
                            // Release owner now
                            _currentToolTip.ClearValue(OwnerProperty);

                            if (_ownToolTip)
                            {
                                BindingOperations.ClearBinding(_currentToolTip, ToolTip.ContentProperty);
                            }
                        }
                        _currentToolTip.FromKeyboard = false;
                        _currentToolTip = null;
                    }
                }
            }
        }
예제 #59
0
            internal bool HandleLeftButtonDown(object sender, MouseButtonEventArgs e)
            {
                if (false != ignoreMouseClick)
                {
                    ignoreMouseClick = false;
                    return(false);
                }

                MouseClickHistory curClick = new MouseClickHistory(sender, e);

                bool eventHandled        = false;
                bool returnFocusToSearch = true;

                if (this.currentState == State.Connection)
                {
                    // Clicking on the canvas while connecting simply cancels
                    // the operation and drop the temporary connector.
                    SetCurrentState(State.None);

                    eventHandled = true; // Mouse event handled.
                }
                else if (this.currentState == State.None)
                {
                    // Record the mouse down position.
                    IInputElement element = sender as IInputElement;
                    mouseDownPos = e.GetPosition(element);

                    // We'll see if there is any node being clicked on. If so,
                    // then the state machine should initiate a drag operation.
                    if (null != GetSelectableFromPoint(mouseDownPos))
                    {
                        InitiateDragSequence();
                    }
                    else
                    {
                        if ((e.Source is Dynamo.Controls.EndlessGrid) == false)
                        {
                            InitiateWindowSelectionSequence();
                        }
                        else if (!MouseClickHistory.CheckIsDoubleClick(prevClick, curClick))
                        {
                            InitiateWindowSelectionSequence();
                        }
                        else
                        {
                            // Double-clicking on the background grid results in
                            // a code block node being created, in which case we
                            // should keep the input focus on the code block to
                            // avoid it being dismissed (with empty content).
                            //
                            CreateCodeBlockNode(mouseDownPos);
                            returnFocusToSearch = false;
                            curClick            = null;
                        }
                    }

                    prevClick = curClick;

                    eventHandled = true; // Mouse event handled.
                }
                else if (this.currentState == State.PanMode)
                {
                    var c = CursorLibrary.GetCursor(CursorSet.HandPanActive);
                    owningWorkspace.CurrentCursor = c;
                }
                else if (this.currentState == State.OrbitMode)
                {
                    var c = CursorLibrary.GetCursor(CursorSet.HandPanActive);
                    owningWorkspace.CurrentCursor = c;
                }

                if (returnFocusToSearch != false)
                {
                    owningWorkspace.DynamoViewModel.ReturnFocusToSearch();
                }

                return(eventHandled);
            }
예제 #60
0
        /// <inheritdoc/>
        protected override void OnGotKeyboardFocus(KeyboardDevice device, IInputElement oldFocus, IInputElement newFocus, RoutedEventData data)
        {
            UpdateTextInputRegion();
            Ultraviolet.GetInput().ShowSoftwareKeyboard(KeyboardMode.Text);

            if (PART_Editor != null)
            {
                PART_Editor.HandleGotKeyboardFocus();
            }

            UpdateIsSelectionActive();

            base.OnGotKeyboardFocus(device, oldFocus, newFocus, data);
        }