From 3b10bc9c7cc2021cfc53fdec5d85f86f19ad19ad Mon Sep 17 00:00:00 2001 From: chylex <info@chylex.com> Date: Mon, 11 Apr 2016 14:11:47 +0200 Subject: [PATCH] Add an example tweet to the Settings Form --- Core/FormNotification.cs | 12 ++++++++---- Core/Handling/ContextMenuHandler.cs | 8 ++++++-- Core/Handling/TweetNotification.cs | 24 ++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 6 deletions(-) diff --git a/Core/FormNotification.cs b/Core/FormNotification.cs index 24c3c5b6..72b90d58 100644 --- a/Core/FormNotification.cs +++ b/Core/FormNotification.cs @@ -19,8 +19,8 @@ public FormNotification(Form owner){ this.owner = owner; - browser = new ChromiumWebBrowser(""){ MenuHandler = new MenuHandlerEmpty() }; - Controls.Add(browser); + browser = new ChromiumWebBrowser("about:blank"){ MenuHandler = new MenuHandlerEmpty() }; + panelBrowser.Controls.Add(browser); } public void ShowNotification(TweetNotification notification){ @@ -33,8 +33,12 @@ public void ShowNotification(TweetNotification notification){ } } - public void ShowNotificationForSettings(){ - browser.Load("about:blank"); + if (browser.Address == "about:blank"){ + browser.Load("about:blank"); + browser.LoadHtml(TweetNotification.ExampleTweet.GenerateHtml(),"http://tweetdeck.twitter.com/"); + resetAnimation = true; + } + MoveToVisibleLocation(); } diff --git a/Core/Handling/ContextMenuHandler.cs b/Core/Handling/ContextMenuHandler.cs index e4cc70a5..5791b461 100644 --- a/Core/Handling/ContextMenuHandler.cs +++ b/Core/Handling/ContextMenuHandler.cs @@ -23,8 +23,12 @@ public void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IF model.AddItem(CefMenuCommand.Reload,"Reload"); model.AddSeparator(); - model.AddItem((CefMenuCommand)MenuSettings,"Settings"); - model.AddSeparator(); + + if (TweetNotification.IsReady){ + model.AddItem((CefMenuCommand)MenuSettings,"Settings"); + model.AddSeparator(); + } + model.AddItem((CefMenuCommand)MenuAbout,"About TweetDick"); } diff --git a/Core/Handling/TweetNotification.cs b/Core/Handling/TweetNotification.cs index ea48d9c5..ed028bd7 100644 --- a/Core/Handling/TweetNotification.cs +++ b/Core/Handling/TweetNotification.cs @@ -6,6 +6,30 @@ sealed class TweetNotification{ private static string FontSizeClass { get; set; } private static string HeadTag { get; set; } + public static bool IsReady{ + get{ + return FontSizeClass != null && HeadTag != null; + } + } + + public static TweetNotification ExampleTweet{ + get{ + StringBuilder build = new StringBuilder(); + build.Append(@"<article><div class='js-stream-item-content item-box js-show-detail'><div class='js-tweet tweet'>"); + build.Append(@"<header class='tweet-header'>"); + build.Append(@"<time class='tweet-timestamp js-timestamp pull-right txt-mute'><a target='_blank' rel='url' href='https://twitter.com/chylexMC' class='txt-small'>0s</a></time>"); + build.Append(@"<a target='_blank' rel='user' href='https://twitter.com/chylexMC' class='account-link link-complex block'>"); + build.Append(@"<div class='obj-left item-img tweet-img'><img width='48' height='48' alt='chylexMC's avatar' src='https://pbs.twimg.com/profile_images/645532929930608642/J56NBJVY_normal.png' class='tweet-avatar avatar pull-right'></div>"); + build.Append(@"<div class='nbfc'><span class='account-inline txt-ellipsis'><b class='fullname link-complex-target'>chylex</b> <span class='username txt-mute'>@chylexMC</span></span></div>"); + build.Append(@"</a>"); + build.Append(@"</header>"); + build.Append(@"<div class='tweet-body'><p class='js-tweet-text tweet-text with-linebreaks'>This is an example tweet, which lets you test the location and duration of popup notifications.</p></div>"); + build.Append(@"</div></div></article>"); + + return new TweetNotification(build.ToString(),95); + } + } + public static void SetFontSizeClass(string newFSClass){ FontSizeClass = newFSClass; }