mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-04-22 00:15:48 +02:00
Implement configurable popup notification duration
This commit is contained in:
parent
53b0aaee10
commit
f81d332d8f
@ -18,6 +18,7 @@ sealed class UserConfig{
|
||||
public Point WindowLocation { get; set; }
|
||||
public Size WindowSize { get; set; }
|
||||
|
||||
public TweetNotification.Duration NotificationDuration { get; set; }
|
||||
public TweetNotification.Position NotificationPosition { get; set; }
|
||||
public Point CustomNotificationPosition { get; set; }
|
||||
public int NotificationEdgeDistance { get; set; }
|
||||
@ -44,6 +45,7 @@ private UserConfig(string file){
|
||||
|
||||
IsMaximized = true;
|
||||
WindowLocation = new Point(32000,32000);
|
||||
NotificationDuration = TweetNotification.Duration.Medium;
|
||||
NotificationPosition = TweetNotification.Position.TopRight;
|
||||
CustomNotificationPosition = new Point(32000,32000);
|
||||
NotificationEdgeDistance = 8;
|
||||
|
@ -11,7 +11,7 @@
|
||||
using System.Drawing;
|
||||
|
||||
namespace TweetDick.Core{
|
||||
public partial class FormBrowser : Form{
|
||||
partial class FormBrowser : Form{
|
||||
private static UserConfig Config{
|
||||
get{
|
||||
return Program.UserConfig;
|
||||
@ -126,8 +126,8 @@ public void OpenAbout(){
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTweetPopup(string tweetHtml, string tweetColumn){
|
||||
notification.ShowNotification(new TweetNotification(tweetHtml));
|
||||
public void OnTweetPopup(TweetNotification tweet){
|
||||
notification.ShowNotification(tweet);
|
||||
}
|
||||
}
|
||||
}
|
@ -50,7 +50,7 @@ private void LoadNextNotification(){
|
||||
browser.LoadHtml(tweet.GenerateHtml(),"http://tweetdeck.twitter.com/");
|
||||
|
||||
timer.Stop();
|
||||
timer.Interval = 5000;
|
||||
timer.Interval = tweet.GetDisplayDuration(Program.UserConfig.NotificationDuration);
|
||||
timer.Start();
|
||||
}
|
||||
|
||||
|
@ -24,9 +24,9 @@ public void OpenSettingsMenu(){
|
||||
});
|
||||
}
|
||||
|
||||
public void OnTweetPopup(string tweetHtml, string tweetColumn){
|
||||
public void OnTweetPopup(string tweetHtml, int tweetCharacters){
|
||||
form.InvokeSafe(() => {
|
||||
form.OnTweetPopup(tweetHtml,tweetColumn);
|
||||
form.OnTweetPopup(new TweetNotification(tweetHtml,tweetCharacters));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace TweetDick.Core.Handling{
|
||||
sealed class TweetNotification{
|
||||
@ -17,10 +18,29 @@ public enum Position{
|
||||
TopLeft, TopRight, BottomLeft, BottomRight, Custom
|
||||
}
|
||||
|
||||
private readonly string html;
|
||||
public enum Duration{
|
||||
Short, Medium, Long, VeryLong
|
||||
}
|
||||
|
||||
public TweetNotification(string html){
|
||||
private readonly string html;
|
||||
private readonly int characters;
|
||||
|
||||
public TweetNotification(string html, int characters){
|
||||
this.html = html;
|
||||
this.characters = characters;
|
||||
}
|
||||
|
||||
public int GetDisplayDuration(Duration modifier){
|
||||
int multiplier;
|
||||
|
||||
switch(modifier){
|
||||
case Duration.Short: multiplier = 40; break;
|
||||
case Duration.Long: multiplier = 60; break;
|
||||
case Duration.VeryLong: multiplier = 75; break;
|
||||
default: multiplier = 50; break;
|
||||
}
|
||||
|
||||
return Math.Max(2500,multiplier*characters);
|
||||
}
|
||||
|
||||
public string GenerateHtml(){
|
||||
|
83
Core/Other/FormSettings.Designer.cs
generated
83
Core/Other/FormSettings.Designer.cs
generated
@ -31,12 +31,20 @@ private void InitializeComponent() {
|
||||
this.radioLocBL = new System.Windows.Forms.RadioButton();
|
||||
this.radioLocTR = new System.Windows.Forms.RadioButton();
|
||||
this.radioLocTL = new System.Windows.Forms.RadioButton();
|
||||
this.groupNotificationDuration = new System.Windows.Forms.GroupBox();
|
||||
this.radioDurVeryLong = new System.Windows.Forms.RadioButton();
|
||||
this.radioDurLong = new System.Windows.Forms.RadioButton();
|
||||
this.radioDurMedium = new System.Windows.Forms.RadioButton();
|
||||
this.radioDurShort = new System.Windows.Forms.RadioButton();
|
||||
this.groupNotificationLocation.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).BeginInit();
|
||||
this.groupNotificationDuration.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupNotificationLocation
|
||||
//
|
||||
this.groupNotificationLocation.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.groupNotificationLocation.Controls.Add(this.labelEdgeDistance);
|
||||
this.groupNotificationLocation.Controls.Add(this.trackBarEdgeDistance);
|
||||
this.groupNotificationLocation.Controls.Add(this.radioLocCustom);
|
||||
@ -46,7 +54,7 @@ private void InitializeComponent() {
|
||||
this.groupNotificationLocation.Controls.Add(this.radioLocTL);
|
||||
this.groupNotificationLocation.Location = new System.Drawing.Point(13, 13);
|
||||
this.groupNotificationLocation.Name = "groupNotificationLocation";
|
||||
this.groupNotificationLocation.Size = new System.Drawing.Size(149, 217);
|
||||
this.groupNotificationLocation.Size = new System.Drawing.Size(148, 217);
|
||||
this.groupNotificationLocation.TabIndex = 0;
|
||||
this.groupNotificationLocation.TabStop = false;
|
||||
this.groupNotificationLocation.Text = "Notification Location";
|
||||
@ -70,7 +78,7 @@ private void InitializeComponent() {
|
||||
this.trackBarEdgeDistance.Maximum = 40;
|
||||
this.trackBarEdgeDistance.Minimum = 8;
|
||||
this.trackBarEdgeDistance.Name = "trackBarEdgeDistance";
|
||||
this.trackBarEdgeDistance.Size = new System.Drawing.Size(137, 45);
|
||||
this.trackBarEdgeDistance.Size = new System.Drawing.Size(136, 45);
|
||||
this.trackBarEdgeDistance.SmallChange = 2;
|
||||
this.trackBarEdgeDistance.TabIndex = 5;
|
||||
this.trackBarEdgeDistance.TickFrequency = 2;
|
||||
@ -137,11 +145,73 @@ private void InitializeComponent() {
|
||||
this.radioLocTL.UseVisualStyleBackColor = true;
|
||||
this.radioLocTL.CheckedChanged += new System.EventHandler(this.radioLoc_CheckedChanged);
|
||||
//
|
||||
// groupNotificationDuration
|
||||
//
|
||||
this.groupNotificationDuration.Controls.Add(this.radioDurVeryLong);
|
||||
this.groupNotificationDuration.Controls.Add(this.radioDurLong);
|
||||
this.groupNotificationDuration.Controls.Add(this.radioDurMedium);
|
||||
this.groupNotificationDuration.Controls.Add(this.radioDurShort);
|
||||
this.groupNotificationDuration.Location = new System.Drawing.Point(167, 13);
|
||||
this.groupNotificationDuration.Name = "groupNotificationDuration";
|
||||
this.groupNotificationDuration.Size = new System.Drawing.Size(148, 118);
|
||||
this.groupNotificationDuration.TabIndex = 1;
|
||||
this.groupNotificationDuration.TabStop = false;
|
||||
this.groupNotificationDuration.Text = "Notification Duration";
|
||||
//
|
||||
// radioDurVeryLong
|
||||
//
|
||||
this.radioDurVeryLong.AutoSize = true;
|
||||
this.radioDurVeryLong.Location = new System.Drawing.Point(6, 92);
|
||||
this.radioDurVeryLong.Name = "radioDurVeryLong";
|
||||
this.radioDurVeryLong.Size = new System.Drawing.Size(73, 17);
|
||||
this.radioDurVeryLong.TabIndex = 3;
|
||||
this.radioDurVeryLong.TabStop = true;
|
||||
this.radioDurVeryLong.Text = "Very Long";
|
||||
this.radioDurVeryLong.UseVisualStyleBackColor = true;
|
||||
this.radioDurVeryLong.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged);
|
||||
//
|
||||
// radioDurLong
|
||||
//
|
||||
this.radioDurLong.AutoSize = true;
|
||||
this.radioDurLong.Location = new System.Drawing.Point(6, 68);
|
||||
this.radioDurLong.Name = "radioDurLong";
|
||||
this.radioDurLong.Size = new System.Drawing.Size(49, 17);
|
||||
this.radioDurLong.TabIndex = 2;
|
||||
this.radioDurLong.TabStop = true;
|
||||
this.radioDurLong.Text = "Long";
|
||||
this.radioDurLong.UseVisualStyleBackColor = true;
|
||||
this.radioDurLong.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged);
|
||||
//
|
||||
// radioDurMedium
|
||||
//
|
||||
this.radioDurMedium.AutoSize = true;
|
||||
this.radioDurMedium.Location = new System.Drawing.Point(6, 44);
|
||||
this.radioDurMedium.Name = "radioDurMedium";
|
||||
this.radioDurMedium.Size = new System.Drawing.Size(62, 17);
|
||||
this.radioDurMedium.TabIndex = 1;
|
||||
this.radioDurMedium.TabStop = true;
|
||||
this.radioDurMedium.Text = "Medium";
|
||||
this.radioDurMedium.UseVisualStyleBackColor = true;
|
||||
this.radioDurMedium.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged);
|
||||
//
|
||||
// radioDurShort
|
||||
//
|
||||
this.radioDurShort.AutoSize = true;
|
||||
this.radioDurShort.Location = new System.Drawing.Point(6, 20);
|
||||
this.radioDurShort.Name = "radioDurShort";
|
||||
this.radioDurShort.Size = new System.Drawing.Size(50, 17);
|
||||
this.radioDurShort.TabIndex = 0;
|
||||
this.radioDurShort.TabStop = true;
|
||||
this.radioDurShort.Text = "Short";
|
||||
this.radioDurShort.UseVisualStyleBackColor = true;
|
||||
this.radioDurShort.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged);
|
||||
//
|
||||
// FormSettings
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(284, 242);
|
||||
this.ClientSize = new System.Drawing.Size(328, 242);
|
||||
this.Controls.Add(this.groupNotificationDuration);
|
||||
this.Controls.Add(this.groupNotificationLocation);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
@ -153,6 +223,8 @@ private void InitializeComponent() {
|
||||
this.groupNotificationLocation.ResumeLayout(false);
|
||||
this.groupNotificationLocation.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).EndInit();
|
||||
this.groupNotificationDuration.ResumeLayout(false);
|
||||
this.groupNotificationDuration.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@ -167,5 +239,10 @@ private void InitializeComponent() {
|
||||
private System.Windows.Forms.RadioButton radioLocTL;
|
||||
private System.Windows.Forms.Label labelEdgeDistance;
|
||||
private System.Windows.Forms.TrackBar trackBarEdgeDistance;
|
||||
private System.Windows.Forms.GroupBox groupNotificationDuration;
|
||||
private System.Windows.Forms.RadioButton radioDurVeryLong;
|
||||
private System.Windows.Forms.RadioButton radioDurLong;
|
||||
private System.Windows.Forms.RadioButton radioDurMedium;
|
||||
private System.Windows.Forms.RadioButton radioDurShort;
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@
|
||||
using TweetDick.Core.Handling;
|
||||
|
||||
namespace TweetDick.Core.Other{
|
||||
public partial class FormSettings : Form{
|
||||
partial class FormSettings : Form{
|
||||
private static UserConfig Config{
|
||||
get{
|
||||
return Program.UserConfig;
|
||||
@ -32,6 +32,13 @@ public FormSettings(FormBrowser browserForm){
|
||||
case TweetNotification.Position.BottomRight: radioLocBR.Checked = true; break;
|
||||
}
|
||||
|
||||
switch(Config.NotificationDuration){
|
||||
case TweetNotification.Duration.Short: radioDurShort.Checked = true; break;
|
||||
case TweetNotification.Duration.Medium: radioDurMedium.Checked = true; break;
|
||||
case TweetNotification.Duration.Long: radioDurLong.Checked = true; break;
|
||||
case TweetNotification.Duration.VeryLong: radioDurVeryLong.Checked = true; break;
|
||||
}
|
||||
|
||||
trackBarEdgeDistance.Value = Config.NotificationEdgeDistance;
|
||||
notification.HideNotification();
|
||||
}
|
||||
@ -61,5 +68,12 @@ private void trackBarEdgeDistance_ValueChanged(object sender, EventArgs e){
|
||||
Config.NotificationEdgeDistance = trackBarEdgeDistance.Value;
|
||||
notification.ShowNotificationForSettings();
|
||||
}
|
||||
|
||||
private void radioDur_CheckedChanged(object sender, EventArgs e){
|
||||
if (radioDurShort.Checked)Config.NotificationDuration = TweetNotification.Duration.Short;
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,7 @@
|
||||
var html = $(tweet.outerHTML);
|
||||
html.find("footer:first").remove();
|
||||
|
||||
$TD.onTweetPopup(html.html(),""); // TODO
|
||||
$TD.onTweetPopup(html.html(),html.find(".js-tweet-text:first").text().length); // TODO column & remove pic links from text()
|
||||
};
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user