public static bool EditSettings(IWin32Window owner, TemporaryBlogSettings blogSettings, bool showAccountSettings, Type selectedPanel) { // make a copy of the blog settings for editing TemporaryBlogSettings editableBlogSettings = blogSettings.Clone() as TemporaryBlogSettings; // show form using (PreferencesForm preferencesForm = new PreferencesForm()) { using (BlogClientUIContextScope uiContextScope = new BlogClientUIContextScope(preferencesForm)) { // customize form title and behavior preferencesForm.Text = String.Format(CultureInfo.CurrentCulture, Res.Get(StringId.WeblogSettings), blogSettings.BlogName); preferencesForm.HideApplyButton(); // panels int iPanel = 0; if (showAccountSettings) preferencesForm.SetEntry(iPanel++, new AccountPanel(blogSettings, editableBlogSettings)); preferencesForm.SetEntry(iPanel++, new ImagesPanel(blogSettings, editableBlogSettings)); preferencesForm.SetEntry(iPanel++, new EditingPanel(blogSettings, editableBlogSettings)); preferencesForm.SetEntry(iPanel++, new BlogPluginsPanel(blogSettings, editableBlogSettings)); preferencesForm.SetEntry(iPanel++, new AdvancedPanel(blogSettings, editableBlogSettings)); preferencesForm.SelectEntry(selectedPanel); // show the dialog return (preferencesForm.ShowDialog(owner) == DialogResult.OK); } } }
private object DetectWeblogSettings(IProgressHost progressHost) { using (BlogClientUIContextScope uiContextScope = new BlogClientUIContextScope(_uiContext)) { try { BlogSettingsDetector blogSettingsDetector = new BlogSettingsDetector(_temporarySettings); blogSettingsDetector.DetectSettings(progressHost); } catch (OperationCancelledException) { // WasCancelled == true } catch (BlogClientOperationCancelledException) { _hostOperation.Cancel(); // WasCancelled == true } catch (Exception ex) { Trace.Fail("Error occurred while downloading weblog posts and categories: " + ex.ToString()); } return this; } }
protected override void DoWork() { using (BlogClientUIContextScope uiContextScope = new BlogClientUIContextScope(_uiContext)) { if (_getPages) _recentPosts = _postSource.GetPages(_request); else _recentPosts = _postSource.GetRecentPosts(_request); if (CancelRequested) AcknowledgeCancel(); } }
protected override void DoWork() { using (BlogClientUIContextScope uiScope = new BlogClientUIContextScope(_uiContext)) { using (Blog blog = new Blog(_blogId)) { // Fix bug 457160 - New post created with a new category // becomes without a category when opened in WLW // // See also PostEditorPostSource.GetPost(string) try { blog.RefreshCategories(); } catch (Exception e) { Trace.Fail("Exception while attempting to refresh categories: " + e.ToString()); } _serverBlogPost = blog.GetPost(_blogPost.Id, _blogPost.IsPage); if (_serverBlogPost == null) _noPostAvailable = true; } } }
public object DetectTemplate(IProgressHost progress) { // if our context has not been set then just return without doing anything // (supports this being an optional step at the end of a chain of // other progress operations) if (_contextSet == false) return this; using (BlogClientUIContextScope uiContextScope = new BlogClientUIContextScope(_uiContext)) { // initial progress progress.UpdateProgress(Res.Get(StringId.ProgressDetectingWeblogEditingStyle)); // build list of detected templates ArrayList blogTemplateFiles = new ArrayList(); // build list of template types that we need to auto-detect ArrayList detectionTargetTypes = new ArrayList(); ArrayList detectionTargetStrategies = new ArrayList(); // try explicit detection of templates BlogEditingTemplateFiles templateFiles = SafeGetTemplates(new ProgressTick(progress, 50, 100)); // see if we got the FramedTempalte if (templateFiles.FramedTemplate != null) blogTemplateFiles.Add(templateFiles.FramedTemplate); else { detectionTargetTypes.Add(BlogEditingTemplateType.Framed); detectionTargetStrategies.Add(BlogEditingTemplateStrategies.GetTemplateStrategy(BlogEditingTemplateStrategies.StrategyType.NoSiblings)); } // see if we got the WebPageTemplate if (templateFiles.WebPageTemplate != null) blogTemplateFiles.Add(templateFiles.WebPageTemplate); else { detectionTargetTypes.Add(BlogEditingTemplateType.Webpage); detectionTargetStrategies.Add(BlogEditingTemplateStrategies.GetTemplateStrategy(BlogEditingTemplateStrategies.StrategyType.Site)); } // perform detection if we have detection targets if (detectionTargetTypes.Count > 0) { BlogEditingTemplateFile[] detectedBlogTemplateFiles = DetectTemplates(new ProgressTick(progress, 50, 100), detectionTargetTypes.ToArray(typeof(BlogEditingTemplateType)) as BlogEditingTemplateType[], detectionTargetStrategies.ToArray(typeof(BlogEditingTemplateStrategy)) as BlogEditingTemplateStrategy[]); if (detectedBlogTemplateFiles != null) blogTemplateFiles.AddRange(detectedBlogTemplateFiles); } // updates member if we succeeded if (blogTemplateFiles.Count > 0) { // capture template files _blogTemplateFiles = blogTemplateFiles.ToArray(typeof(BlogEditingTemplateFile)) as BlogEditingTemplateFile[]; // if we got at least one template by some method then clear any exception // that occurs so we can at least update that tempalte _exception = null; } foreach (BlogEditingTemplateFile file in blogTemplateFiles) { if (file.TemplateType == BlogEditingTemplateType.Webpage) { _postBodyBackgroundColor = BackgroundColorDetector.DetectColor(UrlHelper.SafeToAbsoluteUri(new Uri(file.TemplateFile)), _postBodyBackgroundColor); } } // return return this; } }
private void CommonInit() { // Auto RTL fixup is way too expensive, since it happens // after many controls are already created and showing // onscreen. Do manual RTL mirroring instead. SuppressAutoRtlFixup = true; _blogClientUIContextScope = new BlogClientUIContextScope(this); //InitializeStatusBar(); Icon = ApplicationEnvironment.ProductIcon; AutoScaleMode = AutoScaleMode.None; if (ApplicationPerformance.IsEnabled && !startupLogged) { Application.Idle += LogStartupPerf; } BackColor = Color.Red; }