Exemplo n.º 1
0
        /// <summary>
        /// Clear things.
        /// </summary>
        private async void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (AppSettings.Default.General.ExitWhenClosed == null && !_forceExit)
            {
                e.Cancel = true;
                var closingControl = new ClosingControl();
                FrontDialogOverlay.ShowContent(closingControl, DialogOptionFactory.ClosingOptions, (obj, arg) =>
                {
                    if (closingControl.AsDefault.IsChecked == true)
                    {
                        AppSettings.Default.General.ExitWhenClosed = closingControl.RadioMinimum.IsChecked != true;
                        AppSettings.SaveDefault();
                    }

                    if (closingControl.RadioMinimum.IsChecked == true)
                    {
                        Hide();
                    }
                    else
                    {
                        _forceExit = true;
                        Close();
                    }
                });

                return;
            }

            if (AppSettings.Default.General.ExitWhenClosed == false && !_forceExit)
            {
                WindowState = WindowState.Minimized;
                GetCurrentFirst <MiniWindow>()?.Close();
                Hide();
                e.Cancel = true;
                return;
            }

            if (_disposed)
            {
                return;
            }
            e.Cancel = true;
            GetCurrentFirst <MiniWindow>()?.Close();
            LyricWindow.Dispose();
            NotifyIcon.Dispose();

            if (ConfigWindow != null && !ConfigWindow.IsClosed && ConfigWindow.IsInitialized)
            {
                ConfigWindow.Close();
            }

            if (_controller != null)
            {
                await _controller.DisposeAsync().ConfigureAwait(false);
            }
            _disposed = true;
            await Task.CompletedTask.ConfigureAwait(false);

            Execute.ToUiThread(ForceClose);
        }
Exemplo n.º 2
0
        private void BtnAddCollection_Click(object sender, RoutedEventArgs e)
        {
            var addCollectionControl = new AddCollectionControl();

            FrontDialogOverlay.ShowContent(addCollectionControl, DialogOptionFactory.AddCollectionOptions, (obj, args) =>
            {
                _appDbOperator.AddCollection(addCollectionControl.CollectionName.Text);
                UpdateCollections();
            });
        }
Exemplo n.º 3
0
        private void BtnAddCollection_Click(object sender, RoutedEventArgs e)
        {
            var addCollectionControl = new AddCollectionControl();

            FrontDialogOverlay.ShowContent(addCollectionControl, DialogOptionFactory.AddCollectionOptions, async(obj, args) =>
            {
                await using var dbContext = new ApplicationDbContext();
                await dbContext.AddCollection(addCollectionControl.CollectionName.Text); //todo: exists
                await UpdateCollections();
            });
        }
        private void BtnAddCollection_Click(object sender, RoutedEventArgs e)
        {
            var addCollectionControl = new AddCollectionControl();

            _overlay.ShowContent(addCollectionControl, DialogOptionFactory.AddCollectionOptions, (obj, args) =>
            {
                _appDbOperator.AddCollection(addCollectionControl.CollectionName.Text);

                WindowBase.GetCurrentFirst <MainWindow>().UpdateCollections();
                RefreshList();
            });
        }
Exemplo n.º 5
0
        private void BtnAddCollection_Click(object sender, RoutedEventArgs e)
        {
            var addCollectionControl = new AddCollectionControl();

            _overlay.ShowContent(addCollectionControl, DialogOptionFactory.AddCollectionOptions, async(obj, args) =>
            {
                await using var dbContext = new ApplicationDbContext();
                await dbContext.AddCollection(addCollectionControl.CollectionName.Text);// todo: exist
                await WindowEx.GetCurrentFirst <MainWindow>().UpdateCollections();

                await RefreshList();
            });
        }
Exemplo n.º 6
0
        /// <summary>
        /// Clear things.
        /// </summary>
        private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
        {
            if (AppSettings.Default.General.ExitWhenClosed == null && !ForceExit)
            {
                e.Cancel = true;
                var closingControl = new ClosingControl();
                FrontDialogOverlay.ShowContent(closingControl, DialogOptionFactory.ClosingOptions, (obj, arg) =>
                {
                    if (closingControl.AsDefault.IsChecked == true)
                    {
                        AppSettings.Default.General.ExitWhenClosed = closingControl.RadioMinimum.IsChecked != true;
                        AppSettings.SaveDefault();
                    }

                    if (closingControl.RadioMinimum.IsChecked == true)
                    {
                        Hide();
                    }
                    else
                    {
                        ForceExit = true;
                        Close();
                    }
                });

                return;
            }

            if (AppSettings.Default.General.ExitWhenClosed == false && !ForceExit)
            {
                WindowState = WindowState.Minimized;
                GetCurrentFirst <MiniWindow>()?.Close();
                Hide();
                e.Cancel = true;
                return;
            }

            GetCurrentFirst <MiniWindow>()?.Close();
            PlayController.Default?.Dispose();
            LyricWindow.Dispose();
            NotifyIcon.Dispose();
            if (ConfigWindow != null && !ConfigWindow.IsClosed && ConfigWindow.IsInitialized)
            {
                ConfigWindow.Close();
            }
        }
Exemplo n.º 7
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();
            }
        }
Exemplo n.º 8
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);
            }
        }