private void StartBgThreads() { UploadOriginPhotosToStationManager.Start(); PhotoDownloader.Start(); NewPostManager.Start(); StationState.ShowStationState += StationState_ShowStationState; StationState.Start(); }
private void PreloadThumbnail(string url, string localPicPath) { if (!File.Exists(localPicPath)) { ImageItem _item = new ImageItem(); _item.PostItemType = PostItemType.Thumbnail; _item.ThumbnailPath = url; _item.LocalFilePath_Origin = localPicPath; PhotoDownloader.Add(_item, false); } }
public void Logout() { Program.ShowCrashReporter = false; QuitOption = QuitOption.Logout; try { if (NewPostManager != null) { NewPostManager.AbortThread(); NewPostManager = null; } if (PhotoDownloader != null) { PhotoDownloader.AbortThread(); PhotoDownloader = null; } if (UploadOriginPhotosToStationManager != null) { UploadOriginPhotosToStationManager.AbortThread(); UploadOriginPhotosToStationManager = null; } if (StationState != null) { StationState.AbortThread(); statusStrip = null; } } catch { } Close(); }
public void PrefetchImages(List <Post> posts, bool allSize) { foreach (Post post in posts) { switch (post.type) { case "image": { if (post.attachments.Count == 0) { break; } Attachment _a = post.attachments[0]; string _url = string.Empty; string _fileName = string.Empty; Current.RT.REST.attachments_getRedirectURL_Image(_a, "small", out _url, out _fileName, false); string _localPic = GCONST.CachePath + _fileName; PreloadThumbnail(_url, _localPic); PhotoDownloader.PreloadPictures(post, allSize); break; } case "link": { if (post.preview.thumbnail_url != null) { string _url = post.preview.thumbnail_url; string _localPic = GCONST.CachePath + post.post_id + "_previewthumbnail_" + ".jpg"; PreloadThumbnail(_url, _localPic); } break; } case "rtf": { Attachment _a = null; foreach (Attachment _attachment in post.attachments) { if (_attachment.type == "image") { _a = _attachment; break; } } if (_a != null) { string _url = string.Empty; string _fileName = string.Empty; Current.RT.REST.attachments_getRedirectURL_Image(_a, "small", out _url, out _fileName, false); string _localPic = GCONST.CachePath + _fileName; PreloadThumbnail(_url, _localPic); } break; } case "doc": { Attachment _a = post.attachments[0]; if (_a.image != string.Empty) { string _localPic = GCONST.CachePath + _a.object_id + "_thumbnail" + ".jpg"; string _url = _a.image; _url = Current.RT.REST.attachments_getRedirectURL_PdfCoverPage(_url); PreloadThumbnail(_url, _localPic); } break; } } } }