Exemple #1
0
        /// <summary>
        /// Imports a SGF file into library
        /// </summary>
        /// <returns></returns>
        private async Task ImportSgfFileAsync()
        {
            IsWorking = true;
            try
            {
                var fileContents = await _filePicker.PickAndReadFileAsync(".sgf");

                if (fileContents == null)
                {
                    return;
                }

                string fileName = fileContents.Name;
                fileName = await SgfExport.SaveToLibraryAsync(fileName, fileContents.Contents);

                //add to library
                var fileInfo = await _appDataFileService.GetFileInfoAsync(fileName, SgfFolderName);

                var newItem = await CreateLibraryItemFromFileContentAsync(new FileContentInfo(fileInfo.Name,
                                                                                              fileInfo.Size, fileInfo.LastModified, fileContents.Contents));

                if (newItem != null)
                {
                    LibraryItems.Insert(0, new AppDataLibraryItemViewModel(newItem));
                }
            }
            catch (Exception e)
            {
                //ignore
            }
            finally
            {
                IsWorking = false;
            }
        }
        /// <summary>
        /// Saves game to library
        /// </summary>
        private async Task SaveToLibraryAsync()
        {
            try
            {
                var sgf = ConvertStateToSgf();
                await SgfExport.SaveToLibraryAsync(LibraryItem.FileName, sgf);

                Mvx.Resolve <IAppNotificationService>().TriggerNotification(new BubbleNotification(Localizer.SgfSaveToLibrarySuccessful, Localizer.Success, NotificationType.Success));
            }
            catch (Exception ex)
            {
                //ignore
            }
        }