Esempio n. 1
0
        private void TestArgsDelegate(object sender, RoutedEventArgs e)
        {
            Assert.AreEqual(argsPassedToRaiseEvent, e);
            Assert.AreEqual(eventPassedToRaiseEvent, e.RoutedEvent);
            Assert.AreEqual(sourcePassedToRaiseEvent, e.Source);
            Assert.Throws<InvalidOperationException>(() => e.Source = null);
            Assert.Throws<InvalidOperationException>(() => e.RoutedEvent = null);
            Assert.AreEqual(false, e.Handled);

            enteredInTestArgsDelegate = true;
        }
Esempio n. 2
0
        protected override void OnTouchUp(TouchEventArgs args)
        {
            base.OnTouchUp(args);

            if(!IsModal || args.Source != this)
                return;

            var position = args.WorldPosition - new Vector3(WorldMatrixInternal.M41, WorldMatrixInternal.M42, WorldMatrixInternal.M43);
            if (position.X < 0 || position.X > RenderSize.X
                || position.Y < 0 || position.Y > RenderSize.Y)
            {
                var eventArgs = new RoutedEventArgs(OutsideClickEvent);
                RaiseEvent(eventArgs);
            }
        }
Esempio n. 3
0
 public abstract void Invoke(object sender, RoutedEventArgs args);
Esempio n. 4
0
        public void TestRaiseEvent()
        {
            // Test ArgumentNullException
            Assert.Throws<ArgumentNullException>(() => RaiseEvent(null));

            AddHandler(eventPassedToRaiseEvent, TestArgsDelegate);

            // test that if RoutedEvent of argument is null nothing special happens
            RaiseEvent(new RoutedEventArgs());

            // test the values of the arguments in the delegate
            sourcePassedToRaiseEvent = this;
            argsPassedToRaiseEvent = new RoutedEventArgs(eventPassedToRaiseEvent);
            RaiseEvent(argsPassedToRaiseEvent);
            sourcePassedToRaiseEvent = new UIElementLayeringTests();
            argsPassedToRaiseEvent = new RoutedEventArgs(eventPassedToRaiseEvent, sourcePassedToRaiseEvent);
            RaiseEvent(argsPassedToRaiseEvent);

            // check that the delegate has been called
            Assert.AreEqual(true, enteredInTestArgsDelegate);

            // check that value of the event raised can be modified again after being raised
            Assert.DoesNotThrow(() => argsPassedToRaiseEvent.RoutedEvent = null);
            Assert.DoesNotThrow(() => argsPassedToRaiseEvent.Source = null);

            // test InvalidOperationException
            var eventMyTest = EventManager.RegisterRoutedEvent<MyTestRoutedEventArgs>("myEventTestRaise", RoutingStrategy.Direct, typeof(UIElementLayeringTests));
            Assert.Throws<InvalidOperationException>(() => RaiseEvent(new RoutedEventArgs(eventMyTest)));
        }
Esempio n. 5
0
        private static void ValueChangedClassHandler(object sender, RoutedEventArgs args)
        {
            var slider = (Slider)sender;

            slider.OnValueChanged(args);
        }
Esempio n. 6
0
        private static void ClickClassHandler(object sender, RoutedEventArgs args)
        {
            var buttonBase = (ButtonBase)sender;

            buttonBase.OnClick(args);
        }
Esempio n. 7
0
        /// <summary>
        /// The class handler of the event <see cref="TextChanged"/>.
        /// This method can be overridden in inherited classes to perform actions common to all instances of a class.
        /// </summary>
        /// <param name="args">The arguments of the event</param>
        protected virtual void OnTextChanged(RoutedEventArgs args)
        {

        }
Esempio n. 8
0
        // Function in charge of toggling on/off the lights shadow maps
        private static void ToggleShadowMap(Object sender, RoutedEventArgs args)
        {
            var button = (Button)sender;
            var light = button.DependencyProperties.Get(LightKey);

            var directLight = light != null ? light.Type as IDirectLight : null;
            if (directLight == null)
                return;

            // toggle the shadow and update button text
            directLight.Shadow.Enabled = !directLight.Shadow.Enabled;
            ((TextBlock)button.Content).Text = GetButtonTextOnOffShadow(light);
        }
Esempio n. 9
0
 private void TestClassHandlerEventHandled(Object sender, RoutedEventArgs e)
 {
     testClassHandlerEventHandledTooCalled = true;
 }
Esempio n. 10
0
 private void TestClassHandlerHandled(Object sender, RoutedEventArgs e)
 {
     classHandlerSenderList.Add(sender);
     e.Handled = true;
 }
Esempio n. 11
0
 private void TestAddSenderToClassHandlerList(Object sender, RoutedEventArgs e)
 {
     classHandlerSenderList.Add(sender);
 }
Esempio n. 12
0
 private void TestHandledHandler(Object sender, RoutedEventArgs e)
 {
     senderList.Add(sender);
     e.Handled = true;
 }
Esempio n. 13
0
 private void TestAddSenderToList(Object sender, RoutedEventArgs e)
 {
     senderList.Add(sender);
 }
 private void ModalButton2OnClick(object sender, RoutedEventArgs routedEventArgs)
 {
     uniformGrid.Children.Remove(modal2);
 }
 private void Modal2OnOutsideClick(object sender, RoutedEventArgs routedEventArgs)
 {
     modalButton2Text.Text = "Click on the Button, please";
 }
Esempio n. 16
0
 private void Edit2OnTextChanged(object sender, RoutedEventArgs routedEventArgs)
 {
     Logger.Info("The text of the edit2 box changed: text={0}", edit2.Text);
 }
Esempio n. 17
0
        // Function in charge of toggling on/off the light themselves
        private void ToggleLight(Object sender, RoutedEventArgs args)
        {
            var button = (Button)sender;
            var light = button.DependencyProperties.Get(LightKey);
            if (light == null)
                return;

            // toggle light and update button text
            light.Enabled = !light.Enabled;
            ((TextBlock)button.Content).Text = GetButtonTextOnOffLight(light);

            var buttonShadow = button.DependencyProperties.Get(ShadowButtonKey);
            if (buttonShadow == null)
                return;

            // disable shadow child button
            buttonShadow.Opacity = light.Enabled ? 1.0f : 0.3f;
            buttonShadow.CanBeHitByUser = light.Enabled;
        }
Esempio n. 18
0
        private void TestUnregisterHandlerOnClick(object sender, RoutedEventArgs routedEventArgs)
        {
            ++testUnregisterHandlerCallCount;

            ((Button)sender).Click -= TestUnregisterHandlerOnClick;

            if(testUnregisterHandlerCallCount < 10) // avoid infinite looping on test fail
                ((Button)sender).RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
        }
Esempio n. 19
0
        private static void TextChangedClassHandler(object sender, RoutedEventArgs e)
        {
            var editText = (EditText)sender;

            editText.OnTextChanged(e);
        }
Esempio n. 20
0
 private void TestDelegate2(Object sender, RoutedEventArgs args)
 {
 }
Esempio n. 21
0
        protected override void OnClick(RoutedEventArgs args)
        {
            base.OnClick(args);

            GoToNextState();
        }
Esempio n. 22
0
 private void TestHandlerRaiseOrderOnClick4(object sender, RoutedEventArgs routedEventArgs)
 {
     Assert.AreEqual(3, lastHandlerCalledId);
     lastHandlerCalledId = 4;
 }
Esempio n. 23
0
        /// <summary>
        /// The class handler of the event <see cref="Click"/>.
        /// This method can be overridden in inherited classes to perform actions common to all instances of a class.
        /// </summary>
        /// <param name="args">The arguments of the event</param>
        protected virtual void OnClick(RoutedEventArgs args)
        {

        }
Esempio n. 24
0
        private void TestReccursiveRaiseOnClick(object sender, RoutedEventArgs routedEventArgs)
        {
            ++clickCount;

            if (clickCount < 10)
                ((Button)sender).RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
        }
Esempio n. 25
0
 private void TestRoutedEventHandler(Object sender, RoutedEventArgs e)
 {
 }
Esempio n. 26
0
        /// <summary>
        /// The class handler of the event <see cref="ValueChanged"/>.
        /// This method can be overridden in inherited classes to perform actions common to all instances of a class.
        /// </summary>
        /// <param name="args">The arguments of the event</param>
        protected virtual void OnValueChanged(RoutedEventArgs args)
        {

        }