Exemplo n.º 1
0
        /// <summary>
        /// Method for loading lyric sources.
        /// </summary>
        public void LoadLyricsSources()
        {
            var scripts = SourceScriptManager.GetAllScripts();

            foreach (var s in scripts)
            {
                LrcSources.Add(new LrcSourceModel
                {
                    Name = s.Name,
                    RemoveLrcSourceButtonClickedRelayCommand = _removeLrcSourceButtonClickedRelayCommand
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Handle adding lyric source.
        /// </summary>
        private async void AddLrcSourceStub()
        {
            try
            {
                FileOpenPicker picker = new FileOpenPicker
                {
                    ViewMode = PickerViewMode.List,
                    SuggestedStartLocation = PickerLocationId.DocumentsLibrary,
                };
                picker.FileTypeFilter.Add(CommonSharedStrings.JavaScriptFileFormatSuffix);

                var files = await picker.PickMultipleFilesAsync();

                foreach (var file in files)
                {
                    var name = file.DisplayName;
                    if (LrcSources.Any(source => source.Name == name))
                    {
                        // TODO: let user choose to rename or overwrite.
                    }

                    var text = await FileIO.ReadTextAsync(file);

                    SourceScriptManager.AddScript(name, text);
                    LrcSources.Add(new LrcSourceModel
                    {
                        Name = name,
                        RemoveLrcSourceButtonClickedRelayCommand = _removeLrcSourceButtonClickedRelayCommand
                    });
                }
            }
            catch (SecurityException)
            {
                // Ignore, notify user
            }
            catch (COMException)
            {
                // Ignore, notify user
            }
            catch (FileNotFoundException)
            {
                // Ignore, notify user
            }
        }