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;
        }
Example #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);
            }
        }
        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));
        }
Example #4
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)
        {

        }
Example #5
0
 private void Modal1OnOutsideClick(object sender, RoutedEventArgs routedEventArgs)
 {
     modalButton1Text.Text = "Click on the Button, please";
 }
Example #6
0
        private static void ValueChangedClassHandler(object sender, RoutedEventArgs args)
        {
            var slider = (Slider)sender;

            slider.OnValueChanged(args);
        }
Example #7
0
        protected override void OnClick(RoutedEventArgs args)
        {
            base.OnClick(args);

            GoToNextState();
        }
        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)));
        }
        private void TestReccursiveRaiseOnClick(object sender, RoutedEventArgs routedEventArgs)
        {
            ++clickCount;

            if (clickCount < 10)
                ((Button)sender).RaiseEvent(new RoutedEventArgs(ButtonBase.ClickEvent));
        }
        private void ToggleLight(Object sender, RoutedEventArgs args)
        {
            var button = (Button)sender;
            if (button.Name == "direct")
            {
                directionalLight.Enabled = !directionalLight.Enabled;
                ((TextBlock)button.Content).Text = GetButtonTextOnOff("Direct light: ", directionalLight.Enabled);
                buttonShadow.Opacity = directionalLight.Enabled ? 1.0f : 0.3f;
                buttonShadow.CanBeHitByUser = directionalLight.Enabled;
            }
            else if (button.Name == "spot")
            {
                spotLight.Enabled = !spotLight.Enabled;
                ((TextBlock)button.Content).Text = GetButtonTextOnOff("Spot light: ", spotLight.Enabled);
                buttonSpotShadow.Opacity = directionalLight.Enabled ? 1.0f : 0.3f;
                buttonSpotShadow.CanBeHitByUser = directionalLight.Enabled;
            }
            else if (button.Name == "point")
            {
                var enabled = false;
                foreach (var point in pointLights)
                {
                    point.Enabled = !point.Enabled;
                    enabled = enabled || point.Enabled;
                }

                ((TextBlock)button.Content).Text = GetButtonTextOnOff("Point lights: ", enabled);
                buttonLightRotate.Opacity = enabled ? 1.0f : 0.3f;
                buttonLightRotate.CanBeHitByUser = enabled;
            }
        }
 private void ToggleShadowMap(Object sender, RoutedEventArgs args)
 {
     var button = (Button)sender;
     if (button.Name == "direct")
     {
         directionalLight.ShadowMap = !directionalLight.ShadowMap;
         ((TextBlock)button.Content).Text = GetButtonTextOnOff("Shadow: ", directionalLight.ShadowMap);
     }
     else if (button.Name == "spot")
     {
         spotLight.ShadowMap = !spotLight.ShadowMap;
         ((TextBlock)button.Content).Text = GetButtonTextOnOff("Shadow: ", spotLight.ShadowMap);
     }
 }
Example #12
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)
        {

        }
Example #13
0
        private static void TextChangedClassHandler(object sender, RoutedEventArgs e)
        {
            var editText = (EditText)sender;

            editText.OnTextChanged(e);
        }
Example #14
0
 private void TestRoutedEventHandler(Object sender, RoutedEventArgs e)
 {
 }
Example #15
0
 private void TestDelegate2(Object sender, RoutedEventArgs args)
 {
 }
Example #16
0
 private void TestHandlerRaiseOrderOnClick4(object sender, RoutedEventArgs routedEventArgs)
 {
     Assert.AreEqual(3, lastHandlerCalledId);
     lastHandlerCalledId = 4;
 }
 private void ToogleRotation(Object sender, RoutedEventArgs args)
 {
     var button = (Button)sender;
     rotateLights = !rotateLights;
     ((TextBlock) button.Content).Text = GetButtonTextOnOff("Lights rotation: ", rotateLights);
 }
Example #18
0
 private void TestAddSenderToList(Object sender, RoutedEventArgs e)
 {
     senderList.Add(sender);
 }
Example #19
0
 private void TestHandledHandler(Object sender, RoutedEventArgs e)
 {
     senderList.Add(sender);
     e.Handled = true;
 }
 public abstract void Invoke(object sender, RoutedEventArgs args);
Example #21
0
 private void TestAddSenderToClassHandlerList(Object sender, RoutedEventArgs e)
 {
     classHandlerSenderList.Add(sender);
 }
Example #22
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)
        {

        }
Example #23
0
 private void TestClassHandlerHandled(Object sender, RoutedEventArgs e)
 {
     classHandlerSenderList.Add(sender);
     e.Handled = true;
 }
Example #24
0
 private void ModalButton2OnClick(object sender, RoutedEventArgs routedEventArgs)
 {
     uniformGrid.Children.Remove(modal2);
 }
Example #25
0
 private void TestClassHandlerEventHandled(Object sender, RoutedEventArgs e)
 {
     testClassHandlerEventHandledTooCalled = true;
 }
Example #26
0
 private void Edit2OnTextChanged(object sender, RoutedEventArgs routedEventArgs)
 {
     Logger.Info("The text of the edit2 box changed: text={0}", edit2.Text);
 }
Example #27
0
        private static void ClickClassHandler(object sender, RoutedEventArgs args)
        {
            var buttonBase = (ButtonBase)sender;

            buttonBase.OnClick(args);
        }