Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        Ray        ray = cam.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        bool       bHit = Physics.Raycast(ray, out hit, castDistance, mask);

        if (bHit)
        {
            GameObject other = hit.transform.gameObject;
            //MeshRenderer omr = other.GetComponent<MeshRenderer>();

            if (other.CompareTag("Fadeable"))
            {
                FadeBehavior fb = other.GetComponent <FadeBehavior>();

                if (!fb)
                {
                    fb = other.GetComponentInChildren <FadeBehavior>();
                }

                if (fb)
                {
                    fb.Reset();
                }
            }
            else
            {
                // omr.material.color = Color.red;
            }
        }
    }
        private void AddFadeBehavior(View view)
        {
            var behavior = new FadeBehavior();

            view.Behaviors.Add(behavior);
            behavior.SetBinding(FadeBehavior.IsSelectedProperty, "IsSelected");
        }
Beispiel #3
0
        /// <summary>
        /// 设置淡入淡出
        /// </summary>
        /// <param name="view"></param>
        /// <param name="data"></param>
        private void SetFade(View view, object data)
        {
            var behavior = new FadeBehavior();

            behavior.SetBinding(FadeBehavior.IsSelectedProperty, "IsSelected", BindingMode.TwoWay);
            view.Behaviors.Add(behavior);
        }
        /// <summary>
        /// Called when the timer has elapsed. Removes any stale notifications.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="System.Timers.ElapsedEventArgs"/> instance containing the event data.</param>
        private static void OnTimerElapsed(WindowInfo windowInfo)
        {
            if (notificationWindows.Count > 0 && !notificationWindows.Any(i => i.ID == windowInfo.ID))
            {
                return;
            }
            DateTime now = DateTime.Now;

            if (windowInfo.Window.IsMouseOver)
            {
                Observable
                .Timer(windowInfo.DisplayDuration)
                .ObserveOnDispatcher()
                .Subscribe(x => OnTimerElapsed(windowInfo));
            }
            else
            {
                BehaviorCollection behaviors     = Interaction.GetBehaviors(windowInfo.Window);
                FadeBehavior       fadeBehavior  = behaviors.OfType <FadeBehavior>().First();
                SlideBehavior      slideBehavior = behaviors.OfType <SlideBehavior>().First();

                fadeBehavior.FadeOut();
                slideBehavior.SlideOut();

                EventHandler eventHandler = null;
                eventHandler = (sender2, e2) =>
                {
                    fadeBehavior.FadeOutCompleted -= eventHandler;
                    notificationWindows.Remove(windowInfo);
                    windowInfo.Window.Close();

                    if (notificationsBuffer != null && notificationsBuffer.Count > 0)
                    {
                        var BufferWindowInfo = notificationsBuffer.First();
                        Observable
                        .Timer(BufferWindowInfo.DisplayDuration)
                        .ObserveOnDispatcher()
                        .Subscribe(x => OnTimerElapsed(BufferWindowInfo));
                        notificationWindows.Add(BufferWindowInfo);
                        BufferWindowInfo.Window.Show();
                        notificationsBuffer.Remove(BufferWindowInfo);
                    }
                };
                fadeBehavior.FadeOutCompleted += eventHandler;
            }
        }
Beispiel #5
0
        /// <summary>
        /// The initial animation.
        /// </summary>
        /// <param name="frameworkElement"> The framework element. </param>
        private static void InitAnimation(FrameworkElement frameworkElement)
        {
            Wizard wizard = frameworkElement.FindVisualParent<Wizard>();
            WizardItem wizardItem = frameworkElement.FindVisualParent<WizardItem>();

            if ((wizard != null) && (wizardItem != null))
            {
                WizardAnimation animation = (WizardAnimation)Enum.Parse(
                    typeof(WizardAnimation),
                    GetAnimation(frameworkElement).ToString());

                BehaviorCollection behaviors = Interaction.GetBehaviors(frameworkElement);

                FadeBehavior fadeBehavior = null;
                if ((animation == WizardAnimation.Fade) || (animation == WizardAnimation.FadeAndSlide))
                {
                    fadeBehavior = behaviors.OfType<FadeBehavior>().FirstOrDefault();
                    if (fadeBehavior == null)
                    {
                        fadeBehavior = new FadeBehavior()
                        {
                            Duration = wizard.TransitionDuration.TimeSpan,
                        };
                        behaviors.Add(fadeBehavior);
                    }
                }

                SlideBehavior slideBehavior = null;
                if ((animation == WizardAnimation.Slide) || (animation == WizardAnimation.FadeAndSlide))
                {
                    slideBehavior = behaviors.OfType<SlideBehavior>().FirstOrDefault();
                    if (slideBehavior == null)
                    {
                        slideBehavior = new SlideBehavior()
                        {
                            Duration = wizard.TransitionDuration.TimeSpan,
                        };
                        behaviors.Add(slideBehavior);
                    }
                }

                wizardItem.Entering +=
                    (sender, e2) =>
                    {
                        if (fadeBehavior != null)
                        {
                            fadeBehavior.FadeIn();
                        }

                        if (slideBehavior != null)
                        {
                            slideBehavior.SlideIn();
                        }
                    };
                wizardItem.Leaving +=
                    (sender, e2) =>
                    {
                        if (fadeBehavior != null)
                        {
                            fadeBehavior.FadeOut();
                        }

                        if (slideBehavior != null)
                        {
                            slideBehavior.SlideOut();
                        }
                    };
            }
        }