コード例 #1
0
        private async void BrowseCustom_Click(object sender, RoutedEventArgs e)
        {
            using (var openFileDialog = new CommonOpenFileDialog
            {
                IsFolderPicker = true,
                Title = "Select Folder"
            })
            {
                var result = openFileDialog.ShowDialog();
                if (result != CommonFileDialogResult.Ok)
                {
                    return;
                }
                var path = openFileDialog.FileName;
                try
                {
                    TbCustomPath.Text = path;
                    await Service.Get <OsuFileScanner>().CancelTaskAsync();

                    await Service.Get <OsuFileScanner>().NewScanAndAddAsync(path);

                    AppSettings.Default.General.CustomSongsPath = path;
                    AppSettings.SaveDefault();
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "Error while scanning custom folder: {0}", path);
                    MessageBox.Show(_configWindow, string.Format("{0}: {1}\r\n{2}",
                                                                 I18NUtil.GetString("err-custom-scan"), path, ex.Message),
                                    _configWindow.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
コード例 #2
0
ファイル: AboutPage.xaml.cs プロジェクト: Milkitic/Osu-Player
        private async void CheckUpdate_Click(object sender, RoutedEventArgs e)
        {
            //todo: action
            CheckUpdate.IsEnabled = false;
            bool?hasNew;

            try
            {
                hasNew = await Service.Get <UpdateInst>().CheckUpdateAsync();
            }
            catch (Exception ex)
            {
                MessageBox.Show(_configWindow, I18NUtil.GetString("ui-sets-content-errorWhileCheckingUpdate") + Environment.NewLine +
                                (ex.InnerException?.Message ?? ex.Message),
                                _configWindow.Title, MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            CheckUpdate.IsEnabled = true;

            AppSettings.Default.LastUpdateCheck = DateTime.Now;
            GetLastUpdate();
            AppSettings.SaveDefault();
            if (hasNew == true)
            {
                NewVersion.Visibility = Visibility.Visible;
                NewVersion_Click(sender, e);
            }
            else
            {
                MessageBox.Show(_configWindow, I18NUtil.GetString("ui-sets-content-alreadyNewest"), _configWindow.Title,
                                MessageBoxButton.OK, MessageBoxImage.Information);
            }
        }
コード例 #3
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is IDeviceInfo b))
            {
                return(value);
            }
            if (b.Equals(WasapiInfo.Default))
            {
                return(I18NUtil.GetString("ui-sets-content-systemDefault"));
            }

            return($"({b.OutputMethod}) {b.FriendlyName}");
        }
コード例 #4
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (!(value is DeviceInfo b))
            {
                return(value);
            }
            if (b.Equals(DeviceInfo.DefaultWasapi))
            {
                return(I18NUtil.GetString("ui-sets-content-systemDefault"));
            }

            return($"({b.Provider}) {b.Name}");
        }
コード例 #5
0
        private async void BtnDelCol_Click(object sender, RoutedEventArgs e)
        {
            var result = MessageBox.Show(_mainWindow, I18NUtil.GetString("ui-ensureRemoveCollection"), _mainWindow.Title, MessageBoxButton.OKCancel,
                                         MessageBoxImage.Exclamation);

            if (result != MessageBoxResult.OK)
            {
                return;
            }
            await using var dbContext = new ApplicationDbContext();

            await dbContext.DeleteCollection(ViewModel.Collection);

            _mainWindow.SwitchRecent.IsChecked = true;
            await _mainWindow.UpdateCollections();
        }
コード例 #6
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var shown = (bool)value;

            if (System.Convert.ToString(parameter) == "string")
            {
                return(shown ? I18NUtil.GetString("ui-closeDesktopLyric") : I18NUtil.GetString("ui-openDesktopLyric"));
            }
            else if (System.Convert.ToString(parameter) == "bool")
            {
                return(shown);
            }
            else
            {
                return(null);
            }
        }
コード例 #7
0
        private async void SyncNow_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                await Service.Get <OsuDbInst>().SyncOsuDbAsync(AppSettings.Default.General.DbPath, false);

                AppSettings.Default.LastTimeScanOsuDb = DateTime.Now;
                AppSettings.SaveDefault();
            }
            catch (Exception ex)
            {
                var path = AppSettings.Default.General.DbPath;
                Logger.Error(ex, "Error while scanning custom folder: {0}", path);
                MessageBox.Show(_configWindow, string.Format("{0}: {1}\r\n{2}",
                                                             I18NUtil.GetString("err-custom-scan"), path, ex.Message),
                                _configWindow.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #8
0
        private async void BrowseDb_Click(object sender, RoutedEventArgs e)
        {
            var result = CommonUtils.BrowseDb(out var path);

            if (!result.HasValue || !result.Value)
            {
                return;
            }
            try
            {
                await Service.Get <OsuDbInst>().SyncOsuDbAsync(path, false);

                TbDbPath.Text = path;
                AppSettings.Default.General.DbPath = path;
                AppSettings.SaveDefault();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Error while syncing osu!db: {0}", path);
                MessageBox.Show(_configWindow, string.Format("{0}: {1}\r\n{2}",
                                                             I18NUtil.GetString("err-osudb-sync"), path, ex.Message),
                                _configWindow.Title, MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
コード例 #9
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var locked = (bool)value;

            return(locked ? I18NUtil.GetString("ui-unlockLyric") : I18NUtil.GetString("ui-lockLyric"));
        }
コード例 #10
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            NotificationOverlay.ItemsSource = Notification.NotificationList;
            if (AppSettings.Default.General.FirstOpen)
            {
                FrontDialogOverlay.ShowContent(new WelcomeControl(), new FrontDialogOverlay.ShowContentOptions
                {
                    Height            = 400,
                    Width             = 350,
                    ShowDialogButtons = false,
                    ShowTitleBar      = false
                });
                //WelcomeControl.Show();
                //try
                //{
                //    await Service.Get<OsuDbInst>().LoadLocalDbAsync();
                //}
                //catch (Exception ex)
                //{
                //    Notification.Push(I18NUtil.GetString("err-mapNotInDb"), Title);
                //}

                try
                {
                    await Service.Get <OsuFileScanner>().NewScanAndAddAsync(AppSettings.Default.General.CustomSongsPath);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex, "Error while scanning custom folder: {0}",
                                 AppSettings.Default.General.CustomSongsPath);
                    Notification.Push(I18NUtil.GetString("err-custom-scan"), Title);
                }
            }
            else
            {
                if (DateTime.Now - AppSettings.Default.LastTimeScanOsuDb > TimeSpan.FromDays(1))
                {
                    try
                    {
                        await Service.Get <OsuDbInst>().SyncOsuDbAsync(AppSettings.Default.General.DbPath, true);

                        AppSettings.Default.LastTimeScanOsuDb = DateTime.Now;
                        AppSettings.SaveDefault();
                    }
                    catch (Exception ex)
                    {
                        Logger.Error(ex, "Error while syncing osu!db: {0}", AppSettings.Default.General.DbPath);
                        Notification.Push(I18NUtil.GetString("err-osudb-sync"), Title);
                    }
                }
            }

            UpdateCollections();

            _controller.LoadFinished += Controller_LoadFinished;

            try
            {
                var  updater   = Service.Get <UpdateInst>();
                bool?hasUpdate = await updater.CheckUpdateAsync();

                if (hasUpdate == true && updater.NewRelease.NewVerString != AppSettings.Default.IgnoredVer)
                {
                    var newVersionWindow = new NewVersionWindow(updater.NewRelease, this);
                    newVersionWindow.ShowDialog();
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Error while checking for update");
                Notification.Push(I18NUtil.GetString("err-update-check") + $": {ex.Message}", Title);
            }
        }
コード例 #11
0
ファイル: AboutPage.xaml.cs プロジェクト: Milkitic/Osu-Player
 private void GetLastUpdate()
 {
     LastUpdate.Content = AppSettings.Default.LastUpdateCheck == null
         ? I18NUtil.GetString("ui-sets-content-never")
         : AppSettings.Default.LastUpdateCheck.Value.ToString(_dtFormat);
 }