Example #1
1
		public void AddRemoveHandler ()
		{
			Delegate eh = new EventHandler ((object sender, EventArgs ea) => { });
			Delegate keh = new KeyEventHandler ((object sender, KeyEventArgs ea) => { });
			Delegate meh = new MouseButtonEventHandler ((object sender, MouseButtonEventArgs ea) => { });
			Delegate weh = new MouseWheelEventHandler ((object sender, MouseWheelEventArgs ea) => { });
			Delegate teh = new TextCompositionEventHandler ((object sender, TextCompositionEventArgs ea) => { });

			// OK
			RoutedEvent [] events1 = new RoutedEvent [] { UIElement.KeyDownEvent, UIElement.KeyUpEvent, UIElement.MouseLeftButtonDownEvent, UIElement.MouseLeftButtonUpEvent, UIElement.MouseWheelEvent, UIElement.TextInputEvent, UIElement.TextInputStartEvent, UIElement.TextInputUpdateEvent };
			Delegate [] handlers1 = new Delegate [] { keh, keh, meh, meh, weh, teh, teh, teh };

			// ArgumentNullException
			RoutedEvent [] events2 = new RoutedEvent [] { null, UIElement.KeyUpEvent };
			Delegate [] handlers2 = new Delegate [] { keh, null };

			// ArgumentException
			RoutedEvent [] events3 = new RoutedEvent [] { FrameworkElement.LoadedEvent, UIElement.KeyUpEvent, UIElement.MouseLeftButtonUpEvent, UIElement.MouseLeftButtonUpEvent, UIElement.TextInputUpdateEvent, UIElement.MouseWheelEvent };
			Delegate [] handlers3 = new Delegate [] { eh, meh, keh, teh, eh , meh};

			// NotImplementedException
			RoutedEvent [] events4 = new RoutedEvent [] { UIElement.ManipulationCompletedEvent, UIElement.ManipulationDeltaEvent, UIElement.ManipulationStartedEvent };
			Delegate [] handlers4 = new Delegate [] { eh, eh, eh };

			UIElement ctrl = new MediaElement ();

			// AddHandler
			for (int i = 0; i < events1.Length; i++) {
				ctrl.AddHandler (events1 [i], handlers1 [i], false);
			}
			for (int i = 0; i < events2.Length; i++) {
				Assert.Throws<ArgumentNullException> (() => ctrl.AddHandler (events2 [i], handlers2 [i], false));
			}
			for (int i = 0; i < events3.Length; i++) {
				Assert.Throws<ArgumentException> (() => ctrl.AddHandler (events3 [i], handlers3 [i], false));
			}
			for (int i = 0; i < events4.Length; i++) {
				Assert.Throws<NotImplementedException> (() => ctrl.AddHandler (events4 [i], handlers4 [i], false));
			}
			// RemoveHandler
			for (int i = 0; i < events1.Length; i++) {
				ctrl.RemoveHandler (events1 [i], handlers1 [i]);
			}
			for (int i = 0; i < events2.Length; i++) {
				Assert.Throws<ArgumentNullException> (() => ctrl.RemoveHandler (events2 [i], handlers2 [i]));
			}
			for (int i = 0; i < events3.Length; i++) {
				Assert.Throws<ArgumentException> (() => ctrl.RemoveHandler (events3 [i], handlers3 [i]));
			}
			for (int i = 0; i < events4.Length; i++) {
				Assert.Throws<NotImplementedException> (() => ctrl.RemoveHandler (events4 [i], handlers4 [i]));
			}

		}
Example #2
0
        private static void OnTargetChanged(DependencyObject obj, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue == null || obj == null)
            {
                return;
            }

            EditorAdapterBase   target    = e.NewValue as EditorAdapterBase;
            EditorAdapterBase   oldTarget = e.OldValue as EditorAdapterBase;
            CompletionPopupView view      = obj as CompletionPopupView;

            EventHandler                selectionChanged = (sender, args) => view.Publish(new SelectionChangedEvent(target.CaretIndex));
            KeyEventHandler             previewKeyDown   = (sender, args) => view.Publish(new CancellableKeyEvent(args, EventSource.Editor));
            KeyEventHandler             keyUp            = (sender, args) => view.Publish(new KeyUpEvent(args, EventSource.Editor));
            KeyEventHandler             keyDown          = (sender, args) => view.Publish(new KeyEvent(args, EventSource.Editor));
            TextCompositionEventHandler previewTextInput = (sender, args) => view.Publish(new CancellableInputEvent(args));

            if (target != null)
            {
                target.PreviewTextInput += previewTextInput;
                target.SelectionChanged += selectionChanged;
                target.PreviewKeyDown   += previewKeyDown;
                target.KeyDown          += keyDown;
                target.KeyUp            += keyUp;
            }

            if (oldTarget != null)
            {
                oldTarget.SelectionChanged -= selectionChanged;
                target.PreviewKeyDown      -= previewKeyDown;
                target.KeyDown             -= keyDown;
                target.KeyUp -= keyUp;
            }
        }
Example #3
0
 public MyTextBox()
 {
     TextChanged      += new TextChangedEventHandler(MyTextBox_TextChanged);
     PreviewKeyDown   += new KeyEventHandler(MyTextBox_PreviewKeyDown);
     PreviewTextInput += new TextCompositionEventHandler(MyTextBox_PreviewTextInput);
     DataObject.AddPastingHandler(this, new DataObjectPastingEventHandler(OnPaste));
 }
        private void FireTextInput(TextCompositionEventArgs args)
        {
            TextCompositionEventHandler handler = PreprocessTextInput;

            if (handler != null)
            {
                handler(_wpfTextView, args);
            }
        }
        /// <summary> 
        ///     Removes a handler for the PreviewTextInputStart attached event
        /// </summary> 
        /// <param name="element">UIElement or ContentElement that listens to this event</param> 
        /// <param name="handler">Event Handler to be removed</param>
        public static void RemovePreviewTextInputStartHandler(DependencyObject element, TextCompositionEventHandler handler) 
        {
            if (element == null)
            {
                throw new ArgumentNullException("element"); 
            }
 
            UIElement.RemoveHandler(element, PreviewTextInputStartEvent, handler); 
        }
Example #6
0
 public MainWindow()
 {
     InitializeComponent();
     lviEvents.ItemsSource = _keyEvents;
     KeyDown          += new KeyEventHandler(MainWindow_KeyDown);
     TextInput        += new TextCompositionEventHandler(MainWindow_TextInput);
     PreviewKeyDown   += new KeyEventHandler(MainWindow_KeyDown);
     PreviewTextInput += new TextCompositionEventHandler(MainWindow_TextInput);
     PreviewKeyUp     += new KeyEventHandler(MainWindow_KeyDown);
 }
Example #7
0
        public override void ReadChar(Action <char> callback)
        {
            TextCompositionEventHandler handler = null;

            handler = (s, e) =>
            {
                scrollViewer.TextInput -= handler;
                callback(e.Text[0]);
            };

            scrollViewer.TextInput += handler;
            Keyboard.Focus(scrollViewer);
        }
        static AttachEventHandlerAction()
        {
            //
            // Initialize event handlers.
            //
            eventHandlers[typeof(EventHandler)]       = new EventHandler(OnGenericEvent);
            eventHandlers[typeof(RoutedEventHandler)] = new RoutedEventHandler(OnRoutedEvent);
            eventHandlers[typeof(KeyEventHandler)]    = new KeyEventHandler(OnKeyEvent);
            eventHandlers[typeof(KeyboardFocusChangedEventHandler)] = new KeyboardFocusChangedEventHandler(OnFocusEvent);
            eventHandlers[typeof(TextCompositionEventHandler)]      = new TextCompositionEventHandler(OnTextCompositionEvent);
            eventHandlers[typeof(MouseEventHandler)]                     = new MouseEventHandler(OnMouseEvent);
            eventHandlers[typeof(MouseButtonEventHandler)]               = new MouseButtonEventHandler(OnMouseButtonEvent);
            eventHandlers[typeof(MouseButtonEventHandler)]               = new MouseButtonEventHandler(OnMouseDoubleClickEvent);
            eventHandlers[typeof(MouseWheelEventHandler)]                = new MouseWheelEventHandler(OnMouseWheelEvent);
            eventHandlers[typeof(DragEventHandler)]                      = new DragEventHandler(OnDragEvent);
            eventHandlers[typeof(GiveFeedbackEventHandler)]              = new GiveFeedbackEventHandler(OnFeedbackEvent);
            eventHandlers[typeof(QueryCursorEventHandler)]               = new QueryCursorEventHandler(OnQueryCursorEvent);
            eventHandlers[typeof(ExecutedRoutedEventHandler)]            = new ExecutedRoutedEventHandler(OnExecutedEvent);
            eventHandlers[typeof(CanExecuteRoutedEventHandler)]          = new CanExecuteRoutedEventHandler(OnCanExecuteEvent);
            eventHandlers[typeof(DependencyPropertyChangedEventHandler)] = new DependencyPropertyChangedEventHandler(OnPropertyChangedEvent);

            //
            // Initialize routed event static method list.
            //
            staticMethods = new List <MethodInfo>();

            Type[] types = new Type[] { typeof(Mouse), typeof(Keyboard), typeof(CommandManager) };

            foreach (Type type in types)
            {
                MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Static | BindingFlags.Public);
                foreach (MethodInfo methodInfo in methodInfos)
                {
                    if (methodInfo.Name.EndsWith("Handler", StringComparison.InvariantCulture) &&
                        (methodInfo.Name.StartsWith("Add", StringComparison.InvariantCulture) ||
                         methodInfo.Name.StartsWith("Remove", StringComparison.InvariantCulture)))
                    {
                        staticMethods.Add(methodInfo);
                    }
                }
            }
        }
        public MainWindow()
        {
            InitializeComponent();
            PreviewKeyDown   += OnPreviewKeyDown;
            PreviewTextInput += OnPreviewTextInput;

            TextCompositionEventHandler previewTextInputStartHandler  = OnPreviewTextInputStart;
            TextCompositionEventHandler textInputStartHandler         = OnTextInputStart;
            TextCompositionEventHandler previewTextInputUpdateHandler = OnPreviewTextInputUpdate;
            TextCompositionEventHandler textInputUpdateHandler        = OnTextInputUpdate;
            TextCompositionEventHandler previewTextInputHandler       = OnPreviewTextInput;
            TextCompositionEventHandler textInputHandler = OnTextInput;

            AddHandler(TextCompositionManager.PreviewTextInputStartEvent, previewTextInputStartHandler);
            AddHandler(TextCompositionManager.TextInputStartEvent, textInputStartHandler);
            AddHandler(TextCompositionManager.PreviewTextInputUpdateEvent, previewTextInputUpdateHandler);
            AddHandler(TextCompositionManager.TextInputUpdateEvent, textInputUpdateHandler);
            AddHandler(TextCompositionManager.PreviewTextInputEvent, previewTextInputHandler);
            AddHandler(TextCompositionManager.TextInputEvent, textInputHandler);

            _imeSupport = new ImeSupport(this);
        }
Example #10
0
        public MainWindow()
        {
            AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);

            InitializeComponent();

            Properties.Settings.Default.Upgrade();

            Border b = new()
            {
                BorderThickness = new Thickness(1),
                BorderBrush     = Brushes.Black
            };

            // _screen = new Screen.TextControlScreen(this);
            _screen = new Absolute.AbsoluteScreen(this);
            pnlScreenPlaceholder.Children.Add(b);

            b.Child = (UIElement)_screen;
            Loaded += new RoutedEventHandler(MainWindow_Loaded);

            if (Properties.Settings.Default.LastPlayedGames != null)
            {
                string[] games = Properties.Settings.Default.LastPlayedGames.Split('|');
                _lastPlayedGames = new List <string>(games);
            }

            BuildMainMenu();

            SizeChanged += new SizeChangedEventHandler(MainWindow_SizeChanged);

            TextInput      += new TextCompositionEventHandler(MainWindow_TextInput);
            PreviewKeyDown += new KeyEventHandler(MainWindow_PreviewKeyDown);

            statusBottom.Visibility = System.Windows.Visibility.Hidden;

            SetFrotzOptions();
        }
Example #11
0
        public MyEdit()
            : base()
        {
            AcceptsReturn = false;
            cbup          = new CommandBinding(EditingCommands.MoveUpByLine, new ExecutedRoutedEventHandler(MoveUpByLineExecuted));
            CommandBindings.Add(cbup);
            cbdown = new CommandBinding(EditingCommands.MoveDownByLine, new ExecutedRoutedEventHandler(MoveDownByLineExecuted));
            CommandBindings.Add(cbdown);
            cbleft = new CommandBinding(EditingCommands.MoveLeftByCharacter, new ExecutedRoutedEventHandler(MoveLeftByCharacter));
            CommandBindings.Add(cbleft);
            cbright = new CommandBinding(EditingCommands.MoveRightByCharacter, new ExecutedRoutedEventHandler(MoveRightByCharacter));
            CommandBindings.Add(cbright);

            IsUndoEnabled = false;
            UndoLimit     = 0;

            AllowDrop = false;

            PreviewTextInput += new TextCompositionEventHandler(TextInput_Preview);
            PreviewKeyDown   += new KeyEventHandler(KeyDown_Preview);

            AddHandler(CommandManager.PreviewExecutedEvent, new ExecutedRoutedEventHandler(ExecutedHandler), true);
        }
Example #12
0
		public static UnmanagedEventHandler CreateTextCompositionEventHandlerDispatcher (TextCompositionEventHandler handler)
		{
			return SafeDispatcher( (sender, calldata, closure)
						=> handler (NativeDependencyObjectHelper.FromIntPtr (closure),
								NativeDependencyObjectHelper.FromIntPtr (calldata) as TextCompositionEventArgs ?? new TextCompositionEventArgs (calldata, false)) );
		}
		public static void RemovePreviewTextInputStartHandler (DependencyObject element, TextCompositionEventHandler handler)
		{
			throw new NotImplementedException ();
		}
        /// <summary>
        ///     Adds a handler for the TextInput attached event
        /// </summary> 
        /// <param name="element">UIElement or ContentElement that listens to this event</param>
        /// <param name="handler">Event Handler to be added</param> 
        public static void AddTextInputHandler(DependencyObject element, TextCompositionEventHandler handler) 
        {
            if (element == null) 
            {
                throw new ArgumentNullException("element");
            }
 
            UIElement.AddHandler(element, TextInputEvent, handler);
        } 
Example #15
0
File: Events.cs Project: ynkbt/moon
 public static UnmanagedEventHandler CreateTextCompositionEventHandlerDispatcher(TextCompositionEventHandler handler)
 {
     return(SafeDispatcher((sender, calldata, closure)
                           => handler(NativeDependencyObjectHelper.FromIntPtr(closure),
                                      NativeDependencyObjectHelper.FromIntPtr(calldata) as TextCompositionEventArgs ?? new TextCompositionEventArgs(calldata, false))));
 }
Example #16
0
        public MyEdit()
            : base()
        {
            AcceptsReturn = false;
            cbup = new CommandBinding(EditingCommands.MoveUpByLine, new ExecutedRoutedEventHandler(MoveUpByLineExecuted));
            CommandBindings.Add(cbup);
            cbdown = new CommandBinding(EditingCommands.MoveDownByLine, new ExecutedRoutedEventHandler(MoveDownByLineExecuted));
            CommandBindings.Add(cbdown);
            cbleft = new CommandBinding(EditingCommands.MoveLeftByCharacter, new ExecutedRoutedEventHandler(MoveLeftByCharacter));
            CommandBindings.Add(cbleft);
            cbright = new CommandBinding(EditingCommands.MoveRightByCharacter, new ExecutedRoutedEventHandler(MoveRightByCharacter));
            CommandBindings.Add(cbright);

            IsUndoEnabled = false;
            UndoLimit = 0;

            AllowDrop = false;

            PreviewTextInput += new TextCompositionEventHandler(TextInput_Preview);
            PreviewKeyDown += new KeyEventHandler(KeyDown_Preview);

            AddHandler(CommandManager.PreviewExecutedEvent, new ExecutedRoutedEventHandler(ExecutedHandler), true);
        }
Example #17
0
        public void AddRemoveHandler()
        {
            Delegate eh  = new EventHandler((object sender, EventArgs ea) => { });
            Delegate keh = new KeyEventHandler((object sender, KeyEventArgs ea) => { });
            Delegate meh = new MouseButtonEventHandler((object sender, MouseButtonEventArgs ea) => { });
            Delegate weh = new MouseWheelEventHandler((object sender, MouseWheelEventArgs ea) => { });
            Delegate teh = new TextCompositionEventHandler((object sender, TextCompositionEventArgs ea) => { });

            // OK
            RoutedEvent [] events1   = new RoutedEvent [] { UIElement.KeyDownEvent, UIElement.KeyUpEvent, UIElement.MouseLeftButtonDownEvent, UIElement.MouseLeftButtonUpEvent, UIElement.MouseWheelEvent, UIElement.TextInputEvent, UIElement.TextInputStartEvent, UIElement.TextInputUpdateEvent };
            Delegate []    handlers1 = new Delegate [] { keh, keh, meh, meh, weh, teh, teh, teh };

            // ArgumentNullException
            RoutedEvent [] events2   = new RoutedEvent [] { null, UIElement.KeyUpEvent };
            Delegate []    handlers2 = new Delegate [] { keh, null };

            // ArgumentException
            RoutedEvent [] events3   = new RoutedEvent [] { FrameworkElement.LoadedEvent, UIElement.KeyUpEvent, UIElement.MouseLeftButtonUpEvent, UIElement.MouseLeftButtonUpEvent, UIElement.TextInputUpdateEvent, UIElement.MouseWheelEvent };
            Delegate []    handlers3 = new Delegate [] { eh, meh, keh, teh, eh, meh };

            // NotImplementedException
            RoutedEvent [] events4   = new RoutedEvent [] { UIElement.ManipulationCompletedEvent, UIElement.ManipulationDeltaEvent, UIElement.ManipulationStartedEvent };
            Delegate []    handlers4 = new Delegate [] { eh, eh, eh };

            UIElement ctrl = new MediaElement();

            // AddHandler
            for (int i = 0; i < events1.Length; i++)
            {
                ctrl.AddHandler(events1 [i], handlers1 [i], false);
            }
            for (int i = 0; i < events2.Length; i++)
            {
                Assert.Throws <ArgumentNullException> (() => ctrl.AddHandler(events2 [i], handlers2 [i], false));
            }
            for (int i = 0; i < events3.Length; i++)
            {
                Assert.Throws <ArgumentException> (() => ctrl.AddHandler(events3 [i], handlers3 [i], false));
            }
            for (int i = 0; i < events4.Length; i++)
            {
                Assert.Throws <NotImplementedException> (() => ctrl.AddHandler(events4 [i], handlers4 [i], false));
            }
            // RemoveHandler
            for (int i = 0; i < events1.Length; i++)
            {
                ctrl.RemoveHandler(events1 [i], handlers1 [i]);
            }
            for (int i = 0; i < events2.Length; i++)
            {
                Assert.Throws <ArgumentNullException> (() => ctrl.RemoveHandler(events2 [i], handlers2 [i]));
            }
            for (int i = 0; i < events3.Length; i++)
            {
                Assert.Throws <ArgumentException> (() => ctrl.RemoveHandler(events3 [i], handlers3 [i]));
            }
            for (int i = 0; i < events4.Length; i++)
            {
                Assert.Throws <NotImplementedException> (() => ctrl.RemoveHandler(events4 [i], handlers4 [i]));
            }
        }
 public BaseInputField addTextBoxEventHandler(TextCompositionEventHandler _eventHandler)
 {
     itemInput_txt.PreviewTextInput += _eventHandler;
     return(this);
 }
Example #19
0
 public static void RemovePreviewTextInputStartHandler(System.Windows.DependencyObject element, TextCompositionEventHandler handler)
 {
 }
Example #20
0
 public static void RemoveTextInputUpdateHandler(System.Windows.DependencyObject element, TextCompositionEventHandler handler)
 {
 }
Example #21
0
 /// <summary> 
 /// The default constructor
 /// </summary>
 public DigitBox()
 {
     TextChanged += new TextChangedEventHandler( OnTextChanged );
     KeyDown += new KeyEventHandler( OnKeyDown );
     PreviewTextInput += new TextCompositionEventHandler( OnPreviewTextInput );
 }
		public static void AddTextInputUpdateHandler (DependencyObject element, TextCompositionEventHandler handler)
		{
			throw new NotImplementedException ();
		}
 public static void RemovePreviewTextInputStartHandler(System.Windows.DependencyObject element, TextCompositionEventHandler handler)
 {
 }
Example #24
0
 public static void RemovePreviewTextInputStartHandler(DependencyObject element, TextCompositionEventHandler handler)
 {
     throw new NotImplementedException();
 }
Example #25
0
 public static void AddTextInputUpdateHandler(DependencyObject element, TextCompositionEventHandler handler)
 {
     throw new NotImplementedException();
 }
 public static void RemoveTextInputUpdateHandler(System.Windows.DependencyObject element, TextCompositionEventHandler handler)
 {
 }
Example #27
0
 static void \u202D‫‌‮‭‎‌‬‍‏‪‍​‮‮‍‭‬‏‍‮‭‍‮‪‫‏‮([In] UIElement obj0, [In] TextCompositionEventHandler obj1)
 {
     obj0.PreviewTextInput += obj1;
 }