예제 #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;
            }
        }
예제 #2
0
        /// <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
            }
        }
예제 #3
0
 /// <summary>
 /// Exports SGF
 /// </summary>
 /// <returns></returns>
 private async Task ExportSGFAsync()
 {
     try
     {
         var sgf = ConvertStateToSgf();
         if (await SgfExport.ExportAsync(SuggestedGameFileName, sgf))
         {
             Mvx.Resolve <IAppNotificationService>()
             .TriggerNotification(new BubbleNotification(Localizer.SgfExportSuccessful, Localizer.Success,
                                                         NotificationType.Success));
         }
     }
     catch (Exception ex)
     {
         //ignore
     }
 }