protected void SetTimeout(int milliseconds, Action func)
        {
            var timer = new DispatcherTimerContainingAction
            {
                Interval = new TimeSpan(0, 0, 0, 0, milliseconds),
                Action   = func
            };

            timer.Tick += OnTimeout;
            timer.Start();
        }
Exemple #2
0
        public static void SetTimeout(TimeSpan time, Action <object> func, object data)
        {
            if (func == null)
            {
                throw new ArgumentNullException("func");
            }

            var timer = new DispatcherTimerContainingAction {
                Interval = time, ActionWithData = func, Data = data
            };

            StartTimer(timer);
        }
Exemple #3
0
        public static void SetTimeout(TimeSpan time, Action func)
        {
            if (func == null)
            {
                throw new ArgumentNullException("func");
            }

            var timer = new DispatcherTimerContainingAction {
                Interval = time, Action = func
            };

            StartTimer(timer);
        }
Exemple #4
0
        public static void SetTimeout <T>(TimeSpan time, Action <T> func, T data)
        {
            if (func == null)
            {
                throw new ArgumentNullException("func");
            }

            var timer = new DispatcherTimerContainingAction {
                Interval = time, ActionWithData = d => { if (d is T)
                                                         {
                                                             func((T)d);
                                                         }
                }, Data = data
            };

            StartTimer(timer);
        }
        private void resultListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (resultListView.SelectedItem == null)
            {
                selectedItemText.Text = "(no game selected)";
                return;
            }

            SearchResult selectedItem = resultListView.SelectedItem as SearchResult;
            SearchResultPerSystem summarySelection = (SearchResultPerSystem)systemSummaryListView.SelectedItem;

            int ix = resultListView.SelectedIndex + 1;

            selectedItemText.Text = string.Format("{4}. {0} - {1}, {2}, {3}", selectedItem.SystemName, selectedItem.description, selectedItem.manufacturer, selectedItem.year, ix).Replace(", ,", ",").TrimEnd(' ', ',');

            // send the actual game item's System through for the "(All)" collection or if we are in Genre mode
            if (summarySelection.SystemName.EqualsCI(SystemSummaryAllCollectionName) || SearchListToUse == SearchList.Genre)
            {
                MainWindow.LEDBlinkSystemSelected(selectedItem.SystemName);
            }

            MainWindow.LEDBlinkGameSelected(selectedItem.name);

            CloseAndStopVideoWin();

            // only attempt to video popup if result view has focus
            if (ShowGameVideos && Keyboard.FocusedElement == resultListView.ItemContainerGenerator.ContainerFromItem(selectedItem))
            {
                var timeout = VideoPopupTimeoutInMilliseconds;

                if (videoBorder.Visibility == System.Windows.Visibility.Visible) timeout = 0;

                _videoPopupTimer = Util.SetTimeout(timeout, new Action(() =>
                    {
                        try
                        {
                            if (CurrentViewState != ViewState.Results) return;

                            videoBorder.Width = this.ActualWidth * 0.4;
                            videoBorder.Height = this.ActualHeight * 0.4;
                            videoBorder.Visibility = System.Windows.Visibility.Visible;

                            LoadVideo(selectedItem.SystemName, selectedItem.name);
                        }
                        catch (Exception ex)
                        {
                            ErrorHandler.HandleException(ex);
                        }
                    }));
            }
        }
 private void CloseAndStopVideoWin()
 {
     if (_videoPopupTimer != null)
     {
         _videoPopupTimer.Stop();
         _videoPopupTimer = null;
     }
     if (video.Source != null) video.Stop();
     video.Source = null;
     videoBorder.Visibility = System.Windows.Visibility.Hidden;
 }