mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-09 06:15:49 +02:00
Add a notification duration indicator
This commit is contained in:
parent
3b10bc9c7c
commit
8d7a55e6ed
48
Core/FormNotification.Designer.cs
generated
48
Core/FormNotification.Designer.cs
generated
@ -24,19 +24,52 @@ protected override void Dispose(bool disposing) {
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.timer = new System.Windows.Forms.Timer(this.components);
|
||||
this.timerNext = new System.Windows.Forms.Timer(this.components);
|
||||
this.panelBrowser = new System.Windows.Forms.Panel();
|
||||
this.timerHideProgress = new System.Windows.Forms.Timer(this.components);
|
||||
this.progressBarTimer = new TweetDick.Core.Controls.FlatProgressBar();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// timer
|
||||
// timerNext
|
||||
//
|
||||
this.timer.Tick += new System.EventHandler(this.timer_Tick);
|
||||
this.timerNext.Tick += new System.EventHandler(this.timer_Tick);
|
||||
//
|
||||
// panelBrowser
|
||||
//
|
||||
this.panelBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panelBrowser.BackColor = System.Drawing.Color.White;
|
||||
this.panelBrowser.Location = new System.Drawing.Point(0, 0);
|
||||
this.panelBrowser.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.panelBrowser.Name = "panelBrowser";
|
||||
this.panelBrowser.Size = new System.Drawing.Size(284, 118);
|
||||
this.panelBrowser.TabIndex = 0;
|
||||
//
|
||||
// timerHideProgress
|
||||
//
|
||||
this.timerHideProgress.Interval = 16;
|
||||
this.timerHideProgress.Tick += new System.EventHandler(this.timerHideProgress_Tick);
|
||||
//
|
||||
// progressBarTimer
|
||||
//
|
||||
this.progressBarTimer.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.progressBarTimer.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(28)))), ((int)(((byte)(99)))), ((int)(((byte)(153)))));
|
||||
this.progressBarTimer.Location = new System.Drawing.Point(0, 118);
|
||||
this.progressBarTimer.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.progressBarTimer.Maximum = 1000;
|
||||
this.progressBarTimer.Name = "progressBarTimer";
|
||||
this.progressBarTimer.Size = new System.Drawing.Size(284, 4);
|
||||
this.progressBarTimer.TabIndex = 1;
|
||||
//
|
||||
// FormNotification
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(284, 118);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
|
||||
this.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.ClientSize = new System.Drawing.Size(284, 122);
|
||||
this.Controls.Add(this.progressBarTimer);
|
||||
this.Controls.Add(this.panelBrowser);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Location = new System.Drawing.Point(32000, 32000);
|
||||
this.Name = "FormNotification";
|
||||
this.ShowInTaskbar = false;
|
||||
@ -49,6 +82,9 @@ private void InitializeComponent() {
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Timer timer;
|
||||
private System.Windows.Forms.Timer timerNext;
|
||||
private System.Windows.Forms.Panel panelBrowser;
|
||||
private Controls.FlatProgressBar progressBarTimer;
|
||||
private System.Windows.Forms.Timer timerHideProgress;
|
||||
}
|
||||
}
|
@ -13,6 +13,7 @@ partial class FormNotification : Form{
|
||||
private readonly ChromiumWebBrowser browser;
|
||||
|
||||
private readonly Queue<TweetNotification> tweetQueue = new Queue<TweetNotification>(4);
|
||||
private DateTime timeLeftStart;
|
||||
|
||||
public FormNotification(Form owner){
|
||||
InitializeComponent();
|
||||
@ -28,23 +29,34 @@ public void ShowNotification(TweetNotification notification){
|
||||
|
||||
tweetQueue.Enqueue(notification);
|
||||
|
||||
if (!timer.Enabled){
|
||||
if (!timerNext.Enabled){
|
||||
LoadNextNotification();
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowNotificationForSettings(bool resetAnimation){
|
||||
if (browser.Address == "about:blank"){
|
||||
browser.Load("about:blank");
|
||||
browser.LoadHtml(TweetNotification.ExampleTweet.GenerateHtml(),"http://tweetdeck.twitter.com/");
|
||||
resetAnimation = true;
|
||||
}
|
||||
|
||||
if (resetAnimation){
|
||||
timerNext.Interval = TweetNotification.ExampleTweet.GetDisplayDuration(Program.UserConfig.NotificationDuration);
|
||||
timeLeftStart = DateTime.Now;
|
||||
timerHideProgress.Stop();
|
||||
timerHideProgress.Start();
|
||||
}
|
||||
|
||||
MoveToVisibleLocation();
|
||||
}
|
||||
|
||||
public void HideNotification(){
|
||||
browser.Load("about:blank");
|
||||
Location = new Point(32000,32000);
|
||||
|
||||
timerNext.Stop();
|
||||
timerHideProgress.Stop();
|
||||
}
|
||||
|
||||
private void LoadNextNotification(){
|
||||
@ -53,9 +65,13 @@ private void LoadNextNotification(){
|
||||
browser.Load("about:blank");
|
||||
browser.LoadHtml(tweet.GenerateHtml(),"http://tweetdeck.twitter.com/");
|
||||
|
||||
timer.Stop();
|
||||
timer.Interval = tweet.GetDisplayDuration(Program.UserConfig.NotificationDuration);
|
||||
timer.Start();
|
||||
timerNext.Stop();
|
||||
timerNext.Interval = tweet.GetDisplayDuration(Program.UserConfig.NotificationDuration);
|
||||
timerNext.Start();
|
||||
|
||||
timeLeftStart = DateTime.Now;
|
||||
timerHideProgress.Stop();
|
||||
timerHideProgress.Start();
|
||||
}
|
||||
|
||||
private void MoveToVisibleLocation(){
|
||||
@ -101,6 +117,11 @@ private void timer_Tick(object sender, EventArgs e){
|
||||
}
|
||||
}
|
||||
|
||||
private void timerHideProgress_Tick(object sender, EventArgs e){
|
||||
int elapsed = (int)(DateTime.Now-timeLeftStart).TotalMilliseconds;
|
||||
progressBarTimer.SetValueInstant((int)Math.Min(1000,Math.Round(1001.0*elapsed/timerNext.Interval)));
|
||||
}
|
||||
|
||||
private void FormNotification_FormClosing(object sender, FormClosingEventArgs e){
|
||||
if (e.CloseReason == CloseReason.UserClosing){
|
||||
HideNotification();
|
||||
|
4
Core/Other/FormSettings.Designer.cs
generated
4
Core/Other/FormSettings.Designer.cs
generated
@ -169,6 +169,7 @@ private void InitializeComponent() {
|
||||
this.radioDurVeryLong.Text = "Very Long";
|
||||
this.radioDurVeryLong.UseVisualStyleBackColor = true;
|
||||
this.radioDurVeryLong.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged);
|
||||
this.radioDurVeryLong.Click += new System.EventHandler(this.radioDur_Click);
|
||||
//
|
||||
// radioDurLong
|
||||
//
|
||||
@ -181,6 +182,7 @@ private void InitializeComponent() {
|
||||
this.radioDurLong.Text = "Long";
|
||||
this.radioDurLong.UseVisualStyleBackColor = true;
|
||||
this.radioDurLong.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged);
|
||||
this.radioDurLong.Click += new System.EventHandler(this.radioDur_Click);
|
||||
//
|
||||
// radioDurMedium
|
||||
//
|
||||
@ -193,6 +195,7 @@ private void InitializeComponent() {
|
||||
this.radioDurMedium.Text = "Medium";
|
||||
this.radioDurMedium.UseVisualStyleBackColor = true;
|
||||
this.radioDurMedium.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged);
|
||||
this.radioDurMedium.Click += new System.EventHandler(this.radioDur_Click);
|
||||
//
|
||||
// radioDurShort
|
||||
//
|
||||
@ -205,6 +208,7 @@ private void InitializeComponent() {
|
||||
this.radioDurShort.Text = "Short";
|
||||
this.radioDurShort.UseVisualStyleBackColor = true;
|
||||
this.radioDurShort.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged);
|
||||
this.radioDurShort.Click += new System.EventHandler(this.radioDur_Click);
|
||||
//
|
||||
// FormSettings
|
||||
//
|
||||
|
@ -61,12 +61,12 @@ private void radioLoc_CheckedChanged(object sender, EventArgs e){
|
||||
}
|
||||
|
||||
trackBarEdgeDistance.Enabled = !radioLocCustom.Checked;
|
||||
notification.ShowNotificationForSettings();
|
||||
notification.ShowNotificationForSettings(false);
|
||||
}
|
||||
|
||||
private void trackBarEdgeDistance_ValueChanged(object sender, EventArgs e){
|
||||
Config.NotificationEdgeDistance = trackBarEdgeDistance.Value;
|
||||
notification.ShowNotificationForSettings();
|
||||
notification.ShowNotificationForSettings(false);
|
||||
}
|
||||
|
||||
private void radioDur_CheckedChanged(object sender, EventArgs e){
|
||||
@ -74,6 +74,12 @@ private void radioDur_CheckedChanged(object sender, EventArgs e){
|
||||
else if (radioDurMedium.Checked)Config.NotificationDuration = TweetNotification.Duration.Medium;
|
||||
else if (radioDurLong.Checked)Config.NotificationDuration = TweetNotification.Duration.Long;
|
||||
else if (radioDurVeryLong.Checked)Config.NotificationDuration = TweetNotification.Duration.VeryLong;
|
||||
|
||||
notification.ShowNotificationForSettings(true);
|
||||
}
|
||||
|
||||
private void radioDur_Click(object sender, EventArgs e){
|
||||
notification.ShowNotificationForSettings(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user