public IActionResult Info(string season, string round)
        {
            TrackInfoViewModel trackInfoViewModel = new TrackInfoViewModel();

            trackInfoViewModel.round  = round;
            trackInfoViewModel.season = season;
            return(View(trackInfoViewModel));
        }
示例#2
0
        public async Task ShowNotificationAsync()
        {
            if (this.notification != null)
            {
                this.notification.DoubleClicked -= ShowMainWindow;
            }

            if (!XmlSettingsClient.Instance.Get <bool>("Behaviour", "ShowNotification"))
            {
                return;
            }

            try
            {
                if (this.notification != null)
                {
                    this.notification.Disable();
                }
            }
            catch (Exception ex)
            {
                LogClient.Instance.Logger.Error("Error while trying to disable the notification. Exception: {0}", ex.Message);
            }

            string artworkPath = string.Empty;

            TrackInfoViewModel playingTrackinfoVm = null; // Create a dummy track

            await Task.Run(() =>
            {
                try
                {
                    if (this.playbackService.PlayingTrack != null)
                    {
                        artworkPath                  = ArtworkUtils.GetArtworkPath(this.playbackService.PlayingTrack.AlbumArtworkID);
                        playingTrackinfoVm           = this.container.Resolve <TrackInfoViewModel>();
                        playingTrackinfoVm.TrackInfo = this.playbackService.PlayingTrack;
                    }
                }
                catch (Exception ex)
                {
                    LogClient.Instance.Logger.Error("Error while trying to show the notification. Exception: {0}", ex.Message);
                }
            });

            Application.Current.Dispatcher.Invoke(() =>
            {
                this.notification = new NotificationWindow(playingTrackinfoVm,
                                                           artworkPath,
                                                           (NotificationPosition)XmlSettingsClient.Instance.Get <int>("Behaviour", "NotificationPosition"),
                                                           XmlSettingsClient.Instance.Get <bool>("Behaviour", "ShowNotificationControls"),
                                                           XmlSettingsClient.Instance.Get <int>("Behaviour", "NotificationAutoCloseSeconds"));

                this.notification.DoubleClicked += ShowMainWindow;

                this.notification.Show();
            });
        }
示例#3
0
 public TimingDataViewModel(DriverLapsWindowManager driverLapsWindowManager, DisplaySettingsViewModel displaySettingsViewModel, DriverPresentationsManager driverPresentationsManager, ISessionTelemetryControllerFactory sessionTelemetryControllerFactory)
 {
     TimingDataGridViewModel            = new TimingDataGridViewModel(driverPresentationsManager, displaySettingsViewModel, new ClassColorProvider(new BasicColorPaletteProvider()));
     SessionInfoViewModel               = new SessionInfoViewModel();
     TrackInfoViewModel                 = new TrackInfoViewModel();
     _driverLapsWindowManager           = driverLapsWindowManager;
     _driverPresentationsManager        = driverPresentationsManager;
     _sessionTelemetryControllerFactory = sessionTelemetryControllerFactory;
     DoubleLeftClickCommand             = _driverLapsWindowManager.OpenWindowCommand;
     ReportsController         = new ReportsController(DisplaySettingsViewModel);
     DisplaySettingsViewModel  = displaySettingsViewModel;
     SituationOverviewProvider = new SituationOverviewProvider(TimingDataGridViewModel, displaySettingsViewModel);
 }
 public TimingDataViewModel(DriverLapsWindowManager driverLapsWindowManager, ISettingsProvider settingsProvider, DriverPresentationsManager driverPresentationsManager,
                            ISessionTelemetryControllerFactory sessionTelemetryControllerFactory, IRatingProvider ratingProvider, ITrackRecordsController trackRecordsController, IChampionshipCurrentEventPointsProvider championshipCurrentEventPointsProvider,
                            ISessionEventProvider sessionEventProvider)
 {
     TimingDataGridViewModel            = new TimingDataGridViewModel(driverPresentationsManager, settingsProvider.DisplaySettingsViewModel, new ClassColorProvider(new BasicColorPaletteProvider()));
     SessionInfoViewModel               = new SessionInfoViewModel();
     TrackInfoViewModel                 = new TrackInfoViewModel();
     _driverLapsWindowManager           = driverLapsWindowManager;
     _settingsProvider                  = settingsProvider;
     _sessionTelemetryControllerFactory = sessionTelemetryControllerFactory;
     _ratingProvider         = ratingProvider;
     _trackRecordsController = trackRecordsController;
     _championshipCurrentEventPointsProvider = championshipCurrentEventPointsProvider;
     _sessionEventProvider     = sessionEventProvider;
     DoubleLeftClickCommand    = _driverLapsWindowManager.OpenWindowCommand;
     DisplaySettingsViewModel  = settingsProvider.DisplaySettingsViewModel;
     TrackRecordsViewModel     = _trackRecordsController.TrackRecordsViewModel;
     SituationOverviewProvider = new SituationOverviewProvider(TimingDataGridViewModel, settingsProvider.DisplaySettingsViewModel);
 }
        public NotificationWindow(TrackInfoViewModel trackInfoVm, string coverPictureSource, NotificationPosition position, bool showControls, int maxSecondsVisible) : base()
        {
            this.InitializeComponent();

            this.maxSecondsVisible = maxSecondsVisible;

            int notificationHeight = 66 + 2 * this.notificationShadowSize;
            int notificationWidth  = 286 + 2 * this.notificationShadowSize;

            if (showControls)
            {
                notificationHeight           += 40;
                notificationWidth            += 90;
                this.ControlsPanel.Visibility = Visibility.Visible;
                this.VolumePanel.Visibility   = Visibility.Visible;
            }
            else
            {
                this.ControlsPanel.Visibility = Visibility.Collapsed;
                this.VolumePanel.Visibility   = Visibility.Collapsed;
            }

            if (trackInfoVm != null)
            {
                this.TextBoxTitle.Text  = string.IsNullOrEmpty(trackInfoVm.TrackTitle) ? trackInfoVm.FileName : trackInfoVm.TrackTitle;
                this.TextBoxArtist.Text = trackInfoVm.ArtistName;
            }
            else
            {
                this.TextBoxTitle.Text  = ResourceUtils.GetStringResource("Language_Title");
                this.TextBoxArtist.Text = ResourceUtils.GetStringResource("Language_Artist");
            }

            this.ToolTipTitle.Text  = this.TextBoxTitle.Text;
            this.ToolTipArtist.Text = this.TextBoxArtist.Text;

            if (!string.IsNullOrEmpty(coverPictureSource))
            {
                try
                {
                    BitmapImage coverImage = new BitmapImage();
                    coverImage.BeginInit();
                    coverImage.DecodePixelWidth  = 300; // Needs to be big enough, otherwise the picture is blurry
                    coverImage.DecodePixelHeight = 300; // Needs to be big enough, otherwise the picture is blurry
                    //coverImage.DecodePixelWidth = notificationHeight
                    //coverImage.DecodePixelHeight = notificationHeight
                    coverImage.CacheOption = BitmapCacheOption.OnLoad;
                    coverImage.UriSource   = new Uri(coverPictureSource);
                    coverImage.EndInit();

                    this.CoverPicture.Source = coverImage;
                    this.CloseBorder.Opacity = 1.0;
                }
                catch (Exception)
                {
                    // Swallow
                }
            }
            else
            {
                this.CloseBorder.Opacity = 0.4;
            }


            Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, new Action(() =>
            {
                Rect desktopWorkingArea = System.Windows.SystemParameters.WorkArea;

                // First, set the position
                switch (position)
                {
                case NotificationPosition.BottomLeft:
                    // Bottom left
                    this.Left = desktopWorkingArea.Left + this.notificationMarginFromScreen;
                    this.Top  = desktopWorkingArea.Bottom - notificationHeight - this.notificationMarginFromScreen;
                    break;

                case NotificationPosition.TopLeft:
                    // Top left
                    this.Left = desktopWorkingArea.Left + this.notificationMarginFromScreen;
                    this.Top  = desktopWorkingArea.Top + this.notificationMarginFromScreen;
                    break;

                case NotificationPosition.TopRight:
                    // Top right
                    this.Left = desktopWorkingArea.Right - notificationWidth - this.notificationMarginFromScreen;
                    this.Top  = desktopWorkingArea.Top + this.notificationMarginFromScreen;
                    break;

                case NotificationPosition.BottomRight:
                    // Bottom right
                    this.Left = desktopWorkingArea.Right - notificationWidth - this.notificationMarginFromScreen;
                    this.Top  = desktopWorkingArea.Bottom - notificationHeight - this.notificationMarginFromScreen;
                    break;

                default:
                    break;
                }

                // After setting the position, set the size. The original size op 0px*0px prevents
                // flicker when displaying the popup. Because it briefly appears in the top left
                // corner before getting its desired position.
                this.Width               = notificationWidth;
                this.Height              = notificationHeight;
                this.CoverPicture.Width  = notificationHeight - 2 * this.notificationShadowSize;
                this.CoverPicture.Height = notificationHeight - 2 * this.notificationShadowSize;
                this.CoverTile.Width     = notificationHeight - 2 * this.notificationShadowSize;
                this.CoverTile.Height    = notificationHeight - 2 * this.notificationShadowSize;
            }));

            this.hideTimer.Interval  = TimeSpan.FromSeconds(1);
            this.closeTimer.Interval = TimeSpan.FromSeconds(1);
            this.hideTimer.Tick     += new EventHandler(HideTimer_Tick);
            this.closeTimer.Tick    += new EventHandler(CloseTimer_Tick);
        }