1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-09-14 19:32:10 +02:00

Compare commits

..

24 Commits
1.3 ... 1.3.1

Author SHA1 Message Date
3775b5968d Fix potential memory leaks with FlatProgressBar color brush 2016-08-04 13:43:32 +02:00
ba6242e09d Change notification duration setting to a track bar 2016-07-28 21:58:42 +02:00
f6b0ddddb9 Add FlatButton for generic buttons without double border on focus 2016-07-28 21:51:49 +02:00
9e8d5c6768 Unify group boxes and layout in Settings tab 2016-07-28 15:21:29 +02:00
ef78496d5d Add notification count down toggle option 2016-07-28 14:24:43 +02:00
41a45a14df Change tray highlight to trigger on any notification and reset on window focus
Closes #33
2016-07-27 04:48:09 +02:00
5d3721ad04 Move Import/Export/Reset buttons to Advanced tab and replace them with a hint label 2016-07-26 23:45:20 +02:00
f75bcb505c Unify Settings tab size in Designer for easier manipulation 2016-07-26 23:43:48 +02:00
fa365794a0 Rewrite plugin file methods for the JS promise system 2016-07-24 21:26:24 +02:00
a747ab700e Fix blank space in Plugin Control description when none is provided 2016-07-24 19:28:17 +02:00
b51b017005 Fix plugin script generator causing JS syntax error 2016-07-24 18:14:56 +02:00
b9e1dd5950 Add combined tray icon behavior option
Closes #46
2016-07-24 16:48:26 +02:00
56bf33229b Add a legacy notification load system option 2016-07-24 16:30:58 +02:00
5740dd8c8a Add plugin bridge object to script variable list 2016-07-24 15:35:17 +02:00
d3f205287c Reset Notification Settings example timer when switching tabs 2016-07-24 15:17:08 +02:00
53518cd6e6 Change Notification Settings labels and add edge distance label 2016-07-24 15:13:51 +02:00
0ff3896d51 Add tooltips to Settings items 2016-07-24 14:27:00 +02:00
c64e16471b Add plugin utility bridge with file functionality and a plugin token system 2016-07-23 18:36:58 +02:00
2f2e2b82b8 Reset notification mouse hook variable when disposing 2016-07-11 15:55:18 +02:00
af9a503f3c Fix call order with notification scroll focus 2016-07-10 17:33:21 +02:00
971affa607 Fix unreliable unfocused notification window scroll wheel hook 2016-07-09 21:33:46 +02:00
2de5d6206e Change notification window scrollbar width and remove border radius 2016-07-09 20:54:13 +02:00
34e0bcc56a Focus notification window when mouse wheel is scrolled above it 2016-07-09 19:37:27 +02:00
bb9f09c11f Make sure all Settings controls are disposed when closing 2016-07-09 16:46:08 +02:00
28 changed files with 787 additions and 311 deletions

View File

@@ -16,7 +16,7 @@ namespace TweetDck.Configuration{
Binder = new SerializationCompatibilityHandler() Binder = new SerializationCompatibilityHandler()
}; };
private const int CurrentFileVersion = 3; private const int CurrentFileVersion = 4;
// START OF CONFIGURATION // START OF CONFIGURATION
@@ -25,16 +25,21 @@ namespace TweetDck.Configuration{
public WindowState BrowserWindow { get; set; } public WindowState BrowserWindow { get; set; }
public bool DisplayNotificationTimer { get; set; } public bool DisplayNotificationTimer { get; set; }
public bool NotificationTimerCountDown { get; set; }
public TweetNotification.Duration NotificationDuration { get; set; } public TweetNotification.Duration NotificationDuration { get; set; }
public TweetNotification.Position NotificationPosition { get; set; } public TweetNotification.Position NotificationPosition { get; set; }
public Point CustomNotificationPosition { get; set; } public Point CustomNotificationPosition { get; set; }
public int NotificationEdgeDistance { get; set; } public int NotificationEdgeDistance { get; set; }
public int NotificationDisplay { get; set; } public int NotificationDisplay { get; set; }
public int NotificationDurationValue { get; set; }
public bool NotificationLegacyLoad { get; set; }
public bool ExpandLinksOnHover { get; set; }
public bool EnableTrayHighlight { get; set; }
public bool EnableUpdateCheck { get; set; } public bool EnableUpdateCheck { get; set; }
public string DismissedUpdate { get; set; } public string DismissedUpdate { get; set; }
public bool ExpandLinksOnHover { get; set; }
public PluginConfig Plugins { get; private set; } public PluginConfig Plugins { get; private set; }
public WindowState PluginsWindow { get; set; } public WindowState PluginsWindow { get; set; }
@@ -103,6 +108,7 @@ namespace TweetDck.Configuration{
NotificationEdgeDistance = 8; NotificationEdgeDistance = 8;
EnableUpdateCheck = true; EnableUpdateCheck = true;
ExpandLinksOnHover = true; ExpandLinksOnHover = true;
EnableTrayHighlight = true;
Plugins = new PluginConfig(); Plugins = new PluginConfig();
PluginsWindow = new WindowState(); PluginsWindow = new WindowState();
} }
@@ -131,6 +137,19 @@ namespace TweetDck.Configuration{
++fileVersion; ++fileVersion;
} }
if (fileVersion == 3){
EnableTrayHighlight = true;
switch(NotificationDuration){
case TweetNotification.Duration.Short: NotificationDurationValue = 15; break;
case TweetNotification.Duration.Medium: NotificationDurationValue = 25; break;
case TweetNotification.Duration.Long: NotificationDurationValue = 35; break;
case TweetNotification.Duration.VeryLong: NotificationDurationValue = 45; break;
}
++fileVersion;
}
// update the version // update the version
fileVersion = CurrentFileVersion; fileVersion = CurrentFileVersion;
Save(); Save();

View File

@@ -0,0 +1,20 @@
using System;
using System.Windows.Forms;
namespace TweetDck.Core.Controls{
class FlatButton : Button{
protected override bool ShowFocusCues{
get{
return false;
}
}
public FlatButton(){
GotFocus += FlatButton_GotFocus;
}
private void FlatButton_GotFocus(object sender, EventArgs e){ // removes extra border when focused
NotifyDefault(false);
}
}
}

View File

@@ -3,9 +3,11 @@ using System.Windows.Forms;
namespace TweetDck.Core.Controls{ namespace TweetDck.Core.Controls{
public partial class FlatProgressBar : ProgressBar{ public partial class FlatProgressBar : ProgressBar{
private SolidBrush brush; private readonly SolidBrush brush;
public FlatProgressBar(){ public FlatProgressBar(){
brush = new SolidBrush(Color.White);
SetStyle(ControlStyles.UserPaint,true); SetStyle(ControlStyles.UserPaint,true);
SetStyle(ControlStyles.OptimizedDoubleBuffer,true); SetStyle(ControlStyles.OptimizedDoubleBuffer,true);
} }
@@ -15,8 +17,8 @@ namespace TweetDck.Core.Controls{
} }
protected override void OnPaint(PaintEventArgs e){ protected override void OnPaint(PaintEventArgs e){
if (brush == null || brush.Color != ForeColor){ if (brush.Color != ForeColor){
brush = new SolidBrush(ForeColor); brush.Color = ForeColor;
} }
Rectangle rect = e.ClipRectangle; Rectangle rect = e.ClipRectangle;
@@ -25,9 +27,11 @@ namespace TweetDck.Core.Controls{
} }
protected override void Dispose(bool disposing){ protected override void Dispose(bool disposing){
if (brush != null)brush.Dispose();
base.Dispose(disposing); base.Dispose(disposing);
if (disposing){
brush.Dispose();
}
} }
} }
} }

View File

@@ -3,19 +3,9 @@ using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDck.Core.Controls{ namespace TweetDck.Core.Controls{
sealed partial class TabButton : Button{ sealed partial class TabButton : FlatButton{
protected override bool ShowFocusCues{
get{
return false;
}
}
public Action Callback { get; private set; } public Action Callback { get; private set; }
public TabButton(){
GotFocus += TabButton_GotFocus;
}
public void SetupButton(int locationX, int sizeWidth, string title, Action callback){ public void SetupButton(int locationX, int sizeWidth, string title, Action callback){
Callback = callback; Callback = callback;
@@ -31,9 +21,5 @@ namespace TweetDck.Core.Controls{
UseVisualStyleBackColor = true; UseVisualStyleBackColor = true;
ResumeLayout(true); ResumeLayout(true);
} }
private void TabButton_GotFocus(object sender, EventArgs e){ // removes extra border when focused
NotifyDefault(false);
}
} }
} }

View File

@@ -43,6 +43,7 @@
this.MinimumSize = new System.Drawing.Size(340, 424); this.MinimumSize = new System.Drawing.Size(340, 424);
this.Name = "FormBrowser"; this.Name = "FormBrowser";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
this.Activated += new System.EventHandler(this.FormBrowser_Activated);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormBrowser_FormClosing); this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormBrowser_FormClosing);
this.ResizeEnd += new System.EventHandler(this.FormBrowser_ResizeEnd); this.ResizeEnd += new System.EventHandler(this.FormBrowser_ResizeEnd);
this.Resize += new System.EventHandler(this.FormBrowser_Resize); this.Resize += new System.EventHandler(this.FormBrowser_Resize);

View File

@@ -55,6 +55,7 @@ namespace TweetDck.Core{
this.browser.LoadingStateChanged += Browser_LoadingStateChanged; this.browser.LoadingStateChanged += Browser_LoadingStateChanged;
this.browser.FrameLoadEnd += Browser_FrameLoadEnd; this.browser.FrameLoadEnd += Browser_FrameLoadEnd;
this.browser.RegisterJsObject("$TD",new TweetDeckBridge(this,notification)); this.browser.RegisterJsObject("$TD",new TweetDeckBridge(this,notification));
this.browser.RegisterAsyncJsObject("$TDP",plugins.Bridge);
Controls.Add(browser); Controls.Add(browser);
@@ -81,7 +82,7 @@ namespace TweetDck.Core{
} }
public FormNotification CreateNotificationForm(bool autoHide){ public FormNotification CreateNotificationForm(bool autoHide){
return new FormNotification(this,plugins,trayIcon,autoHide); return new FormNotification(this,plugins,autoHide);
} }
// window setup // window setup
@@ -93,7 +94,7 @@ namespace TweetDck.Core{
} }
private void UpdateTrayIcon(){ private void UpdateTrayIcon(){
trayIcon.Visible = Config.TrayBehavior != TrayIcon.Behavior.Disabled; trayIcon.Visible = Config.TrayBehavior.ShouldDisplayIcon();
} }
// active event handlers // active event handlers
@@ -116,6 +117,12 @@ namespace TweetDck.Core{
} }
} }
private void FormBrowser_Activated(object sender, EventArgs e){
if (!isLoaded)return;
trayIcon.HasNotifications = false;
}
private void FormBrowser_Resize(object sender, EventArgs e){ private void FormBrowser_Resize(object sender, EventArgs e){
if (!isLoaded)return; if (!isLoaded)return;
@@ -123,7 +130,7 @@ namespace TweetDck.Core{
prevState = WindowState; prevState = WindowState;
if (WindowState == FormWindowState.Minimized){ if (WindowState == FormWindowState.Minimized){
if (Config.TrayBehavior == TrayIcon.Behavior.MinimizeToTray){ if (Config.TrayBehavior.ShouldHideOnMinimize()){
Hide(); // hides taskbar too?! welp that works I guess Hide(); // hides taskbar too?! welp that works I guess
} }
} }
@@ -145,7 +152,7 @@ namespace TweetDck.Core{
private void FormBrowser_FormClosing(object sender, FormClosingEventArgs e){ private void FormBrowser_FormClosing(object sender, FormClosingEventArgs e){
if (!isLoaded)return; if (!isLoaded)return;
if (Config.TrayBehavior == TrayIcon.Behavior.CloseToTray && trayIcon.Visible && e.CloseReason == CloseReason.UserClosing){ if (Config.TrayBehavior.ShouldHideOnClose() && trayIcon.Visible && e.CloseReason == CloseReason.UserClosing){
Hide(); // hides taskbar too?! welp that works I guess Hide(); // hides taskbar too?! welp that works I guess
e.Cancel = true; e.Cancel = true;
} }
@@ -233,6 +240,10 @@ namespace TweetDck.Core{
Config.Save(); Config.Save();
updates.Check(false); updates.Check(false);
} }
if (!Config.EnableTrayHighlight){
trayIcon.HasNotifications = false;
}
}; };
ShowChildForm(currentFormSettings); ShowChildForm(currentFormSettings);
@@ -261,8 +272,10 @@ namespace TweetDck.Core{
} }
} }
public void OnTweetSound(){ public void OnTweetNotification(){
if (Config.EnableTrayHighlight && !ContainsFocus){
trayIcon.HasNotifications = true;
}
} }
public void DisplayTooltip(string text){ public void DisplayTooltip(string text){

View File

@@ -21,13 +21,15 @@ namespace TweetDck.Core{
private readonly Form owner; private readonly Form owner;
private readonly PluginManager plugins; private readonly PluginManager plugins;
private readonly TrayIcon trayIcon;
private readonly ChromiumWebBrowser browser; private readonly ChromiumWebBrowser browser;
private readonly Queue<TweetNotification> tweetQueue = new Queue<TweetNotification>(4); private readonly Queue<TweetNotification> tweetQueue = new Queue<TweetNotification>(4);
private readonly bool autoHide; private readonly bool autoHide;
private int timeLeft, totalTime; private int timeLeft, totalTime;
private readonly NativeMethods.HookProc mouseHookDelegate;
private IntPtr mouseHook;
private bool? prevDisplayTimer; private bool? prevDisplayTimer;
private int? prevFontSize; private int? prevFontSize;
@@ -78,14 +80,13 @@ namespace TweetDck.Core{
} }
} }
public FormNotification(FormBrowser owner, PluginManager plugins, TrayIcon trayIcon, bool autoHide){ public FormNotification(FormBrowser owner, PluginManager pluginManager, bool autoHide){
InitializeComponent(); InitializeComponent();
Text = Program.BrandName; Text = Program.BrandName;
this.owner = owner; this.owner = owner;
this.plugins = plugins; this.plugins = pluginManager;
this.trayIcon = trayIcon;
this.autoHide = autoHide; this.autoHide = autoHide;
owner.FormClosed += (sender, args) => Close(); owner.FormClosed += (sender, args) => Close();
@@ -101,6 +102,7 @@ namespace TweetDck.Core{
browser.IsBrowserInitializedChanged += Browser_IsBrowserInitializedChanged; browser.IsBrowserInitializedChanged += Browser_IsBrowserInitializedChanged;
browser.FrameLoadEnd += Browser_FrameLoadEnd; browser.FrameLoadEnd += Browser_FrameLoadEnd;
browser.RegisterJsObject("$TD",new TweetDeckBridge(owner,this)); browser.RegisterJsObject("$TD",new TweetDeckBridge(owner,this));
browser.RegisterAsyncJsObject("$TDP",plugins.Bridge);
panelBrowser.Controls.Add(browser); panelBrowser.Controls.Add(browser);
@@ -109,7 +111,10 @@ namespace TweetDck.Core{
Disposed += (sender, args) => Program.UserConfig.MuteToggled -= Config_MuteToggled; Disposed += (sender, args) => Program.UserConfig.MuteToggled -= Config_MuteToggled;
} }
Disposed += (sender, args) => browser.Dispose(); mouseHookDelegate = MouseHookProc;
mouseHook = NativeMethods.SetWindowsHookEx(NativeMethods.WH_MOUSE_LL,mouseHookDelegate,IntPtr.Zero,0);
Disposed += FormNotification_Disposed;
} }
protected override void WndProc(ref Message m){ protected override void WndProc(ref Message m){
@@ -120,13 +125,27 @@ namespace TweetDck.Core{
base.WndProc(ref m); base.WndProc(ref m);
} }
private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam){
if (!ContainsFocus && wParam.ToInt32() == NativeMethods.WH_MOUSEWHEEL && browser.Bounds.Contains(PointToClient(Cursor.Position))){
// fuck it, Activate() doesn't work with this
Point prevPos = Cursor.Position;
Cursor.Position = PointToScreen(new Point(-1,-1));
NativeMethods.SimulateMouseClick(NativeMethods.MouseButton.Left);
Cursor.Position = prevPos;
}
return NativeMethods.CallNextHookEx(mouseHook,nCode,wParam,lParam);
}
// event handlers // event handlers
private void timerHideProgress_Tick(object sender, EventArgs e){ private void timerHideProgress_Tick(object sender, EventArgs e){
if (Bounds.Contains(Cursor.Position) || FreezeTimer || ContextMenuOpen)return; if (Bounds.Contains(Cursor.Position) || FreezeTimer || ContextMenuOpen)return;
timeLeft -= timerProgress.Interval; timeLeft -= timerProgress.Interval;
progressBarTimer.SetValueInstant((int)Math.Min(1000,Math.Round(1025.0*(totalTime-timeLeft)/totalTime)));
int value = (int)Math.Round(1025.0*(totalTime-timeLeft)/totalTime);
progressBarTimer.SetValueInstant(Math.Min(1000,Math.Max(0,Program.UserConfig.NotificationTimerCountDown ? 1000-value : value)));
if (timeLeft <= 0){ if (timeLeft <= 0){
FinishCurrentTweet(); FinishCurrentTweet();
@@ -137,12 +156,8 @@ namespace TweetDck.Core{
if (Program.UserConfig.MuteNotifications){ if (Program.UserConfig.MuteNotifications){
HideNotification(true); HideNotification(true);
} }
else{ else if (tweetQueue.Count > 0){
if (tweetQueue.Count > 0){ LoadNextNotification();
LoadNextNotification();
}
trayIcon.HasNotifications = false;
} }
} }
@@ -155,7 +170,7 @@ namespace TweetDck.Core{
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){ private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
if (!e.Frame.IsMain)return; if (!e.Frame.IsMain)return;
if (!isInitialized){ if (!isInitialized && !Program.UserConfig.NotificationLegacyLoad){
isInitialized = true; isInitialized = true;
if (Initialized != null){ if (Initialized != null){
@@ -180,12 +195,20 @@ namespace TweetDck.Core{
} }
} }
private void FormNotification_Disposed(object sender, EventArgs e){
browser.Dispose();
if (mouseHook != IntPtr.Zero){
NativeMethods.UnhookWindowsHookEx(mouseHook);
mouseHook = IntPtr.Zero;
}
}
// notification methods // notification methods
public void ShowNotification(TweetNotification notification){ public void ShowNotification(TweetNotification notification){
if (Program.UserConfig.MuteNotifications){ if (Program.UserConfig.MuteNotifications){
tweetQueue.Enqueue(notification); tweetQueue.Enqueue(notification);
trayIcon.HasNotifications = true;
} }
else{ else{
tweetQueue.Enqueue(notification); tweetQueue.Enqueue(notification);
@@ -207,12 +230,12 @@ namespace TweetDck.Core{
} }
public void HideNotification(bool loadBlank){ public void HideNotification(bool loadBlank){
if (loadBlank){ if (loadBlank || Program.UserConfig.NotificationLegacyLoad){
browser.LoadHtml("","about:blank"); browser.LoadHtml("","about:blank");
} }
Location = new Point(-32000,-32000); Location = new Point(-32000,-32000);
progressBarTimer.Value = 0; progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? 1000 : 0;
timerProgress.Stop(); timerProgress.Stop();
} }
@@ -242,10 +265,14 @@ namespace TweetDck.Core{
CurrentUrl = tweet.Url; CurrentUrl = tweet.Url;
timerProgress.Stop(); timerProgress.Stop();
totalTime = timeLeft = tweet.GetDisplayDuration(Program.UserConfig.NotificationDuration); totalTime = timeLeft = tweet.GetDisplayDuration(Program.UserConfig.NotificationDurationValue);
progressBarTimer.Value = 0; progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? 1000 : 0;
browser.LoadHtml(tweet.GenerateHtml(),"http://tweetdeck.twitter.com/?"+DateTime.Now.Ticks); browser.LoadHtml(tweet.GenerateHtml(),"http://tweetdeck.twitter.com/?"+DateTime.Now.Ticks);
if (Program.UserConfig.NotificationLegacyLoad){
OnNotificationReady();
}
} }
private void MoveToVisibleLocation(){ private void MoveToVisibleLocation(){

View File

@@ -83,16 +83,19 @@ namespace TweetDck.Core.Handling{
public void OnTweetPopup(string tweetHtml, string tweetUrl, int tweetCharacters){ public void OnTweetPopup(string tweetHtml, string tweetUrl, int tweetCharacters){
notification.InvokeSafe(() => { notification.InvokeSafe(() => {
form.OnTweetNotification();
notification.ShowNotification(new TweetNotification(tweetHtml,tweetUrl,tweetCharacters)); notification.ShowNotification(new TweetNotification(tweetHtml,tweetUrl,tweetCharacters));
}); });
} }
public void OnTweetSound(){ public void OnTweetSound(){
form.InvokeSafe(form.OnTweetSound); form.InvokeSafe(form.OnTweetNotification);
} }
public void OnNotificationReady(){ public void OnNotificationReady(){
notification.InvokeSafe(notification.OnNotificationReady); if (!Program.UserConfig.NotificationLegacyLoad){
notification.InvokeSafe(notification.OnNotificationReady);
}
} }
public void DisplayTooltip(string text, bool showInNotification){ public void DisplayTooltip(string text, bool showInNotification){

View File

@@ -18,6 +18,12 @@ namespace TweetDck.Core.Handling{
} }
} }
private static string CustomCSS{
get{
return @".scroll-styled-v::-webkit-scrollbar{width:8px}.scroll-styled-v::-webkit-scrollbar-thumb{border-radius:0}";
}
}
public static int FontSizeLevel{ public static int FontSizeLevel{
get{ get{
switch(FontSizeClass){ switch(FontSizeClass){
@@ -80,24 +86,15 @@ namespace TweetDck.Core.Handling{
this.characters = characters; this.characters = characters;
} }
public int GetDisplayDuration(Duration modifier){ public int GetDisplayDuration(int value){
int multiplier; return 2000+Math.Max(1000,value*characters);
switch(modifier){
case Duration.Short: multiplier = 15; break;
case Duration.Long: multiplier = 35; break;
case Duration.VeryLong: multiplier = 45; break;
default: multiplier = 25; break;
}
return 2000+Math.Max(1000,multiplier*characters);
} }
public string GenerateHtml(){ public string GenerateHtml(){
StringBuilder build = new StringBuilder(); StringBuilder build = new StringBuilder();
build.Append("<!DOCTYPE html>"); build.Append("<!DOCTYPE html>");
build.Append("<html class='os-windows txt-base-").Append(FontSizeClass ?? DefaultFontSizeClass).Append("'>"); build.Append("<html class='os-windows txt-base-").Append(FontSizeClass ?? DefaultFontSizeClass).Append("'>");
build.Append("<head>").Append(HeadTag ?? DefaultHeadTag).Append("</head>"); build.Append("<head>").Append(HeadTag ?? DefaultHeadTag).Append("<style type='text/css'>").Append(CustomCSS).Append("</style></head>");
build.Append("<body class='hearty'><div class='app-columns-container'><div class='column scroll-styled-v' style='width:100%;overflow-y:auto'>"); build.Append("<body class='hearty'><div class='app-columns-container'><div class='column scroll-styled-v' style='width:100%;overflow-y:auto'>");
build.Append(html); build.Append(html);
build.Append("</div></div></body>"); build.Append("</div></div></body>");

View File

@@ -24,23 +24,11 @@
/// </summary> /// </summary>
private void InitializeComponent() { private void InitializeComponent() {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormSettings)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(FormSettings));
this.tabPanel = new TweetDck.Core.Controls.TabPanel();
this.btnClose = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button();
this.btnExport = new System.Windows.Forms.Button(); this.labelTip = new System.Windows.Forms.Label();
this.btnImport = new System.Windows.Forms.Button(); this.tabPanel = new TweetDck.Core.Controls.TabPanel();
this.btnReset = new System.Windows.Forms.Button();
this.SuspendLayout(); this.SuspendLayout();
// //
// tabPanel
//
this.tabPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.tabPanel.Location = new System.Drawing.Point(12, 12);
this.tabPanel.Name = "tabPanel";
this.tabPanel.Size = new System.Drawing.Size(480, 313);
this.tabPanel.TabIndex = 3;
//
// btnClose // btnClose
// //
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@@ -54,53 +42,31 @@
this.btnClose.UseVisualStyleBackColor = true; this.btnClose.UseVisualStyleBackColor = true;
this.btnClose.Click += new System.EventHandler(this.btnClose_Click); this.btnClose.Click += new System.EventHandler(this.btnClose_Click);
// //
// btnExport // labelTip
// //
this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.labelTip.AutoSize = true;
this.btnExport.AutoSize = true; this.labelTip.Location = new System.Drawing.Point(12, 333);
this.btnExport.Location = new System.Drawing.Point(12, 331); this.labelTip.Name = "labelTip";
this.btnExport.Name = "btnExport"; this.labelTip.Size = new System.Drawing.Size(310, 13);
this.btnExport.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0); this.labelTip.TabIndex = 5;
this.btnExport.Size = new System.Drawing.Size(94, 23); this.labelTip.Text = "Tip: Move your cursor over an option to see detailed explanation";
this.btnExport.TabIndex = 5;
this.btnExport.Text = "Export Settings";
this.btnExport.UseVisualStyleBackColor = true;
this.btnExport.Click += new System.EventHandler(this.btnExport_Click);
// //
// btnImport // tabPanel
// //
this.btnImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.tabPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
this.btnImport.AutoSize = true; | System.Windows.Forms.AnchorStyles.Left)
this.btnImport.Location = new System.Drawing.Point(112, 331); | System.Windows.Forms.AnchorStyles.Right)));
this.btnImport.Name = "btnImport"; this.tabPanel.Location = new System.Drawing.Point(12, 12);
this.btnImport.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0); this.tabPanel.Name = "tabPanel";
this.btnImport.Size = new System.Drawing.Size(94, 23); this.tabPanel.Size = new System.Drawing.Size(480, 313);
this.btnImport.TabIndex = 6; this.tabPanel.TabIndex = 3;
this.btnImport.Text = "Import Settings";
this.btnImport.UseVisualStyleBackColor = true;
this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
//
// btnReset
//
this.btnReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnReset.AutoSize = true;
this.btnReset.Location = new System.Drawing.Point(212, 331);
this.btnReset.Name = "btnReset";
this.btnReset.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
this.btnReset.Size = new System.Drawing.Size(102, 23);
this.btnReset.TabIndex = 7;
this.btnReset.Text = "Restore Defaults";
this.btnReset.UseVisualStyleBackColor = true;
this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
// //
// FormSettings // FormSettings
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(504, 366); this.ClientSize = new System.Drawing.Size(504, 366);
this.Controls.Add(this.btnReset); this.Controls.Add(this.labelTip);
this.Controls.Add(this.btnImport);
this.Controls.Add(this.btnExport);
this.Controls.Add(this.btnClose); this.Controls.Add(this.btnClose);
this.Controls.Add(this.tabPanel); this.Controls.Add(this.tabPanel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
@@ -119,8 +85,6 @@
private Controls.TabPanel tabPanel; private Controls.TabPanel tabPanel;
private System.Windows.Forms.Button btnClose; private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnExport; private System.Windows.Forms.Label labelTip;
private System.Windows.Forms.Button btnImport;
private System.Windows.Forms.Button btnReset;
} }
} }

View File

@@ -42,66 +42,9 @@ namespace TweetDck.Core.Other{
private void FormSettings_FormClosing(object sender, FormClosingEventArgs e){ private void FormSettings_FormClosing(object sender, FormClosingEventArgs e){
Program.UserConfig.Save(); Program.UserConfig.Save();
}
private void btnExport_Click(object sender, EventArgs e){ foreach(BaseTabSettings control in tabs.Values){
DialogResult resultSaveCredentials = MessageBox.Show("Do you want to include your login session? This will not save your password into the file, but it will allow anyone with the file to login into TweetDeck as you.","Export "+Program.BrandName+" Settings",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button3); control.Dispose();
if (resultSaveCredentials == DialogResult.Cancel)return;
bool saveCredentials = resultSaveCredentials == DialogResult.Yes;
string file;
using(SaveFileDialog dialog = new SaveFileDialog{
AddExtension = true,
AutoUpgradeEnabled = true,
OverwritePrompt = true,
DefaultExt = "tdsettings",
FileName = Program.BrandName+".tdsettings",
Title = "Export "+Program.BrandName+" Settings",
Filter = Program.BrandName+" Settings (*.tdsettings)|*.tdsettings"
}){
file = dialog.ShowDialog() == DialogResult.OK ? dialog.FileName : null;
}
if (file != null){
Program.UserConfig.Save();
ExportManager manager = new ExportManager(file);
if (!manager.Export(saveCredentials)){
Program.HandleException("An exception happened while exporting "+Program.BrandName+" settings.",manager.LastException);
}
}
}
private void btnImport_Click(object sender, EventArgs e){
string file;
using(OpenFileDialog dialog = new OpenFileDialog{
AutoUpgradeEnabled = true,
DereferenceLinks = true,
Title = "Import "+Program.BrandName+" Settings",
Filter = Program.BrandName+" Settings (*.tdsettings)|*.tdsettings"
}){
file = dialog.ShowDialog() == DialogResult.OK ? dialog.FileName : null;
}
if (file != null){
ExportManager manager = new ExportManager(file);
if (manager.Import()){
ReloadUI();
}
else{
Program.HandleException("An exception happened while importing "+Program.BrandName+" settings.",manager.LastException);
}
}
}
private void btnReset_Click(object sender, EventArgs e){
if (MessageBox.Show("This will reset all of your settings, including disabled plugins. Do you want to proceed?","Reset "+Program.BrandName+" Settings",MessageBoxButtons.YesNo,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2) == DialogResult.Yes){
Program.ResetConfig();
ReloadUI();
} }
} }
@@ -109,7 +52,7 @@ namespace TweetDck.Core.Other{
Close(); Close();
} }
private void ReloadUI(){ public void ReloadUI(){
tabs.Clear(); tabs.Clear();
tabPanel.Content.Controls.Clear(); tabPanel.Content.Controls.Clear();
tabPanel.ActiveButton.Callback(); tabPanel.ActiveButton.Callback();

View File

@@ -23,51 +23,105 @@
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() { private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.btnClearCache = new System.Windows.Forms.Button(); this.btnClearCache = new System.Windows.Forms.Button();
this.labelMiscellaneous = new System.Windows.Forms.Label();
this.checkHardwareAcceleration = new System.Windows.Forms.CheckBox(); this.checkHardwareAcceleration = new System.Windows.Forms.CheckBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.btnReset = new System.Windows.Forms.Button();
this.btnImport = new System.Windows.Forms.Button();
this.btnExport = new System.Windows.Forms.Button();
this.groupPerformance = new System.Windows.Forms.GroupBox();
this.groupPerformance.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnClearCache // btnClearCache
// //
this.btnClearCache.Location = new System.Drawing.Point(12, 56); this.btnClearCache.Location = new System.Drawing.Point(6, 44);
this.btnClearCache.Name = "btnClearCache"; this.btnClearCache.Name = "btnClearCache";
this.btnClearCache.Size = new System.Drawing.Size(171, 23); this.btnClearCache.Size = new System.Drawing.Size(171, 23);
this.btnClearCache.TabIndex = 14; this.btnClearCache.TabIndex = 14;
this.btnClearCache.Text = "Clear Cache (calculating)"; this.btnClearCache.Text = "Clear Cache (calculating)";
this.toolTip.SetToolTip(this.btnClearCache, "Clearing cache will free up space taken by downloaded images and other resources." +
"");
this.btnClearCache.UseVisualStyleBackColor = true; this.btnClearCache.UseVisualStyleBackColor = true;
this.btnClearCache.Click += new System.EventHandler(this.btnClearCache_Click); this.btnClearCache.Click += new System.EventHandler(this.btnClearCache_Click);
// //
// labelMiscellaneous
//
this.labelMiscellaneous.AutoSize = true;
this.labelMiscellaneous.Location = new System.Drawing.Point(9, 40);
this.labelMiscellaneous.Margin = new System.Windows.Forms.Padding(3, 11, 3, 0);
this.labelMiscellaneous.Name = "labelMiscellaneous";
this.labelMiscellaneous.Size = new System.Drawing.Size(74, 13);
this.labelMiscellaneous.TabIndex = 13;
this.labelMiscellaneous.Text = "Miscellaneous";
//
// checkHardwareAcceleration // checkHardwareAcceleration
// //
this.checkHardwareAcceleration.AutoSize = true; this.checkHardwareAcceleration.AutoSize = true;
this.checkHardwareAcceleration.Location = new System.Drawing.Point(9, 9); this.checkHardwareAcceleration.Location = new System.Drawing.Point(6, 21);
this.checkHardwareAcceleration.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
this.checkHardwareAcceleration.Name = "checkHardwareAcceleration"; this.checkHardwareAcceleration.Name = "checkHardwareAcceleration";
this.checkHardwareAcceleration.Size = new System.Drawing.Size(134, 17); this.checkHardwareAcceleration.Size = new System.Drawing.Size(134, 17);
this.checkHardwareAcceleration.TabIndex = 12; this.checkHardwareAcceleration.TabIndex = 12;
this.checkHardwareAcceleration.Text = "Hardware Acceleration"; this.checkHardwareAcceleration.Text = "Hardware Acceleration";
this.toolTip.SetToolTip(this.checkHardwareAcceleration, "Uses your graphics card to improve performance.\r\nDisable if you experience issues" +
" with rendering.");
this.checkHardwareAcceleration.UseVisualStyleBackColor = true; this.checkHardwareAcceleration.UseVisualStyleBackColor = true;
this.checkHardwareAcceleration.CheckedChanged += new System.EventHandler(this.checkHardwareAcceleration_CheckedChanged); this.checkHardwareAcceleration.CheckedChanged += new System.EventHandler(this.checkHardwareAcceleration_CheckedChanged);
// //
// btnReset
//
this.btnReset.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnReset.AutoSize = true;
this.btnReset.Location = new System.Drawing.Point(209, 250);
this.btnReset.Name = "btnReset";
this.btnReset.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
this.btnReset.Size = new System.Drawing.Size(102, 23);
this.btnReset.TabIndex = 17;
this.btnReset.Text = "Restore Defaults";
this.btnReset.UseVisualStyleBackColor = true;
this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
//
// btnImport
//
this.btnImport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnImport.AutoSize = true;
this.btnImport.Location = new System.Drawing.Point(109, 250);
this.btnImport.Name = "btnImport";
this.btnImport.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
this.btnImport.Size = new System.Drawing.Size(94, 23);
this.btnImport.TabIndex = 16;
this.btnImport.Text = "Import Settings";
this.btnImport.UseVisualStyleBackColor = true;
this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
//
// btnExport
//
this.btnExport.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.btnExport.AutoSize = true;
this.btnExport.Location = new System.Drawing.Point(9, 250);
this.btnExport.Name = "btnExport";
this.btnExport.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
this.btnExport.Size = new System.Drawing.Size(94, 23);
this.btnExport.TabIndex = 15;
this.btnExport.Text = "Export Settings";
this.btnExport.UseVisualStyleBackColor = true;
this.btnExport.Click += new System.EventHandler(this.btnExport_Click);
//
// groupPerformance
//
this.groupPerformance.Controls.Add(this.checkHardwareAcceleration);
this.groupPerformance.Controls.Add(this.btnClearCache);
this.groupPerformance.Location = new System.Drawing.Point(9, 9);
this.groupPerformance.Name = "groupPerformance";
this.groupPerformance.Size = new System.Drawing.Size(183, 74);
this.groupPerformance.TabIndex = 18;
this.groupPerformance.TabStop = false;
this.groupPerformance.Text = "Performance";
//
// TabSettingsAdvanced // TabSettingsAdvanced
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btnClearCache); this.Controls.Add(this.groupPerformance);
this.Controls.Add(this.labelMiscellaneous); this.Controls.Add(this.btnReset);
this.Controls.Add(this.checkHardwareAcceleration); this.Controls.Add(this.btnImport);
this.Controls.Add(this.btnExport);
this.Name = "TabSettingsAdvanced"; this.Name = "TabSettingsAdvanced";
this.Size = new System.Drawing.Size(239, 120); this.Size = new System.Drawing.Size(478, 282);
this.groupPerformance.ResumeLayout(false);
this.groupPerformance.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -76,7 +130,11 @@
#endregion #endregion
private System.Windows.Forms.Button btnClearCache; private System.Windows.Forms.Button btnClearCache;
private System.Windows.Forms.Label labelMiscellaneous;
private System.Windows.Forms.CheckBox checkHardwareAcceleration; private System.Windows.Forms.CheckBox checkHardwareAcceleration;
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.Button btnReset;
private System.Windows.Forms.Button btnImport;
private System.Windows.Forms.Button btnExport;
private System.Windows.Forms.GroupBox groupPerformance;
} }
} }

View File

@@ -2,6 +2,7 @@
using System.Diagnostics; using System.Diagnostics;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Controls; using TweetDck.Core.Controls;
using TweetDck.Core.Other.Settings.Export;
using TweetDck.Core.Utils; using TweetDck.Core.Utils;
namespace TweetDck.Core.Other.Settings{ namespace TweetDck.Core.Other.Settings{
@@ -57,5 +58,66 @@ namespace TweetDck.Core.Other.Settings{
checkHardwareAcceleration.CheckedChanged += checkHardwareAcceleration_CheckedChanged; checkHardwareAcceleration.CheckedChanged += checkHardwareAcceleration_CheckedChanged;
} }
} }
private void btnExport_Click(object sender, EventArgs e){
DialogResult resultSaveCredentials = MessageBox.Show("Do you want to include your login session? This will not save your password into the file, but it will allow anyone with the file to login into TweetDeck as you.","Export "+Program.BrandName+" Settings",MessageBoxButtons.YesNoCancel,MessageBoxIcon.Question,MessageBoxDefaultButton.Button3);
if (resultSaveCredentials == DialogResult.Cancel)return;
bool saveCredentials = resultSaveCredentials == DialogResult.Yes;
string file;
using(SaveFileDialog dialog = new SaveFileDialog{
AddExtension = true,
AutoUpgradeEnabled = true,
OverwritePrompt = true,
DefaultExt = "tdsettings",
FileName = Program.BrandName+".tdsettings",
Title = "Export "+Program.BrandName+" Settings",
Filter = Program.BrandName+" Settings (*.tdsettings)|*.tdsettings"
}){
file = dialog.ShowDialog() == DialogResult.OK ? dialog.FileName : null;
}
if (file != null){
Program.UserConfig.Save();
ExportManager manager = new ExportManager(file);
if (!manager.Export(saveCredentials)){
Program.HandleException("An exception happened while exporting "+Program.BrandName+" settings.",manager.LastException);
}
}
}
private void btnImport_Click(object sender, EventArgs e){
string file;
using(OpenFileDialog dialog = new OpenFileDialog{
AutoUpgradeEnabled = true,
DereferenceLinks = true,
Title = "Import "+Program.BrandName+" Settings",
Filter = Program.BrandName+" Settings (*.tdsettings)|*.tdsettings"
}){
file = dialog.ShowDialog() == DialogResult.OK ? dialog.FileName : null;
}
if (file != null){
ExportManager manager = new ExportManager(file);
if (manager.Import()){
((FormSettings)ParentForm).ReloadUI();
}
else{
Program.HandleException("An exception happened while importing "+Program.BrandName+" settings.",manager.LastException);
}
}
}
private void btnReset_Click(object sender, EventArgs e){
if (MessageBox.Show("This will reset all of your settings, including disabled plugins. Do you want to proceed?","Reset "+Program.BrandName+" Settings",MessageBoxButtons.YesNo,MessageBoxIcon.Warning,MessageBoxDefaultButton.Button2) == DialogResult.Yes){
Program.ResetConfig();
((FormSettings)ParentForm).ReloadUI();
}
}
} }
} }

View File

@@ -23,19 +23,29 @@
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() { private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.checkExpandLinks = new System.Windows.Forms.CheckBox(); this.checkExpandLinks = new System.Windows.Forms.CheckBox();
this.comboBoxTrayType = new System.Windows.Forms.ComboBox(); this.comboBoxTrayType = new System.Windows.Forms.ComboBox();
this.labelTrayType = new System.Windows.Forms.Label(); this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.checkTrayHighlight = new System.Windows.Forms.CheckBox();
this.groupTray = new System.Windows.Forms.GroupBox();
this.labelTrayIcon = new System.Windows.Forms.Label();
this.groupInterface = new System.Windows.Forms.GroupBox();
this.groupTray.SuspendLayout();
this.groupInterface.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// checkExpandLinks // checkExpandLinks
// //
this.checkExpandLinks.AutoSize = true; this.checkExpandLinks.AutoSize = true;
this.checkExpandLinks.Location = new System.Drawing.Point(9, 9); this.checkExpandLinks.Location = new System.Drawing.Point(9, 21);
this.checkExpandLinks.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
this.checkExpandLinks.Name = "checkExpandLinks"; this.checkExpandLinks.Name = "checkExpandLinks";
this.checkExpandLinks.Size = new System.Drawing.Size(166, 17); this.checkExpandLinks.Size = new System.Drawing.Size(166, 17);
this.checkExpandLinks.TabIndex = 14; this.checkExpandLinks.TabIndex = 14;
this.checkExpandLinks.Text = "Expand Links When Hovered"; this.checkExpandLinks.Text = "Expand Links When Hovered";
this.toolTip.SetToolTip(this.checkExpandLinks, "Expands links inside the tweets. If disabled,\r\nthe full links show up in a toolti" +
"p instead.");
this.checkExpandLinks.UseVisualStyleBackColor = true; this.checkExpandLinks.UseVisualStyleBackColor = true;
this.checkExpandLinks.CheckedChanged += new System.EventHandler(this.checkExpandLinks_CheckedChanged); this.checkExpandLinks.CheckedChanged += new System.EventHandler(this.checkExpandLinks_CheckedChanged);
// //
@@ -43,33 +53,72 @@
// //
this.comboBoxTrayType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxTrayType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxTrayType.FormattingEnabled = true; this.comboBoxTrayType.FormattingEnabled = true;
this.comboBoxTrayType.Location = new System.Drawing.Point(9, 56); this.comboBoxTrayType.Location = new System.Drawing.Point(6, 19);
this.comboBoxTrayType.Name = "comboBoxTrayType"; this.comboBoxTrayType.Name = "comboBoxTrayType";
this.comboBoxTrayType.Size = new System.Drawing.Size(171, 21); this.comboBoxTrayType.Size = new System.Drawing.Size(171, 21);
this.comboBoxTrayType.TabIndex = 13; this.comboBoxTrayType.TabIndex = 13;
this.toolTip.SetToolTip(this.comboBoxTrayType, "Changes behavior of the Tray icon.\r\nRight-click the icon for an action menu.");
this.comboBoxTrayType.SelectedIndexChanged += new System.EventHandler(this.comboBoxTrayType_SelectedIndexChanged); this.comboBoxTrayType.SelectedIndexChanged += new System.EventHandler(this.comboBoxTrayType_SelectedIndexChanged);
// //
// labelTrayType // checkTrayHighlight
// //
this.labelTrayType.AutoSize = true; this.checkTrayHighlight.AutoSize = true;
this.labelTrayType.Location = new System.Drawing.Point(6, 40); this.checkTrayHighlight.Location = new System.Drawing.Point(9, 70);
this.labelTrayType.Margin = new System.Windows.Forms.Padding(3, 11, 3, 0); this.checkTrayHighlight.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
this.labelTrayType.Name = "labelTrayType"; this.checkTrayHighlight.Name = "checkTrayHighlight";
this.labelTrayType.Size = new System.Drawing.Size(52, 13); this.checkTrayHighlight.Size = new System.Drawing.Size(103, 17);
this.labelTrayType.TabIndex = 12; this.checkTrayHighlight.TabIndex = 15;
this.labelTrayType.Text = "Tray Icon"; this.checkTrayHighlight.Text = "Enable Highlight";
this.toolTip.SetToolTip(this.checkTrayHighlight, "Highlights the tray icon if there are new tweets.\r\nOnly works for columns with po" +
"pup or audio notifications.\r\nThe icon resets when the main window is restored.");
this.checkTrayHighlight.UseVisualStyleBackColor = true;
this.checkTrayHighlight.CheckedChanged += new System.EventHandler(this.checkTrayHighlight_CheckedChanged);
//
// groupTray
//
this.groupTray.Controls.Add(this.checkTrayHighlight);
this.groupTray.Controls.Add(this.labelTrayIcon);
this.groupTray.Controls.Add(this.comboBoxTrayType);
this.groupTray.Location = new System.Drawing.Point(9, 63);
this.groupTray.Name = "groupTray";
this.groupTray.Size = new System.Drawing.Size(183, 93);
this.groupTray.TabIndex = 15;
this.groupTray.TabStop = false;
this.groupTray.Text = "System Tray";
//
// labelTrayIcon
//
this.labelTrayIcon.AutoSize = true;
this.labelTrayIcon.Location = new System.Drawing.Point(6, 52);
this.labelTrayIcon.Margin = new System.Windows.Forms.Padding(3, 9, 3, 0);
this.labelTrayIcon.Name = "labelTrayIcon";
this.labelTrayIcon.Size = new System.Drawing.Size(52, 13);
this.labelTrayIcon.TabIndex = 14;
this.labelTrayIcon.Text = "Tray Icon";
//
// groupInterface
//
this.groupInterface.Controls.Add(this.checkExpandLinks);
this.groupInterface.Location = new System.Drawing.Point(9, 9);
this.groupInterface.Name = "groupInterface";
this.groupInterface.Size = new System.Drawing.Size(183, 48);
this.groupInterface.TabIndex = 16;
this.groupInterface.TabStop = false;
this.groupInterface.Text = "User Interface";
// //
// TabSettingsGeneral // TabSettingsGeneral
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.checkExpandLinks); this.Controls.Add(this.groupInterface);
this.Controls.Add(this.comboBoxTrayType); this.Controls.Add(this.groupTray);
this.Controls.Add(this.labelTrayType);
this.Name = "TabSettingsGeneral"; this.Name = "TabSettingsGeneral";
this.Size = new System.Drawing.Size(219, 99); this.Size = new System.Drawing.Size(478, 282);
this.groupTray.ResumeLayout(false);
this.groupTray.PerformLayout();
this.groupInterface.ResumeLayout(false);
this.groupInterface.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
@@ -77,6 +126,10 @@
private System.Windows.Forms.CheckBox checkExpandLinks; private System.Windows.Forms.CheckBox checkExpandLinks;
private System.Windows.Forms.ComboBox comboBoxTrayType; private System.Windows.Forms.ComboBox comboBoxTrayType;
private System.Windows.Forms.Label labelTrayType; private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.GroupBox groupTray;
private System.Windows.Forms.GroupBox groupInterface;
private System.Windows.Forms.Label labelTrayIcon;
private System.Windows.Forms.CheckBox checkTrayHighlight;
} }
} }

View File

@@ -9,9 +9,11 @@ namespace TweetDck.Core.Other.Settings{
comboBoxTrayType.Items.Add("Display Icon Only"); comboBoxTrayType.Items.Add("Display Icon Only");
comboBoxTrayType.Items.Add("Minimize to Tray"); comboBoxTrayType.Items.Add("Minimize to Tray");
comboBoxTrayType.Items.Add("Close to Tray"); comboBoxTrayType.Items.Add("Close to Tray");
comboBoxTrayType.Items.Add("Combined");
comboBoxTrayType.SelectedIndex = Math.Min(Math.Max((int)Config.TrayBehavior,0),comboBoxTrayType.Items.Count-1); comboBoxTrayType.SelectedIndex = Math.Min(Math.Max((int)Config.TrayBehavior,0),comboBoxTrayType.Items.Count-1);
checkExpandLinks.Checked = Program.UserConfig.ExpandLinksOnHover; checkExpandLinks.Checked = Program.UserConfig.ExpandLinksOnHover;
checkTrayHighlight.Checked = Program.UserConfig.EnableTrayHighlight;
} }
private void checkExpandLinks_CheckedChanged(object sender, EventArgs e){ private void checkExpandLinks_CheckedChanged(object sender, EventArgs e){
@@ -25,5 +27,11 @@ namespace TweetDck.Core.Other.Settings{
Config.TrayBehavior = (TrayIcon.Behavior)comboBoxTrayType.SelectedIndex; Config.TrayBehavior = (TrayIcon.Behavior)comboBoxTrayType.SelectedIndex;
} }
private void checkTrayHighlight_CheckedChanged(object sender, EventArgs e){
if (!Ready)return;
Config.EnableTrayHighlight = checkTrayHighlight.Checked;
}
} }
} }

View File

@@ -23,7 +23,9 @@
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() { private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.groupNotificationLocation = new System.Windows.Forms.GroupBox(); this.groupNotificationLocation = new System.Windows.Forms.GroupBox();
this.labelEdgeDistanceValue = new System.Windows.Forms.Label();
this.labelDisplay = new System.Windows.Forms.Label(); this.labelDisplay = new System.Windows.Forms.Label();
this.comboBoxDisplay = new System.Windows.Forms.ComboBox(); this.comboBoxDisplay = new System.Windows.Forms.ComboBox();
this.labelEdgeDistance = new System.Windows.Forms.Label(); this.labelEdgeDistance = new System.Windows.Forms.Label();
@@ -34,20 +36,28 @@
this.radioLocTL = new System.Windows.Forms.RadioButton(); this.radioLocTL = new System.Windows.Forms.RadioButton();
this.trackBarEdgeDistance = new System.Windows.Forms.TrackBar(); this.trackBarEdgeDistance = new System.Windows.Forms.TrackBar();
this.groupNotificationDuration = new System.Windows.Forms.GroupBox(); this.groupNotificationDuration = new System.Windows.Forms.GroupBox();
this.radioDurVeryLong = new System.Windows.Forms.RadioButton(); this.tableLayoutDurationButtons = new System.Windows.Forms.TableLayoutPanel();
this.radioDurLong = new System.Windows.Forms.RadioButton(); this.btnDurationMedium = new TweetDck.Core.Controls.FlatButton();
this.radioDurMedium = new System.Windows.Forms.RadioButton(); this.btnDurationLong = new TweetDck.Core.Controls.FlatButton();
this.radioDurShort = new System.Windows.Forms.RadioButton(); this.btnDurationShort = new TweetDck.Core.Controls.FlatButton();
this.labelDurationValue = new System.Windows.Forms.Label();
this.trackBarDuration = new System.Windows.Forms.TrackBar();
this.groupUserInterface = new System.Windows.Forms.GroupBox(); this.groupUserInterface = new System.Windows.Forms.GroupBox();
this.checkTimerCountDown = new System.Windows.Forms.CheckBox();
this.checkLegacyLoad = new System.Windows.Forms.CheckBox();
this.checkNotificationTimer = new System.Windows.Forms.CheckBox(); this.checkNotificationTimer = new System.Windows.Forms.CheckBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.groupNotificationLocation.SuspendLayout(); this.groupNotificationLocation.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).BeginInit();
this.groupNotificationDuration.SuspendLayout(); this.groupNotificationDuration.SuspendLayout();
this.tableLayoutDurationButtons.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarDuration)).BeginInit();
this.groupUserInterface.SuspendLayout(); this.groupUserInterface.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// groupNotificationLocation // groupNotificationLocation
// //
this.groupNotificationLocation.Controls.Add(this.labelEdgeDistanceValue);
this.groupNotificationLocation.Controls.Add(this.labelDisplay); this.groupNotificationLocation.Controls.Add(this.labelDisplay);
this.groupNotificationLocation.Controls.Add(this.comboBoxDisplay); this.groupNotificationLocation.Controls.Add(this.comboBoxDisplay);
this.groupNotificationLocation.Controls.Add(this.labelEdgeDistance); this.groupNotificationLocation.Controls.Add(this.labelEdgeDistance);
@@ -57,12 +67,23 @@
this.groupNotificationLocation.Controls.Add(this.radioLocTR); this.groupNotificationLocation.Controls.Add(this.radioLocTR);
this.groupNotificationLocation.Controls.Add(this.radioLocTL); this.groupNotificationLocation.Controls.Add(this.radioLocTL);
this.groupNotificationLocation.Controls.Add(this.trackBarEdgeDistance); this.groupNotificationLocation.Controls.Add(this.trackBarEdgeDistance);
this.groupNotificationLocation.Location = new System.Drawing.Point(9, 9); this.groupNotificationLocation.Location = new System.Drawing.Point(198, 9);
this.groupNotificationLocation.Name = "groupNotificationLocation"; this.groupNotificationLocation.Name = "groupNotificationLocation";
this.groupNotificationLocation.Size = new System.Drawing.Size(183, 264); this.groupNotificationLocation.Size = new System.Drawing.Size(183, 264);
this.groupNotificationLocation.TabIndex = 1; this.groupNotificationLocation.TabIndex = 1;
this.groupNotificationLocation.TabStop = false; this.groupNotificationLocation.TabStop = false;
this.groupNotificationLocation.Text = "Notification Location"; this.groupNotificationLocation.Text = "Location";
//
// labelEdgeDistanceValue
//
this.labelEdgeDistanceValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelEdgeDistanceValue.Location = new System.Drawing.Point(143, 214);
this.labelEdgeDistanceValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelEdgeDistanceValue.Name = "labelEdgeDistanceValue";
this.labelEdgeDistanceValue.Size = new System.Drawing.Size(34, 13);
this.labelEdgeDistanceValue.TabIndex = 11;
this.labelEdgeDistanceValue.Text = "0 px";
this.labelEdgeDistanceValue.TextAlign = System.Drawing.ContentAlignment.TopRight;
// //
// labelDisplay // labelDisplay
// //
@@ -105,6 +126,7 @@
this.radioLocCustom.TabIndex = 4; this.radioLocCustom.TabIndex = 4;
this.radioLocCustom.TabStop = true; this.radioLocCustom.TabStop = true;
this.radioLocCustom.Text = "Custom"; this.radioLocCustom.Text = "Custom";
this.toolTip.SetToolTip(this.radioLocCustom, "Drag the notification window to the desired location.");
this.radioLocCustom.UseVisualStyleBackColor = true; this.radioLocCustom.UseVisualStyleBackColor = true;
this.radioLocCustom.CheckedChanged += new System.EventHandler(this.radioLoc_CheckedChanged); this.radioLocCustom.CheckedChanged += new System.EventHandler(this.radioLoc_CheckedChanged);
// //
@@ -165,87 +187,154 @@
this.trackBarEdgeDistance.Maximum = 40; this.trackBarEdgeDistance.Maximum = 40;
this.trackBarEdgeDistance.Minimum = 8; this.trackBarEdgeDistance.Minimum = 8;
this.trackBarEdgeDistance.Name = "trackBarEdgeDistance"; this.trackBarEdgeDistance.Name = "trackBarEdgeDistance";
this.trackBarEdgeDistance.Size = new System.Drawing.Size(171, 45); this.trackBarEdgeDistance.Size = new System.Drawing.Size(141, 45);
this.trackBarEdgeDistance.SmallChange = 2; this.trackBarEdgeDistance.SmallChange = 2;
this.trackBarEdgeDistance.TabIndex = 5; this.trackBarEdgeDistance.TabIndex = 5;
this.trackBarEdgeDistance.TickFrequency = 2; this.trackBarEdgeDistance.TickFrequency = 4;
this.trackBarEdgeDistance.Value = 8; this.trackBarEdgeDistance.Value = 8;
this.trackBarEdgeDistance.ValueChanged += new System.EventHandler(this.trackBarEdgeDistance_ValueChanged); this.trackBarEdgeDistance.ValueChanged += new System.EventHandler(this.trackBarEdgeDistance_ValueChanged);
// //
// groupNotificationDuration // groupNotificationDuration
// //
this.groupNotificationDuration.Controls.Add(this.radioDurVeryLong); this.groupNotificationDuration.Controls.Add(this.tableLayoutDurationButtons);
this.groupNotificationDuration.Controls.Add(this.radioDurLong); this.groupNotificationDuration.Controls.Add(this.labelDurationValue);
this.groupNotificationDuration.Controls.Add(this.radioDurMedium); this.groupNotificationDuration.Controls.Add(this.trackBarDuration);
this.groupNotificationDuration.Controls.Add(this.radioDurShort); this.groupNotificationDuration.Location = new System.Drawing.Point(9, 106);
this.groupNotificationDuration.Location = new System.Drawing.Point(198, 9);
this.groupNotificationDuration.Name = "groupNotificationDuration"; this.groupNotificationDuration.Name = "groupNotificationDuration";
this.groupNotificationDuration.Size = new System.Drawing.Size(183, 119); this.groupNotificationDuration.Size = new System.Drawing.Size(183, 89);
this.groupNotificationDuration.TabIndex = 9; this.groupNotificationDuration.TabIndex = 9;
this.groupNotificationDuration.TabStop = false; this.groupNotificationDuration.TabStop = false;
this.groupNotificationDuration.Text = "Notification Duration"; this.groupNotificationDuration.Text = "Duration";
// //
// radioDurVeryLong // tableLayoutDurationButtons
// //
this.radioDurVeryLong.AutoSize = true; this.tableLayoutDurationButtons.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
this.radioDurVeryLong.Location = new System.Drawing.Point(6, 92); | System.Windows.Forms.AnchorStyles.Right)));
this.radioDurVeryLong.Name = "radioDurVeryLong"; this.tableLayoutDurationButtons.ColumnCount = 3;
this.radioDurVeryLong.Size = new System.Drawing.Size(73, 17); this.tableLayoutDurationButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 32F));
this.radioDurVeryLong.TabIndex = 3; this.tableLayoutDurationButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 36F));
this.radioDurVeryLong.TabStop = true; this.tableLayoutDurationButtons.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 32F));
this.radioDurVeryLong.Text = "Very Long"; this.tableLayoutDurationButtons.Controls.Add(this.btnDurationMedium, 0, 0);
this.radioDurVeryLong.UseVisualStyleBackColor = true; this.tableLayoutDurationButtons.Controls.Add(this.btnDurationLong, 1, 0);
this.radioDurVeryLong.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged); this.tableLayoutDurationButtons.Controls.Add(this.btnDurationShort, 0, 0);
this.radioDurVeryLong.Click += new System.EventHandler(this.radioDur_Click); this.tableLayoutDurationButtons.Location = new System.Drawing.Point(6, 56);
this.tableLayoutDurationButtons.Name = "tableLayoutDurationButtons";
this.tableLayoutDurationButtons.RowCount = 1;
this.tableLayoutDurationButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutDurationButtons.Size = new System.Drawing.Size(171, 27);
this.tableLayoutDurationButtons.TabIndex = 5;
// //
// radioDurLong // btnDurationMedium
// //
this.radioDurLong.AutoSize = true; this.btnDurationMedium.Dock = System.Windows.Forms.DockStyle.Fill;
this.radioDurLong.Location = new System.Drawing.Point(6, 68); this.btnDurationMedium.FlatAppearance.BorderColor = System.Drawing.Color.Gray;
this.radioDurLong.Name = "radioDurLong"; this.btnDurationMedium.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.ControlLight;
this.radioDurLong.Size = new System.Drawing.Size(49, 17); this.btnDurationMedium.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White;
this.radioDurLong.TabIndex = 2; this.btnDurationMedium.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.radioDurLong.TabStop = true; this.btnDurationMedium.Location = new System.Drawing.Point(55, 1);
this.radioDurLong.Text = "Long"; this.btnDurationMedium.Margin = new System.Windows.Forms.Padding(1);
this.radioDurLong.UseVisualStyleBackColor = true; this.btnDurationMedium.Name = "btnDurationMedium";
this.radioDurLong.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged); this.btnDurationMedium.Size = new System.Drawing.Size(59, 25);
this.radioDurLong.Click += new System.EventHandler(this.radioDur_Click); this.btnDurationMedium.TabIndex = 2;
this.btnDurationMedium.Text = "Medium";
this.btnDurationMedium.UseVisualStyleBackColor = true;
this.btnDurationMedium.Click += new System.EventHandler(this.btnDurationMedium_Click);
// //
// radioDurMedium // btnDurationLong
// //
this.radioDurMedium.AutoSize = true; this.btnDurationLong.Dock = System.Windows.Forms.DockStyle.Fill;
this.radioDurMedium.Location = new System.Drawing.Point(6, 44); this.btnDurationLong.FlatAppearance.BorderColor = System.Drawing.Color.Gray;
this.radioDurMedium.Name = "radioDurMedium"; this.btnDurationLong.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.ControlLight;
this.radioDurMedium.Size = new System.Drawing.Size(62, 17); this.btnDurationLong.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White;
this.radioDurMedium.TabIndex = 1; this.btnDurationLong.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.radioDurMedium.TabStop = true; this.btnDurationLong.Location = new System.Drawing.Point(116, 1);
this.radioDurMedium.Text = "Medium"; this.btnDurationLong.Margin = new System.Windows.Forms.Padding(1);
this.radioDurMedium.UseVisualStyleBackColor = true; this.btnDurationLong.Name = "btnDurationLong";
this.radioDurMedium.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged); this.btnDurationLong.Size = new System.Drawing.Size(54, 25);
this.radioDurMedium.Click += new System.EventHandler(this.radioDur_Click); this.btnDurationLong.TabIndex = 1;
this.btnDurationLong.Text = "Long";
this.btnDurationLong.UseVisualStyleBackColor = true;
this.btnDurationLong.Click += new System.EventHandler(this.btnDurationLong_Click);
// //
// radioDurShort // btnDurationShort
// //
this.radioDurShort.AutoSize = true; this.btnDurationShort.Dock = System.Windows.Forms.DockStyle.Fill;
this.radioDurShort.Location = new System.Drawing.Point(6, 20); this.btnDurationShort.FlatAppearance.BorderColor = System.Drawing.Color.Gray;
this.radioDurShort.Name = "radioDurShort"; this.btnDurationShort.FlatAppearance.MouseDownBackColor = System.Drawing.SystemColors.ControlLight;
this.radioDurShort.Size = new System.Drawing.Size(50, 17); this.btnDurationShort.FlatAppearance.MouseOverBackColor = System.Drawing.Color.White;
this.radioDurShort.TabIndex = 0; this.btnDurationShort.FlatStyle = System.Windows.Forms.FlatStyle.Flat;
this.radioDurShort.TabStop = true; this.btnDurationShort.Location = new System.Drawing.Point(1, 1);
this.radioDurShort.Text = "Short"; this.btnDurationShort.Margin = new System.Windows.Forms.Padding(1);
this.radioDurShort.UseVisualStyleBackColor = true; this.btnDurationShort.Name = "btnDurationShort";
this.radioDurShort.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged); this.btnDurationShort.Size = new System.Drawing.Size(52, 25);
this.radioDurShort.Click += new System.EventHandler(this.radioDur_Click); this.btnDurationShort.TabIndex = 0;
this.btnDurationShort.Text = "Short";
this.btnDurationShort.UseVisualStyleBackColor = true;
this.btnDurationShort.Click += new System.EventHandler(this.btnDurationShort_Click);
//
// labelDurationValue
//
this.labelDurationValue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.labelDurationValue.BackColor = System.Drawing.Color.Transparent;
this.labelDurationValue.Location = new System.Drawing.Point(129, 20);
this.labelDurationValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelDurationValue.Name = "labelDurationValue";
this.labelDurationValue.Size = new System.Drawing.Size(48, 13);
this.labelDurationValue.TabIndex = 13;
this.labelDurationValue.Text = "0 ms/c";
this.labelDurationValue.TextAlign = System.Drawing.ContentAlignment.TopRight;
this.toolTip.SetToolTip(this.labelDurationValue, "Milliseconds per character.");
//
// trackBarDuration
//
this.trackBarDuration.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.trackBarDuration.Location = new System.Drawing.Point(6, 19);
this.trackBarDuration.Maximum = 60;
this.trackBarDuration.Minimum = 10;
this.trackBarDuration.Name = "trackBarDuration";
this.trackBarDuration.Size = new System.Drawing.Size(128, 45);
this.trackBarDuration.TabIndex = 12;
this.trackBarDuration.TickFrequency = 5;
this.trackBarDuration.Value = 25;
this.trackBarDuration.ValueChanged += new System.EventHandler(this.trackBarDuration_ValueChanged);
// //
// groupUserInterface // groupUserInterface
// //
this.groupUserInterface.Controls.Add(this.checkTimerCountDown);
this.groupUserInterface.Controls.Add(this.checkLegacyLoad);
this.groupUserInterface.Controls.Add(this.checkNotificationTimer); this.groupUserInterface.Controls.Add(this.checkNotificationTimer);
this.groupUserInterface.Location = new System.Drawing.Point(198, 134); this.groupUserInterface.Location = new System.Drawing.Point(9, 9);
this.groupUserInterface.Name = "groupUserInterface"; this.groupUserInterface.Name = "groupUserInterface";
this.groupUserInterface.Size = new System.Drawing.Size(183, 48); this.groupUserInterface.Size = new System.Drawing.Size(183, 91);
this.groupUserInterface.TabIndex = 10; this.groupUserInterface.TabIndex = 10;
this.groupUserInterface.TabStop = false; this.groupUserInterface.TabStop = false;
this.groupUserInterface.Text = "User Interface"; this.groupUserInterface.Text = "General";
//
// checkTimerCountDown
//
this.checkTimerCountDown.AutoSize = true;
this.checkTimerCountDown.Location = new System.Drawing.Point(6, 44);
this.checkTimerCountDown.Name = "checkTimerCountDown";
this.checkTimerCountDown.Size = new System.Drawing.Size(119, 17);
this.checkTimerCountDown.TabIndex = 6;
this.checkTimerCountDown.Text = "Timer Counts Down";
this.toolTip.SetToolTip(this.checkTimerCountDown, "The notification timer counts down instead of up.");
this.checkTimerCountDown.UseVisualStyleBackColor = true;
this.checkTimerCountDown.CheckedChanged += new System.EventHandler(this.checkTimerCountDown_CheckedChanged);
//
// checkLegacyLoad
//
this.checkLegacyLoad.AutoSize = true;
this.checkLegacyLoad.Location = new System.Drawing.Point(6, 67);
this.checkLegacyLoad.Name = "checkLegacyLoad";
this.checkLegacyLoad.Size = new System.Drawing.Size(139, 17);
this.checkLegacyLoad.TabIndex = 5;
this.checkLegacyLoad.Text = "Legacy Loading System";
this.toolTip.SetToolTip(this.checkLegacyLoad, "Try enabling if notifications do not display.\r\nMight cause delays and visual arti" +
"facts.");
this.checkLegacyLoad.UseVisualStyleBackColor = true;
this.checkLegacyLoad.CheckedChanged += new System.EventHandler(this.checkLegacyLoad_CheckedChanged);
// //
// checkNotificationTimer // checkNotificationTimer
// //
@@ -256,6 +345,7 @@
this.checkNotificationTimer.Size = new System.Drawing.Size(145, 17); this.checkNotificationTimer.Size = new System.Drawing.Size(145, 17);
this.checkNotificationTimer.TabIndex = 4; this.checkNotificationTimer.TabIndex = 4;
this.checkNotificationTimer.Text = "Display Notification Timer"; this.checkNotificationTimer.Text = "Display Notification Timer";
this.toolTip.SetToolTip(this.checkNotificationTimer, "Shows how much time is left before the current notification disappears.");
this.checkNotificationTimer.UseVisualStyleBackColor = true; this.checkNotificationTimer.UseVisualStyleBackColor = true;
this.checkNotificationTimer.CheckedChanged += new System.EventHandler(this.checkNotificationTimer_CheckedChanged); this.checkNotificationTimer.CheckedChanged += new System.EventHandler(this.checkNotificationTimer_CheckedChanged);
// //
@@ -267,13 +357,15 @@
this.Controls.Add(this.groupNotificationDuration); this.Controls.Add(this.groupNotificationDuration);
this.Controls.Add(this.groupNotificationLocation); this.Controls.Add(this.groupNotificationLocation);
this.Name = "TabSettingsNotifications"; this.Name = "TabSettingsNotifications";
this.Size = new System.Drawing.Size(397, 282); this.Size = new System.Drawing.Size(478, 282);
this.ParentChanged += new System.EventHandler(this.TabSettingsNotifications_ParentChanged); this.ParentChanged += new System.EventHandler(this.TabSettingsNotifications_ParentChanged);
this.groupNotificationLocation.ResumeLayout(false); this.groupNotificationLocation.ResumeLayout(false);
this.groupNotificationLocation.PerformLayout(); this.groupNotificationLocation.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).EndInit();
this.groupNotificationDuration.ResumeLayout(false); this.groupNotificationDuration.ResumeLayout(false);
this.groupNotificationDuration.PerformLayout(); this.groupNotificationDuration.PerformLayout();
this.tableLayoutDurationButtons.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.trackBarDuration)).EndInit();
this.groupUserInterface.ResumeLayout(false); this.groupUserInterface.ResumeLayout(false);
this.groupUserInterface.PerformLayout(); this.groupUserInterface.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
@@ -293,11 +385,17 @@
private System.Windows.Forms.RadioButton radioLocTR; private System.Windows.Forms.RadioButton radioLocTR;
private System.Windows.Forms.RadioButton radioLocTL; private System.Windows.Forms.RadioButton radioLocTL;
private System.Windows.Forms.GroupBox groupNotificationDuration; 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;
private System.Windows.Forms.GroupBox groupUserInterface; private System.Windows.Forms.GroupBox groupUserInterface;
private System.Windows.Forms.CheckBox checkNotificationTimer; private System.Windows.Forms.CheckBox checkNotificationTimer;
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.Label labelEdgeDistanceValue;
private System.Windows.Forms.CheckBox checkLegacyLoad;
private System.Windows.Forms.CheckBox checkTimerCountDown;
private System.Windows.Forms.Label labelDurationValue;
private System.Windows.Forms.TrackBar trackBarDuration;
private System.Windows.Forms.TableLayoutPanel tableLayoutDurationButtons;
private TweetDck.Core.Controls.FlatButton btnDurationMedium;
private TweetDck.Core.Controls.FlatButton btnDurationLong;
private TweetDck.Core.Controls.FlatButton btnDurationShort;
} }
} }

View File

@@ -1,6 +1,8 @@
using System; using System;
using System.Globalization;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDck.Core.Handling; using TweetDck.Core.Handling;
using TweetDck.Core.Controls;
namespace TweetDck.Core.Other.Settings{ namespace TweetDck.Core.Other.Settings{
partial class TabSettingsNotifications : BaseTabSettings{ partial class TabSettingsNotifications : BaseTabSettings{
@@ -19,7 +21,7 @@ namespace TweetDck.Core.Other.Settings{
}; };
this.notification.Initialized += (sender, args) => { this.notification.Initialized += (sender, args) => {
this.notification.ShowNotificationForSettings(true); this.InvokeSafe(() => this.notification.ShowNotificationForSettings(true));
}; };
this.notification.Show(this); this.notification.Show(this);
@@ -32,12 +34,8 @@ namespace TweetDck.Core.Other.Settings{
case TweetNotification.Position.Custom: radioLocCustom.Checked = true; break; case TweetNotification.Position.Custom: radioLocCustom.Checked = true; break;
} }
switch(Config.NotificationDuration){ trackBarDuration.Value = Config.NotificationDurationValue;
case TweetNotification.Duration.Short: radioDurShort.Checked = true; break; labelDurationValue.Text = Config.NotificationDurationValue+" ms/c";
case TweetNotification.Duration.Medium: radioDurMedium.Checked = true; break;
case TweetNotification.Duration.Long: radioDurLong.Checked = true; break;
case TweetNotification.Duration.VeryLong: radioDurVeryLong.Checked = true; break;
}
comboBoxDisplay.Items.Add("(Same As "+Program.BrandName+")"); comboBoxDisplay.Items.Add("(Same As "+Program.BrandName+")");
@@ -48,7 +46,14 @@ namespace TweetDck.Core.Other.Settings{
comboBoxDisplay.SelectedIndex = Math.Min(comboBoxDisplay.Items.Count-1,Config.NotificationDisplay); comboBoxDisplay.SelectedIndex = Math.Min(comboBoxDisplay.Items.Count-1,Config.NotificationDisplay);
checkNotificationTimer.Checked = Config.DisplayNotificationTimer; checkNotificationTimer.Checked = Config.DisplayNotificationTimer;
checkTimerCountDown.Enabled = checkNotificationTimer.Checked;
checkTimerCountDown.Checked = Config.NotificationTimerCountDown;
checkLegacyLoad.Checked = Config.NotificationLegacyLoad;
trackBarEdgeDistance.Value = Config.NotificationEdgeDistance; trackBarEdgeDistance.Value = Config.NotificationEdgeDistance;
labelEdgeDistanceValue.Text = trackBarEdgeDistance.Value.ToString(CultureInfo.InvariantCulture)+" px";
Disposed += (sender, args) => this.notification.Dispose();
} }
private void TabSettingsNotifications_ParentChanged(object sender, EventArgs e){ private void TabSettingsNotifications_ParentChanged(object sender, EventArgs e){
@@ -56,7 +61,7 @@ namespace TweetDck.Core.Other.Settings{
notification.HideNotification(false); notification.HideNotification(false);
} }
else{ else{
notification.ShowNotificationForSettings(false); notification.ShowNotificationForSettings(true);
} }
} }
@@ -79,30 +84,54 @@ namespace TweetDck.Core.Other.Settings{
notification.ShowNotificationForSettings(false); notification.ShowNotificationForSettings(false);
} }
private void radioDur_CheckedChanged(object sender, EventArgs e){ private void trackBarDuration_ValueChanged(object sender, EventArgs e){
if (!Ready)return; if (!Ready)return;
if (radioDurShort.Checked)Config.NotificationDuration = TweetNotification.Duration.Short; Config.NotificationDurationValue = trackBarDuration.Value;
else if (radioDurMedium.Checked)Config.NotificationDuration = TweetNotification.Duration.Medium; labelDurationValue.Text = Config.NotificationDurationValue+" ms/c";
else if (radioDurLong.Checked)Config.NotificationDuration = TweetNotification.Duration.Long;
else if (radioDurVeryLong.Checked)Config.NotificationDuration = TweetNotification.Duration.VeryLong;
notification.ShowNotificationForSettings(true); notification.ShowNotificationForSettings(true);
} }
private void radioDur_Click(object sender, EventArgs e){ private void btnDurationShort_Click(object sender, EventArgs e){
if (!Ready)return; if (!Ready)return;
notification.ShowNotificationForSettings(true); trackBarDuration.Value = 15;
}
private void btnDurationMedium_Click(object sender, EventArgs e){
if (!Ready)return;
trackBarDuration.Value = 25;
}
private void btnDurationLong_Click(object sender, EventArgs e){
if (!Ready)return;
trackBarDuration.Value = 35;
} }
private void checkNotificationTimer_CheckedChanged(object sender, EventArgs e){ private void checkNotificationTimer_CheckedChanged(object sender, EventArgs e){
if (!Ready)return; if (!Ready)return;
Config.DisplayNotificationTimer = checkNotificationTimer.Checked; Config.DisplayNotificationTimer = checkNotificationTimer.Checked;
checkTimerCountDown.Enabled = checkNotificationTimer.Checked;
notification.ShowNotificationForSettings(true); notification.ShowNotificationForSettings(true);
} }
private void checkTimerCountDown_CheckedChanged(object sender, EventArgs e){
if (!Ready)return;
Config.NotificationTimerCountDown = checkTimerCountDown.Checked;
notification.ShowNotificationForSettings(true);
}
private void checkLegacyLoad_CheckedChanged(object sender, EventArgs e){
if (!Ready)return;
Config.NotificationLegacyLoad = checkLegacyLoad.Checked;
}
private void comboBoxDisplay_SelectedValueChanged(object sender, EventArgs e){ private void comboBoxDisplay_SelectedValueChanged(object sender, EventArgs e){
if (!Ready)return; if (!Ready)return;
@@ -113,6 +142,7 @@ namespace TweetDck.Core.Other.Settings{
private void trackBarEdgeDistance_ValueChanged(object sender, EventArgs e){ private void trackBarEdgeDistance_ValueChanged(object sender, EventArgs e){
if (!Ready)return; if (!Ready)return;
labelEdgeDistanceValue.Text = trackBarEdgeDistance.Value.ToString(CultureInfo.InvariantCulture)+" px";
Config.NotificationEdgeDistance = trackBarEdgeDistance.Value; Config.NotificationEdgeDistance = trackBarEdgeDistance.Value;
notification.ShowNotificationForSettings(false); notification.ShowNotificationForSettings(false);
} }

View File

@@ -23,41 +23,60 @@
/// the contents of this method with the code editor. /// the contents of this method with the code editor.
/// </summary> /// </summary>
private void InitializeComponent() { private void InitializeComponent() {
this.components = new System.ComponentModel.Container();
this.btnCheckUpdates = new System.Windows.Forms.Button(); this.btnCheckUpdates = new System.Windows.Forms.Button();
this.checkUpdateNotifications = new System.Windows.Forms.CheckBox(); this.checkUpdateNotifications = new System.Windows.Forms.CheckBox();
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.groupGeneral = new System.Windows.Forms.GroupBox();
this.groupGeneral.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// btnCheckUpdates // btnCheckUpdates
// //
this.btnCheckUpdates.Location = new System.Drawing.Point(9, 32); this.btnCheckUpdates.Location = new System.Drawing.Point(6, 44);
this.btnCheckUpdates.Name = "btnCheckUpdates"; this.btnCheckUpdates.Name = "btnCheckUpdates";
this.btnCheckUpdates.Size = new System.Drawing.Size(171, 23); this.btnCheckUpdates.Size = new System.Drawing.Size(171, 23);
this.btnCheckUpdates.TabIndex = 15; this.btnCheckUpdates.TabIndex = 15;
this.btnCheckUpdates.Text = "Check Updates Now"; this.btnCheckUpdates.Text = "Check Updates Now";
this.toolTip.SetToolTip(this.btnCheckUpdates, "Forces an update check, even for updates that had been dismissed.");
this.btnCheckUpdates.UseVisualStyleBackColor = true; this.btnCheckUpdates.UseVisualStyleBackColor = true;
this.btnCheckUpdates.Click += new System.EventHandler(this.btnCheckUpdates_Click); this.btnCheckUpdates.Click += new System.EventHandler(this.btnCheckUpdates_Click);
// //
// checkUpdateNotifications // checkUpdateNotifications
// //
this.checkUpdateNotifications.AutoSize = true; this.checkUpdateNotifications.AutoSize = true;
this.checkUpdateNotifications.Location = new System.Drawing.Point(9, 9); this.checkUpdateNotifications.Location = new System.Drawing.Point(6, 21);
this.checkUpdateNotifications.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
this.checkUpdateNotifications.Name = "checkUpdateNotifications"; this.checkUpdateNotifications.Name = "checkUpdateNotifications";
this.checkUpdateNotifications.Size = new System.Drawing.Size(165, 17); this.checkUpdateNotifications.Size = new System.Drawing.Size(165, 17);
this.checkUpdateNotifications.TabIndex = 14; this.checkUpdateNotifications.TabIndex = 14;
this.checkUpdateNotifications.Text = "Check Updates Automatically"; this.checkUpdateNotifications.Text = "Check Updates Automatically";
this.toolTip.SetToolTip(this.checkUpdateNotifications, "Checks for updates every hour.\r\nIf an update is dismissed, it will not appear aga" +
"in.");
this.checkUpdateNotifications.UseVisualStyleBackColor = true; this.checkUpdateNotifications.UseVisualStyleBackColor = true;
this.checkUpdateNotifications.CheckedChanged += new System.EventHandler(this.checkUpdateNotifications_CheckedChanged); this.checkUpdateNotifications.CheckedChanged += new System.EventHandler(this.checkUpdateNotifications_CheckedChanged);
// //
// groupGeneral
//
this.groupGeneral.Controls.Add(this.checkUpdateNotifications);
this.groupGeneral.Controls.Add(this.btnCheckUpdates);
this.groupGeneral.Location = new System.Drawing.Point(9, 9);
this.groupGeneral.Name = "groupGeneral";
this.groupGeneral.Size = new System.Drawing.Size(183, 75);
this.groupGeneral.TabIndex = 16;
this.groupGeneral.TabStop = false;
this.groupGeneral.Text = "General";
//
// TabSettingsUpdates // TabSettingsUpdates
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.btnCheckUpdates); this.Controls.Add(this.groupGeneral);
this.Controls.Add(this.checkUpdateNotifications);
this.Name = "TabSettingsUpdates"; this.Name = "TabSettingsUpdates";
this.Size = new System.Drawing.Size(211, 78); this.Size = new System.Drawing.Size(478, 282);
this.groupGeneral.ResumeLayout(false);
this.groupGeneral.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout();
} }
@@ -65,5 +84,7 @@
private System.Windows.Forms.Button btnCheckUpdates; private System.Windows.Forms.Button btnCheckUpdates;
private System.Windows.Forms.CheckBox checkUpdateNotifications; private System.Windows.Forms.CheckBox checkUpdateNotifications;
private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.GroupBox groupGeneral;
} }
} }

View File

@@ -5,7 +5,7 @@ using System.Windows.Forms;
namespace TweetDck.Core{ namespace TweetDck.Core{
partial class TrayIcon : Component{ partial class TrayIcon : Component{
public enum Behavior{ // keep order public enum Behavior{ // keep order
Disabled, DisplayOnly, MinimizeToTray, CloseToTray Disabled, DisplayOnly, MinimizeToTray, CloseToTray, Combined
} }
public event EventHandler ClickRestore; public event EventHandler ClickRestore;
@@ -75,4 +75,18 @@ namespace TweetDck.Core{
} }
} }
} }
static class BehaviorExtensions{
public static bool ShouldDisplayIcon(this TrayIcon.Behavior behavior){
return behavior != TrayIcon.Behavior.Disabled;
}
public static bool ShouldHideOnMinimize(this TrayIcon.Behavior behavior){
return behavior == TrayIcon.Behavior.MinimizeToTray || behavior == TrayIcon.Behavior.Combined;
}
public static bool ShouldHideOnClose(this TrayIcon.Behavior behavior){
return behavior == TrayIcon.Behavior.CloseToTray || behavior == TrayIcon.Behavior.Combined;
}
}
} }

View File

@@ -16,10 +16,15 @@ namespace TweetDck.Core.Utils{
public const int SB_HORZ = 0; public const int SB_HORZ = 0;
public const int WH_MOUSE_LL = 14;
public const int WH_MOUSEWHEEL = 0x020A;
public enum MouseButton{ public enum MouseButton{
Left, Right Left, Right
} }
public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);
[DllImport("Shell32.dll")] [DllImport("Shell32.dll")]
public static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2); public static extern int SHChangeNotify(int eventId, int flags, IntPtr item1, IntPtr item2);
@@ -39,6 +44,15 @@ namespace TweetDck.Core.Utils{
[return: MarshalAs(UnmanagedType.Bool)] [return: MarshalAs(UnmanagedType.Bool)]
public static extern bool ShowScrollBar(IntPtr hWnd, int wBar, bool bShow); public static extern bool ShowScrollBar(IntPtr hWnd, int wBar, bool bShow);
[DllImport("user32.dll")]
public static extern IntPtr SetWindowsHookEx(int idHook, HookProc lpfn, IntPtr hInstance, int threadId);
[DllImport("user32.dll")]
public static extern bool UnhookWindowsHookEx(IntPtr idHook);
[DllImport("user32.dll")]
public static extern IntPtr CallNextHookEx(IntPtr idHook, int nCode, IntPtr wParam, IntPtr lParam);
public static void SetFormPos(Form form, int hWndOrder, uint flags){ public static void SetFormPos(Form form, int hWndOrder, uint flags){
SetWindowPos(form.Handle.ToInt32(),hWndOrder,form.Left,form.Top,form.Width,form.Height,flags); SetWindowPos(form.Handle.ToInt32(),hWndOrder,form.Left,form.Top,form.Width,form.Height,flags);
} }

View File

@@ -138,7 +138,7 @@
this.Controls.Add(this.btnToggleState); this.Controls.Add(this.btnToggleState);
this.Controls.Add(this.labelVersion); this.Controls.Add(this.labelVersion);
this.MaximumSize = new System.Drawing.Size(65535, 109); this.MaximumSize = new System.Drawing.Size(65535, 109);
this.MinimumSize = new System.Drawing.Size(0, 83); this.MinimumSize = new System.Drawing.Size(0, 61);
this.Name = "PluginControl"; this.Name = "PluginControl";
this.Padding = new System.Windows.Forms.Padding(3); this.Padding = new System.Windows.Forms.Padding(3);
this.Size = new System.Drawing.Size(530, 109); this.Size = new System.Drawing.Size(530, 109);

View File

@@ -27,13 +27,21 @@ namespace TweetDck.Plugins.Controls{
this.labelName.ForeColor = Color.DarkRed; this.labelName.ForeColor = Color.DarkRed;
this.btnToggleState.Enabled = false; this.btnToggleState.Enabled = false;
} }
else if (labelDescription.Text == string.Empty){
labelDescription.Visible = false;
}
panelDescription_Resize(panelDescription,new EventArgs()); panelDescription_Resize(panelDescription,new EventArgs());
} }
private void panelDescription_Resize(object sender, EventArgs e){ private void panelDescription_Resize(object sender, EventArgs e){
labelDescription.MaximumSize = new Size(panelDescription.Width-SystemInformation.VerticalScrollBarWidth,0); if (labelDescription.Text == string.Empty){
Height = Math.Min(MinimumSize.Height+(labelDescription.Height-13),MaximumSize.Height); Height = MinimumSize.Height;
}
else{
labelDescription.MaximumSize = new Size(panelDescription.Width-SystemInformation.VerticalScrollBarWidth,0);
Height = Math.Min(MinimumSize.Height+9+labelDescription.Height,MaximumSize.Height);
}
} }
private void labelWebsite_Click(object sender, EventArgs e){ private void labelWebsite_Click(object sender, EventArgs e){

View File

@@ -22,6 +22,12 @@ namespace TweetDck.Plugins{
} }
} }
public string FolderPath{
get{
return path;
}
}
private readonly string path; private readonly string path;
private readonly string identifier; private readonly string identifier;
private readonly Dictionary<string,string> metadata = new Dictionary<string,string>(4){ private readonly Dictionary<string,string> metadata = new Dictionary<string,string>(4){

88
Plugins/PluginBridge.cs Normal file
View File

@@ -0,0 +1,88 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace TweetDck.Plugins{
class PluginBridge{
private readonly PluginManager manager;
private readonly Dictionary<string,string> fileCache = new Dictionary<string,string>(2);
public PluginBridge(PluginManager manager){
this.manager = manager;
}
private string GetFullPathIfSafe(int token, string path){
Plugin plugin = manager.GetPluginFromToken(token);
if (plugin == null){
return string.Empty;
}
string fullPath = Path.Combine(plugin.FolderPath,path);
try{
string folderPathName = new DirectoryInfo(plugin.FolderPath).FullName;
DirectoryInfo currentInfo = new DirectoryInfo(fullPath);
while(currentInfo.Parent != null){
if (currentInfo.Parent.FullName == folderPathName){
return fullPath;
}
currentInfo = currentInfo.Parent;
}
}
catch{
// ignore
}
return string.Empty;
}
public void WriteFile(int token, string path, string contents){
string fullPath = GetFullPathIfSafe(token,path);
if (fullPath == string.Empty){
throw new Exception("File path has to be relative to the plugin folder.");
}
// ReSharper disable once AssignNullToNotNullAttribute
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
File.WriteAllText(fullPath,contents,Encoding.UTF8);
fileCache[fullPath] = contents;
}
public string ReadFile(int token, string path){
return ReadFile(token,path,true);
}
public string ReadFile(int token, string path, bool cache){
string fullPath = GetFullPathIfSafe(token,path);
if (fullPath == string.Empty){
throw new Exception("File path has to be relative to the plugin folder.");
}
string cachedContents;
if (fileCache.TryGetValue(fullPath,out cachedContents)){
return cachedContents;
}
return fileCache[fullPath] = File.ReadAllText(fullPath,Encoding.UTF8);
}
public void DeleteFile(int token, string path){
string fullPath = GetFullPathIfSafe(token,path);
if (fullPath == string.Empty){
throw new Exception("File path has to be relative to the plugin folder.");
}
fileCache.Remove(fullPath);
File.Delete(fullPath);
}
}
}

View File

@@ -27,8 +27,8 @@ namespace TweetDck.Plugins{
public static string GetScriptVariables(this PluginEnvironment environment){ public static string GetScriptVariables(this PluginEnvironment environment){
switch(environment){ switch(environment){
case PluginEnvironment.Browser: return "$,$TD,TD"; case PluginEnvironment.Browser: return "$,$TD,$TDP,TD";
case PluginEnvironment.Notification: return "$TD"; case PluginEnvironment.Notification: return "$TD,$TDP";
default: return string.Empty; default: return string.Empty;
} }
} }

View File

@@ -16,17 +16,21 @@ namespace TweetDck.Plugins{
public IEnumerable<Plugin> Plugins { get { return plugins; } } public IEnumerable<Plugin> Plugins { get { return plugins; } }
public PluginConfig Config { get; private set; } public PluginConfig Config { get; private set; }
public PluginBridge Bridge { get; private set; }
public event EventHandler<PluginLoadEventArgs> Reloaded; public event EventHandler<PluginLoadEventArgs> Reloaded;
private readonly string rootPath; private readonly string rootPath;
private readonly HashSet<Plugin> plugins = new HashSet<Plugin>(); private readonly HashSet<Plugin> plugins = new HashSet<Plugin>();
private readonly Dictionary<int,Plugin> tokens = new Dictionary<int,Plugin>();
private readonly Random rand = new Random();
private List<string> loadErrors; private List<string> loadErrors;
public PluginManager(string path, PluginConfig config){ public PluginManager(string path, PluginConfig config){
this.rootPath = path; this.rootPath = path;
this.Config = config; this.Config = config;
this.Bridge = new PluginBridge(this);
} }
public IEnumerable<Plugin> GetPluginsByGroup(PluginGroup group){ public IEnumerable<Plugin> GetPluginsByGroup(PluginGroup group){
@@ -41,9 +45,15 @@ namespace TweetDck.Plugins{
return plugins.Any(plugin => plugin.Environments.HasFlag(environment)); return plugins.Any(plugin => plugin.Environments.HasFlag(environment));
} }
public Plugin GetPluginFromToken(int token){
Plugin plugin;
return tokens.TryGetValue(token,out plugin) ? plugin : null;
}
public void Reload(){ public void Reload(){
HashSet<Plugin> prevPlugins = new HashSet<Plugin>(plugins); HashSet<Plugin> prevPlugins = new HashSet<Plugin>(plugins);
plugins.Clear(); plugins.Clear();
tokens.Clear();
loadErrors = new List<string>(2); loadErrors = new List<string>(2);
@@ -78,7 +88,17 @@ namespace TweetDck.Plugins{
continue; continue;
} }
ScriptLoader.ExecuteScript(frame,PluginScriptGenerator.GeneratePlugin(plugin.Identifier,script,environment),"plugin:"+plugin); int token;
if (tokens.ContainsValue(plugin)){
token = tokens.First(kvp => kvp.Value.Equals(plugin)).Key;
}
else{
token = GenerateToken();
tokens[token] = plugin;
}
ScriptLoader.ExecuteScript(frame,PluginScriptGenerator.GeneratePlugin(plugin.Identifier,script,token,environment),"plugin:"+plugin);
} }
} }
@@ -95,5 +115,17 @@ namespace TweetDck.Plugins{
} }
} }
} }
private int GenerateToken(){
for(int attempt = 0; attempt < 1000; attempt++){
int token = rand.Next();
if (!tokens.ContainsKey(token)){
return token;
}
}
return -tokens.Count;
}
} }
} }

View File

@@ -6,15 +6,18 @@ namespace TweetDck.Plugins{
return config.AnyDisabled ? "window.TD_PLUGINS.disabled = [\""+string.Join("\",\"",config.DisabledPlugins)+"\"];" : string.Empty; return config.AnyDisabled ? "window.TD_PLUGINS.disabled = [\""+string.Join("\",\"",config.DisabledPlugins)+"\"];" : string.Empty;
} }
public static string GeneratePlugin(string pluginIdentifier, string pluginContents, PluginEnvironment environment){ public static string GeneratePlugin(string pluginIdentifier, string pluginContents, int pluginToken, PluginEnvironment environment){
StringBuilder build = new StringBuilder(pluginIdentifier.Length+pluginContents.Length+110); StringBuilder build = new StringBuilder(pluginIdentifier.Length+pluginContents.Length+150);
build.Append("(function(").Append(environment.GetScriptVariables()).Append("){"); build.Append("(function(").Append(environment.GetScriptVariables()).Append("){");
build.Append("window.TD_PLUGINS.install({"); build.Append("let tmp={");
build.Append("id:\"").Append(pluginIdentifier).Append("\","); build.Append("id:\"").Append(pluginIdentifier).Append("\",");
build.Append("obj:new class extends PluginBase{").Append(pluginContents).Append("}"); build.Append("obj:new class extends PluginBase{").Append(pluginContents).Append("}");
build.Append("});"); build.Append("};");
build.Append("tmp.obj.$token=").Append(pluginToken).Append(";");
build.Append("window.TD_PLUGINS.install(tmp);");
build.Append("})(").Append(environment.GetScriptVariables()).Append(");"); build.Append("})(").Append(environment.GetScriptVariables()).Append(");");

View File

@@ -78,6 +78,9 @@
<Compile Include="Configuration\LockManager.cs" /> <Compile Include="Configuration\LockManager.cs" />
<Compile Include="Configuration\UserConfig.cs" /> <Compile Include="Configuration\UserConfig.cs" />
<Compile Include="Core\Controls\ControlExtensions.cs" /> <Compile Include="Core\Controls\ControlExtensions.cs" />
<Compile Include="Core\Controls\FlatButton.cs">
<SubType>Component</SubType>
</Compile>
<Compile Include="Core\Controls\FlatProgressBar.cs"> <Compile Include="Core\Controls\FlatProgressBar.cs">
<SubType>Component</SubType> <SubType>Component</SubType>
</Compile> </Compile>
@@ -186,6 +189,7 @@
</Compile> </Compile>
<Compile Include="Plugins\Plugin.cs" /> <Compile Include="Plugins\Plugin.cs" />
<Compile Include="Plugins\Events\PluginChangedStateEventArgs.cs" /> <Compile Include="Plugins\Events\PluginChangedStateEventArgs.cs" />
<Compile Include="Plugins\PluginBridge.cs" />
<Compile Include="Plugins\PluginConfig.cs" /> <Compile Include="Plugins\PluginConfig.cs" />
<Compile Include="Plugins\PluginEnvironment.cs" /> <Compile Include="Plugins\PluginEnvironment.cs" />
<Compile Include="Plugins\PluginGroup.cs" /> <Compile Include="Plugins\PluginGroup.cs" />