/// <summary> /// Popup a dialog for adding music to a collection. /// </summary> private async void BtnLike_Click(object sender, RoutedEventArgs e) { var entry = BeatmapQuery.FilterByIdentity(InstanceManage.GetInstance <PlayerList>().CurrentIdentity); //var entry = App.PlayerList?.CurrentInfo.Beatmap; if (entry == null) { MsgBox.Show(this, "该图不存在于该osu!db中。", Title, MessageBoxButton.OK, MessageBoxImage.Exclamation); return; } if (!ViewModel.IsMiniMode) { FramePop.Navigate(new SelectCollectionPage(this, entry)); } else { var collection = DbOperate.GetCollections().First(k => k.Locked); if (InstanceManage.GetInstance <PlayerList>().CurrentInfo.IsFavorite) { DbOperate.RemoveMapFromCollection(entry, collection); InstanceManage.GetInstance <PlayerList>().CurrentInfo.IsFavorite = false; } else { await SelectCollectionPage.AddToCollectionAsync(collection, entry); InstanceManage.GetInstance <PlayerList>().CurrentInfo.IsFavorite = true; } } IsMapFavorite(InstanceManage.GetInstance <PlayerList>().CurrentInfo.Identity); }
/// <summary> /// Play next song in list if list exist. /// </summary> /// <param name="isManual">Whether it is called by user (Click next button manually) /// or called by application (A song finished).</param> /// <param name="isNext"></param> private async Task PlayNextAsync(bool isManual, bool isNext) { if (InstanceManage.GetInstance <PlayersInst>().AudioPlayer == null) { return; } (PlayerList.ChangeType result, Beatmap map) = await InstanceManage.GetInstance <PlayerList>().PlayToAsync(isNext, isManual); switch (result) { //case PlayerList.ChangeType.Keep: // await VideoJumpTo(0); // App.StoryboardProvider?.StoryboardTiming.SetTiming(0, false); // PlayMedia(); // break; case PlayerList.ChangeType.Stop: PlayerViewModel.Current.IsPlaying = false; PlayerViewModel.Current.Position = 0; _videoPlay = false; _forcePaused = true; break; case PlayerList.ChangeType.Change: default: //var path = Path.Combine(new FileInfo(PlayerConfig.Current.General.DbPath).Directory.FullName, "Songs", // entry.FolderName, entry.BeatmapFileName); //await PlayNewFile(path); await PlayNewFile(map); break; } }
public GeneralPage(MainWindow mainWindow, ConfigWindow configWindow) { _mainWindow = mainWindow; _configWindow = configWindow; InitializeComponent(); ScannerViewModel = InstanceManage.GetInstance <OsuFileScanner>().ViewModel; }
/// <summary> /// Call lyric provider to check lyric /// </summary> public void SetLyricSynchronously() { if (!LyricWindow.IsVisible) { return; } Task.Run(async() => { if (_searchLyricTask?.IsTaskBusy() == true) { await Task.WhenAny(_searchLyricTask); } _searchLyricTask = Task.Run(async() => { var player = InstanceManage.GetInstance <PlayersInst>().AudioPlayer; if (player == null) { return; } var meta = player.OsuFile.Metadata; var lyricInst = InstanceManage.GetInstance <LyricsInst>(); var lyric = await lyricInst.LyricProvider.GetLyricAsync(meta.ArtistMeta.ToUnicodeString(), meta.TitleMeta.ToUnicodeString(), player.Duration); LyricWindow.SetNewLyric(lyric, player.OsuFile); LyricWindow.StartWork(); }); }); }
private async void BrowseCustom_Click(object sender, RoutedEventArgs e) { 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 InstanceManage.GetInstance <OsuFileScanner>().CancelTaskAsync(); await InstanceManage.GetInstance <OsuFileScanner>().NewScanAndAddAsync(path); PlayerConfig.Current.General.CustomSongsPath = path; PlayerConfig.SaveCurrent(); } catch (Exception ex) { MsgBox.Show(_configWindow, ex.Message, _configWindow.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
private async void CheckUpdate_Click(object sender, RoutedEventArgs e) { //todo: action CheckUpdate.IsEnabled = false; var hasNew = await InstanceManage.GetInstance <Updater>().CheckUpdateAsync(); CheckUpdate.IsEnabled = true; if (hasNew == null) { MsgBox.Show(_configWindow, "检查更新时出错。", _configWindow.Title, MessageBoxButton.OK, MessageBoxImage.Error); return; } PlayerConfig.Current.LastUpdateCheck = DateTime.Now; GetLastUpdate(); PlayerConfig.SaveCurrent(); if (hasNew == true) { NewVersion.Visibility = Visibility.Visible; NewVersion_Click(sender, e); } else { MsgBox.Show(_configWindow, "已是最新版本。", _configWindow.Title, MessageBoxButton.OK, MessageBoxImage.Information); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { UpdateList(); var item = DataModels.FirstOrDefault(k => k.GetIdentity().Equals(InstanceManage.GetInstance <PlayerList>().CurrentInfo.Identity)); RecentList.SelectedItem = item; }
private void PlayMedia() { if (_forcePaused) { return; } InstanceManage.GetInstance <PlayersInst>().AudioPlayer.Play(); // Todo: Set Storyboard }
private void NewVersion_Click(object sender, RoutedEventArgs e) { if (_newVersionWindow != null && !_newVersionWindow.IsClosed) { _newVersionWindow.Close(); } _newVersionWindow = new NewVersionWindow(InstanceManage.GetInstance <Updater>().NewRelease, _mainWindow); _newVersionWindow.ShowDialog(); }
private void Page_Loaded(object sender, RoutedEventArgs e) { CurrentVer.Content = InstanceManage.GetInstance <Updater>().CurrentVersion; if (InstanceManage.GetInstance <Updater>().NewRelease != null) { NewVersion.Visibility = Visibility.Visible; } GetLastUpdate(); }
private async void PlaySelectedDefault() { var map = GetSelectedDefault(); if (map == null) return; //await ParentWindow.PlayNewFile(Path.Combine(Domain.OsuSongPath, map.FolderName, // map.BeatmapFileName)); await ParentWindow.PlayNewFile(map); await InstanceManage.GetInstance<PlayerList>().RefreshPlayListAsync(PlayerList.FreshType.All, PlayListMode.RecentList); }
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(); } }
private void Page_Loaded(object sender, RoutedEventArgs e) { //LblTitle.Content = _collection.Name; var item = ViewModel.Beatmaps?.FirstOrDefault(k => k.GetIdentity().Equals(InstanceManage.GetInstance <PlayerList>()?.CurrentInfo?.Identity)); if (item != null) { MapList.SelectedItem = item; } }
public CollectionPage(MainWindow mainWindow, Collection collectionInfo) { InitializeComponent(); _mainWindow = mainWindow; ViewModel = (CollectionPageViewModel)this.DataContext; ViewModel.CollectionInfo = collectionInfo; var infos = (List <MapInfo>)DbOperate.GetMapsFromCollection(collectionInfo); _entries = infos.ToBeatmapEntries(InstanceManage.GetInstance <OsuDbInst>().Beatmaps, false); ViewModel.Beatmaps = new NumberableObservableCollection <BeatmapDataModel>(_entries.ToDataModels(false)); }
private async void PlaySelected() { var map = GetSelected(); if (map == null) { return; } await _mainWindow.PlayNewFile(Path.Combine(Domain.OsuSongPath, map.FolderName, map.BeatmapFileName)); await InstanceManage.GetInstance <PlayerList>().RefreshPlayListAsync(PlayerList.FreshType.None, PlayListMode.Collection, _entries); }
/// <summary> /// Call lyric provider to check lyric /// todo: this should run synchronously. /// </summary> public void SetLyricSynchronously() { if (!LyricWindow.IsVisible) { return; } if (InstanceManage.GetInstance <PlayersInst>().AudioPlayer == null) { return; } var lyric = InstanceManage.GetInstance <LyricsInst>().LyricProvider.GetLyric(InstanceManage.GetInstance <PlayersInst>().AudioPlayer.OsuFile.Metadata.ArtistMeta.ToUnicodeString(), InstanceManage.GetInstance <PlayersInst>().AudioPlayer.OsuFile.Metadata.TitleMeta.ToUnicodeString(), InstanceManage.GetInstance <PlayersInst>().AudioPlayer.Duration); LyricWindow.SetNewLyric(lyric, InstanceManage.GetInstance <PlayersInst>().AudioPlayer.OsuFile); LyricWindow.StartWork(); }
private async void ItemDelete_Click(object sender, RoutedEventArgs e) { if (MapList.SelectedItem == null) { return; } var selected = MapList.SelectedItems; var entries = ConvertToEntries(selected.Cast <BeatmapDataModel>()); foreach (var entry in entries) { DbOperate.RemoveMapFromCollection(entry.GetIdentity(), ViewModel.CollectionInfo); } //var dataModel = (BeatmapDataModel)MapList.SelectedItem; UpdateList(); await InstanceManage.GetInstance <PlayerList>().RefreshPlayListAsync(PlayerList.FreshType.All, PlayListMode.Collection, _entries); }
private async void Browse_Click(object sender, RoutedEventArgs e) { var result = App.BrowseDb(out var path); if (!result.HasValue || !result.Value) { return; } try { await InstanceManage.GetInstance <OsuDbInst>().LoadNewDbAsync(path); } catch (Exception ex) { MsgBox.Show(_configWindow, ex.Message, _configWindow.Title, MessageBoxButton.OK, MessageBoxImage.Error); } }
private async void ItemDelete_Click(object sender, RoutedEventArgs e) { if (RecentList.SelectedItem == null) { return; } var selected = RecentList.SelectedItems; var entries = ConvertToEntries(selected.Cast <BeatmapDataModel>()); //var searchInfo = (BeatmapDataModel)RecentList.SelectedItem; foreach (var entry in entries) { DbOperate.RemoveFromRecent(entry.GetIdentity()); } UpdateList(); await InstanceManage.GetInstance <PlayerList>().RefreshPlayListAsync(PlayerList.FreshType.All, PlayListMode.RecentList); }
public static void Main() { AppDomain.CurrentDomain.UnhandledException += OnCurrentDomainOnUnhandledException; StartupConfig.Startup(); InstanceManage.AddInstance(new UiMetadata()); InstanceManage.AddInstance(new PlayerList()); InstanceManage.AddInstance(new OsuDbInst()); InstanceManage.AddInstance(new PlayersInst()); InstanceManage.AddInstance(new LyricsInst()); InstanceManage.AddInstance(new Updater()); InstanceManage.GetInstance <LyricsInst>().ReloadLyricProvider(); App app = new App(); app.InitializeComponent(); app.Run(); }
private void ToNormalMode() { ViewModel.IsMiniMode = false; MinHeight = 100 + 38; Height = 720 + 38; MinWidth = 840 + 38; Width = 960 + 38; BtnPrev.Margin = new Thickness(8); BtnPlay.Margin = new Thickness(8); BtnNext.Margin = new Thickness(8); BtnMode.Margin = new Thickness(8); BtnLike.Margin = new Thickness(8); BtnVolume.Margin = new Thickness(8); LblArtist.Margin = new Thickness(0); LblTitle.Margin = new Thickness(0); BtnLike.Width = BtnLike.Height = 24; BtnVolume.Width = BtnVolume.Height = 24; BtnMode.Width = BtnMode.Height = 24; LblMeta.Orientation = Orientation.Horizontal; FuncPanel.Orientation = Orientation.Horizontal; BtnMax.Visibility = Visibility.Collapsed; BorderMini.Visibility = Visibility.Hidden; // modoules BtnOpen.Visibility = Visibility.Visible; ThumbArea.Visibility = Visibility.Visible; ResizeMode = ResizeMode.CanResize; LblProgress.Visibility = Visibility.Visible; LblSeperate.Visibility = Visibility.Visible; PlayProgress.Visibility = Visibility.Visible; //area TitleBarArea.Visibility = Visibility.Visible; TitleBarAreaBack.Visibility = Visibility.Visible; MainFrame.Visibility = Visibility.Visible; SetFaved(InstanceManage.GetInstance <PlayerList>().CurrentInfo.Identity); SetPlayMode(InstanceManage.GetInstance <PlayerList>().PlayerMode); Topmost = false; }