コード例 #1
0
        private void RaiseCanExecuteChanged()
        {
            var act = new Action(() =>
            {
                if (BoundControls != null && BoundControls.Count > 0)
                {
                    List <WeakReference> garbagedObjects = new List <WeakReference>();
                    BoundControls.ForEach(ce =>
                    {
                        object target = ce.Target;
                        if (target != null)
                        {
                            ((EventHandler)(target)).Invoke(null, EventArgs.Empty);
                        }
                        else
                        {
                            garbagedObjects.Add(ce);
                        }
                    });

                    garbagedObjects.ForEach(x => BoundControls.Remove(x));
                    garbagedObjects.Clear();
                }
            });

            WPFUtils.ExecuteOnUIThread(act);
        }
コード例 #2
0
        private void timer_Tick(object sender, EventArgs e)
        {
            if (_isInsideControl || !CanHideControls() || WPFUtils.GetInDesignMode())
            {
                return;
            }

            _timer.Stop();
            if (_stopwatch.ElapsedMilliseconds > 1000 * _hideTimeOutSeconds)
            {
                foreach (UIElement ctrl in _controlsToFade)
                {
                    VisibilityHideAnimation(ctrl, 0, Visibility.Hidden, OnHideCompleted);
                }

                return; //do not start timer
            }
            _timer.Start();
        }