public void Initialize(bool _includeDrafts) { // get the list of blogs, determine how many items we will be displaying, // and then have that drive the view mode string[] blogIds = BlogSettings.GetBlogIds(); int itemCount = (_includeDrafts ? 1 : 0) + 1 + blogIds.Length; _showLargeIcons = itemCount <= 5; // configure owner draw DrawMode = DrawMode.OwnerDrawFixed; SelectionMode = SelectionMode.One; HorizontalScrollbar = false; IntegralHeight = false; ItemHeight = CalculateItemHeight(_showLargeIcons); // populate list if (_includeDrafts) { _draftsIndex = Items.Add(new PostSourceItem(new LocalDraftsPostSource(), this)); } _recentPostsIndex = Items.Add(new PostSourceItem(new LocalRecentPostsPostSource(), this)); ArrayList blogs = new ArrayList(); foreach (string blogId in BlogSettings.GetBlogIds()) { blogs.Add(new PostSourceItem(Res.Get(StringId.Blog), new RemoteWeblogBlogPostSource(blogId), this)); } blogs.Sort(); Items.AddRange(blogs.ToArray()); }
// separate initialize to prevent this code from executing in the designer public void Initialize() { View = View.LargeIcon; MultiSelect = false; HideSelection = false; LabelEdit = false; LabelWrap = true; _imageList = new ImageList(); _imageList.ImageSize = new Size(IMAGE_HEIGHT, IMAGE_WIDTH); _imageList.ColorDepth = ColorDepth.Depth32Bit; _imageList.Images.Add(ResourceHelper.LoadAssemblyResourceBitmap("OpenPost.Images.SelectDraftPostings.png")); _imageList.Images.Add(ResourceHelper.LoadAssemblyResourceBitmap("OpenPost.Images.SelectRecentPostings.png")); _imageList.Images.Add(ResourceHelper.LoadAssemblyResourceBitmap("OpenPost.Images.SelectWebLogPostings.png")); LargeImageList = _imageList; // apply initial sizing UpdateIconSize(); AddPostSource(new LocalDraftsPostSource(), DRAFT_IMAGE_INDEX); AddPostSource(new LocalRecentPostsPostSource(), RECENT_POSTS_IMAGE_INDEX); foreach (string blogId in BlogSettings.GetBlogIds()) { AddPostSource(new RemoteWeblogBlogPostSource(blogId), WEBLOG_IMAGE_INDEX); } // call again to reflect scrollbars that may now exist UpdateIconSize(); }
/// <summary> /// "It looks like the problem with the inline image is due to referrer checking. /// The thumbnail image being used is protected for display only on certain domains. /// These domains include *.blogspot.com and *.google.com. This user is using a /// feature in Blogger which allows him to display his blog directly on his own /// domain, which will not pass the referrer checking. /// /// "The maximum size of a thumbnail image that can be displayed on non-*.blogspot.com /// domains is 800px. (blogs don't actually appear at *.google.com). However, if you /// request a 800px thumbnail, and the image is less than 800px for the maximum /// dimension, then the original image will be returned without the referrer /// restrictions. That sounds like it will work for you, so feel free to give it a /// shot and let me know if you have any further questions or problems." /// -- Anonymous Google Employee /// </summary> private void PicasaRefererBlockingWorkaround(string blogId, FileUploadRole role, ref string srcUrl) { if (role == FileUploadRole.LinkedImage && Options.UsePicasaS1600h) { try { int lastSlash = srcUrl.LastIndexOf('/'); string srcUrl2 = srcUrl.Substring(0, lastSlash) + "/s1600-h" + srcUrl.Substring(lastSlash); HttpWebRequest req = HttpRequestHelper.CreateHttpWebRequest(srcUrl2, true); req.Method = "HEAD"; req.GetResponse().Close(); srcUrl = srcUrl2; return; } catch (WebException we) { Debug.Fail("Picasa s1600-h hack failed: " + we.ToString()); } } try { if (!Options.UsePicasaImgMaxAlways) { // This class doesn't have access to the homePageUrl, so this is a workaround to // to get the homePageUrl while minimizing the amount of code we have to change (we're at MShip/ZBB) foreach (string id in BlogSettings.GetBlogIds()) { using (BlogSettings settings = BlogSettings.ForBlogId(id)) { if (settings.ClientType == "BloggerAtom" && settings.HostBlogId == blogId) { switch (UrlHelper.GetDomain(settings.HomepageUrl).ToUpperInvariant()) { case "BLOGSPOT.COM": case "GOOGLE.COM": return; } } } } } srcUrl += ((srcUrl.IndexOf('?') >= 0) ? "&" : "?") + "imgmax=800"; } catch (Exception ex) { Trace.Fail("Unexpected error while doing Picasa upload: " + ex.ToString()); } }
internal static void CleanupUnusedTemplates() { try { foreach (string blogId in BlogSettings.GetBlogIds()) { using (PostHtmlEditingSettings templateSettings = new PostHtmlEditingSettings(blogId)) templateSettings.CleanupUnusedTemplates(); } } catch (Exception ex) { Trace.Fail("Unexpected exception occurred cleaning up unused templates: " + ex.ToString()); } }