mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-09-14 10:32:10 +02:00
Compare commits
11 Commits
Author | SHA1 | Date | |
---|---|---|---|
5eb64829a5 | |||
5648e9e806 | |||
2a65e20fb9 | |||
1162e9b655 | |||
b8a5c2fb9b | |||
eccd37a3eb | |||
ee282713f8 | |||
c5edad9c4b | |||
293c01b12f | |||
162bbc3221 | |||
9f27020993 |
@@ -80,13 +80,23 @@ namespace TweetDck.Configuration{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Unlock(){
|
public bool Unlock(){
|
||||||
|
bool result = true;
|
||||||
|
|
||||||
if (lockStream != null){
|
if (lockStream != null){
|
||||||
lockStream.Dispose();
|
lockStream.Dispose();
|
||||||
File.Delete(file);
|
|
||||||
|
try{
|
||||||
|
File.Delete(file);
|
||||||
|
}catch(Exception e){
|
||||||
|
Program.Log(e.ToString());
|
||||||
|
result = false;
|
||||||
|
}
|
||||||
|
|
||||||
lockStream = null;
|
lockStream = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool CloseLockingProcess(int timeout){
|
public bool CloseLockingProcess(int timeout){
|
||||||
|
@@ -7,9 +7,9 @@ using TweetDck.Configuration;
|
|||||||
using TweetDck.Core.Handling;
|
using TweetDck.Core.Handling;
|
||||||
using TweetDck.Core.Other;
|
using TweetDck.Core.Other;
|
||||||
using TweetDck.Resources;
|
using TweetDck.Resources;
|
||||||
using TweetDck.Core.Utils;
|
|
||||||
using TweetDck.Core.Controls;
|
using TweetDck.Core.Controls;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
|
using TweetDck.Updates;
|
||||||
|
|
||||||
namespace TweetDck.Core{
|
namespace TweetDck.Core{
|
||||||
sealed partial class FormBrowser : Form{
|
sealed partial class FormBrowser : Form{
|
||||||
@@ -24,6 +24,7 @@ namespace TweetDck.Core{
|
|||||||
private readonly ChromiumWebBrowser browser;
|
private readonly ChromiumWebBrowser browser;
|
||||||
private readonly TweetDeckBridge bridge;
|
private readonly TweetDeckBridge bridge;
|
||||||
private readonly FormNotification notification;
|
private readonly FormNotification notification;
|
||||||
|
private readonly UpdateHandler updates;
|
||||||
|
|
||||||
private FormSettings currentFormSettings;
|
private FormSettings currentFormSettings;
|
||||||
private FormAbout currentFormAbout;
|
private FormAbout currentFormAbout;
|
||||||
@@ -60,6 +61,9 @@ namespace TweetDck.Core{
|
|||||||
notification = CreateNotificationForm(true);
|
notification = CreateNotificationForm(true);
|
||||||
notification.CanMoveWindow = () => false;
|
notification.CanMoveWindow = () => false;
|
||||||
notification.Show();
|
notification.Show();
|
||||||
|
|
||||||
|
updates = new UpdateHandler(browser,this);
|
||||||
|
updates.UpdateAccepted += updates_UpdateAccepted;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ShowChildForm(Form form){
|
private void ShowChildForm(Form form){
|
||||||
@@ -67,6 +71,11 @@ namespace TweetDck.Core{
|
|||||||
form.MoveToCenter(this);
|
form.MoveToCenter(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void ForceClose(){
|
||||||
|
trayIcon.Visible = false; // checked in FormClosing event
|
||||||
|
Close();
|
||||||
|
}
|
||||||
|
|
||||||
public FormNotification CreateNotificationForm(bool autoHide){
|
public FormNotification CreateNotificationForm(bool autoHide){
|
||||||
return new FormNotification(this,bridge,trayIcon,autoHide);
|
return new FormNotification(this,bridge,trayIcon,autoHide);
|
||||||
}
|
}
|
||||||
@@ -105,7 +114,7 @@ namespace TweetDck.Core{
|
|||||||
|
|
||||||
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||||
if (e.Frame.IsMain){
|
if (e.Frame.IsMain){
|
||||||
foreach(string js in ScriptLoader.LoadResources("code.js","update.js").Where(js => js != null)){
|
foreach(string js in ScriptLoader.LoadResources("code.js").Where(js => js != null)){
|
||||||
browser.ExecuteScriptAsync(js);
|
browser.ExecuteScriptAsync(js);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,8 +180,26 @@ namespace TweetDck.Core{
|
|||||||
private void trayIcon_ClickClose(object sender, EventArgs e){
|
private void trayIcon_ClickClose(object sender, EventArgs e){
|
||||||
if (!isLoaded)return;
|
if (!isLoaded)return;
|
||||||
|
|
||||||
trayIcon.Visible = false; // checked in FormClosing event
|
ForceClose();
|
||||||
Close();
|
}
|
||||||
|
|
||||||
|
private void updates_UpdateAccepted(object sender, UpdateAcceptedEventArgs e){
|
||||||
|
Hide();
|
||||||
|
|
||||||
|
FormUpdateDownload downloadForm = new FormUpdateDownload(e.UpdateInfo);
|
||||||
|
downloadForm.MoveToCenter(this);
|
||||||
|
downloadForm.ShowDialog();
|
||||||
|
|
||||||
|
if (downloadForm.UpdateStatus == FormUpdateDownload.Status.Succeeded){
|
||||||
|
UpdateInstallerPath = downloadForm.InstallerPath;
|
||||||
|
ForceClose();
|
||||||
|
}
|
||||||
|
else if (downloadForm.UpdateStatus == FormUpdateDownload.Status.Manual){
|
||||||
|
ForceClose();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
Show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void WndProc(ref Message m){
|
protected override void WndProc(ref Message m){
|
||||||
@@ -193,7 +220,7 @@ namespace TweetDck.Core{
|
|||||||
else{
|
else{
|
||||||
bool prevEnableUpdateCheck = Config.EnableUpdateCheck;
|
bool prevEnableUpdateCheck = Config.EnableUpdateCheck;
|
||||||
|
|
||||||
currentFormSettings = new FormSettings(this);
|
currentFormSettings = new FormSettings(this,updates);
|
||||||
|
|
||||||
currentFormSettings.FormClosed += (sender, args) => {
|
currentFormSettings.FormClosed += (sender, args) => {
|
||||||
currentFormSettings = null;
|
currentFormSettings = null;
|
||||||
@@ -201,8 +228,7 @@ namespace TweetDck.Core{
|
|||||||
if (!prevEnableUpdateCheck && Config.EnableUpdateCheck){
|
if (!prevEnableUpdateCheck && Config.EnableUpdateCheck){
|
||||||
Config.DismissedUpdate = string.Empty;
|
Config.DismissedUpdate = string.Empty;
|
||||||
Config.Save();
|
Config.Save();
|
||||||
|
updates.Check(false);
|
||||||
browser.ExecuteScriptAsync("TDGF_runUpdateCheck",new object[0]);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -252,24 +278,5 @@ namespace TweetDck.Core{
|
|||||||
public void OnImagePastedFinish(){
|
public void OnImagePastedFinish(){
|
||||||
browser.ExecuteScriptAsync("TDGF_tryPasteImageFinish",new object[0]);
|
browser.ExecuteScriptAsync("TDGF_tryPasteImageFinish",new object[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void BeginUpdateProcess(string versionTag, string downloadUrl){
|
|
||||||
Hide();
|
|
||||||
|
|
||||||
FormUpdateDownload downloadForm = new FormUpdateDownload(new UpdateInfo(versionTag,downloadUrl));
|
|
||||||
downloadForm.MoveToCenter(this);
|
|
||||||
downloadForm.ShowDialog();
|
|
||||||
|
|
||||||
if (downloadForm.UpdateStatus == FormUpdateDownload.Status.Succeeded){
|
|
||||||
UpdateInstallerPath = downloadForm.InstallerPath;
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
else if (downloadForm.UpdateStatus == FormUpdateDownload.Status.Manual){
|
|
||||||
Close();
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
Show();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -8,6 +8,7 @@ namespace TweetDck.Core.Handling{
|
|||||||
private const int MenuAbout = 26601;
|
private const int MenuAbout = 26601;
|
||||||
private const int MenuMute = 26602;
|
private const int MenuMute = 26602;
|
||||||
private const int MenuCopyTweetUrl = 26603;
|
private const int MenuCopyTweetUrl = 26603;
|
||||||
|
private const int MenuCopyTweetEmbeddedUrl = 26604;
|
||||||
|
|
||||||
private readonly FormBrowser form;
|
private readonly FormBrowser form;
|
||||||
|
|
||||||
@@ -24,6 +25,11 @@ namespace TweetDck.Core.Handling{
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(TweetDeckBridge.LastHighlightedTweet)){
|
if (!string.IsNullOrEmpty(TweetDeckBridge.LastHighlightedTweet)){
|
||||||
model.AddItem((CefMenuCommand)MenuCopyTweetUrl,"Copy tweet address");
|
model.AddItem((CefMenuCommand)MenuCopyTweetUrl,"Copy tweet address");
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(TweetDeckBridge.LastHighlightedTweetEmbedded)){
|
||||||
|
model.AddItem((CefMenuCommand)MenuCopyTweetEmbeddedUrl,"Copy quoted tweet address");
|
||||||
|
}
|
||||||
|
|
||||||
model.AddSeparator();
|
model.AddSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +77,10 @@ namespace TweetDck.Core.Handling{
|
|||||||
case MenuCopyTweetUrl:
|
case MenuCopyTweetUrl:
|
||||||
Clipboard.SetText(TweetDeckBridge.LastHighlightedTweet,TextDataFormat.UnicodeText);
|
Clipboard.SetText(TweetDeckBridge.LastHighlightedTweet,TextDataFormat.UnicodeText);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case MenuCopyTweetEmbeddedUrl:
|
||||||
|
Clipboard.SetText(TweetDeckBridge.LastHighlightedTweetEmbedded,TextDataFormat.UnicodeText);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@@ -7,6 +7,7 @@ namespace TweetDck.Core.Handling{
|
|||||||
private const int MenuSkipTweet = 26600;
|
private const int MenuSkipTweet = 26600;
|
||||||
private const int MenuFreeze = 26601;
|
private const int MenuFreeze = 26601;
|
||||||
private const int MenuCopyTweetUrl = 26602;
|
private const int MenuCopyTweetUrl = 26602;
|
||||||
|
private const int MenuCopyTweetEmbeddedUrl = 26603;
|
||||||
|
|
||||||
private readonly FormNotification form;
|
private readonly FormNotification form;
|
||||||
private readonly bool enableCustomMenu;
|
private readonly bool enableCustomMenu;
|
||||||
@@ -27,6 +28,11 @@ namespace TweetDck.Core.Handling{
|
|||||||
|
|
||||||
if (!string.IsNullOrEmpty(form.CurrentUrl)){
|
if (!string.IsNullOrEmpty(form.CurrentUrl)){
|
||||||
model.AddItem((CefMenuCommand)MenuCopyTweetUrl,"Copy tweet address");
|
model.AddItem((CefMenuCommand)MenuCopyTweetUrl,"Copy tweet address");
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(TweetDeckBridge.NotificationTweetEmbedded)){
|
||||||
|
model.AddItem((CefMenuCommand)MenuCopyTweetEmbeddedUrl,"Copy quoted tweet address");
|
||||||
|
}
|
||||||
|
|
||||||
model.AddSeparator();
|
model.AddSeparator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -54,6 +60,10 @@ namespace TweetDck.Core.Handling{
|
|||||||
case MenuCopyTweetUrl:
|
case MenuCopyTweetUrl:
|
||||||
Clipboard.SetText(form.CurrentUrl,TextDataFormat.UnicodeText);
|
Clipboard.SetText(form.CurrentUrl,TextDataFormat.UnicodeText);
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
case MenuCopyTweetEmbeddedUrl:
|
||||||
|
Clipboard.SetText(TweetDeckBridge.NotificationTweetEmbedded,TextDataFormat.UnicodeText);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@@ -10,6 +10,8 @@ namespace TweetDck.Core.Handling{
|
|||||||
class TweetDeckBridge{
|
class TweetDeckBridge{
|
||||||
public static string LastRightClickedLink = string.Empty;
|
public static string LastRightClickedLink = string.Empty;
|
||||||
public static string LastHighlightedTweet = string.Empty;
|
public static string LastHighlightedTweet = string.Empty;
|
||||||
|
public static string LastHighlightedTweetEmbedded = string.Empty;
|
||||||
|
public static string NotificationTweetEmbedded = string.Empty;
|
||||||
public static string ClipboardImagePath = string.Empty;
|
public static string ClipboardImagePath = string.Empty;
|
||||||
|
|
||||||
private readonly FormBrowser form;
|
private readonly FormBrowser form;
|
||||||
@@ -32,24 +34,12 @@ namespace TweetDck.Core.Handling{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool UpdateCheckEnabled{
|
|
||||||
get{
|
|
||||||
return Program.UserConfig.EnableUpdateCheck;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool ExpandLinksOnHover{
|
public bool ExpandLinksOnHover{
|
||||||
get{
|
get{
|
||||||
return Program.UserConfig.ExpandLinksOnHover;
|
return Program.UserConfig.ExpandLinksOnHover;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public string DismissedVersionTag{
|
|
||||||
get{
|
|
||||||
return Program.UserConfig.DismissedUpdate ?? string.Empty;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public TweetDeckBridge(FormBrowser form){
|
public TweetDeckBridge(FormBrowser form){
|
||||||
this.form = form;
|
this.form = form;
|
||||||
}
|
}
|
||||||
@@ -70,8 +60,15 @@ namespace TweetDck.Core.Handling{
|
|||||||
form.InvokeSafe(() => LastRightClickedLink = link);
|
form.InvokeSafe(() => LastRightClickedLink = link);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetLastHighlightedTweet(string link){
|
public void SetLastHighlightedTweet(string link, string embeddedLink){
|
||||||
form.InvokeSafe(() => LastHighlightedTweet = link);
|
form.InvokeSafe(() => {
|
||||||
|
LastHighlightedTweet = link;
|
||||||
|
LastHighlightedTweetEmbedded = embeddedLink;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetNotificationTweetEmbedded(string link){
|
||||||
|
form.InvokeSafe(() => NotificationTweetEmbedded = link);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OpenSettingsMenu(){
|
public void OpenSettingsMenu(){
|
||||||
@@ -88,19 +85,6 @@ namespace TweetDck.Core.Handling{
|
|||||||
form.InvokeSafe(form.OnTweetSound);
|
form.InvokeSafe(form.OnTweetSound);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnUpdateAccepted(string versionTag, string downloadUrl){
|
|
||||||
form.InvokeSafe(() => {
|
|
||||||
form.BeginUpdateProcess(versionTag,downloadUrl);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void OnUpdateDismissed(string versionTag){
|
|
||||||
form.InvokeSafe(() => {
|
|
||||||
Program.UserConfig.DismissedUpdate = versionTag;
|
|
||||||
Program.UserConfig.Save();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DisplayTooltip(string text, bool showInNotification){
|
public void DisplayTooltip(string text, bool showInNotification){
|
||||||
form.InvokeSafe(() => {
|
form.InvokeSafe(() => {
|
||||||
form.DisplayTooltip(text,showInNotification);
|
form.DisplayTooltip(text,showInNotification);
|
||||||
|
159
Core/Other/FormSettings.Designer.cs
generated
159
Core/Other/FormSettings.Designer.cs
generated
@@ -47,12 +47,23 @@
|
|||||||
this.radioDurLong = new System.Windows.Forms.RadioButton();
|
this.radioDurLong = new System.Windows.Forms.RadioButton();
|
||||||
this.radioDurMedium = new System.Windows.Forms.RadioButton();
|
this.radioDurMedium = new System.Windows.Forms.RadioButton();
|
||||||
this.radioDurShort = new System.Windows.Forms.RadioButton();
|
this.radioDurShort = new System.Windows.Forms.RadioButton();
|
||||||
|
this.tableColumn3Panel = new System.Windows.Forms.Panel();
|
||||||
|
this.groupAdvancedSettings = new System.Windows.Forms.GroupBox();
|
||||||
|
this.btnClearCache = new System.Windows.Forms.Button();
|
||||||
|
this.labelMiscellaneous = new System.Windows.Forms.Label();
|
||||||
|
this.checkHardwareAcceleration = new System.Windows.Forms.CheckBox();
|
||||||
|
this.tableColumn1Panel = new System.Windows.Forms.Panel();
|
||||||
|
this.labelUpdateNotifications = new System.Windows.Forms.Label();
|
||||||
|
this.btnCheckUpdates = new System.Windows.Forms.Button();
|
||||||
this.groupNotificationLocation.SuspendLayout();
|
this.groupNotificationLocation.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).BeginInit();
|
||||||
this.tableLayout.SuspendLayout();
|
this.tableLayout.SuspendLayout();
|
||||||
this.tableColumn2Panel.SuspendLayout();
|
this.tableColumn2Panel.SuspendLayout();
|
||||||
this.groupUserInterface.SuspendLayout();
|
this.groupUserInterface.SuspendLayout();
|
||||||
this.groupNotificationDuration.SuspendLayout();
|
this.groupNotificationDuration.SuspendLayout();
|
||||||
|
this.tableColumn3Panel.SuspendLayout();
|
||||||
|
this.groupAdvancedSettings.SuspendLayout();
|
||||||
|
this.tableColumn1Panel.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// groupNotificationLocation
|
// groupNotificationLocation
|
||||||
@@ -69,9 +80,9 @@
|
|||||||
this.groupNotificationLocation.Controls.Add(this.radioLocBL);
|
this.groupNotificationLocation.Controls.Add(this.radioLocBL);
|
||||||
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.Location = new System.Drawing.Point(6, 6);
|
this.groupNotificationLocation.Location = new System.Drawing.Point(3, 3);
|
||||||
this.groupNotificationLocation.Name = "groupNotificationLocation";
|
this.groupNotificationLocation.Name = "groupNotificationLocation";
|
||||||
this.groupNotificationLocation.Size = new System.Drawing.Size(183, 278);
|
this.groupNotificationLocation.Size = new System.Drawing.Size(183, 324);
|
||||||
this.groupNotificationLocation.TabIndex = 0;
|
this.groupNotificationLocation.TabIndex = 0;
|
||||||
this.groupNotificationLocation.TabStop = false;
|
this.groupNotificationLocation.TabStop = false;
|
||||||
this.groupNotificationLocation.Text = "Notification Location";
|
this.groupNotificationLocation.Text = "Notification Location";
|
||||||
@@ -79,7 +90,7 @@
|
|||||||
// labelDisplay
|
// labelDisplay
|
||||||
//
|
//
|
||||||
this.labelDisplay.AutoSize = true;
|
this.labelDisplay.AutoSize = true;
|
||||||
this.labelDisplay.Location = new System.Drawing.Point(6, 148);
|
this.labelDisplay.Location = new System.Drawing.Point(3, 148);
|
||||||
this.labelDisplay.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
this.labelDisplay.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||||
this.labelDisplay.Name = "labelDisplay";
|
this.labelDisplay.Name = "labelDisplay";
|
||||||
this.labelDisplay.Size = new System.Drawing.Size(41, 13);
|
this.labelDisplay.Size = new System.Drawing.Size(41, 13);
|
||||||
@@ -92,16 +103,16 @@
|
|||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
this.comboBoxDisplay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
this.comboBoxDisplay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||||
this.comboBoxDisplay.FormattingEnabled = true;
|
this.comboBoxDisplay.FormattingEnabled = true;
|
||||||
this.comboBoxDisplay.Location = new System.Drawing.Point(9, 164);
|
this.comboBoxDisplay.Location = new System.Drawing.Point(6, 164);
|
||||||
this.comboBoxDisplay.Name = "comboBoxDisplay";
|
this.comboBoxDisplay.Name = "comboBoxDisplay";
|
||||||
this.comboBoxDisplay.Size = new System.Drawing.Size(168, 21);
|
this.comboBoxDisplay.Size = new System.Drawing.Size(171, 21);
|
||||||
this.comboBoxDisplay.TabIndex = 7;
|
this.comboBoxDisplay.TabIndex = 7;
|
||||||
this.comboBoxDisplay.SelectedValueChanged += new System.EventHandler(this.comboBoxDisplay_SelectedValueChanged);
|
this.comboBoxDisplay.SelectedValueChanged += new System.EventHandler(this.comboBoxDisplay_SelectedValueChanged);
|
||||||
//
|
//
|
||||||
// labelEdgeDistance
|
// labelEdgeDistance
|
||||||
//
|
//
|
||||||
this.labelEdgeDistance.AutoSize = true;
|
this.labelEdgeDistance.AutoSize = true;
|
||||||
this.labelEdgeDistance.Location = new System.Drawing.Point(6, 197);
|
this.labelEdgeDistance.Location = new System.Drawing.Point(3, 197);
|
||||||
this.labelEdgeDistance.Margin = new System.Windows.Forms.Padding(3, 9, 3, 0);
|
this.labelEdgeDistance.Margin = new System.Windows.Forms.Padding(3, 9, 3, 0);
|
||||||
this.labelEdgeDistance.Name = "labelEdgeDistance";
|
this.labelEdgeDistance.Name = "labelEdgeDistance";
|
||||||
this.labelEdgeDistance.Size = new System.Drawing.Size(103, 13);
|
this.labelEdgeDistance.Size = new System.Drawing.Size(103, 13);
|
||||||
@@ -191,11 +202,13 @@
|
|||||||
//
|
//
|
||||||
// tableLayout
|
// tableLayout
|
||||||
//
|
//
|
||||||
this.tableLayout.ColumnCount = 2;
|
this.tableLayout.ColumnCount = 3;
|
||||||
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33F));
|
||||||
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50F));
|
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.33F));
|
||||||
|
this.tableLayout.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 33.34F));
|
||||||
|
this.tableLayout.Controls.Add(this.tableColumn1Panel, 0, 0);
|
||||||
this.tableLayout.Controls.Add(this.tableColumn2Panel, 1, 0);
|
this.tableLayout.Controls.Add(this.tableColumn2Panel, 1, 0);
|
||||||
this.tableLayout.Controls.Add(this.groupNotificationLocation, 0, 0);
|
this.tableLayout.Controls.Add(this.tableColumn3Panel, 2, 0);
|
||||||
this.tableLayout.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.tableLayout.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.tableLayout.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize;
|
this.tableLayout.GrowStyle = System.Windows.Forms.TableLayoutPanelGrowStyle.FixedSize;
|
||||||
this.tableLayout.Location = new System.Drawing.Point(0, 0);
|
this.tableLayout.Location = new System.Drawing.Point(0, 0);
|
||||||
@@ -203,18 +216,18 @@
|
|||||||
this.tableLayout.Padding = new System.Windows.Forms.Padding(3);
|
this.tableLayout.Padding = new System.Windows.Forms.Padding(3);
|
||||||
this.tableLayout.RowCount = 1;
|
this.tableLayout.RowCount = 1;
|
||||||
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
this.tableLayout.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||||
this.tableLayout.Size = new System.Drawing.Size(384, 290);
|
this.tableLayout.Size = new System.Drawing.Size(576, 336);
|
||||||
this.tableLayout.TabIndex = 2;
|
this.tableLayout.TabIndex = 2;
|
||||||
//
|
//
|
||||||
// tableColumn2Panel
|
// tableColumn2Panel
|
||||||
//
|
//
|
||||||
this.tableColumn2Panel.Controls.Add(this.groupUserInterface);
|
|
||||||
this.tableColumn2Panel.Controls.Add(this.groupNotificationDuration);
|
this.tableColumn2Panel.Controls.Add(this.groupNotificationDuration);
|
||||||
|
this.tableColumn2Panel.Controls.Add(this.groupUserInterface);
|
||||||
this.tableColumn2Panel.Dock = System.Windows.Forms.DockStyle.Fill;
|
this.tableColumn2Panel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
this.tableColumn2Panel.Location = new System.Drawing.Point(192, 3);
|
this.tableColumn2Panel.Location = new System.Drawing.Point(192, 3);
|
||||||
this.tableColumn2Panel.Margin = new System.Windows.Forms.Padding(0);
|
this.tableColumn2Panel.Margin = new System.Windows.Forms.Padding(0);
|
||||||
this.tableColumn2Panel.Name = "tableColumn2Panel";
|
this.tableColumn2Panel.Name = "tableColumn2Panel";
|
||||||
this.tableColumn2Panel.Size = new System.Drawing.Size(189, 284);
|
this.tableColumn2Panel.Size = new System.Drawing.Size(189, 330);
|
||||||
this.tableColumn2Panel.TabIndex = 3;
|
this.tableColumn2Panel.TabIndex = 3;
|
||||||
//
|
//
|
||||||
// groupUserInterface
|
// groupUserInterface
|
||||||
@@ -222,6 +235,8 @@
|
|||||||
this.groupUserInterface.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
this.groupUserInterface.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||||
| System.Windows.Forms.AnchorStyles.Left)
|
| System.Windows.Forms.AnchorStyles.Left)
|
||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
|
this.groupUserInterface.Controls.Add(this.btnCheckUpdates);
|
||||||
|
this.groupUserInterface.Controls.Add(this.labelUpdateNotifications);
|
||||||
this.groupUserInterface.Controls.Add(this.checkExpandLinks);
|
this.groupUserInterface.Controls.Add(this.checkExpandLinks);
|
||||||
this.groupUserInterface.Controls.Add(this.comboBoxTrayType);
|
this.groupUserInterface.Controls.Add(this.comboBoxTrayType);
|
||||||
this.groupUserInterface.Controls.Add(this.labelTrayType);
|
this.groupUserInterface.Controls.Add(this.labelTrayType);
|
||||||
@@ -229,7 +244,7 @@
|
|||||||
this.groupUserInterface.Controls.Add(this.checkNotificationTimer);
|
this.groupUserInterface.Controls.Add(this.checkNotificationTimer);
|
||||||
this.groupUserInterface.Location = new System.Drawing.Point(3, 128);
|
this.groupUserInterface.Location = new System.Drawing.Point(3, 128);
|
||||||
this.groupUserInterface.Name = "groupUserInterface";
|
this.groupUserInterface.Name = "groupUserInterface";
|
||||||
this.groupUserInterface.Size = new System.Drawing.Size(183, 153);
|
this.groupUserInterface.Size = new System.Drawing.Size(183, 199);
|
||||||
this.groupUserInterface.TabIndex = 3;
|
this.groupUserInterface.TabIndex = 3;
|
||||||
this.groupUserInterface.TabStop = false;
|
this.groupUserInterface.TabStop = false;
|
||||||
this.groupUserInterface.Text = "User Interface";
|
this.groupUserInterface.Text = "User Interface";
|
||||||
@@ -252,17 +267,16 @@
|
|||||||
| System.Windows.Forms.AnchorStyles.Right)));
|
| System.Windows.Forms.AnchorStyles.Right)));
|
||||||
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, 116);
|
this.comboBoxTrayType.Location = new System.Drawing.Point(6, 92);
|
||||||
this.comboBoxTrayType.Margin = new System.Windows.Forms.Padding(3, 3, 3, 12);
|
|
||||||
this.comboBoxTrayType.Name = "comboBoxTrayType";
|
this.comboBoxTrayType.Name = "comboBoxTrayType";
|
||||||
this.comboBoxTrayType.Size = new System.Drawing.Size(168, 21);
|
this.comboBoxTrayType.Size = new System.Drawing.Size(171, 21);
|
||||||
this.comboBoxTrayType.TabIndex = 10;
|
this.comboBoxTrayType.TabIndex = 10;
|
||||||
this.comboBoxTrayType.SelectedIndexChanged += new System.EventHandler(this.comboBoxTrayType_SelectedIndexChanged);
|
this.comboBoxTrayType.SelectedIndexChanged += new System.EventHandler(this.comboBoxTrayType_SelectedIndexChanged);
|
||||||
//
|
//
|
||||||
// labelTrayType
|
// labelTrayType
|
||||||
//
|
//
|
||||||
this.labelTrayType.AutoSize = true;
|
this.labelTrayType.AutoSize = true;
|
||||||
this.labelTrayType.Location = new System.Drawing.Point(6, 100);
|
this.labelTrayType.Location = new System.Drawing.Point(3, 76);
|
||||||
this.labelTrayType.Margin = new System.Windows.Forms.Padding(3, 11, 3, 0);
|
this.labelTrayType.Margin = new System.Windows.Forms.Padding(3, 11, 3, 0);
|
||||||
this.labelTrayType.Name = "labelTrayType";
|
this.labelTrayType.Name = "labelTrayType";
|
||||||
this.labelTrayType.Size = new System.Drawing.Size(52, 13);
|
this.labelTrayType.Size = new System.Drawing.Size(52, 13);
|
||||||
@@ -272,12 +286,12 @@
|
|||||||
// checkUpdateNotifications
|
// checkUpdateNotifications
|
||||||
//
|
//
|
||||||
this.checkUpdateNotifications.AutoSize = true;
|
this.checkUpdateNotifications.AutoSize = true;
|
||||||
this.checkUpdateNotifications.Location = new System.Drawing.Point(6, 69);
|
this.checkUpdateNotifications.Location = new System.Drawing.Point(6, 145);
|
||||||
this.checkUpdateNotifications.Margin = new System.Windows.Forms.Padding(3, 4, 3, 3);
|
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(115, 17);
|
this.checkUpdateNotifications.Size = new System.Drawing.Size(165, 17);
|
||||||
this.checkUpdateNotifications.TabIndex = 5;
|
this.checkUpdateNotifications.TabIndex = 5;
|
||||||
this.checkUpdateNotifications.Text = "Check for Updates";
|
this.checkUpdateNotifications.Text = "Check Updates Automatically";
|
||||||
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);
|
||||||
//
|
//
|
||||||
@@ -360,11 +374,98 @@
|
|||||||
this.radioDurShort.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged);
|
this.radioDurShort.CheckedChanged += new System.EventHandler(this.radioDur_CheckedChanged);
|
||||||
this.radioDurShort.Click += new System.EventHandler(this.radioDur_Click);
|
this.radioDurShort.Click += new System.EventHandler(this.radioDur_Click);
|
||||||
//
|
//
|
||||||
|
// tableColumn3Panel
|
||||||
|
//
|
||||||
|
this.tableColumn3Panel.Controls.Add(this.groupAdvancedSettings);
|
||||||
|
this.tableColumn3Panel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableColumn3Panel.Location = new System.Drawing.Point(381, 3);
|
||||||
|
this.tableColumn3Panel.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.tableColumn3Panel.Name = "tableColumn3Panel";
|
||||||
|
this.tableColumn3Panel.Size = new System.Drawing.Size(192, 330);
|
||||||
|
this.tableColumn3Panel.TabIndex = 4;
|
||||||
|
//
|
||||||
|
// groupAdvancedSettings
|
||||||
|
//
|
||||||
|
this.groupAdvancedSettings.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.groupAdvancedSettings.Controls.Add(this.btnClearCache);
|
||||||
|
this.groupAdvancedSettings.Controls.Add(this.labelMiscellaneous);
|
||||||
|
this.groupAdvancedSettings.Controls.Add(this.checkHardwareAcceleration);
|
||||||
|
this.groupAdvancedSettings.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.groupAdvancedSettings.Name = "groupAdvancedSettings";
|
||||||
|
this.groupAdvancedSettings.Size = new System.Drawing.Size(183, 324);
|
||||||
|
this.groupAdvancedSettings.TabIndex = 0;
|
||||||
|
this.groupAdvancedSettings.TabStop = false;
|
||||||
|
this.groupAdvancedSettings.Text = "Advanced Settings";
|
||||||
|
//
|
||||||
|
// btnClearCache
|
||||||
|
//
|
||||||
|
this.btnClearCache.Location = new System.Drawing.Point(9, 68);
|
||||||
|
this.btnClearCache.Name = "btnClearCache";
|
||||||
|
this.btnClearCache.Size = new System.Drawing.Size(171, 23);
|
||||||
|
this.btnClearCache.TabIndex = 11;
|
||||||
|
this.btnClearCache.Text = "Clear Cache (calculating)";
|
||||||
|
this.btnClearCache.UseVisualStyleBackColor = true;
|
||||||
|
this.btnClearCache.Click += new System.EventHandler(this.btnClearCache_Click);
|
||||||
|
//
|
||||||
|
// labelMiscellaneous
|
||||||
|
//
|
||||||
|
this.labelMiscellaneous.AutoSize = true;
|
||||||
|
this.labelMiscellaneous.Location = new System.Drawing.Point(6, 52);
|
||||||
|
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 = 10;
|
||||||
|
this.labelMiscellaneous.Text = "Miscellaneous";
|
||||||
|
//
|
||||||
|
// checkHardwareAcceleration
|
||||||
|
//
|
||||||
|
this.checkHardwareAcceleration.AutoSize = true;
|
||||||
|
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.Size = new System.Drawing.Size(134, 17);
|
||||||
|
this.checkHardwareAcceleration.TabIndex = 5;
|
||||||
|
this.checkHardwareAcceleration.Text = "Hardware Acceleration";
|
||||||
|
this.checkHardwareAcceleration.UseVisualStyleBackColor = true;
|
||||||
|
this.checkHardwareAcceleration.CheckedChanged += new System.EventHandler(this.checkHardwareAcceleration_CheckedChanged);
|
||||||
|
//
|
||||||
|
// tableColumn1Panel
|
||||||
|
//
|
||||||
|
this.tableColumn1Panel.Controls.Add(this.groupNotificationLocation);
|
||||||
|
this.tableColumn1Panel.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.tableColumn1Panel.Location = new System.Drawing.Point(3, 3);
|
||||||
|
this.tableColumn1Panel.Margin = new System.Windows.Forms.Padding(0);
|
||||||
|
this.tableColumn1Panel.Name = "tableColumn1Panel";
|
||||||
|
this.tableColumn1Panel.Size = new System.Drawing.Size(189, 330);
|
||||||
|
this.tableColumn1Panel.TabIndex = 5;
|
||||||
|
//
|
||||||
|
// labelUpdateNotifications
|
||||||
|
//
|
||||||
|
this.labelUpdateNotifications.AutoSize = true;
|
||||||
|
this.labelUpdateNotifications.Location = new System.Drawing.Point(3, 127);
|
||||||
|
this.labelUpdateNotifications.Margin = new System.Windows.Forms.Padding(3, 11, 3, 0);
|
||||||
|
this.labelUpdateNotifications.Name = "labelUpdateNotifications";
|
||||||
|
this.labelUpdateNotifications.Size = new System.Drawing.Size(103, 13);
|
||||||
|
this.labelUpdateNotifications.TabIndex = 12;
|
||||||
|
this.labelUpdateNotifications.Text = "Update Notifications";
|
||||||
|
//
|
||||||
|
// btnCheckUpdates
|
||||||
|
//
|
||||||
|
this.btnCheckUpdates.Location = new System.Drawing.Point(6, 168);
|
||||||
|
this.btnCheckUpdates.Name = "btnCheckUpdates";
|
||||||
|
this.btnCheckUpdates.Size = new System.Drawing.Size(171, 23);
|
||||||
|
this.btnCheckUpdates.TabIndex = 13;
|
||||||
|
this.btnCheckUpdates.Text = "Check Updates Now";
|
||||||
|
this.btnCheckUpdates.UseVisualStyleBackColor = true;
|
||||||
|
this.btnCheckUpdates.Click += new System.EventHandler(this.btnCheckUpdates_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(384, 290);
|
this.ClientSize = new System.Drawing.Size(576, 336);
|
||||||
this.Controls.Add(this.tableLayout);
|
this.Controls.Add(this.tableLayout);
|
||||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||||
@@ -382,6 +483,10 @@
|
|||||||
this.groupUserInterface.PerformLayout();
|
this.groupUserInterface.PerformLayout();
|
||||||
this.groupNotificationDuration.ResumeLayout(false);
|
this.groupNotificationDuration.ResumeLayout(false);
|
||||||
this.groupNotificationDuration.PerformLayout();
|
this.groupNotificationDuration.PerformLayout();
|
||||||
|
this.tableColumn3Panel.ResumeLayout(false);
|
||||||
|
this.groupAdvancedSettings.ResumeLayout(false);
|
||||||
|
this.groupAdvancedSettings.PerformLayout();
|
||||||
|
this.tableColumn1Panel.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -411,5 +516,13 @@
|
|||||||
private System.Windows.Forms.ComboBox comboBoxTrayType;
|
private System.Windows.Forms.ComboBox comboBoxTrayType;
|
||||||
private System.Windows.Forms.Label labelTrayType;
|
private System.Windows.Forms.Label labelTrayType;
|
||||||
private System.Windows.Forms.CheckBox checkExpandLinks;
|
private System.Windows.Forms.CheckBox checkExpandLinks;
|
||||||
|
private System.Windows.Forms.Panel tableColumn3Panel;
|
||||||
|
private System.Windows.Forms.GroupBox groupAdvancedSettings;
|
||||||
|
private System.Windows.Forms.CheckBox checkHardwareAcceleration;
|
||||||
|
private System.Windows.Forms.Label labelMiscellaneous;
|
||||||
|
private System.Windows.Forms.Button btnClearCache;
|
||||||
|
private System.Windows.Forms.Panel tableColumn1Panel;
|
||||||
|
private System.Windows.Forms.Label labelUpdateNotifications;
|
||||||
|
private System.Windows.Forms.Button btnCheckUpdates;
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -1,7 +1,11 @@
|
|||||||
using System;
|
using System;
|
||||||
|
using System.Diagnostics;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using TweetDck.Configuration;
|
using TweetDck.Configuration;
|
||||||
using TweetDck.Core.Handling;
|
using TweetDck.Core.Handling;
|
||||||
|
using TweetDck.Core.Utils;
|
||||||
|
using TweetDck.Core.Controls;
|
||||||
|
using TweetDck.Updates;
|
||||||
|
|
||||||
namespace TweetDck.Core.Other{
|
namespace TweetDck.Core.Other{
|
||||||
sealed partial class FormSettings : Form{
|
sealed partial class FormSettings : Form{
|
||||||
@@ -12,14 +16,22 @@ namespace TweetDck.Core.Other{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private readonly FormNotification notification;
|
private readonly FormNotification notification;
|
||||||
private bool isLoaded;
|
private readonly UpdateHandler updates;
|
||||||
|
|
||||||
public FormSettings(FormBrowser browserForm){
|
private bool isLoaded;
|
||||||
|
private int updateCheckEventId;
|
||||||
|
|
||||||
|
public FormSettings(FormBrowser browserForm, UpdateHandler updates){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Shown += (sender, args) => isLoaded = true;
|
Shown += (sender, args) => isLoaded = true;
|
||||||
|
|
||||||
Text = Program.BrandName+" Settings";
|
Text = Program.BrandName+" Settings";
|
||||||
|
|
||||||
|
this.updates = updates;
|
||||||
|
|
||||||
|
updates.CheckFinished += updates_CheckFinished;
|
||||||
|
Disposed += (sender, args) => updates.CheckFinished -= updates_CheckFinished;
|
||||||
|
|
||||||
notification = browserForm.CreateNotificationForm(false);
|
notification = browserForm.CreateNotificationForm(false);
|
||||||
notification.CanMoveWindow = () => radioLocCustom.Checked;
|
notification.CanMoveWindow = () => radioLocCustom.Checked;
|
||||||
|
|
||||||
@@ -64,6 +76,16 @@ namespace TweetDck.Core.Other{
|
|||||||
checkNotificationTimer.Checked = Config.DisplayNotificationTimer;
|
checkNotificationTimer.Checked = Config.DisplayNotificationTimer;
|
||||||
checkExpandLinks.Checked = Config.ExpandLinksOnHover;
|
checkExpandLinks.Checked = Config.ExpandLinksOnHover;
|
||||||
checkUpdateNotifications.Checked = Config.EnableUpdateCheck;
|
checkUpdateNotifications.Checked = Config.EnableUpdateCheck;
|
||||||
|
checkHardwareAcceleration.Checked = HardwareAcceleration.IsEnabled;
|
||||||
|
|
||||||
|
BrowserCache.CalculateCacheSize(bytes => this.InvokeSafe(() => {
|
||||||
|
if (bytes == -1L){
|
||||||
|
btnClearCache.Text = "Clear Cache (unknown size)";
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
btnClearCache.Text = "Clear Cache ("+(int)Math.Ceiling(bytes/(1024.0*1024.0))+" MB)";
|
||||||
|
}
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormSettings_FormClosing(object sender, FormClosingEventArgs e){
|
private void FormSettings_FormClosing(object sender, FormClosingEventArgs e){
|
||||||
@@ -150,5 +172,68 @@ namespace TweetDck.Core.Other{
|
|||||||
|
|
||||||
Config.EnableUpdateCheck = checkUpdateNotifications.Checked;
|
Config.EnableUpdateCheck = checkUpdateNotifications.Checked;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void checkHardwareAcceleration_CheckedChanged(object sender, EventArgs e){
|
||||||
|
if (!isLoaded)return;
|
||||||
|
|
||||||
|
bool succeeded = false;
|
||||||
|
|
||||||
|
if (checkHardwareAcceleration.Checked){
|
||||||
|
if (HardwareAcceleration.CanEnable){
|
||||||
|
succeeded = HardwareAcceleration.Enable();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
MessageBox.Show("Cannot enable hardware acceleration, the libraries libEGL.dll and libGLESv2.dll could not be restored.",Program.BrandName+" Settings",MessageBoxButtons.OK,MessageBoxIcon.Error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
succeeded = HardwareAcceleration.Disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (succeeded && MessageBox.Show("The application must restart for the setting to take place. Do you want to restart now?",Program.BrandName+" Settings",MessageBoxButtons.YesNo,MessageBoxIcon.Information) == DialogResult.Yes){ // TODO
|
||||||
|
Process.Start(Application.ExecutablePath,"-restart");
|
||||||
|
Application.Exit();
|
||||||
|
}
|
||||||
|
else if (!succeeded){
|
||||||
|
checkHardwareAcceleration.CheckedChanged -= checkHardwareAcceleration_CheckedChanged;
|
||||||
|
checkHardwareAcceleration.Checked = HardwareAcceleration.IsEnabled;
|
||||||
|
checkHardwareAcceleration.CheckedChanged += checkHardwareAcceleration_CheckedChanged;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnClearCache_Click(object sender, EventArgs e){
|
||||||
|
if (!isLoaded)return;
|
||||||
|
|
||||||
|
isLoaded = false;
|
||||||
|
btnClearCache.Enabled = false;
|
||||||
|
isLoaded = true; // OTHERWISE WINFORMS CALLS THE ONCLICK EVENT FOR A RANDOM RADIO BUTTON WHAT THE CUNTFUCK IS THIS
|
||||||
|
|
||||||
|
BrowserCache.SetClearOnExit();
|
||||||
|
|
||||||
|
MessageBox.Show("Cache will be automatically cleared when "+Program.BrandName+" exits.","Clear Cache",MessageBoxButtons.OK,MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void btnCheckUpdates_Click(object sender, EventArgs e){
|
||||||
|
if (!isLoaded)return;
|
||||||
|
|
||||||
|
Config.DismissedUpdate = string.Empty;
|
||||||
|
Config.Save();
|
||||||
|
|
||||||
|
updateCheckEventId = updates.Check(true);
|
||||||
|
|
||||||
|
isLoaded = false;
|
||||||
|
btnCheckUpdates.Enabled = false;
|
||||||
|
isLoaded = true; // SAME AS ABOVE
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updates_CheckFinished(object sender, UpdateCheckEventArgs e){
|
||||||
|
if (e.EventId == updateCheckEventId){
|
||||||
|
btnCheckUpdates.Enabled = true;
|
||||||
|
|
||||||
|
if (!e.UpdateAvailable){
|
||||||
|
MessageBox.Show("Your version of "+Program.BrandName+" is up to date.","No Updates Available",MessageBoxButtons.OK,MessageBoxIcon.Information);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
53
Core/Utils/BrowserCache.cs
Normal file
53
Core/Utils/BrowserCache.cs
Normal file
@@ -0,0 +1,53 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace TweetDck.Core.Utils{
|
||||||
|
static class BrowserCache{
|
||||||
|
private static bool ClearOnExit { get; set; }
|
||||||
|
|
||||||
|
private static readonly string IndexFile = Path.Combine(Program.StoragePath,"index");
|
||||||
|
|
||||||
|
private static IEnumerable<string> CacheFiles{
|
||||||
|
get{
|
||||||
|
return Directory.EnumerateFiles(Program.StoragePath).Where(path => {
|
||||||
|
string file = Path.GetFileName(path);
|
||||||
|
return file != null && (file.StartsWith("data_",StringComparison.Ordinal) || file.StartsWith("f_",StringComparison.Ordinal));
|
||||||
|
}).Concat(new[]{ IndexFile });
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void CalculateCacheSize(Action<long> callbackBytes){
|
||||||
|
Task<long> task = new Task<long>(() => {
|
||||||
|
return CacheFiles.Select(file => {
|
||||||
|
try{
|
||||||
|
return new FileInfo(file).Length;
|
||||||
|
}catch{
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
}).Sum();
|
||||||
|
});
|
||||||
|
|
||||||
|
task.ContinueWith(originalTask => callbackBytes(originalTask.Exception == null ? originalTask.Result : -1L),TaskContinuationOptions.ExecuteSynchronously);
|
||||||
|
task.Start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void SetClearOnExit(){
|
||||||
|
ClearOnExit = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Exit(){
|
||||||
|
if (ClearOnExit){
|
||||||
|
foreach(string file in CacheFiles){
|
||||||
|
try{
|
||||||
|
File.Delete(file);
|
||||||
|
}catch{
|
||||||
|
// welp, too bad
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
60
Core/Utils/HardwareAcceleration.cs
Normal file
60
Core/Utils/HardwareAcceleration.cs
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
using System;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
|
namespace TweetDck.Core.Utils{
|
||||||
|
static class HardwareAcceleration{
|
||||||
|
private static readonly string LibEGL = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"libEGL.dll");
|
||||||
|
private static readonly string LibGLES = Path.Combine(AppDomain.CurrentDomain.BaseDirectory,"libGLESv2.dll");
|
||||||
|
|
||||||
|
private static readonly string DisabledLibEGL = LibEGL+".bak";
|
||||||
|
private static readonly string DisabledLibGLES = LibGLES+".bak";
|
||||||
|
|
||||||
|
public static bool IsEnabled{
|
||||||
|
get{
|
||||||
|
return File.Exists(LibEGL) && File.Exists(LibGLES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool CanEnable{
|
||||||
|
get{
|
||||||
|
return File.Exists(DisabledLibEGL) && File.Exists(DisabledLibGLES);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Enable(){
|
||||||
|
if (IsEnabled)return false;
|
||||||
|
|
||||||
|
try{
|
||||||
|
File.Move(DisabledLibEGL,LibEGL);
|
||||||
|
File.Move(DisabledLibGLES,LibGLES);
|
||||||
|
return true;
|
||||||
|
}catch{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static bool Disable(){
|
||||||
|
if (!IsEnabled)return false;
|
||||||
|
|
||||||
|
try{
|
||||||
|
if (File.Exists(DisabledLibEGL)){
|
||||||
|
File.Delete(DisabledLibEGL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (File.Exists(DisabledLibGLES)){
|
||||||
|
File.Delete(DisabledLibGLES);
|
||||||
|
}
|
||||||
|
}catch{
|
||||||
|
// woops
|
||||||
|
}
|
||||||
|
|
||||||
|
try{
|
||||||
|
File.Move(LibEGL,DisabledLibEGL);
|
||||||
|
File.Move(LibGLES,DisabledLibGLES);
|
||||||
|
return true;
|
||||||
|
}catch{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
52
Program.cs
52
Program.cs
@@ -9,6 +9,8 @@ using TweetDck.Configuration;
|
|||||||
using TweetDck.Core;
|
using TweetDck.Core;
|
||||||
using TweetDck.Migration;
|
using TweetDck.Migration;
|
||||||
using TweetDck.Core.Utils;
|
using TweetDck.Core.Utils;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading;
|
||||||
|
|
||||||
[assembly: CLSCompliant(true)]
|
[assembly: CLSCompliant(true)]
|
||||||
namespace TweetDck{
|
namespace TweetDck{
|
||||||
@@ -21,13 +23,14 @@ namespace TweetDck{
|
|||||||
public const string Website = "http://tweetdick.chylex.com";
|
public const string Website = "http://tweetdick.chylex.com";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
public const string VersionTag = "1.2.1";
|
public const string VersionTag = "1.2.3";
|
||||||
public const string VersionFull = "1.2.1.0";
|
public const string VersionFull = "1.2.3.0";
|
||||||
|
|
||||||
public static readonly string StoragePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),BrandName);
|
public static readonly string StoragePath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),BrandName);
|
||||||
public static readonly string TemporaryPath = Path.Combine(Path.GetTempPath(),BrandName);
|
public static readonly string TemporaryPath = Path.Combine(Path.GetTempPath(),BrandName);
|
||||||
|
|
||||||
private static readonly LockManager LockManager = new LockManager(Path.Combine(StoragePath,".lock"));
|
private static readonly LockManager LockManager = new LockManager(Path.Combine(StoragePath,".lock"));
|
||||||
|
private static bool HasCleanedUp;
|
||||||
|
|
||||||
public static UserConfig UserConfig { get; private set; }
|
public static UserConfig UserConfig { get; private set; }
|
||||||
|
|
||||||
@@ -42,16 +45,32 @@ namespace TweetDck{
|
|||||||
Application.EnableVisualStyles();
|
Application.EnableVisualStyles();
|
||||||
Application.SetCompatibleTextRenderingDefault(false);
|
Application.SetCompatibleTextRenderingDefault(false);
|
||||||
|
|
||||||
if (!LockManager.Lock()){
|
if (Environment.GetCommandLineArgs().Contains("-restart")){
|
||||||
if (MessageBox.Show("Another instance of "+BrandName+" is already running.\r\nDo you want to close it?",BrandName+" is Already Running",MessageBoxButtons.YesNo,MessageBoxIcon.Error,MessageBoxDefaultButton.Button2) == DialogResult.Yes){
|
for(int attempt = 0; attempt < 21; attempt++){
|
||||||
if (!LockManager.CloseLockingProcess(10000)){
|
if (LockManager.Lock()){
|
||||||
MessageBox.Show("Could not close the other process.",BrandName+" Has Failed :(",MessageBoxButtons.OK,MessageBoxIcon.Error);
|
break;
|
||||||
|
}
|
||||||
|
else if (attempt == 20){
|
||||||
|
MessageBox.Show(BrandName+" is taking too long to close, please wait and then start the application again manually.",BrandName+" Cannot Restart",MessageBoxButtons.OK,MessageBoxIcon.Error);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else{
|
||||||
LockManager.Lock();
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (!LockManager.Lock()){
|
||||||
|
if (MessageBox.Show("Another instance of "+BrandName+" is already running.\r\nDo you want to close it?",BrandName+" is Already Running",MessageBoxButtons.YesNo,MessageBoxIcon.Error,MessageBoxDefaultButton.Button2) == DialogResult.Yes){
|
||||||
|
if (!LockManager.CloseLockingProcess(10000)){
|
||||||
|
MessageBox.Show("Could not close the other process.",BrandName+" Has Failed :(",MessageBoxButtons.OK,MessageBoxIcon.Error);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LockManager.Lock();
|
||||||
|
}
|
||||||
|
else return;
|
||||||
}
|
}
|
||||||
else return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
UserConfig = UserConfig.Load(Path.Combine(StoragePath,"TD_UserConfig.cfg"));
|
UserConfig = UserConfig.Load(Path.Combine(StoragePath,"TD_UserConfig.cfg"));
|
||||||
@@ -83,11 +102,7 @@ namespace TweetDck{
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Application.ApplicationExit += (sender, args) => {
|
Application.ApplicationExit += (sender, args) => ExitCleanup();
|
||||||
UserConfig.Save();
|
|
||||||
ExitCleanup();
|
|
||||||
Cef.Shutdown();
|
|
||||||
};
|
|
||||||
|
|
||||||
FormBrowser mainForm = new FormBrowser();
|
FormBrowser mainForm = new FormBrowser();
|
||||||
Application.Run(mainForm);
|
Application.Run(mainForm);
|
||||||
@@ -126,8 +141,11 @@ namespace TweetDck{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void ExitCleanup(){
|
private static void ExitCleanup(){
|
||||||
|
if (HasCleanedUp)return;
|
||||||
|
|
||||||
|
UserConfig.Save();
|
||||||
|
|
||||||
try{
|
try{
|
||||||
LockManager.Unlock();
|
|
||||||
Directory.Delete(TemporaryPath,true);
|
Directory.Delete(TemporaryPath,true);
|
||||||
}catch(DirectoryNotFoundException){
|
}catch(DirectoryNotFoundException){
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
@@ -136,6 +154,10 @@ namespace TweetDck{
|
|||||||
}
|
}
|
||||||
|
|
||||||
Cef.Shutdown();
|
Cef.Shutdown();
|
||||||
|
BrowserCache.Exit();
|
||||||
|
|
||||||
|
LockManager.Unlock();
|
||||||
|
HasCleanedUp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -16,8 +16,8 @@ namespace TweetDck.Resources{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IList<string> LoadResources(params string[] names){
|
public static IEnumerable<string> LoadResources(params string[] names){
|
||||||
return names.Select(LoadResource).ToList();
|
return names.Select(LoadResource);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -173,7 +173,7 @@
|
|||||||
var me = $(this);
|
var me = $(this);
|
||||||
var rel = me.attr("rel");
|
var rel = me.attr("rel");
|
||||||
|
|
||||||
if (!me.is(".link-complex") && !(rel === "mediaPreview" && me.closest("#open-modal").length === 0) && rel !== "list" && rel !== "user"){
|
if (!me.is(".link-complex") && !(rel === "mediaPreview" && me.closest("#open-modal").length === 0) && rel !== "list" && rel !== "user" && rel !== "tweet"){
|
||||||
$TD.openBrowser(me.attr("href"));
|
$TD.openBrowser(me.attr("href"));
|
||||||
onUrlOpened();
|
onUrlOpened();
|
||||||
}
|
}
|
||||||
@@ -223,13 +223,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($TD.expandLinksOnHover){
|
if ($TD.expandLinksOnHover){
|
||||||
var expanded = me.attr("data-full-url");
|
tooltipTimer = window.setTimeout(function(){
|
||||||
expanded = cutStart(expanded,"https://");
|
var expanded = me.attr("data-full-url");
|
||||||
expanded = cutStart(expanded,"http://");
|
expanded = cutStart(expanded,"https://");
|
||||||
expanded = cutStart(expanded,"www.");
|
expanded = cutStart(expanded,"http://");
|
||||||
|
expanded = cutStart(expanded,"www.");
|
||||||
|
|
||||||
me.attr("td-prev-text",text);
|
me.attr("td-prev-text",text);
|
||||||
me.text(expanded);
|
me.text(expanded);
|
||||||
|
},200);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
tooltipTimer = window.setTimeout(function(){
|
tooltipTimer = window.setTimeout(function(){
|
||||||
@@ -247,8 +249,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.clearTimeout(tooltipTimer);
|
||||||
|
|
||||||
if (tooltipDisplayed){
|
if (tooltipDisplayed){
|
||||||
window.clearTimeout(tooltipTimer);
|
|
||||||
tooltipDisplayed = false;
|
tooltipDisplayed = false;
|
||||||
$TD.displayTooltip(null,false);
|
$TD.displayTooltip(null,false);
|
||||||
}
|
}
|
||||||
@@ -315,9 +318,9 @@
|
|||||||
(function(){
|
(function(){
|
||||||
var lastTweet = "";
|
var lastTweet = "";
|
||||||
|
|
||||||
var updateHighlightedTweet = function(link){
|
var updateHighlightedTweet = function(link, embeddedLink){
|
||||||
if (lastTweet != link){
|
if (lastTweet != link){
|
||||||
$TD.setLastHighlightedTweet(link);
|
$TD.setLastHighlightedTweet(link,embeddedLink);
|
||||||
lastTweet = link;
|
lastTweet = link;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -327,11 +330,13 @@
|
|||||||
highlightedTweetEle = $(this);
|
highlightedTweetEle = $(this);
|
||||||
|
|
||||||
var link = $(this).find("time").first().children("a").first();
|
var link = $(this).find("time").first().children("a").first();
|
||||||
updateHighlightedTweet(link.length > 0 ? link.attr("href") : "");
|
var embedded = $(this).find(".quoted-tweet[data-tweet-id]").first();
|
||||||
|
|
||||||
|
updateHighlightedTweet(link.length > 0 ? link.attr("href") : "",embedded.length > 0 ? embedded.find(".account-link").first().attr("href")+"/status/"+embedded.attr("data-tweet-id") : "");
|
||||||
}
|
}
|
||||||
else if (e.type === "mouseleave"){
|
else if (e.type === "mouseleave"){
|
||||||
highlightedTweetEle = null;
|
highlightedTweetEle = null;
|
||||||
updateHighlightedTweet("");
|
updateHighlightedTweet("","");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
@@ -50,13 +50,15 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($TD.expandLinksOnHover){
|
if ($TD.expandLinksOnHover){
|
||||||
var expanded = url;
|
tooltipTimer = window.setTimeout(function(){
|
||||||
expanded = cutStart(expanded,"https://");
|
var expanded = url;
|
||||||
expanded = cutStart(expanded,"http://");
|
expanded = cutStart(expanded,"https://");
|
||||||
expanded = cutStart(expanded,"www.");
|
expanded = cutStart(expanded,"http://");
|
||||||
|
expanded = cutStart(expanded,"www.");
|
||||||
|
|
||||||
e.currentTarget.setAttribute("td-prev-text",text);
|
e.currentTarget.setAttribute("td-prev-text",text);
|
||||||
e.currentTarget.innerHTML = expanded;
|
e.currentTarget.innerHTML = expanded;
|
||||||
|
},200);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
tooltipTimer = window.setTimeout(function(){
|
tooltipTimer = window.setTimeout(function(){
|
||||||
@@ -77,8 +79,9 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
window.clearTimeout(tooltipTimer);
|
||||||
|
|
||||||
if (tooltipDisplayed){
|
if (tooltipDisplayed){
|
||||||
window.clearTimeout(tooltipTimer);
|
|
||||||
tooltipDisplayed = false;
|
tooltipDisplayed = false;
|
||||||
$TD.displayTooltip(null,true);
|
$TD.displayTooltip(null,true);
|
||||||
}
|
}
|
||||||
@@ -95,4 +98,20 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
//
|
||||||
|
// Block: Setup embedded tweet address for context menu
|
||||||
|
//
|
||||||
|
(function(){
|
||||||
|
var embedded = document.getElementsByClassName("quoted-tweet");
|
||||||
|
if (embedded.length === 0)return;
|
||||||
|
|
||||||
|
var tweetId = embedded[0].getAttribute("data-tweet-id");
|
||||||
|
if (!tweetId)return;
|
||||||
|
|
||||||
|
var account = embedded[0].getElementsByClassName("account-link");
|
||||||
|
if (account.length === 0)return;
|
||||||
|
|
||||||
|
$TD.setNotificationTweetEmbedded(account[0].getAttribute("href")+"/status/"+tweetId);
|
||||||
|
})();
|
||||||
})($TD);
|
})($TD);
|
@@ -1,4 +1,4 @@
|
|||||||
(function($,$TD){
|
(function($,$TDU){
|
||||||
//
|
//
|
||||||
// Variable: Current timeout ID for update checking.
|
// Variable: Current timeout ID for update checking.
|
||||||
//
|
//
|
||||||
@@ -7,7 +7,12 @@
|
|||||||
//
|
//
|
||||||
// Constant: Update exe file name.
|
// Constant: Update exe file name.
|
||||||
//
|
//
|
||||||
const updateFileName = $TD.brandName+".Update.exe";
|
const updateFileName = $TDU.brandName+".Update.exe";
|
||||||
|
|
||||||
|
//
|
||||||
|
// Constant: Url that returns JSON data about latest version.
|
||||||
|
//
|
||||||
|
const updateCheckUrl = "https://api.github.com/repos/chylex/"+$TDU.brandName+"/releases/latest";
|
||||||
|
|
||||||
//
|
//
|
||||||
// Function: Creates the update notification element. Removes the old one if already exists.
|
// Function: Creates the update notification element. Removes the old one if already exists.
|
||||||
@@ -22,7 +27,7 @@
|
|||||||
|
|
||||||
var html = [
|
var html = [
|
||||||
"<div id='tweetdck-update'>",
|
"<div id='tweetdck-update'>",
|
||||||
"<p class='tdu-title'>"+$TD.brandName+" Update</p>",
|
"<p class='tdu-title'>"+$TDU.brandName+" Update</p>",
|
||||||
"<p class='tdu-info'>Version "+version+" is now available.</p>",
|
"<p class='tdu-info'>Version "+version+" is now available.</p>",
|
||||||
"<div class='tdu-buttons'>",
|
"<div class='tdu-buttons'>",
|
||||||
"<button class='btn btn-positive tdu-btn-download'><span class='label'>Download</button>",
|
"<button class='btn btn-positive tdu-btn-download'><span class='label'>Download</button>",
|
||||||
@@ -85,11 +90,11 @@
|
|||||||
|
|
||||||
buttonDiv.children(".tdu-btn-download").click(function(){
|
buttonDiv.children(".tdu-btn-download").click(function(){
|
||||||
ele.remove();
|
ele.remove();
|
||||||
$TD.onUpdateAccepted(version,download);
|
$TDU.onUpdateAccepted(version,download);
|
||||||
});
|
});
|
||||||
|
|
||||||
buttonDiv.children(".tdu-btn-dismiss").click(function(){
|
buttonDiv.children(".tdu-btn-dismiss").click(function(){
|
||||||
$TD.onUpdateDismissed(version);
|
$TDU.onUpdateDismissed(version);
|
||||||
ele.slideUp(function(){ ele.remove(); });
|
ele.slideUp(function(){ ele.remove(); });
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -103,25 +108,30 @@
|
|||||||
//
|
//
|
||||||
// Function: Runs an update check and updates all DOM elements appropriately.
|
// Function: Runs an update check and updates all DOM elements appropriately.
|
||||||
//
|
//
|
||||||
var runUpdateCheck = function(){
|
var runUpdateCheck = function(force, eventID){
|
||||||
clearTimeout(updateCheckTimeoutID);
|
clearTimeout(updateCheckTimeoutID);
|
||||||
updateCheckTimeoutID = setTimeout(runUpdateCheck,1000*60*60); // 1 hour
|
updateCheckTimeoutID = setTimeout(runUpdateCheck,1000*60*60); // 1 hour
|
||||||
|
|
||||||
if (!$TD.updateCheckEnabled)return;
|
if (!$TDU.updateCheckEnabled && !force)return;
|
||||||
|
|
||||||
$.getJSON("https://api.github.com/repos/chylex/"+$TD.brandName+"/releases/latest",function(response){
|
$.getJSON(updateCheckUrl,function(response){
|
||||||
var tagName = response.tag_name;
|
var tagName = response.tag_name;
|
||||||
|
var hasUpdate = tagName !== $TDU.versionTag && tagName !== $TDU.dismissedVersionTag && response.assets.length > 0;
|
||||||
|
|
||||||
if (tagName !== $TD.versionTag && tagName !== $TD.dismissedVersionTag && response.assets.length > 0){
|
if (hasUpdate){
|
||||||
var obj = response.assets.find(asset => asset.name === updateFileName) || response.assets[0];
|
var obj = response.assets.find(asset => asset.name === updateFileName) || response.assets[0];
|
||||||
createUpdateNotificationElement(tagName,obj.browser_download_url);
|
createUpdateNotificationElement(tagName,obj.browser_download_url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (eventID !== 0){
|
||||||
|
$TDU.onUpdateCheckFinished(eventID,hasUpdate,tagName);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
//
|
//
|
||||||
// Block: Setup global functions.
|
// Block: Setup global functions.
|
||||||
//
|
//
|
||||||
window.TDGF_runUpdateCheck = runUpdateCheck;
|
window.TDUF_runUpdateCheck = runUpdateCheck;
|
||||||
runUpdateCheck();
|
runUpdateCheck();
|
||||||
})($,$TD);
|
})($,$TDU);
|
||||||
|
@@ -126,10 +126,10 @@
|
|||||||
<Compile Include="Core\Other\FormSettings.Designer.cs">
|
<Compile Include="Core\Other\FormSettings.Designer.cs">
|
||||||
<DependentUpon>FormSettings.cs</DependentUpon>
|
<DependentUpon>FormSettings.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Core\Other\FormUpdateDownload.cs">
|
<Compile Include="Updates\FormUpdateDownload.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Core\Other\FormUpdateDownload.Designer.cs">
|
<Compile Include="Updates\FormUpdateDownload.Designer.cs">
|
||||||
<DependentUpon>FormUpdateDownload.cs</DependentUpon>
|
<DependentUpon>FormUpdateDownload.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
<Compile Include="Core\TrayIcon.cs">
|
<Compile Include="Core\TrayIcon.cs">
|
||||||
@@ -138,9 +138,14 @@
|
|||||||
<Compile Include="Core\TrayIcon.Designer.cs">
|
<Compile Include="Core\TrayIcon.Designer.cs">
|
||||||
<DependentUpon>TrayIcon.cs</DependentUpon>
|
<DependentUpon>TrayIcon.cs</DependentUpon>
|
||||||
</Compile>
|
</Compile>
|
||||||
|
<Compile Include="Core\Utils\BrowserCache.cs" />
|
||||||
<Compile Include="Core\Utils\BrowserUtils.cs" />
|
<Compile Include="Core\Utils\BrowserUtils.cs" />
|
||||||
|
<Compile Include="Core\Utils\HardwareAcceleration.cs" />
|
||||||
<Compile Include="Core\Utils\NativeMethods.cs" />
|
<Compile Include="Core\Utils\NativeMethods.cs" />
|
||||||
<Compile Include="Core\Utils\UpdateInfo.cs" />
|
<Compile Include="Updates\UpdateAcceptedEventArgs.cs" />
|
||||||
|
<Compile Include="Updates\UpdateCheckEventArgs.cs" />
|
||||||
|
<Compile Include="Updates\UpdateHandler.cs" />
|
||||||
|
<Compile Include="Updates\UpdateInfo.cs" />
|
||||||
<Compile Include="Migration\FormMigrationQuestion.cs">
|
<Compile Include="Migration\FormMigrationQuestion.cs">
|
||||||
<SubType>Form</SubType>
|
<SubType>Form</SubType>
|
||||||
</Compile>
|
</Compile>
|
||||||
@@ -217,7 +222,7 @@
|
|||||||
<EmbeddedResource Include="Core\Other\FormSettings.resx">
|
<EmbeddedResource Include="Core\Other\FormSettings.resx">
|
||||||
<DependentUpon>FormSettings.cs</DependentUpon>
|
<DependentUpon>FormSettings.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Core\Other\FormUpdateDownload.resx">
|
<EmbeddedResource Include="Updates\FormUpdateDownload.resx">
|
||||||
<DependentUpon>FormUpdateDownload.cs</DependentUpon>
|
<DependentUpon>FormUpdateDownload.cs</DependentUpon>
|
||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<EmbeddedResource Include="Properties\Resources.resx">
|
<EmbeddedResource Include="Properties\Resources.resx">
|
||||||
|
@@ -1,4 +1,4 @@
|
|||||||
namespace TweetDck.Core.Other {
|
namespace TweetDck.Updates {
|
||||||
partial class FormUpdateDownload {
|
partial class FormUpdateDownload {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Required designer variable.
|
/// Required designer variable.
|
@@ -6,7 +6,7 @@ using System.Windows.Forms;
|
|||||||
using TweetDck.Core.Controls;
|
using TweetDck.Core.Controls;
|
||||||
using TweetDck.Core.Utils;
|
using TweetDck.Core.Utils;
|
||||||
|
|
||||||
namespace TweetDck.Core.Other{
|
namespace TweetDck.Updates{
|
||||||
sealed partial class FormUpdateDownload : Form{
|
sealed partial class FormUpdateDownload : Form{
|
||||||
public string InstallerPath{
|
public string InstallerPath{
|
||||||
get{
|
get{
|
11
Updates/UpdateAcceptedEventArgs.cs
Normal file
11
Updates/UpdateAcceptedEventArgs.cs
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace TweetDck.Updates{
|
||||||
|
class UpdateAcceptedEventArgs : EventArgs{
|
||||||
|
public readonly UpdateInfo UpdateInfo;
|
||||||
|
|
||||||
|
public UpdateAcceptedEventArgs(UpdateInfo info){
|
||||||
|
this.UpdateInfo = info;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
15
Updates/UpdateCheckEventArgs.cs
Normal file
15
Updates/UpdateCheckEventArgs.cs
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
|
||||||
|
namespace TweetDck.Updates{
|
||||||
|
class UpdateCheckEventArgs : EventArgs{
|
||||||
|
public int EventId { get; private set; }
|
||||||
|
public bool UpdateAvailable { get; private set; }
|
||||||
|
public string LatestVersion { get; private set; }
|
||||||
|
|
||||||
|
public UpdateCheckEventArgs(int eventId, bool updateAvailable, string latestVersion){
|
||||||
|
EventId = eventId;
|
||||||
|
UpdateAvailable = updateAvailable;
|
||||||
|
LatestVersion = latestVersion;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
98
Updates/UpdateHandler.cs
Normal file
98
Updates/UpdateHandler.cs
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using CefSharp;
|
||||||
|
using CefSharp.WinForms;
|
||||||
|
using TweetDck.Core;
|
||||||
|
using TweetDck.Core.Controls;
|
||||||
|
using TweetDck.Resources;
|
||||||
|
|
||||||
|
namespace TweetDck.Updates{
|
||||||
|
class UpdateHandler{
|
||||||
|
private readonly ChromiumWebBrowser browser;
|
||||||
|
private readonly FormBrowser form;
|
||||||
|
|
||||||
|
public event EventHandler<UpdateAcceptedEventArgs> UpdateAccepted;
|
||||||
|
public event EventHandler<UpdateCheckEventArgs> CheckFinished;
|
||||||
|
|
||||||
|
private int lastEventId;
|
||||||
|
|
||||||
|
public UpdateHandler(ChromiumWebBrowser browser, FormBrowser form){
|
||||||
|
this.browser = browser;
|
||||||
|
this.form = form;
|
||||||
|
browser.FrameLoadEnd += browser_FrameLoadEnd;
|
||||||
|
browser.RegisterJsObject("$TDU",new Bridge(this));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||||
|
if (e.Frame.IsMain){
|
||||||
|
foreach(string js in ScriptLoader.LoadResources("update.js").Where(js => js != null)){
|
||||||
|
browser.ExecuteScriptAsync(js);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public int Check(bool force){
|
||||||
|
browser.ExecuteScriptAsync("TDUF_runUpdateCheck",force,++lastEventId);
|
||||||
|
return lastEventId;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TriggerUpdateAcceptedEvent(UpdateAcceptedEventArgs args){
|
||||||
|
if (UpdateAccepted != null){
|
||||||
|
form.InvokeSafe(() => UpdateAccepted(this,args));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void TriggerCheckFinishedEvent(UpdateCheckEventArgs args){
|
||||||
|
if (CheckFinished != null){
|
||||||
|
form.InvokeSafe(() => CheckFinished(this,args));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Bridge{
|
||||||
|
public string BrandName{
|
||||||
|
get{
|
||||||
|
return Program.BrandName;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string VersionTag{
|
||||||
|
get{
|
||||||
|
return Program.VersionTag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool UpdateCheckEnabled{
|
||||||
|
get{
|
||||||
|
return Program.UserConfig.EnableUpdateCheck;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public string DismissedVersionTag{
|
||||||
|
get{
|
||||||
|
return Program.UserConfig.DismissedUpdate ?? string.Empty;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private readonly UpdateHandler owner;
|
||||||
|
|
||||||
|
public Bridge(UpdateHandler owner){
|
||||||
|
this.owner = owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnUpdateCheckFinished(int eventId, bool isUpdateAvailable, string latestVersion){
|
||||||
|
owner.TriggerCheckFinishedEvent(new UpdateCheckEventArgs(eventId,isUpdateAvailable,latestVersion));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnUpdateAccepted(string versionTag, string downloadUrl){
|
||||||
|
owner.TriggerUpdateAcceptedEvent(new UpdateAcceptedEventArgs(new UpdateInfo(versionTag,downloadUrl)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnUpdateDismissed(string versionTag){
|
||||||
|
owner.form.InvokeSafe(() => {
|
||||||
|
Program.UserConfig.DismissedUpdate = versionTag;
|
||||||
|
Program.UserConfig.Save();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@@ -1,4 +1,6 @@
|
|||||||
namespace TweetDck.Core.Utils{
|
using TweetDck.Core.Utils;
|
||||||
|
|
||||||
|
namespace TweetDck.Updates{
|
||||||
class UpdateInfo{
|
class UpdateInfo{
|
||||||
public readonly string VersionTag;
|
public readonly string VersionTag;
|
||||||
public readonly string DownloadUrl;
|
public readonly string DownloadUrl;
|
Reference in New Issue
Block a user