internal async void SendToClipboard(ClipboardGetData clipboardGetData) { if (clipboardGetData.ContentTypeId == ContentTypes.Image) { var url = SimpleFileTokenData.CreateUrl(clipboardGetData.FileContentUrl); var path = Path.Combine(this.tempPath, Path.GetFileNameWithoutExtension(Path.GetTempFileName()) + Path.GetExtension(clipboardGetData.FileContentUrl)); using (WebClient client = new WebClient()) { await client.DownloadFileTaskAsync(url, path); } var bs = new BitmapImage(new Uri(path)); Clipboard.SetImage(bs); } if (clipboardGetData.ContentTypeId == ContentTypes.File) { var url = SimpleFileTokenData.CreateUrl(clipboardGetData.FileContentUrl); using (var client = new WebClient()) { string path = Path.Combine(this.tempPath, clipboardGetData.FileName); await client.DownloadFileTaskAsync(url, path); StringCollection paths = new StringCollection(); paths.Add(path); Clipboard.SetFileDropList(paths); } } else if (clipboardGetData.ContentTypeId == ContentTypes.PlainText) { Clipboard.SetText(clipboardGetData.TextContent); } }
protected override void OnReadingDataModel(ClipboardGetData data) { if (data.ContentTypeId == ContentTypes.Image) { BitmapImage bitmapImage = new BitmapImage(SimpleFileTokenData.CreateUrl(data.FileContentUrl), new RequestCachePolicy(RequestCacheLevel.CacheIfAvailable)); this.ImageSource = bitmapImage; this.FileName = string.Empty; } else if (data.ContentTypeId == ContentTypes.File) { this.FileContentUrl = SimpleFileTokenData.CreateUrl(data.FileContentUrl); } LaneEntryViewModel laneGetData; if (data.LaneId != null && (laneGetData = this.hostViewModel.Lanes.FirstOrDefault(o => o.Id == data.LaneId)) != null) { var color = (Color)ColorConverter.ConvertFromString(laneGetData.Color); this.LaneColorBrush = new SolidColorBrush(color); } else { var color = (Color)ColorConverter.ConvertFromString("#5effffff"); this.LaneColorBrush = new SolidColorBrush(color); } this.TextContentShort = this.TextContent.TruncateWithEllepsis(700, 8); }
public async void LoadItem() { this.IsBusy = true; try { await this.accountViewModel.Initialize(); GroupDetailGetData group = await App.Client.GroupGetAsync(this.idGuid, this.Name); this.IsJoined = group.Users.Any(o => o.Id == this.accountViewModel.Id); this.UpdateJoinLeaveText(); this.SetDataModel(group); this.Posts.Clear(); this.Posts.AddRangeSequential(group.Posts.Select(p => new PostEntryViewModel().GetWithDataModel(p))); this.Icon = SimpleFileTokenData.CreateUrl(group.Icon); this.idGuid = group.Id; } catch (Exception exception) { this.Message = exception.ToString(); } finally { this.IsBusy = false; } }
public async void LoadItemById(Guid itemId) { this.IsBusy = true; try { PostDetailGetData post = await App.Client.PostGetAsync(itemId); this.SetDataModel(post); this.PostTitle = $"{post.AuthorName} wrote {post.TimeAgo.ToStringForHumans()} ago"; this.Avatar = SimpleFileTokenData.CreateUrl(post.Avatar); this.Image = SimpleFileTokenData.CreateUrl(post.Image); this.Replys.Clear(); ObservableCollection <PostReplyGetData> replys = new ObservableCollection <PostReplyGetData>(post.Replys); foreach (PostReplyGetData item in replys) { this.Replys.Add(new ReplyEntryViewModel().GetWithDataModel(item)); } } catch (Exception exception) { this.Message = exception.ToString(); } finally { this.IsBusy = false; } }
private async void SaveCommandExecute(object obj) { this.IsBusy = true; this.Message = string.Empty; try { ProfilePutData data = this.WriteToDataModel(); await App.Client.ProfilePutAsync(data); FileParameter file = null; if (obj is Stream stream) { file = new FileParameter(stream, System.IO.Path.GetFileName(this.mediaFile.Path)); } else if (this.IconNewAnimated != null) { file = new FileParameter(this.mediaFile.GetStream(), System.IO.Path.GetFileName(this.mediaFile.Path)); } if (file != null) { var avatarData = await App.Client.ProfileAvatarAsync(file); this.mediaFile = null; this.IconCurrent = SimpleFileTokenData.CreateUrl(avatarData.LocalUrl); this.IconNewAnimated = null; this.IconNewCrop = null; } await Shell.Current.GoToAsync(".."); } catch (ApiException exception) { this.Message = exception.ToString(); } finally { this.IsBusy = true; } this.IsBusy = false; }
protected override void OnReadingDataModel(ClipboardGetData data) { if (data == null) { this.ImageSource = null; this.FileName = null; this.TextContent = null; this.ShareUrl = null; this.SelectedLane = null; return; } if (data.ContentTypeId == ContentTypes.File) { this.ImageSource = null; this.FileName = data.FileName; this.TextContent = null; this.ShareUrl = SimpleFileTokenData.CreateUrl(data.FileContentUrl).AbsoluteUri; } else if (data.ContentTypeId == ContentTypes.PlainText) { this.ImageSource = null; this.FileName = null; this.TextContent = data.TextContent; this.ShareUrl = null; } else if (data.ContentTypeId == ContentTypes.Image) { this.ImageSource = SimpleFileTokenData.CreateUrl(data.FileContentUrl); this.FileName = null; this.TextContent = null; this.ShareUrl = this.ImageSource.AbsoluteUri; } this.SelectedLane = this.Lanes.FirstOrDefault(o => o.Id == data.LaneId) ?? this.Lanes.First(); }
internal async void Initialize() { this.IsBusy = true; try { ProfileGetData profile = await App.Client.ProfileGetAsync(this.Id); this.SetDataModel(profile); this.Avatar = SimpleFileTokenData.CreateUrl(profile.Avatar); this.Groups.Clear(); this.Groups.AddRangeSequential(profile.Groups.Select(g => new GroupEntryViewModel().GetWithDataModel(g))); this.Message = null; } catch (Exception exception) { this.Message = exception.ToString(); } finally { this.IsBusy = false; } }
protected override void OnReadingDataModel(PostReplyGetData data) { this.ReplyTitle = $"{data.AuthorName} wrote {data.TimeAgo.ToStringForHumans()} ago"; this.Avatar = SimpleFileTokenData.CreateUrl(data.Avatar); this.AvatarTapped = new Command(this.AvatarTappedExecute); }
protected override void OnReadingDataModel(ProfileGetData data) { this.IconCurrent = SimpleFileTokenData.CreateUrl(data.Avatar); this.IconNewAnimated = null; this.IconNewCrop = null; }
protected override void OnReadingDataModel(PostGetData data) { this.PostTitle = $"{data.AuthorName} wrote {data.TimeAgo.ToStringForHumans()} ago"; this.Avatar = SimpleFileTokenData.CreateUrl(data.Avatar); this.Image = SimpleFileTokenData.CreateUrl(data.Image); }
protected override void OnReadingDataModel(GroupGetData data) { this.GroupIcon = SimpleFileTokenData.CreateUrl(data.Icon); }