コード例 #1
0
        private async void HistoryAdapter_ShareItemRequested(object sender, HistoryListItem e)
        {
            if (e.Data.Data is ReceivedText)
            {
                await DataStorageProviders.TextReceiveContentManager.OpenAsync();

                string text = DataStorageProviders.TextReceiveContentManager.GetItemContent(e.Data.Id);
                DataStorageProviders.TextReceiveContentManager.Close();

                ShareHelper.ShareText(this, text);
            }
            else if (e.Data.Data is ReceivedUrl)
            {
                ShareHelper.ShareText(this, (e.Data.Data as ReceivedUrl).Uri.OriginalString);
            }
            else if (e.Data.Data is ReceivedFile || e.Data.Data is ReceivedFileCollection)
            {
                ReceivedFile receivedFile;
                if (e.Data.Data is ReceivedFile)
                {
                    receivedFile = e.Data.Data as ReceivedFile;
                }
                else
                {
                    receivedFile = (e.Data.Data as ReceivedFileCollection).Files.First();
                }

                Java.IO.File file = new Java.IO.File(Path.Combine(receivedFile.StorePath, receivedFile.Name));
                ShareHelper.ShareFile(this, file);
            }
        }
コード例 #2
0
        private void HistoryAdapter_BrowseFilesRequested(object sender, HistoryListItem e)
        {
            var intent = new Intent(this, typeof(HistoryBrowseActivity));

            intent.PutExtra("guid", e.Data.Id.ToString());
            StartActivity(intent);
        }
コード例 #3
0
        private async Task Move(HistoryListItem item, string newPath)
        {
            Settings settings = new Settings(this);

            try
            {
                //QuickShare.Common.Classes.ReceivedSaveAsHelper.SaveAsProgress += ReceivedSaveAsHelper_SaveAsProgress;
                await QuickShare.Common.Classes.ReceivedSaveAsHelper.SaveAs(guid : item.Data.Id,
                                                                            selectedFolder : new FileSystemFolder(newPath),
                                                                            defaultDownloadFolder : settings.DefaultDownloadFolder,
                                                                            pathToFileConverter : async path =>
                {
                    if (!File.Exists(path))
                    {
                        throw new FileNotFoundException("File not found.");
                    }
                    return(new FileSystemFile(path));
                },
                                                                            pathToFolderConverter : async path =>
                {
                    return(new FileSystemFolder(path));
                });

                Toast.MakeText(this, "Files moved successfully.", ToastLength.Long).Show();
                historyAdapter.NotifyItemChanged(item.Position);
            }
            catch (QuickShare.Common.Classes.SaveAsFailedException ex)
            {
                Toast.MakeText(this, ex.Message + "\n" + ex.ExtraDetails, ToastLength.Long).Show();
            }
            finally
            {
                //QuickShare.Common.Classes.ReceivedSaveAsHelper.SaveAsProgress -= ReceivedSaveAsHelper_SaveAsProgress;
            }
        }
コード例 #4
0
        private void HistoryAdapter_MoveFilesRequested(object sender, HistoryListItem e)
        {
            moveItem = e;

            Settings settings = new Settings(this);

            if (settings.UseSystemFolderPicker)
            {
                Intent i = new Intent(Intent.ActionOpenDocumentTree);
                i.AddCategory(Intent.CategoryDefault);
                i.PutExtra("android.content.extra.SHOW_ADVANCED", true);
                i.PutExtra("android.content.extra.FANCY", true);
                i.PutExtra("android.content.extra.SHOW_FILESIZE", true);
                i.PutExtra("android.provider.extra.INITIAL_URI", settings.DefaultDownloadFolder);
                StartActivityForResult(Intent.CreateChooser(i, "Move to"), SystemFolderPickerId);
            }
            else
            {
                Intent i = new Intent(this, settings.Theme == AppTheme.Dark ? typeof(BackHandlingFilePickerActivityDark) : typeof(BackHandlingFilePickerActivityLight));

                i.PutExtra(FilePickerActivity.ExtraAllowCreateDir, true);
                i.PutExtra(FilePickerActivity.ExtraMode, FilePickerActivity.ModeDir);
                i.PutExtra(FilePickerActivity.ExtraStartPath, settings.DefaultDownloadFolder);

                StartActivityForResult(i, CustomFolderPickerId);
            }
        }
コード例 #5
0
        private async void HistoryAdapter_RemoveItemRequested(object sender, HistoryListItem e)
        {
            await DataStorageProviders.HistoryManager.OpenAsync();

            DataStorageProviders.HistoryManager.Remove(e.Data.Id);
            DataStorageProviders.HistoryManager.Close();

            historyAdapter.NotifyItemRemoved(e.Position);
        }
コード例 #6
0
        private async void HistoryAdapter_CopyToClipboardRequested(object sender, HistoryListItem e)
        {
            if (e.Data.Data is ReceivedText)
            {
                await ClipboardHelper.CopyTextToClipboard(this, e.Data.Id);
            }
            else if (e.Data.Data is ReceivedUrl)
            {
                var uriString = (e.Data.Data as ReceivedUrl).Uri.OriginalString;

                ClipboardHelper.SetClipboardText(this, uriString);
            }
        }
コード例 #7
0
        public IHttpActionResult Put(HistoryListItem model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var service = CreateHistoryService();

            if (!service.UpdateHistory(model))
            {
                return(InternalServerError());
            }

            return(Ok());
        }
コード例 #8
0
        private void HistoryAdapter_OpenFileRequested(object sender, HistoryListItem e)
        {
            ReceivedFile file;

            if (e.Data.Data is ReceivedFile)
            {
                file = e.Data.Data as ReceivedFile;
            }
            else
            {
                file = (e.Data.Data as ReceivedFileCollection).Files.First();
            }

            var filePath = Path.Combine(file.StorePath, file.Name);

            LaunchHelper.OpenFile(this, filePath);
        }
コード例 #9
0
ファイル: HistoryService.cs プロジェクト: linenoiz801/FLAPI
        public HistoryListItem GetHistoryById(int historyId)
        {
            HistoryListItem result = new HistoryListItem();

            using (var ctx = new ApplicationDbContext())
            {
                var query =
                    ctx
                    .Histories
                    .Single((b => b.Id == historyId));

                result.Id          = query.Id;
                result.EventName   = query.EventName;
                result.EventDate   = query.EventDate;
                result.Description = query.Description;
                result.GameId      = query.GameId;

                return(result);
            }
        }
コード例 #10
0
ファイル: HistoryService.cs プロジェクト: linenoiz801/FLAPI
        public bool UpdateHistory(HistoryListItem model)
        {
            using (var ctx = new ApplicationDbContext())
            {
                var query =
                    ctx
                    .Histories
                    .SingleOrDefault(e => e.Id == model.Id);

                if (query != null)
                {
                    query.EventDate   = model.EventDate;
                    query.EventName   = model.EventName;
                    query.Description = model.Description;
                    query.GameId      = model.GameId;

                    return(ctx.SaveChanges() == 1);
                }
                else
                {
                    return(false);
                }
            }
        }
コード例 #11
0
 /// <summary>
 /// Function to map history list item.
 /// </summary>
 /// <param name="actualItem">The actual item.</param>
 /// <param name="newItems">The new item list.</param>
 private static void Map(HistoryListItem actualItem, IList<HistoryListItem> newItems)
 {
     if (actualItem.OldValue != null && actualItem.NewValue != null)
     {
         var oldValue = ConvertHistoryStartDateTime(actualItem.OldValue);
         var newValue = ConvertHistoryStartDateTime(actualItem.NewValue);
         if (oldValue.HasValue && newValue.HasValue)
         {
             var status = oldValue < newValue ? Postponed : Preponed;
             actualItem.NewValue = string.Format(CultureInfo.CurrentCulture, "{0} {1} ({2}) {3} ({4})", status, To, newValue, From, oldValue);
             newItems.Add(actualItem);
         }
     }
 }
コード例 #12
0
 private void HistoryAdapter_UrlLaunchRequested(object sender, HistoryListItem e)
 {
     LaunchHelper.LaunchUrl(this, (e.Data.Data as ReceivedUrl).Uri.OriginalString);
 }