Example #1
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //// todo: This should be kept since the application exit last time.
            //BtnRecent_Click(sender, e);
            if (PlayerConfig.Current.General.FirstOpen)
            {
                WelcomeViewModel.ShowWelcome = true;
                await LoadLocalDbAsync();
            }
            else
            {
                await InstanceManage.GetInstance <OsuFileScanner>().NewScanAndAddAsync(PlayerConfig.Current.General.CustomSongsPath);

                await InstanceManage.GetInstance <OsuDbInst>().SyncOsuDbAsync(PlayerConfig.Current.General.DbPath, true);

                await InstanceManage.GetInstance <OsuDbInst>().LoadLocalDbAsync();

                //ScanSynchronously();
                //SyncSynchronously();
            }

            UpdateCollections();
            //LoadSurfaceSettings();

            if (PlayerConfig.Current.CurrentPath != null && PlayerConfig.Current.Play.Memory)
            {
                var entries = BeatmapQuery.FilterByIdentities(PlayerConfig.Current.CurrentList);
                await InstanceManage.GetInstance <PlayerList>()
                .RefreshPlayListAsync(PlayerList.FreshType.All, beatmaps: entries);

                bool play = PlayerConfig.Current.Play.AutoPlay;
                await PlayNewFile(PlayerConfig.Current.CurrentPath, play);
            }

            await SetPlayMode(PlayerConfig.Current.Play.PlayListMode);

            var helper = new WindowInteropHelper(this);
            var source = HwndSource.FromHwnd(helper.Handle);

            source?.AddHook(HwndMessageHook);

            //if (PlayerConfig.Current.General.FirstOpen)
            //{
            //    ViewModel.ShowWelcome = true;
            //}

            var  updater   = InstanceManage.GetInstance <Updater>();
            bool?hasUpdate = await updater.CheckUpdateAsync();

            if (hasUpdate == true && updater.NewRelease.NewVerString != PlayerConfig.Current.IgnoredVer)
            {
                var newVersionWindow = new NewVersionWindow(updater.NewRelease, this);
                newVersionWindow.ShowDialog();
            }
        }
Example #2
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            App.NotificationList            = new ObservableCollection <NotificationOption>();
            NotificationOverlay.ItemsSource = App.NotificationList;
            if (AppSettings.Default.General.FirstOpen)
            {
                FrontDialogOverlay.ShowContent(new WelcomeControl(), new FrontDialogOverlay.ShowContentOptions
                {
                    Height            = 400,
                    Width             = 350,
                    ShowDialogButtons = false,
                    ShowTitleBar      = false
                });
                //WelcomeControl.Show();
                await Services.Get <OsuDbInst>().LoadLocalDbAsync();

                await Services.Get <OsuFileScanner>().NewScanAndAddAsync(AppSettings.Default.General.CustomSongsPath);
            }
            else
            {
                if (DateTime.Now - AppSettings.Default.LastTimeScanOsuDb > TimeSpan.FromDays(1))
                {
                    await Services.Get <OsuDbInst>().SyncOsuDbAsync(AppSettings.Default.General.DbPath, true);

                    AppSettings.Default.LastTimeScanOsuDb = DateTime.Now;
                    AppSettings.SaveDefault();
                }
            }

            UpdateCollections();

            PlayController.Default.OnNewFileLoaded += Controller_OnNewFileLoaded;
            PlayController.Default.OnLikeClick     += Controller_OnLikeClick;
            PlayController.Default.OnThumbClick    += Controller_OnThumbClick;

            var  updater   = Services.Get <Updater>();
            bool?hasUpdate = await updater.CheckUpdateAsync();

            if (hasUpdate == true && updater.NewRelease.NewVerString != AppSettings.Default.IgnoredVer)
            {
                var newVersionWindow = new NewVersionWindow(updater.NewRelease, this);
                newVersionWindow.ShowDialog();
            }
        }
Example #3
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //// todo: This should be kept since the application exit last time.
            //BtnRecent_Click(sender, e);
            UpdateCollections();
            LoadSurfaceSettings();
            await LoadDb();

            if (PlayerConfig.Current.CurrentPath != null && PlayerConfig.Current.Play.Memory)
            {
                var entries = InstanceManage.GetInstance <OsuDbInst>().Beatmaps
                              .FilterByIdentities(PlayerConfig.Current.CurrentList);
                if (App.UseDbMode)
                {
                    await InstanceManage.GetInstance <PlayerList>()
                    .RefreshPlayListAsync(PlayerList.FreshType.All, entries: entries);
                }

                bool play = PlayerConfig.Current.Play.AutoPlay;
                await PlayNewFile(PlayerConfig.Current.CurrentPath, play);
            }

            if (App.UseDbMode)
            {
                await SetPlayMode(PlayerConfig.Current.Play.PlayListMode);
            }

            var helper = new WindowInteropHelper(this);
            var source = HwndSource.FromHwnd(helper.Handle);

            source?.AddHook(HwndMessageHook);

            bool?sb = await InstanceManage.GetInstance <Updater>().CheckUpdateAsync();

            if (sb.HasValue && sb.Value && InstanceManage.GetInstance <Updater>().NewRelease.NewVerString != PlayerConfig.Current.IgnoredVer)
            {
                NewVersionWindow newVersionWindow = new NewVersionWindow(InstanceManage.GetInstance <Updater>().NewRelease, this);
                newVersionWindow.ShowDialog();
            }
        }
Example #4
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);
            }
        }