mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-09-14 01:32:10 +02:00
Compare commits
190 Commits
Author | SHA1 | Date | |
---|---|---|---|
6eaafd883b | |||
5961a80b23 | |||
f41c6fe533 | |||
65b8efe13c | |||
89529f9c96 | |||
e90f6ebc63 | |||
5888d540a6 | |||
ae8b740600 | |||
ab4e2f5bda | |||
1091b6d232 | |||
fc89744238 | |||
34e049a002 | |||
980bf2c307 | |||
762aea1e20 | |||
c1aefc7163 | |||
9480ba26e0 | |||
c2c9160ed9 | |||
175b067a17 | |||
9d8656ca20 | |||
0863001c80 | |||
0ee22a30ad | |||
447697ba45 | |||
aea77ff909 | |||
af5da76f72 | |||
a369c65451 | |||
318f65f187 | |||
1cd60e831c | |||
b988959eaa | |||
1eb1f9848a | |||
7f6cc0da01 | |||
19fcb69525 | |||
22cef0a44c | |||
2459d31bff | |||
19f104239a | |||
bd0be65038 | |||
bbb7907e54 | |||
a6963a18d4 | |||
92716ea3e0 | |||
aec4c1feea | |||
d505b3305b | |||
a34a02e14d | |||
26d2d7a51e | |||
c2f7e52d13 | |||
de68d8934d | |||
4fdf7fc958 | |||
42a5e72f19 | |||
f7359ebc8a | |||
f395ac53dc | |||
1113e0b559 | |||
5e3bd31862 | |||
11d978dad1 | |||
f7961024d7 | |||
72973a8707 | |||
68254f48d5 | |||
eac4f30c50 | |||
25680fa980 | |||
ff5e1da14d | |||
95afff7879 | |||
50bd526025 | |||
108a0fefc3 | |||
dd8c5d27be | |||
b2937bc776 | |||
4d8e764211 | |||
544b8664fd | |||
d0610865bd | |||
ebc0b51590 | |||
4487f1169e | |||
85559b6083 | |||
1056273c57 | |||
61af2ebc8b | |||
9121c86656 | |||
1ccefe853a | |||
aca438b837 | |||
7210c29cd8 | |||
26d90c0c9b | |||
a03b222a95 | |||
7944a24d3c | |||
cc8459c759 | |||
10074ff92c | |||
173f25bebc | |||
31680fc4ae | |||
e937d43614 | |||
20e29a7975 | |||
ef815dabce | |||
1fb133e6b8 | |||
50b58cd6a6 | |||
01485d7ef9 | |||
b17c6a5ac7 | |||
d2ed2b4a00 | |||
710a7524a1 | |||
2be46464d6 | |||
8d536a6734 | |||
250d502238 | |||
e8de7266d0 | |||
9414f372d7 | |||
b0f9de67cf | |||
9b082e114e | |||
816a5334ac | |||
15a4e10da9 | |||
01b9302b0c | |||
442126a11a | |||
a9c140c0fc | |||
97ad7a3e68 | |||
7d737eefb6 | |||
4ac05b38d3 | |||
651bbbb672 | |||
52da4d8687 | |||
36063ae76a | |||
2fcec2d2cd | |||
762a7fdfb7 | |||
cd7aeaeed2 | |||
6f414d312c | |||
1b5304efb7 | |||
d59375308f | |||
8c9509a906 | |||
fb86d8f3a8 | |||
50e909cb3d | |||
2f54edf7e7 | |||
c251603e1e | |||
4476edb6c3 | |||
28fc67660f | |||
6e8b5a5ce5 | |||
e53681416f | |||
acb5e184e8 | |||
bdbafb3e5c | |||
ac70cf87c6 | |||
93de835ab4 | |||
2ea38b88ce | |||
2c4f2be57d | |||
fa4beea425 | |||
7a976edc82 | |||
bb22c35221 | |||
ff3dc59016 | |||
2e4dd3df3e | |||
b82e5d33f9 | |||
65d56b336b | |||
7836d61173 | |||
898437720b | |||
d9a80d1085 | |||
ab3d8b0ae2 | |||
b865074c32 | |||
2b8ca77c0d | |||
fa8b4e1e7f | |||
a310c5bcc1 | |||
b5dccd6b91 | |||
c2bcb39b38 | |||
4515add0a0 | |||
5b6aaec48c | |||
810e56ca31 | |||
5bcc8ac2e0 | |||
f5bfb35867 | |||
9088b8cd07 | |||
a7d90dc708 | |||
5968b57a01 | |||
94946a9ed6 | |||
561aec5ef0 | |||
e31696d843 | |||
8b33fd2002 | |||
064e43750f | |||
29d2f4f681 | |||
c11b40b94a | |||
e874e1d798 | |||
01244ec632 | |||
671657e2b0 | |||
dff7278e2e | |||
0881328636 | |||
a951c3a7c9 | |||
b25fae54fe | |||
a87bc4609e | |||
3e68026949 | |||
78d6d285cd | |||
72e3596a3c | |||
643ebcaab4 | |||
52ef6cd95a | |||
4aec2f3260 | |||
73549515eb | |||
d83d2660cf | |||
8de913172c | |||
4acfd64cff | |||
b56f90ed52 | |||
1375630727 | |||
668825bc01 | |||
90414ae579 | |||
41c8caa2a4 | |||
15305ecabe | |||
50090effd4 | |||
6dffdcd1ed | |||
db9daf2714 | |||
502ac4ebc1 | |||
3f44f3bab4 |
4
.github/FUNDING.yml
vendored
Normal file
4
.github/FUNDING.yml
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
# These are supported funding model platforms
|
||||
|
||||
patreon: chylex
|
||||
ko_fi: chylex
|
58
Application/LockHandler.cs
Normal file
58
Application/LockHandler.cs
Normal file
@@ -0,0 +1,58 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Application;
|
||||
|
||||
namespace TweetDuck.Application{
|
||||
class LockHandler : IAppLockHandler{
|
||||
private const int WaitRetryDelay = 250;
|
||||
private const int RestoreFailTimeout = 2000;
|
||||
private const int CloseNaturallyTimeout = 10000;
|
||||
private const int CloseKillTimeout = 5000;
|
||||
|
||||
bool IAppLockHandler.RestoreProcess(Process process){
|
||||
if (process.MainWindowHandle == IntPtr.Zero){ // restore if the original process is in tray
|
||||
NativeMethods.BroadcastMessage(Program.WindowRestoreMessage, (uint)process.Id, 0);
|
||||
|
||||
if (WindowsUtils.TrySleepUntil(() => CheckProcessExited(process) || (process.MainWindowHandle != IntPtr.Zero && process.Responding), RestoreFailTimeout, WaitRetryDelay)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IAppLockHandler.CloseProcess(Process process){
|
||||
try{
|
||||
if (process.CloseMainWindow()){
|
||||
// ReSharper disable once AccessToDisposedClosure
|
||||
WindowsUtils.TrySleepUntil(() => CheckProcessExited(process), CloseNaturallyTimeout, WaitRetryDelay);
|
||||
}
|
||||
|
||||
if (!process.HasExited){
|
||||
process.Kill();
|
||||
// ReSharper disable once AccessToDisposedClosure
|
||||
WindowsUtils.TrySleepUntil(() => CheckProcessExited(process), CloseKillTimeout, WaitRetryDelay);
|
||||
}
|
||||
|
||||
if (process.HasExited){
|
||||
process.Dispose();
|
||||
return true;
|
||||
}
|
||||
else{
|
||||
return false;
|
||||
}
|
||||
}catch(Exception ex) when (ex is InvalidOperationException || ex is Win32Exception){
|
||||
bool hasExited = CheckProcessExited(process);
|
||||
process.Dispose();
|
||||
return hasExited;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool CheckProcessExited(Process process){
|
||||
process.Refresh();
|
||||
return process.HasExited;
|
||||
}
|
||||
}
|
||||
}
|
16
Application/SystemHandler.cs
Normal file
16
Application/SystemHandler.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using TweetLib.Core.Application;
|
||||
|
||||
namespace TweetDuck.Application{
|
||||
class SystemHandler : IAppSystemHandler{
|
||||
void IAppSystemHandler.OpenFileExplorer(string path){
|
||||
if (File.Exists(path)){
|
||||
using(Process.Start("explorer.exe", "/select,\"" + path.Replace('/', '\\') + "\"")){}
|
||||
}
|
||||
else if (Directory.Exists(path)){
|
||||
using(Process.Start("explorer.exe", '"' + path.Replace('/', '\\') + '"')){}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
41
Browser/Adapters/CefScriptExecutor.cs
Normal file
41
Browser/Adapters/CefScriptExecutor.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.IO;
|
||||
using CefSharp;
|
||||
using TweetLib.Core.Browser;
|
||||
|
||||
namespace TweetDuck.Browser.Adapters{
|
||||
sealed class CefScriptExecutor : IScriptExecutor{
|
||||
private readonly IWebBrowser browser;
|
||||
|
||||
public CefScriptExecutor(IWebBrowser browser){
|
||||
this.browser = browser;
|
||||
}
|
||||
|
||||
public void RunFunction(string name, params object[] args){
|
||||
browser.ExecuteScriptAsync(name, args);
|
||||
}
|
||||
|
||||
public void RunScript(string identifier, string script){
|
||||
using IFrame frame = browser.GetMainFrame();
|
||||
RunScript(frame, script, identifier);
|
||||
}
|
||||
|
||||
public bool RunFile(string file){
|
||||
using IFrame frame = browser.GetMainFrame();
|
||||
return RunFile(frame, file);
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
public static void RunScript(IFrame frame, string script, string identifier){
|
||||
if (script != null){
|
||||
frame.ExecuteJavaScriptAsync(script, identifier, 1);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool RunFile(IFrame frame, string file){
|
||||
string script = Program.Resources.Load(file);
|
||||
RunScript(frame, script, "root:" + Path.GetFileNameWithoutExtension(file));
|
||||
return script != null;
|
||||
}
|
||||
}
|
||||
}
|
38
Browser/Bridge/PropertyBridge.cs
Normal file
38
Browser/Bridge/PropertyBridge.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Text;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetLib.Core;
|
||||
using TweetLib.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Browser.Bridge{
|
||||
static class PropertyBridge{
|
||||
public enum Environment{
|
||||
Browser, Notification
|
||||
}
|
||||
|
||||
public static string GenerateScript(Environment environment){
|
||||
static string Bool(bool value) => value ? "true;" : "false;";
|
||||
static string Str(string value) => $"\"{value}\";";
|
||||
|
||||
UserConfig config = Program.Config.User;
|
||||
StringBuilder build = new StringBuilder(384).Append("(function(x){");
|
||||
|
||||
build.Append("x.expandLinksOnHover=").Append(Bool(config.ExpandLinksOnHover));
|
||||
|
||||
if (environment == Environment.Browser){
|
||||
build.Append("x.focusDmInput=").Append(Bool(config.FocusDmInput));
|
||||
build.Append("x.openSearchInFirstColumn=").Append(Bool(config.OpenSearchInFirstColumn));
|
||||
build.Append("x.keepLikeFollowDialogsOpen=").Append(Bool(config.KeepLikeFollowDialogsOpen));
|
||||
build.Append("x.muteNotifications=").Append(Bool(config.MuteNotifications));
|
||||
build.Append("x.notificationMediaPreviews=").Append(Bool(config.NotificationMediaPreviews));
|
||||
build.Append("x.translationTarget=").Append(Str(config.TranslationTarget));
|
||||
build.Append("x.firstDayOfWeek=").Append(config.CalendarFirstDay == -1 ? LocaleUtils.GetJQueryDayOfWeek(Lib.Culture.DateTimeFormat.FirstDayOfWeek) : config.CalendarFirstDay);
|
||||
}
|
||||
|
||||
if (environment == Environment.Notification){
|
||||
build.Append("x.skipOnLinkClick=").Append(Bool(config.NotificationSkipOnLinkClick));
|
||||
}
|
||||
|
||||
return build.Append("})(window.$TDX=window.$TDX||{});if(window.TDGF_onPropertiesUpdated)window.TDGF_onPropertiesUpdated()").ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,37 +1,23 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Management;
|
||||
using TweetDuck.Core.Notification;
|
||||
using TweetDuck.Core.Other;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Resources;
|
||||
using TweetDuck.Browser.Handling;
|
||||
using TweetDuck.Browser.Notification;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Dialogs;
|
||||
using TweetDuck.Management;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Features.Notifications;
|
||||
using TweetLib.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Bridge{
|
||||
namespace TweetDuck.Browser.Bridge{
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
class TweetDeckBridge{
|
||||
public static string FontSize { get; private set; }
|
||||
public static string NotificationHeadLayout { get; private set; }
|
||||
public static readonly ContextInfo ContextInfo = new ContextInfo();
|
||||
|
||||
private static readonly Dictionary<string, string> SessionData = new Dictionary<string, string>(2);
|
||||
|
||||
public static void ResetStaticProperties(){
|
||||
FontSize = NotificationHeadLayout = null;
|
||||
}
|
||||
|
||||
public static void RestoreSessionData(IFrame frame){
|
||||
if (SessionData.Count > 0){
|
||||
StringBuilder build = new StringBuilder().Append("window.TD_SESSION={");
|
||||
|
||||
foreach(KeyValuePair<string, string> kvp in SessionData){
|
||||
build.Append(kvp.Key).Append(":'").Append(kvp.Value.Replace("'", "\\'")).Append("',");
|
||||
}
|
||||
|
||||
ScriptLoader.ExecuteScript(frame, build.Append("}").ToString(), "gen:session");
|
||||
SessionData.Clear();
|
||||
}
|
||||
FormNotificationBase.FontSize = null;
|
||||
FormNotificationBase.HeadLayout = null;
|
||||
}
|
||||
|
||||
private readonly FormBrowser form;
|
||||
@@ -56,35 +42,27 @@ namespace TweetDuck.Core.Bridge{
|
||||
}
|
||||
|
||||
public void OnIntroductionClosed(bool showGuide, bool allowDataCollection){
|
||||
form.InvokeAsyncSafe(() => {
|
||||
form.OnIntroductionClosed(showGuide, allowDataCollection);
|
||||
});
|
||||
form.InvokeAsyncSafe(() => form.OnIntroductionClosed(showGuide, allowDataCollection));
|
||||
}
|
||||
|
||||
public void LoadNotificationLayout(string fontSize, string headLayout){
|
||||
form.InvokeAsyncSafe(() => {
|
||||
FontSize = fontSize;
|
||||
NotificationHeadLayout = headLayout;
|
||||
FormNotificationBase.FontSize = fontSize;
|
||||
FormNotificationBase.HeadLayout = headLayout;
|
||||
});
|
||||
}
|
||||
|
||||
public void SetRightClickedLink(string type, string url){
|
||||
ContextInfo.SetLink(type, url);
|
||||
ContextMenuBase.CurrentInfo.SetLink(type, url);
|
||||
}
|
||||
|
||||
public void SetRightClickedChirp(string tweetUrl, string quoteUrl, string chirpAuthors, string chirpImages){
|
||||
ContextInfo.SetChirp(tweetUrl, quoteUrl, chirpAuthors, chirpImages);
|
||||
ContextMenuBase.CurrentInfo.SetChirp(tweetUrl, quoteUrl, chirpAuthors, chirpImages);
|
||||
}
|
||||
|
||||
public void DisplayTooltip(string text){
|
||||
form.InvokeAsyncSafe(() => form.DisplayTooltip(text));
|
||||
}
|
||||
|
||||
public void SetSessionData(string key, string value){
|
||||
form.InvokeSafe(() => { // do not use InvokeAsyncSafe, return only after invocation
|
||||
SessionData.Add(key, value);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Notification only
|
||||
@@ -110,7 +88,7 @@ namespace TweetDuck.Core.Bridge{
|
||||
public void OnTweetPopup(string columnId, string chirpId, string columnName, string tweetHtml, int tweetCharacters, string tweetUrl, string quoteUrl){
|
||||
notification.InvokeAsyncSafe(() => {
|
||||
form.OnTweetNotification();
|
||||
notification.ShowNotification(new TweetNotification(columnId, chirpId, columnName, tweetHtml, tweetCharacters, tweetUrl, quoteUrl));
|
||||
notification.ShowNotification(new DesktopNotification(columnId, chirpId, columnName, tweetHtml, tweetCharacters, tweetUrl, quoteUrl));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -125,31 +103,50 @@ namespace TweetDuck.Core.Bridge{
|
||||
form.InvokeAsyncSafe(() => form.OnTweetScreenshotReady(html, width));
|
||||
}
|
||||
|
||||
public void PlayVideo(string url, string username){
|
||||
form.InvokeAsyncSafe(() => form.PlayVideo(url, username));
|
||||
public void PlayVideo(string videoUrl, string tweetUrl, string username, IJavascriptCallback callShowOverlay){
|
||||
form.InvokeAsyncSafe(() => form.PlayVideo(videoUrl, tweetUrl, username, callShowOverlay));
|
||||
}
|
||||
|
||||
public void StopVideo(){
|
||||
form.InvokeAsyncSafe(form.StopVideo);
|
||||
}
|
||||
|
||||
public void FixClipboard(){
|
||||
form.InvokeAsyncSafe(WindowsUtils.ClipboardStripHtmlStyles);
|
||||
form.InvokeAsyncSafe(ClipboardManager.StripHtmlStyles);
|
||||
}
|
||||
|
||||
public void OpenBrowser(string url){
|
||||
form.InvokeAsyncSafe(() => BrowserUtils.OpenExternalBrowser(url));
|
||||
}
|
||||
|
||||
public void MakeGetRequest(string url, IJavascriptCallback onSuccess, IJavascriptCallback onError){
|
||||
Task.Run(async () => {
|
||||
var client = WebUtils.NewClient(BrowserUtils.UserAgentVanilla);
|
||||
|
||||
try{
|
||||
var result = await client.DownloadStringTaskAsync(url);
|
||||
await onSuccess.ExecuteAsync(result);
|
||||
}catch(Exception e){
|
||||
await onError.ExecuteAsync(e.Message);
|
||||
}finally{
|
||||
onSuccess.Dispose();
|
||||
onError.Dispose();
|
||||
client.Dispose();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public int GetIdleSeconds(){
|
||||
return NativeMethods.GetIdleSeconds();
|
||||
}
|
||||
|
||||
public void Alert(string type, string contents){
|
||||
MessageBoxIcon icon;
|
||||
|
||||
switch(type){
|
||||
case "error": icon = MessageBoxIcon.Error; break;
|
||||
case "warning": icon = MessageBoxIcon.Warning; break;
|
||||
case "info": icon = MessageBoxIcon.Information; break;
|
||||
default: icon = MessageBoxIcon.None; break;
|
||||
}
|
||||
MessageBoxIcon icon = type switch{
|
||||
"error" => MessageBoxIcon.Error,
|
||||
"warning" => MessageBoxIcon.Warning,
|
||||
"info" => MessageBoxIcon.Information,
|
||||
_ => MessageBoxIcon.None
|
||||
};
|
||||
|
||||
FormMessage.Show("TweetDuck Browser Message", contents, icon, FormMessage.OK);
|
||||
}
|
65
Browser/Bridge/UpdateBridge.cs
Normal file
65
Browser/Bridge/UpdateBridge.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Controls;
|
||||
using TweetLib.Core.Features.Updates;
|
||||
|
||||
namespace TweetDuck.Browser.Bridge{
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
class UpdateBridge{
|
||||
private readonly UpdateHandler updates;
|
||||
private readonly Control sync;
|
||||
|
||||
private UpdateInfo nextUpdate = null;
|
||||
|
||||
public event EventHandler<UpdateInfo> UpdateAccepted;
|
||||
public event EventHandler<UpdateInfo> UpdateDismissed;
|
||||
|
||||
public UpdateBridge(UpdateHandler updates, Control sync){
|
||||
this.sync = sync;
|
||||
|
||||
this.updates = updates;
|
||||
this.updates.CheckFinished += updates_CheckFinished;
|
||||
}
|
||||
|
||||
internal void Cleanup(){
|
||||
updates.CheckFinished -= updates_CheckFinished;
|
||||
nextUpdate?.DeleteInstaller();
|
||||
}
|
||||
|
||||
private void updates_CheckFinished(object sender, UpdateCheckEventArgs e){
|
||||
UpdateInfo foundUpdate = e.Result.HasValue ? e.Result.Value : null;
|
||||
|
||||
if (nextUpdate != null && !nextUpdate.Equals(foundUpdate)){
|
||||
nextUpdate.DeleteInstaller();
|
||||
}
|
||||
|
||||
nextUpdate = foundUpdate;
|
||||
}
|
||||
|
||||
private void HandleInteractionEvent(EventHandler<UpdateInfo> eventHandler){
|
||||
UpdateInfo tmpInfo = nextUpdate;
|
||||
|
||||
if (tmpInfo != null){
|
||||
sync.InvokeAsyncSafe(() => eventHandler?.Invoke(this, tmpInfo));
|
||||
}
|
||||
}
|
||||
|
||||
// Bridge methods
|
||||
|
||||
public void TriggerUpdateCheck(){
|
||||
updates.Check(false);
|
||||
}
|
||||
|
||||
public void OnUpdateAccepted(){
|
||||
HandleInteractionEvent(UpdateAccepted);
|
||||
}
|
||||
|
||||
public void OnUpdateDismissed(){
|
||||
HandleInteractionEvent(UpdateDismissed);
|
||||
|
||||
nextUpdate?.DeleteInstaller();
|
||||
nextUpdate = null;
|
||||
}
|
||||
}
|
||||
}
|
161
Browser/Data/ContextInfo.cs
Normal file
161
Browser/Data/ContextInfo.cs
Normal file
@@ -0,0 +1,161 @@
|
||||
using System;
|
||||
using CefSharp;
|
||||
using TweetLib.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Browser.Data{
|
||||
sealed class ContextInfo{
|
||||
private LinkInfo link;
|
||||
private ChirpInfo? chirp;
|
||||
|
||||
public ContextInfo(){
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void SetLink(string type, string url){
|
||||
link = string.IsNullOrEmpty(url) ? null : new LinkInfo(type, url);
|
||||
}
|
||||
|
||||
public void SetChirp(string tweetUrl, string quoteUrl, string chirpAuthors, string chirpImages){
|
||||
chirp = string.IsNullOrEmpty(tweetUrl) ? (ChirpInfo?)null : new ChirpInfo(tweetUrl, quoteUrl, chirpAuthors, chirpImages);
|
||||
}
|
||||
|
||||
public ContextData Reset(){
|
||||
link = null;
|
||||
chirp = null;
|
||||
return ContextData.Empty;
|
||||
}
|
||||
|
||||
public ContextData Create(IContextMenuParams parameters){
|
||||
ContextData.Builder builder = new ContextData.Builder();
|
||||
builder.AddContext(parameters);
|
||||
|
||||
if (link != null){
|
||||
builder.AddOverride(link.Type, link.Url);
|
||||
}
|
||||
|
||||
if (chirp.HasValue){
|
||||
builder.AddChirp(chirp.Value);
|
||||
}
|
||||
|
||||
return builder.Build();
|
||||
}
|
||||
|
||||
// Data structures
|
||||
|
||||
private sealed class LinkInfo{
|
||||
public string Type { get; }
|
||||
public string Url { get; }
|
||||
|
||||
public LinkInfo(string type, string url){
|
||||
this.Type = type;
|
||||
this.Url = url;
|
||||
}
|
||||
}
|
||||
|
||||
public struct ChirpInfo{
|
||||
public string TweetUrl { get; }
|
||||
public string QuoteUrl { get; }
|
||||
|
||||
public string[] Authors => chirpAuthors?.Split(';') ?? StringUtils.EmptyArray;
|
||||
public string[] Images => chirpImages?.Split(';') ?? StringUtils.EmptyArray;
|
||||
|
||||
private readonly string chirpAuthors;
|
||||
private readonly string chirpImages;
|
||||
|
||||
public ChirpInfo(string tweetUrl, string quoteUrl, string chirpAuthors, string chirpImages){
|
||||
this.TweetUrl = tweetUrl;
|
||||
this.QuoteUrl = quoteUrl;
|
||||
this.chirpAuthors = chirpAuthors;
|
||||
this.chirpImages = chirpImages;
|
||||
}
|
||||
}
|
||||
|
||||
// Constructed context
|
||||
|
||||
[Flags]
|
||||
public enum ContextType{
|
||||
Unknown = 0,
|
||||
Link = 0b0001,
|
||||
Image = 0b0010,
|
||||
Video = 0b0100,
|
||||
Chirp = 0b1000
|
||||
}
|
||||
|
||||
public sealed class ContextData{
|
||||
public static readonly ContextData Empty = new Builder().Build();
|
||||
|
||||
public ContextType Types { get; }
|
||||
|
||||
public string LinkUrl { get; }
|
||||
public string UnsafeLinkUrl { get; }
|
||||
public string MediaUrl { get; }
|
||||
|
||||
public ChirpInfo Chirp { get; }
|
||||
|
||||
public ContextData(ContextType types, string linkUrl, string unsafeLinkUrl, string mediaUrl, ChirpInfo chirp){
|
||||
Types = types;
|
||||
LinkUrl = linkUrl;
|
||||
UnsafeLinkUrl = unsafeLinkUrl;
|
||||
MediaUrl = mediaUrl;
|
||||
Chirp = chirp;
|
||||
}
|
||||
|
||||
public sealed class Builder{
|
||||
private ContextType types = ContextType.Unknown;
|
||||
|
||||
private string linkUrl = string.Empty;
|
||||
private string unsafeLinkUrl = string.Empty;
|
||||
private string mediaUrl = string.Empty;
|
||||
|
||||
private ChirpInfo chirp = default;
|
||||
|
||||
public void AddContext(IContextMenuParams parameters){
|
||||
ContextMenuType flags = parameters.TypeFlags;
|
||||
|
||||
if (flags.HasFlag(ContextMenuType.Media) && parameters.HasImageContents){
|
||||
types |= ContextType.Image;
|
||||
types &= ~ContextType.Video;
|
||||
mediaUrl = parameters.SourceUrl;
|
||||
}
|
||||
|
||||
if (flags.HasFlag(ContextMenuType.Link)){
|
||||
types |= ContextType.Link;
|
||||
linkUrl = parameters.LinkUrl;
|
||||
unsafeLinkUrl = parameters.UnfilteredLinkUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddOverride(string type, string url){
|
||||
switch(type){
|
||||
case "link":
|
||||
types |= ContextType.Link;
|
||||
linkUrl = url;
|
||||
unsafeLinkUrl = url;
|
||||
break;
|
||||
|
||||
case "image":
|
||||
types |= ContextType.Image;
|
||||
types &= ~(ContextType.Video | ContextType.Link);
|
||||
mediaUrl = url;
|
||||
break;
|
||||
|
||||
case "video":
|
||||
types |= ContextType.Video;
|
||||
types &= ~(ContextType.Image | ContextType.Link);
|
||||
mediaUrl = url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void AddChirp(ChirpInfo chirp){
|
||||
this.types |= ContextType.Chirp;
|
||||
this.chirp = chirp;
|
||||
}
|
||||
|
||||
public ContextData Build(){
|
||||
return new ContextData(types, linkUrl, unsafeLinkUrl, mediaUrl, chirp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,6 +1,6 @@
|
||||
using CefSharp;
|
||||
|
||||
namespace TweetDuck.Data{
|
||||
namespace TweetDuck.Browser.Data{
|
||||
sealed class ResourceLink{
|
||||
public string Url { get; }
|
||||
public IResourceHandler Handler { get; }
|
@@ -1,10 +1,10 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Data.Serialization;
|
||||
using TweetDuck.Controls;
|
||||
using TweetLib.Core.Serialization.Converters;
|
||||
using TweetLib.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Data{
|
||||
namespace TweetDuck.Browser.Data{
|
||||
sealed class WindowState{
|
||||
private Rectangle rect;
|
||||
private bool isMaximized;
|
@@ -1,21 +1,10 @@
|
||||
namespace TweetDuck.Core {
|
||||
namespace TweetDuck.Browser {
|
||||
sealed partial class FormBrowser {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
@@ -24,7 +13,7 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.trayIcon = new TweetDuck.Core.Other.TrayIcon(this.components);
|
||||
this.trayIcon = new TrayIcon(this.components);
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.timerResize = new System.Windows.Forms.Timer(this.components);
|
||||
this.SuspendLayout();
|
||||
@@ -38,10 +27,10 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = TweetDuck.Core.Utils.TwitterUtils.BackgroundColor;
|
||||
this.BackColor = TweetDuck.Utils.TwitterUtils.BackgroundColor;
|
||||
this.ClientSize = new System.Drawing.Size(1008, 730);
|
||||
this.Icon = Properties.Resources.icon;
|
||||
this.Location = TweetDuck.Core.Controls.ControlExtensions.InvisibleLocation;
|
||||
this.Location = TweetDuck.Controls.ControlExtensions.InvisibleLocation;
|
||||
this.MinimumSize = new System.Drawing.Size(348, 424);
|
||||
this.Name = "FormBrowser";
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
@@ -57,7 +46,7 @@
|
||||
|
||||
#endregion
|
||||
|
||||
private TweetDuck.Core.Other.TrayIcon trayIcon;
|
||||
private TrayIcon trayIcon;
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
private System.Windows.Forms.Timer timerResize;
|
||||
}
|
@@ -1,27 +1,30 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Browser.Bridge;
|
||||
using TweetDuck.Browser.Handling;
|
||||
using TweetDuck.Browser.Handling.General;
|
||||
using TweetDuck.Browser.Notification;
|
||||
using TweetDuck.Browser.Notification.Screenshot;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Core.Bridge;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Handling;
|
||||
using TweetDuck.Core.Handling.General;
|
||||
using TweetDuck.Core.Management;
|
||||
using TweetDuck.Core.Notification;
|
||||
using TweetDuck.Core.Notification.Screenshot;
|
||||
using TweetDuck.Core.Other;
|
||||
using TweetDuck.Core.Other.Analytics;
|
||||
using TweetDuck.Core.Other.Settings.Dialogs;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Plugins.Enums;
|
||||
using TweetDuck.Plugins.Events;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Dialogs;
|
||||
using TweetDuck.Dialogs.Settings;
|
||||
using TweetDuck.Management;
|
||||
using TweetDuck.Management.Analytics;
|
||||
using TweetDuck.Updates;
|
||||
using TweetDuck.Updates.Events;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
using TweetLib.Core.Features.Plugins.Events;
|
||||
using TweetLib.Core.Features.Updates;
|
||||
|
||||
namespace TweetDuck.Core{
|
||||
namespace TweetDuck.Browser{
|
||||
sealed partial class FormBrowser : Form, AnalyticsFile.IProvider{
|
||||
private static UserConfig Config => Program.UserConfig;
|
||||
private static UserConfig Config => Program.Config.User;
|
||||
|
||||
public bool IsWaiting{
|
||||
set{
|
||||
@@ -50,6 +53,7 @@ namespace TweetDuck.Core{
|
||||
private readonly UpdateHandler updates;
|
||||
private readonly FormNotificationTweet notification;
|
||||
private readonly ContextMenu contextMenu;
|
||||
private readonly UpdateBridge updateBridge;
|
||||
|
||||
private bool isLoaded;
|
||||
private FormWindowState prevState;
|
||||
@@ -63,7 +67,7 @@ namespace TweetDuck.Core{
|
||||
|
||||
Text = Program.BrandName;
|
||||
|
||||
this.plugins = new PluginManager(Program.PluginPath, Program.PluginConfigFilePath);
|
||||
this.plugins = new PluginManager(Program.Config.Plugins, Program.PluginPath, Program.PluginDataPath);
|
||||
this.plugins.Reloaded += plugins_Reloaded;
|
||||
this.plugins.Executed += plugins_Executed;
|
||||
this.plugins.Reload();
|
||||
@@ -71,24 +75,21 @@ namespace TweetDuck.Core{
|
||||
this.notification = new FormNotificationTweet(this, plugins);
|
||||
this.notification.Show();
|
||||
|
||||
this.browser = new TweetDeckBrowser(this, new TweetDeckBridge.Browser(this, notification));
|
||||
this.contextMenu = ContextMenuBrowser.CreateMenu(this);
|
||||
this.updates = new UpdateHandler(new UpdateCheckClient(Program.InstallerPath), TaskScheduler.FromCurrentSynchronizationContext());
|
||||
this.updates.CheckFinished += updates_CheckFinished;
|
||||
|
||||
this.plugins.Register(browser, PluginEnvironment.Browser, this, true);
|
||||
this.updateBridge = new UpdateBridge(updates, this);
|
||||
this.updateBridge.UpdateAccepted += updateBridge_UpdateAccepted;
|
||||
this.updateBridge.UpdateDismissed += updateBridge_UpdateDismissed;
|
||||
|
||||
this.browser = new TweetDeckBrowser(this, plugins, new TweetDeckBridge.Browser(this, notification), updateBridge);
|
||||
this.contextMenu = ContextMenuBrowser.CreateMenu(this);
|
||||
|
||||
Controls.Add(new MenuStrip{ Visible = false }); // fixes Alt freezing the program in Win 10 Anniversary Update
|
||||
|
||||
Disposed += (sender, args) => {
|
||||
Config.MuteToggled -= Config_MuteToggled;
|
||||
Config.TrayBehaviorChanged -= Config_TrayBehaviorChanged;
|
||||
|
||||
browser.Dispose();
|
||||
updates.Dispose();
|
||||
contextMenu.Dispose();
|
||||
|
||||
notificationScreenshotManager?.Dispose();
|
||||
videoPlayer?.Dispose();
|
||||
analytics?.Dispose();
|
||||
};
|
||||
|
||||
Config.MuteToggled += Config_MuteToggled;
|
||||
@@ -103,11 +104,6 @@ namespace TweetDuck.Core{
|
||||
UpdateFormIcon();
|
||||
}
|
||||
|
||||
this.updates = new UpdateHandler(browser, Program.InstallerPath);
|
||||
this.updates.CheckFinished += updates_CheckFinished;
|
||||
this.updates.UpdateAccepted += updates_UpdateAccepted;
|
||||
this.updates.UpdateDismissed += updates_UpdateDismissed;
|
||||
|
||||
if (Config.AllowDataCollection){
|
||||
analytics = new AnalyticsManager(this, plugins, Program.AnalyticsFilePath);
|
||||
}
|
||||
@@ -115,6 +111,23 @@ namespace TweetDuck.Core{
|
||||
RestoreWindow();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing){
|
||||
if (disposing){
|
||||
components?.Dispose();
|
||||
|
||||
browser.Dispose();
|
||||
updates.Dispose();
|
||||
notification.Dispose();
|
||||
contextMenu.Dispose();
|
||||
|
||||
notificationScreenshotManager?.Dispose();
|
||||
videoPlayer?.Dispose();
|
||||
analytics?.Dispose();
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void ShowChildForm(Form form){
|
||||
form.VisibleChanged += (sender, args) => form.MoveToCenter(this);
|
||||
form.Show(this);
|
||||
@@ -148,7 +161,9 @@ namespace TweetDuck.Core{
|
||||
}
|
||||
|
||||
private void FormBrowser_Activated(object sender, EventArgs e){
|
||||
if (!isLoaded)return;
|
||||
if (!isLoaded){
|
||||
return;
|
||||
}
|
||||
|
||||
trayIcon.HasNotifications = false;
|
||||
|
||||
@@ -158,14 +173,18 @@ namespace TweetDuck.Core{
|
||||
}
|
||||
|
||||
private void FormBrowser_LocationChanged(object sender, EventArgs e){
|
||||
if (!isLoaded)return;
|
||||
if (!isLoaded){
|
||||
return;
|
||||
}
|
||||
|
||||
timerResize.Stop();
|
||||
timerResize.Start();
|
||||
}
|
||||
|
||||
private void FormBrowser_Resize(object sender, EventArgs e){
|
||||
if (!isLoaded)return;
|
||||
if (!isLoaded){
|
||||
return;
|
||||
}
|
||||
|
||||
if (WindowState != prevState){
|
||||
prevState = WindowState;
|
||||
@@ -186,7 +205,9 @@ namespace TweetDuck.Core{
|
||||
}
|
||||
|
||||
private void FormBrowser_ResizeEnd(object sender, EventArgs e){ // also triggers when the window moves
|
||||
if (!isLoaded)return;
|
||||
if (!isLoaded){
|
||||
return;
|
||||
}
|
||||
|
||||
timerResize.Stop();
|
||||
|
||||
@@ -197,7 +218,9 @@ namespace TweetDuck.Core{
|
||||
}
|
||||
|
||||
private void FormBrowser_FormClosing(object sender, FormClosingEventArgs e){
|
||||
if (!isLoaded)return;
|
||||
if (!isLoaded){
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.TrayBehavior.ShouldHideOnClose() && trayIcon.Visible && e.CloseReason == CloseReason.UserClosing){
|
||||
Hide(); // hides taskbar too?! welp that works I guess
|
||||
@@ -207,7 +230,7 @@ namespace TweetDuck.Core{
|
||||
|
||||
private void FormBrowser_FormClosed(object sender, FormClosedEventArgs e){
|
||||
if (isLoaded && UpdateInstallerPath == null){
|
||||
updates.CleanupDownload();
|
||||
updateBridge.Cleanup();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -233,7 +256,9 @@ namespace TweetDuck.Core{
|
||||
|
||||
private void plugins_Reloaded(object sender, PluginErrorEventArgs e){
|
||||
if (e.HasErrors){
|
||||
this.InvokeAsyncSafe(() => { // TODO not needed but makes code consistent...
|
||||
FormMessage.Error("Error Loading Plugins", "The following plugins will not be available until the issues are resolved:\n\n" + string.Join("\n\n", e.Errors), FormMessage.OK);
|
||||
});
|
||||
}
|
||||
|
||||
if (isLoaded){
|
||||
@@ -241,9 +266,11 @@ namespace TweetDuck.Core{
|
||||
}
|
||||
}
|
||||
|
||||
private static void plugins_Executed(object sender, PluginErrorEventArgs e){
|
||||
private void plugins_Executed(object sender, PluginErrorEventArgs e){
|
||||
if (e.HasErrors){
|
||||
this.InvokeAsyncSafe(() => {
|
||||
FormMessage.Error("Error Executing Plugins", "Failed to execute the following plugins:\n\n" + string.Join("\n\n", e.Errors), FormMessage.OK);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,7 +279,7 @@ namespace TweetDuck.Core{
|
||||
string tag = update.VersionTag;
|
||||
|
||||
if (tag != Program.VersionTag && tag != Config.DismissedUpdate){
|
||||
updates.PrepareUpdate(update);
|
||||
update.BeginSilentDownload();
|
||||
browser.ShowUpdateNotification(tag, update.ReleaseNotes);
|
||||
}
|
||||
else{
|
||||
@@ -268,8 +295,7 @@ namespace TweetDuck.Core{
|
||||
ignoreUpdateCheckError = true;
|
||||
}
|
||||
|
||||
private void updates_UpdateAccepted(object sender, UpdateEventArgs e){
|
||||
this.InvokeAsyncSafe(() => {
|
||||
private void updateBridge_UpdateAccepted(object sender, UpdateInfo update){
|
||||
FormManager.CloseAllDialogs();
|
||||
|
||||
if (!string.IsNullOrEmpty(Config.DismissedUpdate)){
|
||||
@@ -277,7 +303,7 @@ namespace TweetDuck.Core{
|
||||
Config.Save();
|
||||
}
|
||||
|
||||
updates.BeginUpdateDownload(this, e.UpdateInfo, update => {
|
||||
void OnFinished(){
|
||||
UpdateDownloadStatus status = update.DownloadStatus;
|
||||
|
||||
if (status == UpdateDownloadStatus.Done){
|
||||
@@ -291,20 +317,42 @@ namespace TweetDuck.Core{
|
||||
else{
|
||||
Show();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private void updates_UpdateDismissed(object sender, UpdateEventArgs e){
|
||||
this.InvokeAsyncSafe(() => {
|
||||
Config.DismissedUpdate = e.UpdateInfo.VersionTag;
|
||||
if (update.DownloadStatus.IsFinished(true)){
|
||||
OnFinished();
|
||||
}
|
||||
else{
|
||||
FormUpdateDownload downloadForm = new FormUpdateDownload(update);
|
||||
|
||||
downloadForm.VisibleChanged += (sender2, args2) => {
|
||||
downloadForm.MoveToCenter(this);
|
||||
Hide();
|
||||
};
|
||||
|
||||
downloadForm.FormClosed += (sender2, args2) => {
|
||||
if (downloadForm.DialogResult != DialogResult.OK){
|
||||
update.CancelDownload();
|
||||
}
|
||||
|
||||
downloadForm.Dispose();
|
||||
OnFinished();
|
||||
};
|
||||
|
||||
downloadForm.Show();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateBridge_UpdateDismissed(object sender, UpdateInfo update){
|
||||
Config.DismissedUpdate = update.VersionTag;
|
||||
Config.Save();
|
||||
});
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m){
|
||||
if (isLoaded && m.Msg == Program.WindowRestoreMessage){
|
||||
if (WindowsUtils.CurrentProcessID == m.WParam.ToInt32()){
|
||||
using Process me = Process.GetCurrentProcess();
|
||||
|
||||
if (me.Id == m.WParam.ToInt32()){
|
||||
trayIcon_ClickRestore(trayIcon, EventArgs.Empty);
|
||||
}
|
||||
|
||||
@@ -341,10 +389,7 @@ namespace TweetDuck.Core{
|
||||
}
|
||||
|
||||
public void ReloadToTweetDeck(){
|
||||
#if DEBUG
|
||||
Resources.ScriptLoader.HotSwap();
|
||||
#endif
|
||||
|
||||
Program.Resources.OnReloadTriggered();
|
||||
ignoreUpdateCheckError = false;
|
||||
browser.ReloadToTweetDeck();
|
||||
AnalyticsFile.BrowserReloads.Trigger();
|
||||
@@ -465,14 +510,14 @@ namespace TweetDuck.Core{
|
||||
public void OpenProfileImport(){
|
||||
FormManager.TryFind<FormSettings>()?.Close();
|
||||
|
||||
using(DialogSettingsManage dialog = new DialogSettingsManage(plugins, true)){
|
||||
if (dialog.ShowDialog() == DialogResult.OK && !dialog.IsRestarting){
|
||||
using DialogSettingsManage dialog = new DialogSettingsManage(plugins, true);
|
||||
|
||||
if (!dialog.IsDisposed && dialog.ShowDialog() == DialogResult.OK && !dialog.IsRestarting){ // needs disposal check because the dialog may be closed in constructor
|
||||
BrowserProcessHandler.UpdatePrefs();
|
||||
FormManager.TryFind<FormPlugins>()?.Close();
|
||||
plugins.Reload(); // also reloads the browser
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnTweetNotification(){ // may be called multiple times, once for each type of notification
|
||||
if (Config.EnableTrayHighlight && !ContainsFocus){
|
||||
@@ -484,24 +529,40 @@ namespace TweetDuck.Core{
|
||||
AnalyticsFile.SoundNotifications.Trigger();
|
||||
}
|
||||
|
||||
public void PlayVideo(string url, string username){
|
||||
if (string.IsNullOrEmpty(url)){
|
||||
videoPlayer?.Close();
|
||||
return;
|
||||
}
|
||||
public void PlayVideo(string videoUrl, string tweetUrl, string username, IJavascriptCallback callShowOverlay){
|
||||
string playerPath = Config.VideoPlayerPath;
|
||||
|
||||
if (playerPath == null || !File.Exists(playerPath)){
|
||||
if (videoPlayer == null){
|
||||
videoPlayer = new VideoPlayer(this);
|
||||
|
||||
videoPlayer.ProcessExited += (sender, args) => {
|
||||
browser.HideVideoOverlay(true);
|
||||
};
|
||||
videoPlayer.ProcessExited += (sender, args) => browser.HideVideoOverlay(true);
|
||||
}
|
||||
|
||||
callShowOverlay.ExecuteAsync();
|
||||
callShowOverlay.Dispose();
|
||||
|
||||
videoPlayer.Launch(videoUrl, tweetUrl, username);
|
||||
}
|
||||
else{
|
||||
callShowOverlay.Dispose();
|
||||
|
||||
string quotedUrl = '"' + videoUrl + '"';
|
||||
string playerArgs = Config.VideoPlayerPathArgs == null ? quotedUrl : Config.VideoPlayerPathArgs + ' ' + quotedUrl;
|
||||
|
||||
try{
|
||||
using(Process.Start(playerPath, playerArgs)){}
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Error Opening Video Player", "Could not open the video player.", true, e);
|
||||
}
|
||||
}
|
||||
|
||||
videoPlayer.Launch(url, username);
|
||||
AnalyticsFile.VideoPlays.Trigger();
|
||||
}
|
||||
|
||||
public void StopVideo(){
|
||||
videoPlayer?.Close();
|
||||
}
|
||||
|
||||
public bool ProcessBrowserKey(Keys key){
|
||||
if (videoPlayer != null && videoPlayer.Running){
|
||||
videoPlayer.SendKeyEvent(key);
|
@@ -1,21 +1,26 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
using System.Linq;
|
||||
using TweetDuck.Core.Bridge;
|
||||
using TweetDuck.Core.Management;
|
||||
using TweetDuck.Core.Notification;
|
||||
using TweetDuck.Core.Other;
|
||||
using TweetDuck.Core.Other.Analytics;
|
||||
using TweetDuck.Resources;
|
||||
using TweetDuck.Browser.Adapters;
|
||||
using TweetDuck.Browser.Data;
|
||||
using TweetDuck.Browser.Notification;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Dialogs;
|
||||
using TweetDuck.Management;
|
||||
using TweetDuck.Management.Analytics;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Features.Twitter;
|
||||
using TweetLib.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Handling{
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
abstract class ContextMenuBase : IContextMenuHandler{
|
||||
private static TwitterUtils.ImageQuality ImageQuality => Program.UserConfig.TwitterImageQuality;
|
||||
public static ContextInfo CurrentInfo { get; } = new ContextInfo();
|
||||
|
||||
protected static UserConfig Config => Program.Config.User;
|
||||
private static ImageQuality ImageQuality => Config.TwitterImageQuality;
|
||||
|
||||
private const CefMenuCommand MenuOpenLinkUrl = (CefMenuCommand)26500;
|
||||
private const CefMenuCommand MenuCopyLinkUrl = (CefMenuCommand)26501;
|
||||
@@ -23,14 +28,14 @@ namespace TweetDuck.Core.Handling{
|
||||
private const CefMenuCommand MenuViewImage = (CefMenuCommand)26503;
|
||||
private const CefMenuCommand MenuOpenMediaUrl = (CefMenuCommand)26504;
|
||||
private const CefMenuCommand MenuCopyMediaUrl = (CefMenuCommand)26505;
|
||||
private const CefMenuCommand MenuSaveMedia = (CefMenuCommand)26506;
|
||||
private const CefMenuCommand MenuSaveTweetImages = (CefMenuCommand)26507;
|
||||
private const CefMenuCommand MenuSearchInBrowser = (CefMenuCommand)26508;
|
||||
private const CefMenuCommand MenuReadApplyROT13 = (CefMenuCommand)26509;
|
||||
private const CefMenuCommand MenuCopyImage = (CefMenuCommand)26506;
|
||||
private const CefMenuCommand MenuSaveMedia = (CefMenuCommand)26507;
|
||||
private const CefMenuCommand MenuSaveTweetImages = (CefMenuCommand)26508;
|
||||
private const CefMenuCommand MenuSearchInBrowser = (CefMenuCommand)26509;
|
||||
private const CefMenuCommand MenuReadApplyROT13 = (CefMenuCommand)26510;
|
||||
private const CefMenuCommand MenuOpenDevTools = (CefMenuCommand)26599;
|
||||
|
||||
protected ContextInfo.LinkInfo LastLink { get; private set; }
|
||||
protected ContextInfo.ChirpInfo LastChirp { get; private set; }
|
||||
protected ContextInfo.ContextData Context { get; private set; }
|
||||
|
||||
private readonly AnalyticsFile.IProvider analytics;
|
||||
|
||||
@@ -38,19 +43,12 @@ namespace TweetDuck.Core.Handling{
|
||||
this.analytics = analytics;
|
||||
}
|
||||
|
||||
private void ResetContextInfo(){
|
||||
LastLink = default(ContextInfo.LinkInfo);
|
||||
LastChirp = default(ContextInfo.ChirpInfo);
|
||||
TweetDeckBridge.ContextInfo.Reset();
|
||||
}
|
||||
|
||||
public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model){
|
||||
if (!TwitterUtils.IsTweetDeckWebsite(frame) || browser.IsLoading){
|
||||
ResetContextInfo();
|
||||
if (!TwitterUrls.IsTweetDeck(frame.Url) || browser.IsLoading){
|
||||
Context = CurrentInfo.Reset();
|
||||
}
|
||||
else{
|
||||
LastLink = TweetDeckBridge.ContextInfo.Link;
|
||||
LastChirp = TweetDeckBridge.ContextInfo.Chirp;
|
||||
Context = CurrentInfo.Create(parameters);
|
||||
}
|
||||
|
||||
if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection) && !parameters.TypeFlags.HasFlag(ContextMenuType.Editable)){
|
||||
@@ -60,15 +58,12 @@ namespace TweetDuck.Core.Handling{
|
||||
model.AddSeparator();
|
||||
}
|
||||
|
||||
bool hasTweetImage = LastLink.IsImage;
|
||||
bool hasTweetVideo = LastLink.IsVideo;
|
||||
static string TextOpen(string name) => "Open " + name + " in browser";
|
||||
static string TextCopy(string name) => "Copy " + name + " address";
|
||||
static string TextSave(string name) => "Save " + name + " as...";
|
||||
|
||||
string TextOpen(string name) => "Open "+name+" in browser";
|
||||
string TextCopy(string name) => "Copy "+name+" address";
|
||||
string TextSave(string name) => "Save "+name+" as...";
|
||||
|
||||
if (parameters.TypeFlags.HasFlag(ContextMenuType.Link) && !parameters.UnfilteredLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal) && !hasTweetImage && !hasTweetVideo){
|
||||
if (TwitterUtils.RegexAccount.IsMatch(parameters.UnfilteredLinkUrl)){
|
||||
if (Context.Types.HasFlag(ContextInfo.ContextType.Link) && !Context.UnsafeLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal)){
|
||||
if (TwitterUrls.RegexAccount.IsMatch(Context.UnsafeLinkUrl)){
|
||||
model.AddItem(MenuOpenLinkUrl, TextOpen("account"));
|
||||
model.AddItem(MenuCopyLinkUrl, TextCopy("account"));
|
||||
model.AddItem(MenuCopyUsername, "Copy account username");
|
||||
@@ -81,19 +76,20 @@ namespace TweetDuck.Core.Handling{
|
||||
model.AddSeparator();
|
||||
}
|
||||
|
||||
if (hasTweetVideo){
|
||||
if (Context.Types.HasFlag(ContextInfo.ContextType.Video)){
|
||||
model.AddItem(MenuOpenMediaUrl, TextOpen("video"));
|
||||
model.AddItem(MenuCopyMediaUrl, TextCopy("video"));
|
||||
model.AddItem(MenuSaveMedia, TextSave("video"));
|
||||
model.AddSeparator();
|
||||
}
|
||||
else if (((parameters.TypeFlags.HasFlag(ContextMenuType.Media) && parameters.HasImageContents) || hasTweetImage) && parameters.SourceUrl != TweetNotification.AppLogo.Url){
|
||||
else if (Context.Types.HasFlag(ContextInfo.ContextType.Image) && Context.MediaUrl != FormNotificationBase.AppLogo.Url){
|
||||
model.AddItem(MenuViewImage, "View image in photo viewer");
|
||||
model.AddItem(MenuOpenMediaUrl, TextOpen("image"));
|
||||
model.AddItem(MenuCopyMediaUrl, TextCopy("image"));
|
||||
model.AddItem(MenuCopyImage, "Copy image");
|
||||
model.AddItem(MenuSaveMedia, TextSave("image"));
|
||||
|
||||
if (LastChirp.Images.Length > 1){
|
||||
if (Context.Chirp.Images.Length > 1){
|
||||
model.AddItem(MenuSaveTweetImages, TextSave("all images"));
|
||||
}
|
||||
|
||||
@@ -106,64 +102,55 @@ namespace TweetDuck.Core.Handling{
|
||||
|
||||
switch(commandId){
|
||||
case MenuOpenLinkUrl:
|
||||
OpenBrowser(control, LastLink.GetUrl(parameters, true));
|
||||
OpenBrowser(control, Context.LinkUrl);
|
||||
break;
|
||||
|
||||
case MenuCopyLinkUrl:
|
||||
SetClipboardText(control, LastLink.GetUrl(parameters, false));
|
||||
SetClipboardText(control, Context.UnsafeLinkUrl);
|
||||
break;
|
||||
|
||||
case MenuCopyUsername:
|
||||
Match match = TwitterUtils.RegexAccount.Match(parameters.UnfilteredLinkUrl);
|
||||
SetClipboardText(control, match.Success ? match.Groups[1].Value : parameters.UnfilteredLinkUrl);
|
||||
case MenuCopyUsername: {
|
||||
string url = Context.UnsafeLinkUrl;
|
||||
Match match = TwitterUrls.RegexAccount.Match(url);
|
||||
|
||||
SetClipboardText(control, match.Success ? match.Groups[1].Value : url);
|
||||
control.InvokeAsyncSafe(analytics.AnalyticsFile.CopiedUsernames.Trigger);
|
||||
break;
|
||||
}
|
||||
|
||||
case MenuOpenMediaUrl:
|
||||
OpenBrowser(control, TwitterUtils.GetMediaLink(LastLink.GetMediaSource(parameters), ImageQuality));
|
||||
OpenBrowser(control, TwitterUrls.GetMediaLink(Context.MediaUrl, ImageQuality));
|
||||
break;
|
||||
|
||||
case MenuCopyMediaUrl:
|
||||
SetClipboardText(control, TwitterUtils.GetMediaLink(LastLink.GetMediaSource(parameters), ImageQuality));
|
||||
SetClipboardText(control, TwitterUrls.GetMediaLink(Context.MediaUrl, ImageQuality));
|
||||
break;
|
||||
|
||||
case MenuViewImage: {
|
||||
void ViewImage(string path){
|
||||
string ext = Path.GetExtension(path);
|
||||
|
||||
if (TwitterUtils.ValidImageExtensions.Contains(ext)){
|
||||
WindowsUtils.OpenAssociatedProgram(path);
|
||||
}
|
||||
else{
|
||||
FormMessage.Error("Image Download", "Invalid file extension "+ext, FormMessage.OK);
|
||||
}
|
||||
}
|
||||
|
||||
string url = LastLink.GetMediaSource(parameters);
|
||||
string file = Path.Combine(BrowserCache.CacheFolder, TwitterUtils.GetImageFileName(url) ?? Path.GetRandomFileName());
|
||||
case MenuCopyImage: {
|
||||
string url = Context.MediaUrl;
|
||||
|
||||
control.InvokeAsyncSafe(() => {
|
||||
if (File.Exists(file)){
|
||||
ViewImage(file);
|
||||
}
|
||||
else{
|
||||
analytics.AnalyticsFile.ViewedImages.Trigger();
|
||||
|
||||
BrowserUtils.DownloadFileAsync(TwitterUtils.GetMediaLink(url, ImageQuality), file, () => {
|
||||
ViewImage(file);
|
||||
}, ex => {
|
||||
FormMessage.Error("Image Download", "An error occurred while downloading the image: "+ex.Message, FormMessage.OK);
|
||||
TwitterUtils.CopyImage(url, ImageQuality);
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case MenuViewImage: {
|
||||
string url = Context.MediaUrl;
|
||||
|
||||
control.InvokeAsyncSafe(() => {
|
||||
TwitterUtils.ViewImage(url, ImageQuality);
|
||||
analytics.AnalyticsFile.ViewedImages.Trigger();
|
||||
});
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case MenuSaveMedia: {
|
||||
bool isVideo = LastLink.IsVideo;
|
||||
string url = LastLink.GetMediaSource(parameters);
|
||||
string username = LastChirp.Authors.LastOrDefault();
|
||||
bool isVideo = Context.Types.HasFlag(ContextInfo.ContextType.Video);
|
||||
string url = Context.MediaUrl;
|
||||
string username = Context.Chirp.Authors.LastOrDefault();
|
||||
|
||||
control.InvokeAsyncSafe(() => {
|
||||
if (isVideo){
|
||||
@@ -180,8 +167,8 @@ namespace TweetDuck.Core.Handling{
|
||||
}
|
||||
|
||||
case MenuSaveTweetImages: {
|
||||
string[] urls = LastChirp.Images;
|
||||
string username = LastChirp.Authors.LastOrDefault();
|
||||
string[] urls = Context.Chirp.Images;
|
||||
string username = Context.Chirp.Authors.LastOrDefault();
|
||||
|
||||
control.InvokeAsyncSafe(() => {
|
||||
TwitterUtils.DownloadImages(urls, username, ImageQuality);
|
||||
@@ -204,7 +191,7 @@ namespace TweetDuck.Core.Handling{
|
||||
break;
|
||||
|
||||
case MenuOpenDevTools:
|
||||
browserControl.ShowDevTools();
|
||||
browserControl.OpenDevToolsCustom();
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -212,7 +199,7 @@ namespace TweetDuck.Core.Handling{
|
||||
}
|
||||
|
||||
public virtual void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame){
|
||||
ResetContextInfo();
|
||||
Context = CurrentInfo.Reset();
|
||||
}
|
||||
|
||||
public virtual bool RunContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback){
|
||||
@@ -220,7 +207,7 @@ namespace TweetDuck.Core.Handling{
|
||||
}
|
||||
|
||||
protected static void DeselectAll(IFrame frame){
|
||||
ScriptLoader.ExecuteScript(frame, "window.getSelection().removeAllRanges()", "gen:deselect");
|
||||
CefScriptExecutor.RunScript(frame, "window.getSelection().removeAllRanges()", "gen:deselect");
|
||||
}
|
||||
|
||||
protected static void OpenBrowser(Control control, string url){
|
||||
@@ -228,7 +215,7 @@ namespace TweetDuck.Core.Handling{
|
||||
}
|
||||
|
||||
protected static void SetClipboardText(Control control, string text){
|
||||
control.InvokeAsyncSafe(() => WindowsUtils.SetClipboard(text, TextDataFormat.UnicodeText));
|
||||
control.InvokeAsyncSafe(() => ClipboardManager.SetText(text, TextDataFormat.UnicodeText));
|
||||
}
|
||||
|
||||
protected static void InsertSelectionSearchItem(IMenuModel model, CefMenuCommand insertCommand, string insertLabel){
|
@@ -1,9 +1,10 @@
|
||||
using CefSharp;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Browser.Data;
|
||||
using TweetDuck.Controls;
|
||||
using TweetLib.Core.Features.Twitter;
|
||||
|
||||
namespace TweetDuck.Core.Handling{
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
sealed class ContextMenuBrowser : ContextMenuBase{
|
||||
private const CefMenuCommand MenuGlobal = (CefMenuCommand)26600;
|
||||
private const CefMenuCommand MenuMute = (CefMenuCommand)26601;
|
||||
@@ -52,16 +53,16 @@ namespace TweetDuck.Core.Handling{
|
||||
|
||||
base.OnBeforeContextMenu(browserControl, browser, frame, parameters, model);
|
||||
|
||||
if (isSelecting && !isEditing && TwitterUtils.IsTweetDeckWebsite(frame)){
|
||||
if (isSelecting && !isEditing && TwitterUrls.IsTweetDeck(frame.Url)){
|
||||
InsertSelectionSearchItem(model, MenuSearchInColumn, "Search in a column");
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(LastChirp.TweetUrl) && !isSelecting && !isEditing){
|
||||
if (Context.Types.HasFlag(ContextInfo.ContextType.Chirp) && !isSelecting && !isEditing){
|
||||
model.AddItem(MenuOpenTweetUrl, "Open tweet in browser");
|
||||
model.AddItem(MenuCopyTweetUrl, "Copy tweet address");
|
||||
model.AddItem(MenuScreenshotTweet, "Screenshot tweet to clipboard");
|
||||
|
||||
if (!string.IsNullOrEmpty(LastChirp.QuoteUrl)){
|
||||
if (!string.IsNullOrEmpty(Context.Chirp.QuoteUrl)){
|
||||
model.AddSeparator();
|
||||
model.AddItem(MenuOpenQuotedTweetUrl, "Open quoted tweet in browser");
|
||||
model.AddItem(MenuCopyQuotedTweetUrl, "Copy quoted tweet address");
|
||||
@@ -77,7 +78,7 @@ namespace TweetDuck.Core.Handling{
|
||||
|
||||
globalMenu.AddItem(CefMenuCommand.Reload, TitleReloadBrowser);
|
||||
globalMenu.AddCheckItem(MenuMute, TitleMuteNotifications);
|
||||
globalMenu.SetChecked(MenuMute, Program.UserConfig.MuteNotifications);
|
||||
globalMenu.SetChecked(MenuMute, Config.MuteNotifications);
|
||||
globalMenu.AddSeparator();
|
||||
|
||||
globalMenu.AddItem(MenuSettings, TitleSettings);
|
||||
@@ -119,11 +120,11 @@ namespace TweetDuck.Core.Handling{
|
||||
return true;
|
||||
|
||||
case MenuOpenTweetUrl:
|
||||
OpenBrowser(form, LastChirp.TweetUrl);
|
||||
OpenBrowser(form, Context.Chirp.TweetUrl);
|
||||
return true;
|
||||
|
||||
case MenuCopyTweetUrl:
|
||||
SetClipboardText(form, LastChirp.TweetUrl);
|
||||
SetClipboardText(form, Context.Chirp.TweetUrl);
|
||||
return true;
|
||||
|
||||
case MenuScreenshotTweet:
|
||||
@@ -131,11 +132,11 @@ namespace TweetDuck.Core.Handling{
|
||||
return true;
|
||||
|
||||
case MenuOpenQuotedTweetUrl:
|
||||
OpenBrowser(form, LastChirp.QuoteUrl);
|
||||
OpenBrowser(form, Context.Chirp.QuoteUrl);
|
||||
return true;
|
||||
|
||||
case MenuCopyQuotedTweetUrl:
|
||||
SetClipboardText(form, LastChirp.QuoteUrl);
|
||||
SetClipboardText(form, Context.Chirp.QuoteUrl);
|
||||
return true;
|
||||
|
||||
case MenuWriteApplyROT13:
|
||||
@@ -163,7 +164,7 @@ namespace TweetDuck.Core.Handling{
|
||||
menu.MenuItems.Add(TitleAboutProgram, (sender, args) => form.OpenAbout());
|
||||
|
||||
menu.Popup += (sender, args) => {
|
||||
menu.MenuItems[1].Checked = Program.UserConfig.MuteNotifications;
|
||||
menu.MenuItems[1].Checked = Config.MuteNotifications;
|
||||
form.AnalyticsFile.BrowserContextMenus.Trigger();
|
||||
};
|
||||
|
||||
@@ -171,8 +172,8 @@ namespace TweetDuck.Core.Handling{
|
||||
}
|
||||
|
||||
private static void ToggleMuteNotifications(){
|
||||
Program.UserConfig.MuteNotifications = !Program.UserConfig.MuteNotifications;
|
||||
Program.UserConfig.Save();
|
||||
Config.MuteNotifications = !Config.MuteNotifications;
|
||||
Config.Save();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Other.Analytics;
|
||||
using TweetDuck.Management.Analytics;
|
||||
|
||||
namespace TweetDuck.Core.Handling{
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
sealed class ContextMenuGuide : ContextMenuBase{
|
||||
public ContextMenuGuide(AnalyticsFile.IProvider analytics) : base(analytics){}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Notification;
|
||||
using TweetDuck.Browser.Notification;
|
||||
using TweetDuck.Controls;
|
||||
|
||||
namespace TweetDuck.Core.Handling{
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
sealed class ContextMenuNotification : ContextMenuBase{
|
||||
private const CefMenuCommand MenuViewDetail = (CefMenuCommand)26600;
|
||||
private const CefMenuCommand MenuSkipTweet = (CefMenuCommand)26601;
|
@@ -2,7 +2,7 @@
|
||||
using CefSharp;
|
||||
using CefSharp.Enums;
|
||||
|
||||
namespace TweetDuck.Core.Handling{
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
sealed class DragHandlerBrowser : IDragHandler{
|
||||
private readonly RequestHandlerBrowser requestHandler;
|
||||
|
@@ -3,7 +3,7 @@ using System.IO;
|
||||
using System.Text;
|
||||
using CefSharp;
|
||||
|
||||
namespace TweetDuck.Core.Handling.Filters{
|
||||
namespace TweetDuck.Browser.Handling.Filters{
|
||||
abstract class ResponseFilterBase : IResponseFilter{
|
||||
private enum State{
|
||||
Reading, Writing, Done
|
||||
@@ -25,9 +25,9 @@ namespace TweetDuck.Core.Handling.Filters{
|
||||
int responseLength = responseData.Length;
|
||||
|
||||
if (state == State.Reading){
|
||||
int bytesToRead = Math.Min(responseLength-offset, (int)Math.Min(dataIn.Length, int.MaxValue));
|
||||
int bytesToRead = Math.Min(responseLength - offset, (int)Math.Min(dataIn?.Length ?? 0, int.MaxValue));
|
||||
|
||||
dataIn.Read(responseData, offset, bytesToRead);
|
||||
dataIn?.Read(responseData, offset, bytesToRead);
|
||||
offset += bytesToRead;
|
||||
|
||||
dataInRead = bytesToRead;
|
@@ -1,7 +1,7 @@
|
||||
using System.Text;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace TweetDuck.Core.Handling.Filters{
|
||||
namespace TweetDuck.Browser.Handling.Filters{
|
||||
sealed class ResponseFilterVendor : ResponseFilterBase{
|
||||
private static readonly Regex RegexRestoreJQuery = new Regex(@"(\w+)\.fn=\1\.prototype", RegexOptions.Compiled);
|
||||
|
@@ -1,19 +1,21 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using CefSharp;
|
||||
using TweetDuck.Configuration;
|
||||
|
||||
namespace TweetDuck.Core.Handling.General{
|
||||
namespace TweetDuck.Browser.Handling.General{
|
||||
sealed class BrowserProcessHandler : IBrowserProcessHandler{
|
||||
public static Task UpdatePrefs(){
|
||||
return Cef.UIThreadTaskFactory.StartNew(UpdatePrefsInternal);
|
||||
}
|
||||
|
||||
private static void UpdatePrefsInternal(){
|
||||
using(IRequestContext ctx = Cef.GetGlobalRequestContext()){
|
||||
ctx.SetPreference("browser.enable_spellchecking", Program.UserConfig.EnableSpellCheck, out string _);
|
||||
ctx.SetPreference("spellcheck.dictionary", Program.UserConfig.SpellCheckLanguage, out string _);
|
||||
ctx.SetPreference("settings.a11y.animation_policy", Program.UserConfig.EnableAnimatedImages ? "allowed" : "none", out string _);
|
||||
}
|
||||
UserConfig config = Program.Config.User;
|
||||
using IRequestContext ctx = Cef.GetGlobalRequestContext();
|
||||
|
||||
ctx.SetPreference("browser.enable_spellchecking", config.EnableSpellCheck, out string _);
|
||||
ctx.SetPreference("spellcheck.dictionary", config.SpellCheckLanguage, out string _);
|
||||
ctx.SetPreference("settings.a11y.animation_policy", config.EnableAnimatedImages ? "allowed" : "none", out string _);
|
||||
}
|
||||
|
||||
void IBrowserProcessHandler.OnContextInitialized(){
|
@@ -1,15 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
|
||||
namespace TweetDuck.Core.Handling.General{
|
||||
namespace TweetDuck.Browser.Handling.General{
|
||||
sealed class FileDialogHandler : IDialogHandler{
|
||||
public bool OnFileDialog(IWebBrowser browserControl, IBrowser browser, CefFileDialogMode mode, CefFileDialogFlags flags, string title, string defaultFilePath, List<string> acceptFilters, int selectedAcceptFilter, IFileDialogCallback callback){
|
||||
if (mode == CefFileDialogMode.Open || mode == CefFileDialogMode.OpenMultiple){
|
||||
string allFilters = string.Join(";", acceptFilters.Select(filter => "*"+filter));
|
||||
string allFilters = string.Join(";", acceptFilters.SelectMany(ParseFileType).Where(filter => !string.IsNullOrEmpty(filter)).Select(filter => "*" + filter));
|
||||
|
||||
using(OpenFileDialog dialog = new OpenFileDialog{
|
||||
AutoUpgradeEnabled = true,
|
||||
@@ -19,8 +18,8 @@ namespace TweetDuck.Core.Handling.General{
|
||||
Filter = $"All Supported Formats ({allFilters})|{allFilters}|All Files (*.*)|*.*"
|
||||
}){
|
||||
if (dialog.ShowDialog() == DialogResult.OK){
|
||||
string ext = Path.GetExtension(dialog.FileName);
|
||||
callback.Continue(acceptFilters.FindIndex(filter => filter.Equals(ext, StringComparison.OrdinalIgnoreCase)), dialog.FileNames.ToList());
|
||||
string ext = Path.GetExtension(dialog.FileName)?.ToLower();
|
||||
callback.Continue(acceptFilters.FindIndex(filter => ParseFileType(filter).Contains(ext)), dialog.FileNames.ToList());
|
||||
}
|
||||
else{
|
||||
callback.Cancel();
|
||||
@@ -36,5 +35,27 @@ namespace TweetDuck.Core.Handling.General{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static IEnumerable<string> ParseFileType(string type){
|
||||
if (string.IsNullOrEmpty(type)){
|
||||
return new string[0];
|
||||
}
|
||||
|
||||
if (type[0] == '.'){
|
||||
return new string[]{ type };
|
||||
}
|
||||
|
||||
switch(type){
|
||||
case "image/jpeg": return new string[]{ ".jpg", ".jpeg" };
|
||||
case "image/png": return new string[]{ ".png" };
|
||||
case "image/gif": return new string[]{ ".gif" };
|
||||
case "image/webp": return new string[]{ ".webp" };
|
||||
case "video/mp4": return new string[]{ ".mp4" };
|
||||
case "video/quicktime": return new string[]{ ".mov", ".qt" };
|
||||
}
|
||||
|
||||
System.Diagnostics.Debugger.Break();
|
||||
return new string[0];
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,27 +1,29 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Other;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Dialogs;
|
||||
using TweetDuck.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Handling.General{
|
||||
namespace TweetDuck.Browser.Handling.General{
|
||||
sealed class JavaScriptDialogHandler : IJsDialogHandler{
|
||||
private static FormMessage CreateMessageForm(string caption, string text){
|
||||
MessageBoxIcon icon = MessageBoxIcon.None;
|
||||
int pipe = text.IndexOf('|');
|
||||
|
||||
if (pipe != -1){
|
||||
switch(text.Substring(0, pipe)){
|
||||
case "error": icon = MessageBoxIcon.Error; break;
|
||||
case "warning": icon = MessageBoxIcon.Warning; break;
|
||||
case "info": icon = MessageBoxIcon.Information; break;
|
||||
case "question": icon = MessageBoxIcon.Question; break;
|
||||
default: return new FormMessage(caption, text, icon);
|
||||
}
|
||||
icon = text.Substring(0, pipe) switch{
|
||||
"error" => MessageBoxIcon.Error,
|
||||
"warning" => MessageBoxIcon.Warning,
|
||||
"info" => MessageBoxIcon.Information,
|
||||
"question" => MessageBoxIcon.Question,
|
||||
_ => MessageBoxIcon.None
|
||||
};
|
||||
|
||||
if (icon != MessageBoxIcon.None){
|
||||
text = text.Substring(pipe + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return new FormMessage(caption, text, icon);
|
||||
}
|
@@ -1,14 +1,18 @@
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Handling.General{
|
||||
namespace TweetDuck.Browser.Handling.General{
|
||||
sealed class LifeSpanHandler : ILifeSpanHandler{
|
||||
private static bool IsPopupAllowed(string url){
|
||||
return url.StartsWith("https://twitter.com/teams/authorize?");
|
||||
}
|
||||
|
||||
public static bool HandleLinkClick(IWebBrowser browserControl, WindowOpenDisposition targetDisposition, string targetUrl){
|
||||
switch(targetDisposition){
|
||||
case WindowOpenDisposition.NewBackgroundTab:
|
||||
case WindowOpenDisposition.NewForegroundTab:
|
||||
case WindowOpenDisposition.NewPopup:
|
||||
case WindowOpenDisposition.NewPopup when !IsPopupAllowed(targetUrl):
|
||||
case WindowOpenDisposition.NewWindow:
|
||||
browserControl.AsControl().InvokeAsyncSafe(() => BrowserUtils.OpenExternalBrowser(targetUrl));
|
||||
return true;
|
47
Browser/Handling/KeyboardHandlerBase.cs
Normal file
47
Browser/Handling/KeyboardHandlerBase.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Dialogs;
|
||||
using TweetDuck.Utils;
|
||||
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
class KeyboardHandlerBase : IKeyboardHandler{
|
||||
protected virtual bool HandleRawKey(IWebBrowser browserControl, IBrowser browser, Keys key, CefEventFlags modifiers){
|
||||
if (modifiers == (CefEventFlags.ControlDown | CefEventFlags.ShiftDown) && key == Keys.I){
|
||||
if (BrowserUtils.HasDevTools){
|
||||
browserControl.OpenDevToolsCustom();
|
||||
}
|
||||
else{
|
||||
browserControl.AsControl().InvokeSafe(() => {
|
||||
string extraMessage;
|
||||
|
||||
if (Program.IsPortable){
|
||||
extraMessage = "Please download the portable installer, select the folder with your current installation of TweetDuck Portable, and tick 'Install dev tools' during the installation process.";
|
||||
}
|
||||
else{
|
||||
extraMessage = "Please download the installer, and tick 'Install dev tools' during the installation process. The installer will automatically find and update your current installation of TweetDuck.";
|
||||
}
|
||||
|
||||
FormMessage.Information("Dev Tools", "You do not have dev tools installed. " + extraMessage, FormMessage.OK);
|
||||
});
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IKeyboardHandler.OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut){
|
||||
if (type == KeyType.RawKeyDown && !browser.FocusedFrame.Url.StartsWith("chrome-devtools://")){
|
||||
return HandleRawKey(browserControl, browser, (Keys)windowsKeyCode, modifiers);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IKeyboardHandler.OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
20
Browser/Handling/KeyboardHandlerBrowser.cs
Normal file
20
Browser/Handling/KeyboardHandlerBrowser.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
sealed class KeyboardHandlerBrowser : KeyboardHandlerBase{
|
||||
private readonly FormBrowser form;
|
||||
|
||||
public KeyboardHandlerBrowser(FormBrowser form){
|
||||
this.form = form;
|
||||
}
|
||||
|
||||
protected override bool HandleRawKey(IWebBrowser browserControl, IBrowser browser, Keys key, CefEventFlags modifiers){
|
||||
if (base.HandleRawKey(browserControl, browser, key, modifiers)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return form.ProcessBrowserKey(key);
|
||||
}
|
||||
}
|
||||
}
|
44
Browser/Handling/KeyboardHandlerNotification.cs
Normal file
44
Browser/Handling/KeyboardHandlerNotification.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Browser.Notification;
|
||||
using TweetDuck.Controls;
|
||||
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
sealed class KeyboardHandlerNotification : KeyboardHandlerBase{
|
||||
private readonly FormNotificationBase notification;
|
||||
|
||||
public KeyboardHandlerNotification(FormNotificationBase notification){
|
||||
this.notification = notification;
|
||||
}
|
||||
|
||||
private void TriggerKeyboardShortcutAnalytics(){
|
||||
notification.InvokeAsyncSafe(notification.AnalyticsFile.NotificationKeyboardShortcuts.Trigger);
|
||||
}
|
||||
|
||||
protected override bool HandleRawKey(IWebBrowser browserControl, IBrowser browser, Keys key, CefEventFlags modifiers){
|
||||
if (base.HandleRawKey(browserControl, browser, key, modifiers)){
|
||||
return true;
|
||||
}
|
||||
|
||||
switch(key){
|
||||
case Keys.Enter:
|
||||
notification.InvokeAsyncSafe(notification.FinishCurrentNotification);
|
||||
TriggerKeyboardShortcutAnalytics();
|
||||
return true;
|
||||
|
||||
case Keys.Escape:
|
||||
notification.InvokeAsyncSafe(notification.HideNotification);
|
||||
TriggerKeyboardShortcutAnalytics();
|
||||
return true;
|
||||
|
||||
case Keys.Space:
|
||||
notification.InvokeAsyncSafe(() => notification.FreezeTimer = !notification.FreezeTimer);
|
||||
TriggerKeyboardShortcutAnalytics();
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
82
Browser/Handling/RequestHandlerBase.cs
Normal file
82
Browser/Handling/RequestHandlerBase.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using CefSharp;
|
||||
using CefSharp.Handler;
|
||||
using TweetDuck.Browser.Handling.General;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
class RequestHandlerBase : DefaultRequestHandler{
|
||||
private static readonly Regex TweetDeckResourceUrl = new Regex(@"/dist/(.*?)\.(.*?)\.(css|js)$");
|
||||
private static readonly SortedList<string, string> TweetDeckHashes = new SortedList<string, string>(4);
|
||||
|
||||
public static void LoadResourceRewriteRules(string rules){
|
||||
if (string.IsNullOrEmpty(rules)){
|
||||
return;
|
||||
}
|
||||
|
||||
TweetDeckHashes.Clear();
|
||||
|
||||
foreach(string rule in rules.Replace(" ", "").ToLower().Split(',')){
|
||||
var (key, hash) = StringUtils.SplitInTwo(rule, '=') ?? throw new ArgumentException("A rule must have one '=' character: " + rule);
|
||||
|
||||
if (hash.All(chr => char.IsDigit(chr) || (chr >= 'a' && chr <= 'f'))){
|
||||
TweetDeckHashes.Add(key, hash);
|
||||
}
|
||||
else{
|
||||
throw new ArgumentException("Invalid hash characters: " + rule);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly bool autoReload;
|
||||
|
||||
public RequestHandlerBase(bool autoReload){
|
||||
this.autoReload = autoReload;
|
||||
}
|
||||
|
||||
public override bool OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture){
|
||||
return LifeSpanHandler.HandleLinkClick(browserControl, targetDisposition, targetUrl);
|
||||
}
|
||||
|
||||
public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){
|
||||
if (BrowserUtils.HasDevTools){
|
||||
NameValueCollection headers = request.Headers;
|
||||
headers.Remove("x-devtools-emulate-network-conditions-client-id");
|
||||
request.Headers = headers;
|
||||
}
|
||||
|
||||
return base.OnBeforeResourceLoad(browserControl, browser, frame, request, callback);
|
||||
}
|
||||
|
||||
public override bool OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response){
|
||||
if ((request.ResourceType == ResourceType.Script || request.ResourceType == ResourceType.Stylesheet) && TweetDeckHashes.Count > 0){
|
||||
string url = request.Url;
|
||||
Match match = TweetDeckResourceUrl.Match(url);
|
||||
|
||||
if (match.Success && TweetDeckHashes.TryGetValue($"{match.Groups[1]}.{match.Groups[3]}", out string hash)){
|
||||
if (match.Groups[2].Value == hash){
|
||||
Program.Reporter.LogVerbose("[RequestHandlerBase] Accepting " + url);
|
||||
}
|
||||
else{
|
||||
Program.Reporter.LogVerbose("[RequestHandlerBase] Replacing " + url + " hash with " + hash);
|
||||
request.Url = TweetDeckResourceUrl.Replace(url, $"/dist/$1.{hash}.$3");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnResourceResponse(browserControl, browser, frame, request, response);
|
||||
}
|
||||
|
||||
public override void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status){
|
||||
if (autoReload){
|
||||
browser.Reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
69
Browser/Handling/RequestHandlerBrowser.cs
Normal file
69
Browser/Handling/RequestHandlerBrowser.cs
Normal file
@@ -0,0 +1,69 @@
|
||||
using System.Collections.Specialized;
|
||||
using CefSharp;
|
||||
using TweetDuck.Browser.Handling.Filters;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Features.Twitter;
|
||||
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
sealed class RequestHandlerBrowser : RequestHandlerBase{
|
||||
private const string UrlVendorResource = "/dist/vendor";
|
||||
private const string UrlLoadingSpinner = "/backgrounds/spinner_blue";
|
||||
|
||||
public string BlockNextUserNavUrl { get; set; }
|
||||
|
||||
public RequestHandlerBrowser() : base(true){}
|
||||
|
||||
public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){
|
||||
if (request.ResourceType == ResourceType.MainFrame){
|
||||
if (request.Url.EndsWith("//twitter.com/")){
|
||||
request.Url = TwitterUrls.TweetDeck; // redirect plain twitter.com requests, fixes bugs with login 2FA
|
||||
}
|
||||
}
|
||||
else if (request.ResourceType == ResourceType.Script){
|
||||
string url = request.Url;
|
||||
|
||||
if (url.Contains("analytics.")){
|
||||
callback.Dispose();
|
||||
return CefReturnValue.Cancel;
|
||||
}
|
||||
else if (url.Contains(UrlVendorResource)){
|
||||
NameValueCollection headers = request.Headers;
|
||||
headers["Accept-Encoding"] = "identity";
|
||||
request.Headers = headers;
|
||||
}
|
||||
}
|
||||
|
||||
return base.OnBeforeResourceLoad(browserControl, browser, frame, request, callback);
|
||||
}
|
||||
|
||||
public override bool OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect){
|
||||
if (userGesture && request.TransitionType == TransitionType.LinkClicked){
|
||||
bool block = request.Url == BlockNextUserNavUrl;
|
||||
BlockNextUserNavUrl = string.Empty;
|
||||
return block;
|
||||
}
|
||||
else if (request.TransitionType.HasFlag(TransitionType.ForwardBack) && TwitterUrls.IsTweetDeck(frame.Url)){
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnBeforeBrowse(browserControl, browser, frame, request, userGesture, isRedirect);
|
||||
}
|
||||
|
||||
public override bool OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response){
|
||||
if (request.ResourceType == ResourceType.Image && request.Url.Contains(UrlLoadingSpinner)){
|
||||
request.Url = TwitterUtils.LoadingSpinner.Url;
|
||||
return true;
|
||||
}
|
||||
|
||||
return base.OnResourceResponse(browserControl, browser, frame, request, response);
|
||||
}
|
||||
|
||||
public override IResponseFilter GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response){
|
||||
if (request.ResourceType == ResourceType.Script && request.Url.Contains(UrlVendorResource) && int.TryParse(response.ResponseHeaders["Content-Length"], out int totalBytes)){
|
||||
return new ResponseFilterVendor(totalBytes);
|
||||
}
|
||||
|
||||
return base.GetResourceResponseFilter(browserControl, browser, frame, request, response);
|
||||
}
|
||||
}
|
||||
}
|
43
Browser/Handling/ResourceHandlerFactory.cs
Normal file
43
Browser/Handling/ResourceHandlerFactory.cs
Normal file
@@ -0,0 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using CefSharp;
|
||||
using TweetDuck.Browser.Data;
|
||||
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
sealed class ResourceHandlerFactory : IResourceHandlerFactory{
|
||||
public bool HasHandlers => !handlers.IsEmpty;
|
||||
|
||||
private readonly ConcurrentDictionary<string, IResourceHandler> handlers = new ConcurrentDictionary<string, IResourceHandler>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
public IResourceHandler GetResourceHandler(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request){
|
||||
try{
|
||||
return handlers.TryGetValue(request.Url, out IResourceHandler handler) ? handler : null;
|
||||
}finally{
|
||||
request.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// registration
|
||||
|
||||
public bool RegisterHandler(string url, IResourceHandler handler){
|
||||
if (Uri.TryCreate(url, UriKind.Absolute, out Uri uri)){
|
||||
handlers.AddOrUpdate(uri.AbsoluteUri, handler, (key, prev) => handler);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool RegisterHandler(ResourceLink link){
|
||||
return RegisterHandler(link.Url, link.Handler);
|
||||
}
|
||||
|
||||
public bool UnregisterHandler(string url){
|
||||
return handlers.TryRemove(url, out IResourceHandler _);
|
||||
}
|
||||
|
||||
public bool UnregisterHandler(ResourceLink link){
|
||||
return UnregisterHandler(link.Url);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,9 @@
|
||||
using CefSharp;
|
||||
using System.Collections.Specialized;
|
||||
using System.Collections.Specialized;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using CefSharp;
|
||||
|
||||
namespace TweetDuck.Core.Handling{
|
||||
namespace TweetDuck.Browser.Handling{
|
||||
sealed class ResourceHandlerNotification : IResourceHandler{
|
||||
private readonly NameValueCollection headers = new NameValueCollection(0);
|
||||
private MemoryStream dataIn;
|
@@ -1,18 +1,18 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Resources;
|
||||
using TweetDuck.Controls;
|
||||
using TweetLib.Core.Features.Notifications;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
|
||||
namespace TweetDuck.Core.Notification.Example{
|
||||
namespace TweetDuck.Browser.Notification.Example{
|
||||
sealed class FormNotificationExample : FormNotificationMain{
|
||||
public override bool RequiresResize => true;
|
||||
protected override bool CanDragWindow => Program.UserConfig.NotificationPosition == TweetNotification.Position.Custom;
|
||||
protected override bool CanDragWindow => Config.NotificationPosition == DesktopNotification.Position.Custom;
|
||||
|
||||
protected override FormBorderStyle NotificationBorderStyle{
|
||||
get{
|
||||
if (Program.UserConfig.NotificationSize == TweetNotification.Size.Custom){
|
||||
if (Config.NotificationSize == DesktopNotification.Size.Custom){
|
||||
switch(base.NotificationBorderStyle){
|
||||
case FormBorderStyle.FixedSingle: return FormBorderStyle.Sizable;
|
||||
case FormBorderStyle.FixedToolWindow: return FormBorderStyle.SizableToolWindow;
|
||||
@@ -23,20 +23,22 @@ namespace TweetDuck.Core.Notification.Example{
|
||||
}
|
||||
}
|
||||
|
||||
protected override string BodyClasses => base.BodyClasses + " td-example";
|
||||
|
||||
public event EventHandler Ready;
|
||||
|
||||
private readonly TweetNotification exampleNotification;
|
||||
private readonly DesktopNotification exampleNotification;
|
||||
|
||||
public FormNotificationExample(FormBrowser owner, PluginManager pluginManager) : base(owner, pluginManager, false){
|
||||
browser.LoadingStateChanged += browser_LoadingStateChanged;
|
||||
|
||||
string exampleTweetHTML = ScriptLoader.LoadResourceSilent("pages/example.html")?.Replace("{avatar}", TweetNotification.AppLogo.Url) ?? string.Empty;
|
||||
string exampleTweetHTML = Program.Resources.LoadSilent("pages/example.html")?.Replace("{avatar}", AppLogo.Url) ?? string.Empty;
|
||||
|
||||
#if DEBUG
|
||||
exampleTweetHTML = exampleTweetHTML.Replace("</p>", @"</p><div style='margin-top:256px'>Scrollbar test padding...</div>");
|
||||
#endif
|
||||
|
||||
exampleNotification = TweetNotification.Example(exampleTweetHTML, 176);
|
||||
exampleNotification = new DesktopNotification(string.Empty, string.Empty, "Home", exampleTweetHTML, 176, string.Empty, string.Empty);
|
||||
}
|
||||
|
||||
private void browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){
|
@@ -1,21 +1,10 @@
|
||||
namespace TweetDuck.Core.Notification {
|
||||
namespace TweetDuck.Browser.Notification {
|
||||
partial class FormNotificationBase {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
@@ -34,7 +23,7 @@
|
||||
this.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.ClientSize = new System.Drawing.Size(284, 122);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Location = TweetDuck.Core.Controls.ControlExtensions.InvisibleLocation;
|
||||
this.Location = TweetDuck.Controls.ControlExtensions.InvisibleLocation;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FormNotification";
|
@@ -1,62 +1,69 @@
|
||||
using CefSharp.WinForms;
|
||||
using System.Drawing;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using TweetDuck.Browser.Data;
|
||||
using TweetDuck.Browser.Handling;
|
||||
using TweetDuck.Browser.Handling.General;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Core.Bridge;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Handling;
|
||||
using TweetDuck.Core.Handling.General;
|
||||
using TweetDuck.Core.Other.Analytics;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Management.Analytics;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Features.Notifications;
|
||||
using TweetLib.Core.Features.Twitter;
|
||||
|
||||
namespace TweetDuck.Browser.Notification{
|
||||
abstract partial class FormNotificationBase : Form, AnalyticsFile.IProvider{
|
||||
public static readonly ResourceLink AppLogo = new ResourceLink("https://ton.twimg.com/tduck/avatar", ResourceHandler.FromByteArray(Properties.Resources.avatar, "image/png"));
|
||||
|
||||
public static string FontSize = null;
|
||||
public static string HeadLayout = null;
|
||||
|
||||
protected static UserConfig Config => Program.Config.User;
|
||||
|
||||
namespace TweetDuck.Core.Notification{
|
||||
partial class FormNotificationBase : Form, AnalyticsFile.IProvider{
|
||||
protected static int FontSizeLevel{
|
||||
get{
|
||||
switch(TweetDeckBridge.FontSize){
|
||||
case "largest": return 4;
|
||||
case "large": return 3;
|
||||
case "small": return 1;
|
||||
case "smallest": return 0;
|
||||
default: return 2;
|
||||
}
|
||||
}
|
||||
get => FontSize switch{
|
||||
"largest" => 4,
|
||||
"large" => 3,
|
||||
"small" => 1,
|
||||
"smallest" => 0,
|
||||
_ => 2
|
||||
};
|
||||
}
|
||||
|
||||
protected virtual Point PrimaryLocation{
|
||||
get{
|
||||
UserConfig config = Program.UserConfig;
|
||||
Screen screen;
|
||||
|
||||
if (config.NotificationDisplay > 0 && config.NotificationDisplay <= Screen.AllScreens.Length){
|
||||
screen = Screen.AllScreens[config.NotificationDisplay-1];
|
||||
if (Config.NotificationDisplay > 0 && Config.NotificationDisplay <= Screen.AllScreens.Length){
|
||||
screen = Screen.AllScreens[Config.NotificationDisplay - 1];
|
||||
}
|
||||
else{
|
||||
screen = Screen.FromControl(owner);
|
||||
}
|
||||
|
||||
int edgeDist = config.NotificationEdgeDistance;
|
||||
int edgeDist = Config.NotificationEdgeDistance;
|
||||
|
||||
switch(config.NotificationPosition){
|
||||
case TweetNotification.Position.TopLeft:
|
||||
switch(Config.NotificationPosition){
|
||||
case DesktopNotification.Position.TopLeft:
|
||||
return new Point(screen.WorkingArea.X + edgeDist, screen.WorkingArea.Y + edgeDist);
|
||||
|
||||
case TweetNotification.Position.TopRight:
|
||||
case DesktopNotification.Position.TopRight:
|
||||
return new Point(screen.WorkingArea.X + screen.WorkingArea.Width - edgeDist - Width, screen.WorkingArea.Y + edgeDist);
|
||||
|
||||
case TweetNotification.Position.BottomLeft:
|
||||
case DesktopNotification.Position.BottomLeft:
|
||||
return new Point(screen.WorkingArea.X + edgeDist, screen.WorkingArea.Y + screen.WorkingArea.Height - edgeDist - Height);
|
||||
|
||||
case TweetNotification.Position.BottomRight:
|
||||
case DesktopNotification.Position.BottomRight:
|
||||
return new Point(screen.WorkingArea.X + screen.WorkingArea.Width - edgeDist - Width, screen.WorkingArea.Y + screen.WorkingArea.Height - edgeDist - Height);
|
||||
|
||||
case TweetNotification.Position.Custom:
|
||||
if (!config.IsCustomNotificationPositionSet){
|
||||
config.CustomNotificationPosition = new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+edgeDist);
|
||||
config.Save();
|
||||
case DesktopNotification.Position.Custom:
|
||||
if (!Config.IsCustomNotificationPositionSet){
|
||||
Config.CustomNotificationPosition = new Point(screen.WorkingArea.X + screen.WorkingArea.Width - edgeDist - Width, screen.WorkingArea.Y + edgeDist);
|
||||
Config.Save();
|
||||
}
|
||||
|
||||
return config.CustomNotificationPosition;
|
||||
return Config.CustomNotificationPosition;
|
||||
}
|
||||
|
||||
return Location;
|
||||
@@ -93,14 +100,14 @@ namespace TweetDuck.Core.Notification{
|
||||
protected override bool ShowWithoutActivation => true;
|
||||
|
||||
protected float DpiScale { get; }
|
||||
protected double SizeScale => DpiScale*Program.UserConfig.ZoomLevel/100.0;
|
||||
protected double SizeScale => DpiScale * Config.ZoomLevel / 100.0;
|
||||
|
||||
protected readonly FormBrowser owner;
|
||||
protected readonly ChromiumWebBrowser browser;
|
||||
|
||||
private readonly ResourceHandlerNotification resourceHandler = new ResourceHandlerNotification();
|
||||
|
||||
private TweetNotification currentNotification;
|
||||
private DesktopNotification currentNotification;
|
||||
private int pauseCounter;
|
||||
|
||||
public string CurrentTweetUrl => currentNotification?.TweetUrl;
|
||||
@@ -120,25 +127,24 @@ namespace TweetDuck.Core.Notification{
|
||||
this.owner = owner;
|
||||
this.owner.FormClosed += owner_FormClosed;
|
||||
|
||||
ResourceHandlerFactory resourceHandlerFactory = new ResourceHandlerFactory();
|
||||
resourceHandlerFactory.RegisterHandler(TwitterUrls.TweetDeck, this.resourceHandler);
|
||||
resourceHandlerFactory.RegisterHandler(AppLogo);
|
||||
|
||||
this.browser = new ChromiumWebBrowser("about:blank"){
|
||||
MenuHandler = new ContextMenuNotification(this, enableContextMenu),
|
||||
JsDialogHandler = new JavaScriptDialogHandler(),
|
||||
LifeSpanHandler = new LifeSpanHandler(),
|
||||
RequestHandler = new RequestHandlerBase(false)
|
||||
RequestHandler = new RequestHandlerBase(false),
|
||||
ResourceHandlerFactory = resourceHandlerFactory
|
||||
};
|
||||
|
||||
this.browser.Dock = DockStyle.None;
|
||||
this.browser.ClientSize = ClientSize;
|
||||
|
||||
browser.SetupResourceHandler(TwitterUtils.TweetDeckURL, this.resourceHandler);
|
||||
browser.SetupResourceHandler(TweetNotification.AppLogo);
|
||||
this.browser.SetupZoomEvents();
|
||||
|
||||
Controls.Add(browser);
|
||||
|
||||
Disposed += (sender, args) => {
|
||||
this.browser.Dispose();
|
||||
this.owner.FormClosed -= owner_FormClosed;
|
||||
};
|
||||
Disposed += (sender, args) => this.owner.FormClosed -= owner_FormClosed;
|
||||
|
||||
DpiScale = this.GetDPIScale();
|
||||
|
||||
@@ -146,6 +152,16 @@ namespace TweetDuck.Core.Notification{
|
||||
UpdateTitle();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing){
|
||||
if (disposing){
|
||||
components?.Dispose();
|
||||
browser.Dispose();
|
||||
resourceHandler.Dispose();
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m){
|
||||
if (m.Msg == 0x0112 && (m.WParam.ToInt32() & 0xFFF0) == 0xF010 && !CanDragWindow){ // WM_SYSCOMMAND, SC_MOVE
|
||||
return;
|
||||
@@ -184,15 +200,13 @@ namespace TweetDuck.Core.Notification{
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string GetTweetHTML(TweetNotification tweet){
|
||||
return tweet.GenerateHtml(IsCursorOverBrowser ? "td-notification td-hover" : "td-notification", this);
|
||||
}
|
||||
protected abstract string GetTweetHTML(DesktopNotification tweet);
|
||||
|
||||
protected virtual void LoadTweet(TweetNotification tweet){
|
||||
protected virtual void LoadTweet(DesktopNotification tweet){
|
||||
currentNotification = tweet;
|
||||
resourceHandler.SetHTML(GetTweetHTML(tweet));
|
||||
|
||||
browser.Load(TwitterUtils.TweetDeckURL);
|
||||
browser.Load(TwitterUrls.TweetDeck);
|
||||
DisplayTooltip(null);
|
||||
}
|
||||
|
||||
@@ -202,7 +216,7 @@ namespace TweetDuck.Core.Notification{
|
||||
|
||||
protected virtual void UpdateTitle(){
|
||||
string title = currentNotification?.ColumnTitle;
|
||||
Text = string.IsNullOrEmpty(title) || !Program.UserConfig.DisplayNotificationColumn ? Program.BrandName : Program.BrandName+" - "+title;
|
||||
Text = string.IsNullOrEmpty(title) || !Config.DisplayNotificationColumn ? Program.BrandName : $"{Program.BrandName} - {title}";
|
||||
}
|
||||
|
||||
public void ShowTweetDetail(){
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Notification {
|
||||
namespace TweetDuck.Browser.Notification {
|
||||
partial class FormNotificationMain {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -26,7 +26,7 @@
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.timerDisplayDelay = new System.Windows.Forms.Timer(this.components);
|
||||
this.timerProgress = new System.Windows.Forms.Timer(this.components);
|
||||
this.progressBarTimer = new TweetDuck.Core.Controls.FlatProgressBar();
|
||||
this.progressBarTimer = new TweetDuck.Controls.FlatProgressBar();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// timerDisplayDelay
|
@@ -1,20 +1,20 @@
|
||||
using CefSharp;
|
||||
using System;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Core.Bridge;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Handling;
|
||||
using TweetDuck.Core.Other.Interfaces;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Data;
|
||||
using CefSharp;
|
||||
using TweetDuck.Browser.Adapters;
|
||||
using TweetDuck.Browser.Bridge;
|
||||
using TweetDuck.Browser.Handling;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Plugins.Enums;
|
||||
using TweetDuck.Resources;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Data;
|
||||
using TweetLib.Core.Features.Notifications;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
using TweetLib.Core.Features.Plugins.Enums;
|
||||
|
||||
namespace TweetDuck.Core.Notification{
|
||||
abstract partial class FormNotificationMain : FormNotificationBase, ITweetDeckBrowser{
|
||||
namespace TweetDuck.Browser.Notification{
|
||||
abstract partial class FormNotificationMain : FormNotificationBase{
|
||||
private readonly PluginManager plugins;
|
||||
private readonly int timerBarHeight;
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace TweetDuck.Core.Notification{
|
||||
|
||||
public virtual bool RequiresResize{
|
||||
get{
|
||||
return !prevDisplayTimer.HasValue || !prevFontSize.HasValue || prevDisplayTimer != Program.UserConfig.DisplayNotificationTimer || prevFontSize != FontSizeLevel;
|
||||
return !prevDisplayTimer.HasValue || !prevFontSize.HasValue || prevDisplayTimer != Config.DisplayNotificationTimer || prevFontSize != FontSizeLevel;
|
||||
}
|
||||
|
||||
set{
|
||||
@@ -39,37 +39,29 @@ namespace TweetDuck.Core.Notification{
|
||||
prevFontSize = null;
|
||||
}
|
||||
else{
|
||||
prevDisplayTimer = Program.UserConfig.DisplayNotificationTimer;
|
||||
prevDisplayTimer = Config.DisplayNotificationTimer;
|
||||
prevFontSize = FontSizeLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private int BaseClientWidth{
|
||||
get{
|
||||
switch(Program.UserConfig.NotificationSize){
|
||||
default:
|
||||
return BrowserUtils.Scale(284, SizeScale*(1.0+0.05*FontSizeLevel));
|
||||
|
||||
case TweetNotification.Size.Custom:
|
||||
return Program.UserConfig.CustomNotificationSize.Width;
|
||||
}
|
||||
}
|
||||
get => Config.NotificationSize switch{
|
||||
DesktopNotification.Size.Custom => Config.CustomNotificationSize.Width,
|
||||
_ => BrowserUtils.Scale(284, SizeScale * (1.0 + 0.05 * FontSizeLevel))
|
||||
};
|
||||
}
|
||||
|
||||
private int BaseClientHeight{
|
||||
get{
|
||||
switch(Program.UserConfig.NotificationSize){
|
||||
default:
|
||||
return BrowserUtils.Scale(122, SizeScale*(1.0+0.08*FontSizeLevel));
|
||||
|
||||
case TweetNotification.Size.Custom:
|
||||
return Program.UserConfig.CustomNotificationSize.Height;
|
||||
}
|
||||
}
|
||||
get => Config.NotificationSize switch{
|
||||
DesktopNotification.Size.Custom => Config.CustomNotificationSize.Height,
|
||||
_ => BrowserUtils.Scale(122, SizeScale * (1.0 + 0.08 * FontSizeLevel))
|
||||
};
|
||||
}
|
||||
|
||||
public Size BrowserSize => Program.UserConfig.DisplayNotificationTimer ? new Size(ClientSize.Width, ClientSize.Height-timerBarHeight) : ClientSize;
|
||||
protected virtual string BodyClasses => IsCursorOverBrowser ? "td-notification td-hover" : "td-notification";
|
||||
|
||||
public Size BrowserSize => Config.DisplayNotificationTimer ? new Size(ClientSize.Width, ClientSize.Height - timerBarHeight) : ClientSize;
|
||||
|
||||
protected FormNotificationMain(FormBrowser owner, PluginManager pluginManager, bool enableContextMenu) : base(owner, enableContextMenu){
|
||||
InitializeComponent();
|
||||
@@ -83,34 +75,12 @@ namespace TweetDuck.Core.Notification{
|
||||
browser.LoadingStateChanged += Browser_LoadingStateChanged;
|
||||
browser.FrameLoadEnd += Browser_FrameLoadEnd;
|
||||
|
||||
plugins.Register(this, PluginEnvironment.Notification, this);
|
||||
plugins.Register(PluginEnvironment.Notification, new PluginDispatcher(browser));
|
||||
|
||||
mouseHookDelegate = MouseHookProc;
|
||||
Disposed += (sender, args) => StopMouseHook(true);
|
||||
}
|
||||
|
||||
// implementation of ITweetDeckBrowser
|
||||
|
||||
bool ITweetDeckBrowser.IsTweetDeckWebsite => IsNotificationVisible;
|
||||
|
||||
void ITweetDeckBrowser.RegisterBridge(string name, object obj){
|
||||
browser.RegisterAsyncJsObject(name, obj);
|
||||
}
|
||||
|
||||
void ITweetDeckBrowser.OnFrameLoaded(Action<IFrame> callback){
|
||||
browser.FrameLoadEnd += (sender, args) => {
|
||||
IFrame frame = args.Frame;
|
||||
|
||||
if (frame.IsMain && browser.Address != "about:blank"){
|
||||
callback(frame);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void ITweetDeckBrowser.ExecuteFunction(string name, params object[] args){
|
||||
browser.ExecuteScriptAsync(name, args);
|
||||
}
|
||||
|
||||
// mouse wheel hook
|
||||
|
||||
private void StartMouseHook(){
|
||||
@@ -132,14 +102,7 @@ namespace TweetDuck.Core.Notification{
|
||||
int eventType = wParam.ToInt32();
|
||||
|
||||
if (eventType == NativeMethods.WM_MOUSEWHEEL && IsCursorOverBrowser){
|
||||
if (Arguments.HasFlag(Arguments.ArgNotificationScrollWA)){
|
||||
int delta = BrowserUtils.Scale(NativeMethods.GetMouseHookData(lParam), Program.UserConfig.NotificationScrollSpeed*0.01);
|
||||
browser.ExecuteScriptAsync("window.scrollBy", 0, -Math.Round(delta/0.72));
|
||||
}
|
||||
else{
|
||||
browser.SendMouseWheelEvent(0, 0, 0, BrowserUtils.Scale(NativeMethods.GetMouseHookData(lParam), Program.UserConfig.NotificationScrollSpeed*0.01), CefEventFlags.None);
|
||||
}
|
||||
|
||||
browser.SendMouseWheelEvent(0, 0, 0, BrowserUtils.Scale(NativeMethods.GetMouseHookData(lParam), Config.NotificationScrollSpeed * 0.01), CefEventFlags.None);
|
||||
return NativeMethods.HOOK_HANDLED;
|
||||
}
|
||||
else if (eventType == NativeMethods.WM_XBUTTONDOWN && DesktopBounds.Contains(Cursor.Position)){
|
||||
@@ -189,9 +152,11 @@ namespace TweetDuck.Core.Notification{
|
||||
}
|
||||
|
||||
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||
if (e.Frame.IsMain && browser.Address != "about:blank"){
|
||||
e.Frame.ExecuteJavaScriptAsync(PropertyBridge.GenerateScript(PropertyBridge.Environment.Notification));
|
||||
ScriptLoader.ExecuteScript(e.Frame, ScriptLoader.LoadResource("notification.js", this), "root:notification");
|
||||
IFrame frame = e.Frame;
|
||||
|
||||
if (frame.IsMain && browser.Address != "about:blank"){
|
||||
frame.ExecuteJavaScriptAsync(PropertyBridge.GenerateScript(PropertyBridge.Environment.Notification));
|
||||
CefScriptExecutor.RunFile(frame, "notification.js");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -201,14 +166,23 @@ namespace TweetDuck.Core.Notification{
|
||||
}
|
||||
|
||||
private void timerHideProgress_Tick(object sender, EventArgs e){
|
||||
if (Bounds.Contains(Cursor.Position) || FreezeTimer || ContextMenuOpen){
|
||||
bool isCursorInside = Bounds.Contains(Cursor.Position);
|
||||
|
||||
if (isCursorInside){
|
||||
StartMouseHook();
|
||||
}
|
||||
else{
|
||||
StopMouseHook(false);
|
||||
}
|
||||
|
||||
if (isCursorInside || FreezeTimer || ContextMenuOpen){
|
||||
return;
|
||||
}
|
||||
|
||||
timeLeft -= timerProgress.Interval;
|
||||
|
||||
int value = BrowserUtils.Scale(progressBarTimer.Maximum + 25, (totalTime - timeLeft) / (double)totalTime);
|
||||
progressBarTimer.SetValueInstant(Program.UserConfig.NotificationTimerCountDown ? progressBarTimer.Maximum-value : value);
|
||||
progressBarTimer.SetValueInstant(Config.NotificationTimerCountDown ? progressBarTimer.Maximum - value : value);
|
||||
|
||||
if (timeLeft <= 0){
|
||||
FinishCurrentNotification();
|
||||
@@ -217,14 +191,14 @@ namespace TweetDuck.Core.Notification{
|
||||
|
||||
// notification methods
|
||||
|
||||
public virtual void ShowNotification(TweetNotification notification){
|
||||
public virtual void ShowNotification(DesktopNotification notification){
|
||||
LoadTweet(notification);
|
||||
}
|
||||
|
||||
public override void HideNotification(){
|
||||
base.HideNotification();
|
||||
|
||||
progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? progressBarTimer.Maximum : progressBarTimer.Minimum;
|
||||
progressBarTimer.Value = Config.NotificationTimerCountDown ? progressBarTimer.Maximum : progressBarTimer.Minimum;
|
||||
timerProgress.Stop();
|
||||
totalTime = 0;
|
||||
|
||||
@@ -254,8 +228,8 @@ namespace TweetDuck.Core.Notification{
|
||||
}
|
||||
}
|
||||
|
||||
protected override string GetTweetHTML(TweetNotification tweet){
|
||||
string html = base.GetTweetHTML(tweet);
|
||||
protected override string GetTweetHTML(DesktopNotification tweet){
|
||||
string html = tweet.GenerateHtml(BodyClasses, HeadLayout, Config.CustomNotificationCSS);
|
||||
|
||||
foreach(InjectedHTML injection in plugins.NotificationInjections){
|
||||
html = injection.InjectInto(html);
|
||||
@@ -264,16 +238,16 @@ namespace TweetDuck.Core.Notification{
|
||||
return html;
|
||||
}
|
||||
|
||||
protected override void LoadTweet(TweetNotification tweet){
|
||||
protected override void LoadTweet(DesktopNotification tweet){
|
||||
timerProgress.Stop();
|
||||
totalTime = timeLeft = tweet.GetDisplayDuration(Program.UserConfig.NotificationDurationValue);
|
||||
progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? progressBarTimer.Maximum : progressBarTimer.Minimum;
|
||||
totalTime = timeLeft = tweet.GetDisplayDuration(Config.NotificationDurationValue);
|
||||
progressBarTimer.Value = Config.NotificationTimerCountDown ? progressBarTimer.Maximum : progressBarTimer.Minimum;
|
||||
|
||||
base.LoadTweet(tweet);
|
||||
}
|
||||
|
||||
protected override void SetNotificationSize(int width, int height){
|
||||
if (Program.UserConfig.DisplayNotificationTimer){
|
||||
if (Config.DisplayNotificationTimer){
|
||||
ClientSize = new Size(width, height + timerBarHeight);
|
||||
progressBarTimer.Visible = true;
|
||||
}
|
||||
@@ -292,7 +266,6 @@ namespace TweetDuck.Core.Notification{
|
||||
}
|
||||
|
||||
MoveToVisibleLocation();
|
||||
StartMouseHook();
|
||||
}
|
||||
|
||||
protected virtual void OnNotificationReady(){
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Notification {
|
||||
namespace TweetDuck.Browser.Notification {
|
||||
partial class FormNotificationTweet {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
@@ -1,11 +1,12 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using TweetDuck.Plugins;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Features.Notifications;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
|
||||
namespace TweetDuck.Core.Notification{
|
||||
namespace TweetDuck.Browser.Notification{
|
||||
sealed partial class FormNotificationTweet : FormNotificationMain{
|
||||
private const int NonIntrusiveIdleLimit = 30;
|
||||
private const int TrimMinimum = 32;
|
||||
@@ -25,17 +26,17 @@ namespace TweetDuck.Core.Notification{
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Queue<TweetNotification> tweetQueue = new Queue<TweetNotification>(4);
|
||||
private readonly Queue<DesktopNotification> tweetQueue = new Queue<DesktopNotification>(4);
|
||||
private bool needsTrim;
|
||||
private bool hasTemporarilyMoved;
|
||||
|
||||
public FormNotificationTweet(FormBrowser owner, PluginManager pluginManager) : base(owner, pluginManager, true){
|
||||
InitializeComponent();
|
||||
|
||||
Program.UserConfig.MuteToggled += Config_MuteToggled;
|
||||
Disposed += (sender, args) => Program.UserConfig.MuteToggled -= Config_MuteToggled;
|
||||
Config.MuteToggled += Config_MuteToggled;
|
||||
Disposed += (sender, args) => Config.MuteToggled -= Config_MuteToggled;
|
||||
|
||||
if (Program.UserConfig.MuteNotifications){
|
||||
if (Config.MuteNotifications){
|
||||
PauseNotification();
|
||||
}
|
||||
}
|
||||
@@ -57,7 +58,7 @@ namespace TweetDuck.Core.Notification{
|
||||
// event handlers
|
||||
|
||||
private void Config_MuteToggled(object sender, EventArgs e){
|
||||
if (Program.UserConfig.MuteNotifications){
|
||||
if (Config.MuteNotifications){
|
||||
PauseNotification();
|
||||
}
|
||||
else{
|
||||
@@ -73,7 +74,7 @@ namespace TweetDuck.Core.Notification{
|
||||
}
|
||||
|
||||
private void timerIdlePauseCheck_Tick(object sender, EventArgs e){
|
||||
if (NativeMethods.GetIdleSeconds() < Program.UserConfig.NotificationIdlePauseSeconds){
|
||||
if (NativeMethods.GetIdleSeconds() < Config.NotificationIdlePauseSeconds){
|
||||
ResumeNotification();
|
||||
timerIdlePauseCheck.Stop();
|
||||
}
|
||||
@@ -81,7 +82,7 @@ namespace TweetDuck.Core.Notification{
|
||||
|
||||
// notification methods
|
||||
|
||||
public override void ShowNotification(TweetNotification notification){
|
||||
public override void ShowNotification(DesktopNotification notification){
|
||||
tweetQueue.Enqueue(notification);
|
||||
|
||||
if (!IsPaused){
|
||||
@@ -128,7 +129,7 @@ namespace TweetDuck.Core.Notification{
|
||||
|
||||
private void LoadNextNotification(){
|
||||
if (!IsNotificationVisible){
|
||||
if (Program.UserConfig.NotificationNonIntrusiveMode && IsCursorOverNotificationArea && NativeMethods.GetIdleSeconds() < NonIntrusiveIdleLimit){
|
||||
if (Config.NotificationNonIntrusiveMode && IsCursorOverNotificationArea && NativeMethods.GetIdleSeconds() < NonIntrusiveIdleLimit){
|
||||
if (!timerCursorCheck.Enabled){
|
||||
PauseNotification();
|
||||
timerCursorCheck.Start();
|
||||
@@ -136,7 +137,7 @@ namespace TweetDuck.Core.Notification{
|
||||
|
||||
return;
|
||||
}
|
||||
else if (Program.UserConfig.NotificationIdlePauseSeconds > 0 && NativeMethods.GetIdleSeconds() >= Program.UserConfig.NotificationIdlePauseSeconds){
|
||||
else if (Config.NotificationIdlePauseSeconds > 0 && NativeMethods.GetIdleSeconds() >= Config.NotificationIdlePauseSeconds){
|
||||
if (!timerIdlePauseCheck.Enabled){
|
||||
PauseNotification();
|
||||
timerIdlePauseCheck.Start();
|
@@ -3,14 +3,15 @@ using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Other;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Data;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Resources;
|
||||
using TweetDuck.Browser.Adapters;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Dialogs;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Data;
|
||||
using TweetLib.Core.Features.Notifications;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
|
||||
namespace TweetDuck.Core.Notification.Screenshot{
|
||||
namespace TweetDuck.Browser.Notification.Screenshot{
|
||||
sealed class FormNotificationScreenshotable : FormNotificationBase{
|
||||
protected override bool CanDragWindow => false;
|
||||
|
||||
@@ -29,24 +30,23 @@ namespace TweetDuck.Core.Notification.Screenshot{
|
||||
return;
|
||||
}
|
||||
|
||||
string script = ScriptLoader.LoadResourceSilent("screenshot.js");
|
||||
string script = Program.Resources.LoadSilent("screenshot.js");
|
||||
|
||||
if (script == null){
|
||||
this.InvokeAsyncSafe(callback);
|
||||
return;
|
||||
}
|
||||
|
||||
using(IFrame frame = args.Browser.MainFrame){
|
||||
ScriptLoader.ExecuteScript(frame, script.Replace("{width}", realWidth.ToString()).Replace("{frames}", TweetScreenshotManager.WaitFrames.ToString()), "gen:screenshot");
|
||||
}
|
||||
using IFrame frame = args.Browser.MainFrame;
|
||||
CefScriptExecutor.RunScript(frame, script.Replace("{width}", realWidth.ToString()).Replace("{frames}", TweetScreenshotManager.WaitFrames.ToString()), "gen:screenshot");
|
||||
};
|
||||
|
||||
SetNotificationSize(realWidth, 1024);
|
||||
LoadTweet(new TweetNotification(string.Empty, string.Empty, string.Empty, html, 0, string.Empty, string.Empty));
|
||||
LoadTweet(new DesktopNotification(string.Empty, string.Empty, string.Empty, html, 0, string.Empty, string.Empty));
|
||||
}
|
||||
|
||||
protected override string GetTweetHTML(TweetNotification tweet){
|
||||
string html = tweet.GenerateHtml("td-screenshot", this);
|
||||
protected override string GetTweetHTML(DesktopNotification tweet){
|
||||
string html = tweet.GenerateHtml("td-screenshot", HeadLayout, Config.CustomNotificationCSS);
|
||||
|
||||
foreach(InjectedHTML injection in plugins.NotificationInjections){
|
||||
html = injection.InjectInto(html);
|
||||
@@ -82,7 +82,8 @@ namespace TweetDuck.Core.Notification.Screenshot{
|
||||
return false;
|
||||
}
|
||||
else{
|
||||
using(Bitmap bmp = new Bitmap(ClientSize.Width, Math.Max(1, height), PixelFormat.Format32bppRgb)){
|
||||
using Bitmap bmp = new Bitmap(ClientSize.Width, Math.Max(1, height), PixelFormat.Format32bppRgb);
|
||||
|
||||
try{
|
||||
NativeMethods.RenderSourceIntoBitmap(context, bmp);
|
||||
}finally{
|
||||
@@ -95,4 +96,3 @@ namespace TweetDuck.Core.Notification.Screenshot{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,8 +1,10 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Controls;
|
||||
|
||||
namespace TweetDuck.Core.Notification.Screenshot{
|
||||
namespace TweetDuck.Browser.Notification.Screenshot{
|
||||
[SuppressMessage("ReSharper", "UnusedMember.Global")]
|
||||
sealed class ScreenshotBridge{
|
||||
private readonly Control owner;
|
||||
|
@@ -8,8 +8,8 @@
|
||||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Controls;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
|
||||
#if GEN_SCREENSHOT_FRAMES
|
||||
using System.Drawing.Imaging;
|
||||
@@ -17,7 +17,7 @@ using System.IO;
|
||||
using TweetDuck.Core.Utils;
|
||||
#endif
|
||||
|
||||
namespace TweetDuck.Core.Notification.Screenshot{
|
||||
namespace TweetDuck.Browser.Notification.Screenshot{
|
||||
sealed class TweetScreenshotManager : IDisposable{
|
||||
private readonly FormBrowser owner;
|
||||
private readonly PluginManager plugins;
|
48
Browser/Notification/SoundNotification.cs
Normal file
48
Browser/Notification/SoundNotification.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Dialogs;
|
||||
using TweetDuck.Dialogs.Settings;
|
||||
using TweetDuck.Management;
|
||||
|
||||
namespace TweetDuck.Browser.Notification{
|
||||
static class SoundNotification{
|
||||
public const string SupportedFormats = "*.wav;*.ogg;*.mp3;*.flac;*.opus;*.weba;*.webm";
|
||||
|
||||
public static IResourceHandler CreateFileHandler(string path){
|
||||
string mimeType = Path.GetExtension(path) switch{
|
||||
".weba" => "audio/webm",
|
||||
".webm" => "audio/webm",
|
||||
".wav" => "audio/wav",
|
||||
".ogg" => "audio/ogg",
|
||||
".mp3" => "audio/mp3",
|
||||
".flac" => "audio/flac",
|
||||
".opus" => "audio/ogg; codecs=opus",
|
||||
_ => null
|
||||
};
|
||||
|
||||
try{
|
||||
return ResourceHandler.FromFilePath(path, mimeType);
|
||||
}catch{
|
||||
FormBrowser browser = FormManager.TryFind<FormBrowser>();
|
||||
|
||||
browser?.InvokeAsyncSafe(() => {
|
||||
using FormMessage form = new FormMessage("Sound Notification Error", "Could not find custom notification sound file:\n" + path, MessageBoxIcon.Error);
|
||||
form.AddButton(FormMessage.Ignore, ControlType.Cancel | ControlType.Focused);
|
||||
|
||||
Button btnViewOptions = form.AddButton("View Options");
|
||||
btnViewOptions.Width += 16;
|
||||
btnViewOptions.Location = new Point(btnViewOptions.Location.X - 16, btnViewOptions.Location.Y);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions){
|
||||
browser.OpenSettings(typeof(TabSettingsSounds));
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,21 +1,10 @@
|
||||
namespace TweetDuck.Core.Other {
|
||||
namespace TweetDuck.Browser {
|
||||
partial class TrayIcon {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
@@ -4,13 +4,13 @@ using System.Windows.Forms;
|
||||
using TweetDuck.Configuration;
|
||||
using Res = TweetDuck.Properties.Resources;
|
||||
|
||||
namespace TweetDuck.Core.Other{
|
||||
namespace TweetDuck.Browser{
|
||||
sealed partial class TrayIcon : Component{
|
||||
public enum Behavior{ // keep order
|
||||
Disabled, DisplayOnly, MinimizeToTray, CloseToTray, Combined
|
||||
}
|
||||
|
||||
private static UserConfig Config => Program.UserConfig;
|
||||
private static UserConfig Config => Program.Config.User;
|
||||
|
||||
public event EventHandler ClickRestore;
|
||||
public event EventHandler ClickClose;
|
||||
@@ -56,12 +56,22 @@ namespace TweetDuck.Core.Other{
|
||||
this.notifyIcon.Text = Program.BrandName;
|
||||
|
||||
Config.MuteToggled += Config_MuteToggled;
|
||||
Disposed += (sender, args) => Config.MuteToggled -= Config_MuteToggled;
|
||||
}
|
||||
|
||||
public TrayIcon(IContainer container) : this(){
|
||||
container.Add(this);
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing){
|
||||
if (disposing){
|
||||
components?.Dispose();
|
||||
contextMenu.Dispose();
|
||||
}
|
||||
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void UpdateIcon(){
|
||||
if (Visible){
|
||||
notifyIcon.Icon = hasNotifications ? Res.icon_tray_new : Config.MuteNotifications ? Res.icon_tray_muted : Res.icon_tray;
|
@@ -4,19 +4,27 @@ using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using TweetDuck.Browser.Adapters;
|
||||
using TweetDuck.Browser.Bridge;
|
||||
using TweetDuck.Browser.Handling;
|
||||
using TweetDuck.Browser.Handling.General;
|
||||
using TweetDuck.Browser.Notification;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Core.Bridge;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Handling;
|
||||
using TweetDuck.Core.Handling.General;
|
||||
using TweetDuck.Core.Management;
|
||||
using TweetDuck.Core.Notification;
|
||||
using TweetDuck.Core.Other.Interfaces;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Resources;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
using TweetLib.Core.Features.Plugins.Enums;
|
||||
using TweetLib.Core.Features.Twitter;
|
||||
using TweetLib.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Browser{
|
||||
sealed class TweetDeckBrowser : IDisposable{
|
||||
private static UserConfig Config => Program.Config.User;
|
||||
|
||||
private const string ErrorUrl = "http://td/error";
|
||||
private const string TwitterStyleUrl = "https://abs.twimg.com/tduck/css";
|
||||
|
||||
namespace TweetDuck.Core{
|
||||
sealed class TweetDeckBrowser : ITweetDeckBrowser, IDisposable{
|
||||
public bool Ready { get; private set; }
|
||||
|
||||
public bool Enabled{
|
||||
@@ -30,27 +38,31 @@ namespace TweetDuck.Core{
|
||||
return false;
|
||||
}
|
||||
|
||||
using(IFrame frame = browser.GetBrowser().MainFrame){
|
||||
return TwitterUtils.IsTweetDeckWebsite(frame);
|
||||
}
|
||||
using IFrame frame = browser.GetBrowser().MainFrame;
|
||||
return TwitterUrls.IsTweetDeck(frame.Url);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ChromiumWebBrowser browser;
|
||||
private readonly ResourceHandlerFactory resourceHandlerFactory = new ResourceHandlerFactory();
|
||||
|
||||
private string prevSoundNotificationPath = null;
|
||||
|
||||
public TweetDeckBrowser(FormBrowser owner, TweetDeckBridge bridge){
|
||||
public TweetDeckBrowser(FormBrowser owner, PluginManager plugins, TweetDeckBridge tdBridge, UpdateBridge updateBridge){
|
||||
resourceHandlerFactory.RegisterHandler(FormNotificationBase.AppLogo);
|
||||
resourceHandlerFactory.RegisterHandler(TwitterUtils.LoadingSpinner);
|
||||
|
||||
RequestHandlerBrowser requestHandler = new RequestHandlerBrowser();
|
||||
|
||||
this.browser = new ChromiumWebBrowser(TwitterUtils.TweetDeckURL){
|
||||
this.browser = new ChromiumWebBrowser(TwitterUrls.TweetDeck){
|
||||
DialogHandler = new FileDialogHandler(),
|
||||
DragHandler = new DragHandlerBrowser(requestHandler),
|
||||
MenuHandler = new ContextMenuBrowser(owner),
|
||||
JsDialogHandler = new JavaScriptDialogHandler(),
|
||||
KeyboardHandler = new KeyboardHandlerBrowser(owner),
|
||||
LifeSpanHandler = new LifeSpanHandler(),
|
||||
RequestHandler = requestHandler
|
||||
RequestHandler = requestHandler,
|
||||
ResourceHandlerFactory = resourceHandlerFactory
|
||||
};
|
||||
|
||||
this.browser.LoadingStateChanged += browser_LoadingStateChanged;
|
||||
@@ -58,20 +70,19 @@ namespace TweetDuck.Core{
|
||||
this.browser.FrameLoadEnd += browser_FrameLoadEnd;
|
||||
this.browser.LoadError += browser_LoadError;
|
||||
|
||||
this.browser.RegisterAsyncJsObject("$TD", bridge);
|
||||
this.browser.RegisterAsyncJsObject("$TD", tdBridge);
|
||||
this.browser.RegisterAsyncJsObject("$TDU", updateBridge);
|
||||
|
||||
this.browser.BrowserSettings.BackgroundColor = (uint)TwitterUtils.BackgroundColor.ToArgb();
|
||||
this.browser.Dock = DockStyle.None;
|
||||
this.browser.Location = ControlExtensions.InvisibleLocation;
|
||||
|
||||
this.browser.SetupResourceHandler(TweetNotification.AppLogo);
|
||||
this.browser.SetupResourceHandler(TwitterUtils.LoadingSpinner);
|
||||
this.browser.SetupZoomEvents();
|
||||
|
||||
owner.Controls.Add(browser);
|
||||
plugins.Register(PluginEnvironment.Browser, new PluginDispatcher(browser));
|
||||
|
||||
Program.UserConfig.MuteToggled += UserConfig_MuteToggled;
|
||||
Program.UserConfig.ZoomLevelChanged += UserConfig_ZoomLevelChanged;
|
||||
Program.UserConfig.SoundNotificationChanged += UserConfig_SoundNotificationInfoChanged;
|
||||
Config.MuteToggled += Config_MuteToggled;
|
||||
Config.SoundNotificationChanged += Config_SoundNotificationInfoChanged;
|
||||
}
|
||||
|
||||
// setup and management
|
||||
@@ -89,31 +100,12 @@ namespace TweetDuck.Core{
|
||||
}
|
||||
|
||||
public void Dispose(){
|
||||
Program.UserConfig.MuteToggled -= UserConfig_MuteToggled;
|
||||
Program.UserConfig.ZoomLevelChanged -= UserConfig_ZoomLevelChanged;
|
||||
Program.UserConfig.SoundNotificationChanged -= UserConfig_SoundNotificationInfoChanged;
|
||||
Config.MuteToggled -= Config_MuteToggled;
|
||||
Config.SoundNotificationChanged -= Config_SoundNotificationInfoChanged;
|
||||
|
||||
browser.Dispose();
|
||||
}
|
||||
|
||||
void ITweetDeckBrowser.RegisterBridge(string name, object obj){
|
||||
browser.RegisterAsyncJsObject(name, obj);
|
||||
}
|
||||
|
||||
void ITweetDeckBrowser.OnFrameLoaded(Action<IFrame> callback){
|
||||
browser.FrameLoadEnd += (sender, args) => {
|
||||
IFrame frame = args.Frame;
|
||||
|
||||
if (frame.IsMain && TwitterUtils.IsTweetDeckWebsite(frame)){
|
||||
callback(frame);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void ITweetDeckBrowser.ExecuteFunction(string name, params object[] args){
|
||||
browser.ExecuteScriptAsync(name, args);
|
||||
}
|
||||
|
||||
// event handlers
|
||||
|
||||
private void browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){
|
||||
@@ -131,41 +123,51 @@ namespace TweetDuck.Core{
|
||||
IFrame frame = e.Frame;
|
||||
|
||||
if (frame.IsMain){
|
||||
if (Program.UserConfig.ZoomLevel != 100){
|
||||
BrowserUtils.SetZoomLevel(browser.GetBrowser(), Program.UserConfig.ZoomLevel);
|
||||
}
|
||||
|
||||
if (TwitterUtils.IsTwitterWebsite(frame)){
|
||||
ScriptLoader.ExecuteFile(frame, "twitter.js", browser);
|
||||
string url = frame.Url;
|
||||
|
||||
if (TwitterUrls.IsTwitter(url)){
|
||||
string css = Program.Resources.Load("styles/twitter.css");
|
||||
resourceHandlerFactory.RegisterHandler(TwitterStyleUrl, ResourceHandler.FromString(css, mimeType: "text/css"));
|
||||
|
||||
CefScriptExecutor.RunFile(frame, "twitter.js");
|
||||
}
|
||||
|
||||
if (!TwitterUrls.IsTwitterLogin2Factor(url)){
|
||||
frame.ExecuteJavaScriptAsync(TwitterUtils.BackgroundColorOverride);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||
IFrame frame = e.Frame;
|
||||
string url = frame.Url;
|
||||
|
||||
if (frame.IsMain && TwitterUtils.IsTweetDeckWebsite(frame)){
|
||||
if (frame.IsMain){
|
||||
if (TwitterUrls.IsTweetDeck(url)){
|
||||
UpdateProperties();
|
||||
TweetDeckBridge.RestoreSessionData(frame);
|
||||
ScriptLoader.ExecuteFile(frame, "code.js", browser);
|
||||
ScriptLoader.ExecuteFile(frame, "update.js", browser);
|
||||
CefScriptExecutor.RunFile(frame, "code.js");
|
||||
|
||||
InjectBrowserCSS();
|
||||
ReinjectCustomCSS(Program.UserConfig.CustomBrowserCSS);
|
||||
UserConfig_SoundNotificationInfoChanged(null, EventArgs.Empty);
|
||||
ReinjectCustomCSS(Config.CustomBrowserCSS);
|
||||
Config_SoundNotificationInfoChanged(null, EventArgs.Empty);
|
||||
|
||||
TweetDeckBridge.ResetStaticProperties();
|
||||
|
||||
if (Arguments.HasFlag(Arguments.ArgIgnoreGDPR)){
|
||||
ScriptLoader.ExecuteScript(frame, "TD.storage.Account.prototype.requiresConsent = function(){ return false; }", "gen:gdpr");
|
||||
CefScriptExecutor.RunScript(frame, "TD.storage.Account.prototype.requiresConsent = function(){ return false; }", "gen:gdpr");
|
||||
}
|
||||
|
||||
if (Program.UserConfig.FirstRun){
|
||||
ScriptLoader.ExecuteFile(frame, "introduction.js", browser);
|
||||
if (Config.FirstRun){
|
||||
CefScriptExecutor.RunFile(frame, "introduction.js");
|
||||
}
|
||||
}
|
||||
|
||||
CefScriptExecutor.RunFile(frame, "update.js");
|
||||
}
|
||||
|
||||
if (url == ErrorUrl){
|
||||
resourceHandlerFactory.UnregisterHandler(ErrorUrl);
|
||||
}
|
||||
}
|
||||
|
||||
private void browser_LoadError(object sender, LoadErrorEventArgs e){
|
||||
@@ -174,32 +176,40 @@ namespace TweetDuck.Core{
|
||||
}
|
||||
|
||||
if (!e.FailedUrl.StartsWith("http://td/", StringComparison.Ordinal)){
|
||||
string errorPage = ScriptLoader.LoadResourceSilent("pages/error.html");
|
||||
string errorPage = Program.Resources.LoadSilent("pages/error.html");
|
||||
|
||||
if (errorPage != null){
|
||||
browser.LoadHtml(errorPage.Replace("{err}", BrowserUtils.GetErrorName(e.ErrorCode)), "http://td/error");
|
||||
string errorName = Enum.GetName(typeof(CefErrorCode), e.ErrorCode);
|
||||
string errorTitle = StringUtils.ConvertPascalCaseToScreamingSnakeCase(errorName ?? string.Empty);
|
||||
|
||||
resourceHandlerFactory.RegisterHandler(ErrorUrl, ResourceHandler.FromString(errorPage.Replace("{err}", errorTitle)));
|
||||
browser.Load(ErrorUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void UserConfig_MuteToggled(object sender, EventArgs e){
|
||||
private void Config_MuteToggled(object sender, EventArgs e){
|
||||
UpdateProperties();
|
||||
}
|
||||
|
||||
private void UserConfig_ZoomLevelChanged(object sender, EventArgs e){
|
||||
BrowserUtils.SetZoomLevel(browser.GetBrowser(), Program.UserConfig.ZoomLevel);
|
||||
}
|
||||
|
||||
private void UserConfig_SoundNotificationInfoChanged(object sender, EventArgs e){
|
||||
private void Config_SoundNotificationInfoChanged(object sender, EventArgs e){
|
||||
const string soundUrl = "https://ton.twimg.com/tduck/updatesnd";
|
||||
bool hasCustomSound = Program.UserConfig.IsCustomSoundNotificationSet;
|
||||
|
||||
if (prevSoundNotificationPath != Program.UserConfig.NotificationSoundPath){
|
||||
browser.SetupResourceHandler(soundUrl, hasCustomSound ? SoundNotification.CreateFileHandler(Program.UserConfig.NotificationSoundPath) : null);
|
||||
prevSoundNotificationPath = Program.UserConfig.NotificationSoundPath;
|
||||
bool hasCustomSound = Config.IsCustomSoundNotificationSet;
|
||||
string newNotificationPath = Config.NotificationSoundPath;
|
||||
|
||||
if (prevSoundNotificationPath != newNotificationPath){
|
||||
prevSoundNotificationPath = newNotificationPath;
|
||||
|
||||
if (hasCustomSound){
|
||||
resourceHandlerFactory.RegisterHandler(soundUrl, SoundNotification.CreateFileHandler(newNotificationPath));
|
||||
}
|
||||
else{
|
||||
resourceHandlerFactory.UnregisterHandler(soundUrl);
|
||||
}
|
||||
}
|
||||
|
||||
browser.ExecuteScriptAsync("TDGF_setSoundNotificationData", hasCustomSound, Program.UserConfig.NotificationSoundVolume);
|
||||
browser.ExecuteScriptAsync("TDGF_setSoundNotificationData", hasCustomSound, Config.NotificationSoundVolume);
|
||||
}
|
||||
|
||||
// external handling
|
||||
@@ -215,7 +225,7 @@ namespace TweetDuck.Core{
|
||||
// javascript calls
|
||||
|
||||
public void ReloadToTweetDeck(){
|
||||
browser.ExecuteScriptAsync($"if(window.TDGF_reload)window.TDGF_reload();else window.location.href='{TwitterUtils.TweetDeckURL}'");
|
||||
browser.ExecuteScriptAsync($"if(window.TDGF_reload)window.TDGF_reload();else window.location.href='{TwitterUrls.TweetDeck}'");
|
||||
}
|
||||
|
||||
public void UpdateProperties(){
|
||||
@@ -223,7 +233,7 @@ namespace TweetDuck.Core{
|
||||
}
|
||||
|
||||
public void InjectBrowserCSS(){
|
||||
browser.ExecuteScriptAsync("TDGF_injectBrowserCSS", ScriptLoader.LoadResource("styles/browser.css", browser)?.TrimEnd() ?? string.Empty);
|
||||
browser.ExecuteScriptAsync("TDGF_injectBrowserCSS", Program.Resources.Load("styles/browser.css")?.TrimEnd() ?? string.Empty);
|
||||
}
|
||||
|
||||
public void ReinjectCustomCSS(string css){
|
||||
@@ -263,7 +273,7 @@ namespace TweetDuck.Core{
|
||||
}
|
||||
|
||||
public void OpenDevTools(){
|
||||
browser.ShowDevTools();
|
||||
browser.OpenDevToolsCustom();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
using System;
|
||||
using TweetDuck.Data;
|
||||
using TweetLib.Core.Collections;
|
||||
|
||||
namespace TweetDuck.Configuration{
|
||||
static class Arguments{
|
||||
@@ -7,7 +7,7 @@ namespace TweetDuck.Configuration{
|
||||
public const string ArgDataFolder = "-datafolder";
|
||||
public const string ArgLogging = "-log";
|
||||
public const string ArgIgnoreGDPR = "-nogdpr";
|
||||
public const string ArgNotificationScrollWA = "-nscrollwa";
|
||||
public const string ArgFreeze = "-freeze";
|
||||
|
||||
// internal args
|
||||
public const string ArgRestart = "-restart";
|
||||
@@ -22,8 +22,8 @@ namespace TweetDuck.Configuration{
|
||||
return Current.HasFlag(flag);
|
||||
}
|
||||
|
||||
public static string GetValue(string key, string defaultValue){
|
||||
return Current.GetValue(key, defaultValue);
|
||||
public static string GetValue(string key){
|
||||
return Current.GetValue(key);
|
||||
}
|
||||
|
||||
public static CommandLineArgs GetCurrentClean(){
|
||||
|
82
Configuration/ConfigManager.cs
Normal file
82
Configuration/ConfigManager.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using TweetDuck.Browser.Data;
|
||||
using TweetLib.Core.Features.Configuration;
|
||||
using TweetLib.Core.Features.Plugins.Config;
|
||||
using TweetLib.Core.Serialization.Converters;
|
||||
using TweetLib.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Configuration{
|
||||
sealed class ConfigManager : IConfigManager{
|
||||
public UserConfig User { get; }
|
||||
public SystemConfig System { get; }
|
||||
public PluginConfig Plugins { get; }
|
||||
|
||||
public event EventHandler ProgramRestartRequested;
|
||||
|
||||
private readonly FileConfigInstance<UserConfig> infoUser;
|
||||
private readonly FileConfigInstance<SystemConfig> infoSystem;
|
||||
private readonly PluginConfigInstance<PluginConfig> infoPlugins;
|
||||
|
||||
private readonly IConfigInstance<BaseConfig>[] infoList;
|
||||
|
||||
public ConfigManager(){
|
||||
User = new UserConfig(this);
|
||||
System = new SystemConfig(this);
|
||||
Plugins = new PluginConfig(this);
|
||||
|
||||
infoList = new IConfigInstance<BaseConfig>[]{
|
||||
infoUser = new FileConfigInstance<UserConfig>(Program.UserConfigFilePath, User, "program options"),
|
||||
infoSystem = new FileConfigInstance<SystemConfig>(Program.SystemConfigFilePath, System, "system options"),
|
||||
infoPlugins = new PluginConfigInstance<PluginConfig>(Program.PluginConfigFilePath, Plugins)
|
||||
};
|
||||
|
||||
// TODO refactor further
|
||||
|
||||
infoUser.Serializer.RegisterTypeConverter(typeof(WindowState), WindowState.Converter);
|
||||
|
||||
infoUser.Serializer.RegisterTypeConverter(typeof(Point), new SingleTypeConverter<Point>{
|
||||
ConvertToString = value => $"{value.X} {value.Y}",
|
||||
ConvertToObject = value => {
|
||||
int[] elements = StringUtils.ParseInts(value, ' ');
|
||||
return new Point(elements[0], elements[1]);
|
||||
}
|
||||
});
|
||||
|
||||
infoUser.Serializer.RegisterTypeConverter(typeof(Size), new SingleTypeConverter<Size>{
|
||||
ConvertToString = value => $"{value.Width} {value.Height}",
|
||||
ConvertToObject = value => {
|
||||
int[] elements = StringUtils.ParseInts(value, ' ');
|
||||
return new Size(elements[0], elements[1]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void LoadAll(){
|
||||
infoUser.Load();
|
||||
infoSystem.Load();
|
||||
infoPlugins.Load();
|
||||
}
|
||||
|
||||
public void SaveAll(){
|
||||
infoUser.Save();
|
||||
infoSystem.Save();
|
||||
infoPlugins.Save();
|
||||
}
|
||||
|
||||
public void ReloadAll(){
|
||||
infoUser.Reload();
|
||||
infoSystem.Reload();
|
||||
infoPlugins.Reload();
|
||||
}
|
||||
|
||||
void IConfigManager.TriggerProgramRestartRequested(){
|
||||
ProgramRestartRequested?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
|
||||
IConfigInstance<BaseConfig> IConfigManager.GetInstanceInfo(BaseConfig instance){
|
||||
Type instanceType = instance.GetType();
|
||||
return Array.Find(infoList, info => info.Instance.GetType() == instanceType); // TODO handle null
|
||||
}
|
||||
}
|
||||
}
|
51
Configuration/PluginConfig.cs
Normal file
51
Configuration/PluginConfig.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using TweetLib.Core.Features.Configuration;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
using TweetLib.Core.Features.Plugins.Config;
|
||||
using TweetLib.Core.Features.Plugins.Events;
|
||||
|
||||
namespace TweetDuck.Configuration{
|
||||
sealed class PluginConfig : BaseConfig, IPluginConfig{
|
||||
private static readonly string[] DefaultDisabled = {
|
||||
"official/clear-columns",
|
||||
"official/reply-account"
|
||||
};
|
||||
|
||||
// CONFIGURATION DATA
|
||||
|
||||
private readonly HashSet<string> disabled = new HashSet<string>(DefaultDisabled);
|
||||
|
||||
// EVENTS
|
||||
|
||||
public event EventHandler<PluginChangedStateEventArgs> PluginChangedState;
|
||||
|
||||
// END OF CONFIG
|
||||
|
||||
public PluginConfig(IConfigManager configManager) : base(configManager){}
|
||||
|
||||
protected override BaseConfig ConstructWithDefaults(IConfigManager configManager){
|
||||
return new PluginConfig(configManager);
|
||||
}
|
||||
|
||||
// INTERFACE IMPLEMENTATION
|
||||
|
||||
IEnumerable<string> IPluginConfig.DisabledPlugins => disabled;
|
||||
|
||||
void IPluginConfig.Reset(IEnumerable<string> newDisabledPlugins){
|
||||
disabled.Clear();
|
||||
disabled.UnionWith(newDisabledPlugins);
|
||||
}
|
||||
|
||||
public void SetEnabled(Plugin plugin, bool enabled){
|
||||
if ((enabled && disabled.Remove(plugin.Identifier)) || (!enabled && disabled.Add(plugin.Identifier))){
|
||||
PluginChangedState?.Invoke(this, new PluginChangedStateEventArgs(plugin, enabled));
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsEnabled(Plugin plugin){
|
||||
return !disabled.Contains(plugin.Identifier);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,43 +1,28 @@
|
||||
using System;
|
||||
using TweetDuck.Data.Serialization;
|
||||
using TweetLib.Core.Features.Configuration;
|
||||
|
||||
namespace TweetDuck.Configuration{
|
||||
sealed class SystemConfig{
|
||||
private static readonly FileSerializer<SystemConfig> Serializer = new FileSerializer<SystemConfig>();
|
||||
sealed class SystemConfig : BaseConfig{
|
||||
|
||||
// CONFIGURATION DATA
|
||||
|
||||
public bool HardwareAcceleration { get; set; } = true;
|
||||
public bool _hardwareAcceleration = true;
|
||||
|
||||
public bool ClearCacheAutomatically { get; set; } = true;
|
||||
public int ClearCacheThreshold { get; set; } = 250;
|
||||
|
||||
// SPECIAL PROPERTIES
|
||||
|
||||
public bool HardwareAcceleration{
|
||||
get => _hardwareAcceleration;
|
||||
set => UpdatePropertyWithRestartRequest(ref _hardwareAcceleration, value);
|
||||
}
|
||||
|
||||
// END OF CONFIG
|
||||
|
||||
private readonly string file;
|
||||
public SystemConfig(IConfigManager configManager) : base(configManager){}
|
||||
|
||||
private SystemConfig(string file){
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
public void Save(){
|
||||
try{
|
||||
Serializer.Write(file, this);
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not save the system configuration file.", true, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static SystemConfig Load(string file){
|
||||
SystemConfig config = new SystemConfig(file);
|
||||
|
||||
try{
|
||||
Serializer.ReadIfExists(file, config);
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not open the system configuration file. If you continue, you will lose system specific configuration such as Hardware Acceleration.", true, e);
|
||||
}
|
||||
|
||||
return config;
|
||||
protected override BaseConfig ConstructWithDefaults(IConfigManager configManager){
|
||||
return new SystemConfig(configManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,37 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Notification;
|
||||
using TweetDuck.Core.Other;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Data;
|
||||
using TweetDuck.Data.Serialization;
|
||||
using TweetDuck.Browser;
|
||||
using TweetDuck.Browser.Data;
|
||||
using TweetDuck.Controls;
|
||||
using TweetLib.Core.Features.Configuration;
|
||||
using TweetLib.Core.Features.Notifications;
|
||||
using TweetLib.Core.Features.Twitter;
|
||||
|
||||
namespace TweetDuck.Configuration{
|
||||
sealed class UserConfig{
|
||||
private static readonly FileSerializer<UserConfig> Serializer = new FileSerializer<UserConfig>();
|
||||
|
||||
static UserConfig(){
|
||||
Serializer.RegisterTypeConverter(typeof(WindowState), WindowState.Converter);
|
||||
|
||||
Serializer.RegisterTypeConverter(typeof(Point), new SingleTypeConverter<Point>{
|
||||
ConvertToString = value => $"{value.X} {value.Y}",
|
||||
ConvertToObject = value => {
|
||||
int[] elements = StringUtils.ParseInts(value, ' ');
|
||||
return new Point(elements[0], elements[1]);
|
||||
}
|
||||
});
|
||||
|
||||
Serializer.RegisterTypeConverter(typeof(Size), new SingleTypeConverter<Size>{
|
||||
ConvertToString = value => $"{value.Width} {value.Height}",
|
||||
ConvertToObject = value => {
|
||||
int[] elements = StringUtils.ParseInts(value, ' ');
|
||||
return new Size(elements[0], elements[1]);
|
||||
}
|
||||
});
|
||||
}
|
||||
sealed class UserConfig : BaseConfig{
|
||||
|
||||
// CONFIGURATION DATA
|
||||
|
||||
@@ -42,23 +19,31 @@ namespace TweetDuck.Configuration{
|
||||
public Size PluginsWindowSize { get; set; } = Size.Empty;
|
||||
|
||||
public bool ExpandLinksOnHover { get; set; } = true;
|
||||
public bool FocusDmInput { get; set; } = true;
|
||||
public bool OpenSearchInFirstColumn { get; set; } = true;
|
||||
public bool KeepLikeFollowDialogsOpen { get; set; } = true;
|
||||
public bool BestImageQuality { get; set; } = true;
|
||||
public bool EnableAnimatedImages { get; set; } = true;
|
||||
|
||||
public bool IgnoreTrackingUrlWarning { get; set; } = false;
|
||||
public bool EnableSmoothScrolling { get; set; } = true;
|
||||
private bool _enableSmoothScrolling = true;
|
||||
private bool _enableTouchAdjustment = false;
|
||||
private string _customCefArgs = null;
|
||||
|
||||
public string BrowserPath { get; set; } = null;
|
||||
public string BrowserPathArgs { get; set; } = null;
|
||||
public bool IgnoreTrackingUrlWarning { get; set; } = false;
|
||||
public string SearchEngineUrl { get; set; } = null;
|
||||
private int _zoomLevel = 100;
|
||||
private bool _muteNotifications;
|
||||
|
||||
public string VideoPlayerPath { get; set; } = null;
|
||||
public string VideoPlayerPathArgs { get; set; } = null;
|
||||
public int VideoPlayerVolume { get; set; } = 50;
|
||||
|
||||
public bool EnableSpellCheck { get; set; } = false;
|
||||
public string SpellCheckLanguage { get; set; } = "en-US";
|
||||
private string _spellCheckLanguage = "en-US";
|
||||
|
||||
public string TranslationTarget { get; set; } = "en";
|
||||
public int CalendarFirstDay { get; set; } = -1;
|
||||
|
||||
private TrayIcon.Behavior _trayBehavior = TrayIcon.Behavior.Disabled;
|
||||
public bool EnableTrayHighlight { get; set; } = true;
|
||||
@@ -76,29 +61,32 @@ namespace TweetDuck.Configuration{
|
||||
public bool NotificationTimerCountDown { get; set; } = false;
|
||||
public int NotificationDurationValue { get; set; } = 25;
|
||||
|
||||
public TweetNotification.Position NotificationPosition { get; set; } = TweetNotification.Position.TopRight;
|
||||
public DesktopNotification.Position NotificationPosition { get; set; } = DesktopNotification.Position.TopRight;
|
||||
public Point CustomNotificationPosition { get; set; } = ControlExtensions.InvisibleLocation;
|
||||
public int NotificationDisplay { get; set; } = 0;
|
||||
public int NotificationEdgeDistance { get; set; } = 8;
|
||||
|
||||
public TweetNotification.Size NotificationSize { get; set; } = TweetNotification.Size.Auto;
|
||||
public DesktopNotification.Size NotificationSize { get; set; } = DesktopNotification.Size.Auto;
|
||||
public Size CustomNotificationSize { get; set; } = Size.Empty;
|
||||
public int NotificationScrollSpeed { get; set; } = 100;
|
||||
|
||||
private string _notificationSoundPath;
|
||||
private int _notificationSoundVolume = 100;
|
||||
|
||||
public string CustomCefArgs { get; set; } = null;
|
||||
private bool _muteNotifications;
|
||||
|
||||
public string CustomBrowserCSS { get; set; } = null;
|
||||
public string CustomNotificationCSS { get; set; } = null;
|
||||
|
||||
public bool DevToolsWindowOnTop { get; set; } = true;
|
||||
|
||||
// SPECIAL PROPERTIES
|
||||
|
||||
public bool IsCustomNotificationPositionSet => CustomNotificationPosition != ControlExtensions.InvisibleLocation;
|
||||
public bool IsCustomNotificationSizeSet => CustomNotificationSize != Size.Empty;
|
||||
public bool IsCustomSoundNotificationSet => NotificationSoundPath != string.Empty;
|
||||
|
||||
public TwitterUtils.ImageQuality TwitterImageQuality => BestImageQuality ? TwitterUtils.ImageQuality.Orig : TwitterUtils.ImageQuality.Default;
|
||||
public ImageQuality TwitterImageQuality => BestImageQuality ? ImageQuality.Best : ImageQuality.Default;
|
||||
|
||||
public string NotificationSoundPath{
|
||||
get => _notificationSoundPath ?? string.Empty;
|
||||
@@ -125,6 +113,26 @@ namespace TweetDuck.Configuration{
|
||||
set => UpdatePropertyWithEvent(ref _trayBehavior, value, TrayBehaviorChanged);
|
||||
}
|
||||
|
||||
public bool EnableSmoothScrolling{
|
||||
get => _enableSmoothScrolling;
|
||||
set => UpdatePropertyWithRestartRequest(ref _enableSmoothScrolling, value);
|
||||
}
|
||||
|
||||
public bool EnableTouchAdjustment{
|
||||
get => _enableTouchAdjustment;
|
||||
set => UpdatePropertyWithRestartRequest(ref _enableTouchAdjustment, value);
|
||||
}
|
||||
|
||||
public string CustomCefArgs{
|
||||
get => _customCefArgs;
|
||||
set => UpdatePropertyWithRestartRequest(ref _customCefArgs, value);
|
||||
}
|
||||
|
||||
public string SpellCheckLanguage{
|
||||
get => _spellCheckLanguage;
|
||||
set => UpdatePropertyWithRestartRequest(ref _spellCheckLanguage, value);
|
||||
}
|
||||
|
||||
// EVENTS
|
||||
|
||||
public event EventHandler MuteToggled;
|
||||
@@ -134,105 +142,10 @@ namespace TweetDuck.Configuration{
|
||||
|
||||
// END OF CONFIG
|
||||
|
||||
private readonly string file;
|
||||
public UserConfig(IConfigManager configManager) : base(configManager){}
|
||||
|
||||
private UserConfig(string file){
|
||||
this.file = file;
|
||||
}
|
||||
|
||||
private void UpdatePropertyWithEvent<T>(ref T field, T value, EventHandler eventHandler){
|
||||
if (!EqualityComparer<T>.Default.Equals(field, value)){
|
||||
field = value;
|
||||
eventHandler?.Invoke(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public void Save(){
|
||||
try{
|
||||
if (File.Exists(file)){
|
||||
string backupFile = GetBackupFile(file);
|
||||
File.Delete(backupFile);
|
||||
File.Move(file, backupFile);
|
||||
}
|
||||
|
||||
Serializer.Write(file, this);
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not save the configuration file.", true, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void Reload(){
|
||||
try{
|
||||
LoadInternal(false);
|
||||
}catch(FileNotFoundException){
|
||||
try{
|
||||
Serializer.Write(file, new UserConfig(file));
|
||||
LoadInternal(false);
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not regenerate configuration file.", true, e);
|
||||
}
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not reload configuration file.", true, e);
|
||||
}
|
||||
}
|
||||
|
||||
public void Reset(){
|
||||
try{
|
||||
File.Delete(file);
|
||||
File.Delete(GetBackupFile(file));
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not delete configuration files to reset the options.", true, e);
|
||||
return;
|
||||
}
|
||||
|
||||
Reload();
|
||||
}
|
||||
|
||||
private void LoadInternal(bool backup){
|
||||
Serializer.Read(backup ? GetBackupFile(file) : file, this);
|
||||
|
||||
if (NotificationScrollSpeed == 10){ // incorrect initial value
|
||||
NotificationScrollSpeed = 100;
|
||||
Save();
|
||||
}
|
||||
}
|
||||
|
||||
public static UserConfig Load(string file){
|
||||
Exception firstException = null;
|
||||
|
||||
for(int attempt = 0; attempt < 2; attempt++){
|
||||
try{
|
||||
UserConfig config = new UserConfig(file);
|
||||
config.LoadInternal(attempt > 0);
|
||||
return config;
|
||||
}catch(FileNotFoundException){
|
||||
}catch(DirectoryNotFoundException){
|
||||
break;
|
||||
}catch(Exception e){
|
||||
if (attempt == 0){
|
||||
firstException = e;
|
||||
Program.Reporter.Log(e.ToString());
|
||||
}
|
||||
else if (firstException is FormatException){
|
||||
Program.Reporter.HandleException("Configuration Error", "The configuration file is outdated or corrupted. If you continue, your program options will be reset.", true, e);
|
||||
return new UserConfig(file);
|
||||
}
|
||||
else if (firstException != null){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not open the backup configuration file. If you continue, your program options will be reset.", true, e);
|
||||
return new UserConfig(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (firstException != null){
|
||||
Program.Reporter.HandleException("Configuration Error", "Could not open the configuration file.", true, firstException);
|
||||
}
|
||||
|
||||
return new UserConfig(file);
|
||||
}
|
||||
|
||||
public static string GetBackupFile(string file){
|
||||
return file+".bak";
|
||||
protected override BaseConfig ConstructWithDefaults(IConfigManager configManager){
|
||||
return new UserConfig(configManager);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDuck.Core.Controls{
|
||||
namespace TweetDuck.Controls{
|
||||
static class ControlExtensions{
|
||||
public static readonly Point InvisibleLocation = new Point(-32000, -32000);
|
||||
|
||||
@@ -21,17 +21,16 @@ namespace TweetDuck.Core.Controls{
|
||||
}
|
||||
|
||||
public static float GetDPIScale(this Control control){
|
||||
using(Graphics graphics = control.CreateGraphics()){
|
||||
using Graphics graphics = control.CreateGraphics();
|
||||
return graphics.DpiY / 96F;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool IsFullyOutsideView(this Form form){
|
||||
return !Screen.AllScreens.Any(screen => screen.WorkingArea.IntersectsWith(form.Bounds));
|
||||
}
|
||||
|
||||
public static void MoveToCenter(this Form targetForm, Form parentForm){
|
||||
targetForm.Location = new Point(parentForm.Location.X+parentForm.Width/2-targetForm.Width/2, parentForm.Location.Y+parentForm.Height/2-targetForm.Height/2);
|
||||
targetForm.Location = new Point(parentForm.Location.X + (parentForm.Width / 2) - (targetForm.Width / 2), parentForm.Location.Y + (parentForm.Height / 2) - (targetForm.Height / 2));
|
||||
}
|
||||
|
||||
public static void SetValueInstant(this ProgressBar bar, int value){
|
||||
@@ -63,7 +62,8 @@ namespace TweetDuck.Core.Controls{
|
||||
trackBar.Value = trackBar.SmallChange * (int)Math.Floor(((double)trackBar.Value / trackBar.SmallChange) + 0.5);
|
||||
return false;
|
||||
}
|
||||
else return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void EnableMultilineShortcuts(this TextBox textBox){
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDuck.Core.Controls{
|
||||
namespace TweetDuck.Controls{
|
||||
sealed class FlatButton : Button{
|
||||
protected override bool ShowFocusCues => false;
|
||||
|
@@ -2,7 +2,7 @@
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDuck.Core.Controls{
|
||||
namespace TweetDuck.Controls{
|
||||
sealed class FlatProgressBar : ProgressBar{
|
||||
private readonly SolidBrush brush;
|
||||
|
@@ -1,13 +1,8 @@
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Plugins.Controls{
|
||||
sealed class PluginListFlowLayout : FlowLayoutPanel{
|
||||
public PluginListFlowLayout(){
|
||||
FlowDirection = FlowDirection.TopDown;
|
||||
WrapContents = false;
|
||||
}
|
||||
using TweetDuck.Utils;
|
||||
|
||||
namespace TweetDuck.Controls{
|
||||
sealed class FlowLayoutPanelNoHScroll : FlowLayoutPanel{
|
||||
protected override void WndProc(ref Message m){
|
||||
if (m.Msg == 0x85){ // WM_NCPAINT
|
||||
NativeMethods.ShowScrollBar(Handle, NativeMethods.SB_HORZ, false); // basically fuck the horizontal scrollbar very much
|
22
Controls/LabelVertical.cs
Normal file
22
Controls/LabelVertical.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDuck.Controls{
|
||||
sealed class LabelVertical : Label{
|
||||
public int LineHeight { get; set; }
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e){
|
||||
int y = (int)Math.Floor((ClientRectangle.Height - Text.Length * LineHeight) / 2F) - 1;
|
||||
using Brush brush = new SolidBrush(ForeColor);
|
||||
|
||||
foreach(char chr in Text){
|
||||
string str = chr.ToString();
|
||||
float x = (ClientRectangle.Width - e.Graphics.MeasureString(str, Font).Width) / 2F;
|
||||
|
||||
e.Graphics.DrawString(str, Font, brush, x, y);
|
||||
y += LineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,7 @@
|
||||
using System.ComponentModel;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDuck.Core.Controls{
|
||||
namespace TweetDuck.Controls{
|
||||
sealed class NumericUpDownEx : NumericUpDown{
|
||||
public string TextSuffix { get; set ; }
|
||||
|
@@ -1,32 +0,0 @@
|
||||
using System.Text;
|
||||
|
||||
namespace TweetDuck.Core.Bridge{
|
||||
static class PropertyBridge{
|
||||
public enum Environment{
|
||||
Browser, Notification
|
||||
}
|
||||
|
||||
public static string GenerateScript(Environment environment){
|
||||
string Bool(bool value) => value ? "true;" : "false;";
|
||||
string Str(string value) => '"'+value+"\";";
|
||||
|
||||
StringBuilder build = new StringBuilder().Append("(function(x){");
|
||||
|
||||
build.Append("x.expandLinksOnHover=").Append(Bool(Program.UserConfig.ExpandLinksOnHover));
|
||||
|
||||
if (environment == Environment.Browser){
|
||||
build.Append("x.openSearchInFirstColumn=").Append(Bool(Program.UserConfig.OpenSearchInFirstColumn));
|
||||
build.Append("x.keepLikeFollowDialogsOpen=").Append(Bool(Program.UserConfig.KeepLikeFollowDialogsOpen));
|
||||
build.Append("x.muteNotifications=").Append(Bool(Program.UserConfig.MuteNotifications));
|
||||
build.Append("x.notificationMediaPreviews=").Append(Bool(Program.UserConfig.NotificationMediaPreviews));
|
||||
build.Append("x.translationTarget=").Append(Str(Program.UserConfig.TranslationTarget));
|
||||
}
|
||||
|
||||
if (environment == Environment.Notification){
|
||||
build.Append("x.skipOnLinkClick=").Append(Bool(Program.UserConfig.NotificationSkipOnLinkClick));
|
||||
}
|
||||
|
||||
return build.Append("})(window.$TDX=window.$TDX||{})").ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDuck.Core.Controls{
|
||||
sealed class LabelVertical : Label{
|
||||
public int LineHeight { get; set; }
|
||||
|
||||
protected override void OnPaint(PaintEventArgs e){
|
||||
int y = (int)Math.Floor((ClientRectangle.Height-Text.Length*LineHeight)/2F)-1;
|
||||
|
||||
using(Brush brush = new SolidBrush(ForeColor)){
|
||||
foreach(char chr in Text){
|
||||
string str = chr.ToString();
|
||||
float x = (ClientRectangle.Width-e.Graphics.MeasureString(str, Font).Width)/2F;
|
||||
|
||||
e.Graphics.DrawString(str, Font, brush, x, y);
|
||||
y += LineHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,20 +0,0 @@
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
|
||||
namespace TweetDuck.Core.Handling{
|
||||
sealed class KeyboardHandlerBrowser : IKeyboardHandler{
|
||||
private readonly FormBrowser form;
|
||||
|
||||
public KeyboardHandlerBrowser(FormBrowser form){
|
||||
this.form = form;
|
||||
}
|
||||
|
||||
bool IKeyboardHandler.OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut){
|
||||
return type == KeyType.RawKeyDown && form.ProcessBrowserKey((Keys)windowsKeyCode);
|
||||
}
|
||||
|
||||
bool IKeyboardHandler.OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,45 +0,0 @@
|
||||
using CefSharp;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Notification;
|
||||
|
||||
namespace TweetDuck.Core.Handling {
|
||||
sealed class KeyboardHandlerNotification : IKeyboardHandler{
|
||||
private readonly FormNotificationBase notification;
|
||||
|
||||
public KeyboardHandlerNotification(FormNotificationBase notification){
|
||||
this.notification = notification;
|
||||
}
|
||||
|
||||
private void TriggerKeyboardShortcutAnalytics(){
|
||||
notification.InvokeAsyncSafe(notification.AnalyticsFile.NotificationKeyboardShortcuts.Trigger);
|
||||
}
|
||||
|
||||
bool IKeyboardHandler.OnPreKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey, ref bool isKeyboardShortcut){
|
||||
if (type == KeyType.RawKeyDown && !browser.FocusedFrame.Url.StartsWith("chrome-devtools://")){
|
||||
switch((Keys)windowsKeyCode){
|
||||
case Keys.Enter:
|
||||
notification.InvokeAsyncSafe(notification.FinishCurrentNotification);
|
||||
TriggerKeyboardShortcutAnalytics();
|
||||
return true;
|
||||
|
||||
case Keys.Escape:
|
||||
notification.InvokeAsyncSafe(notification.HideNotification);
|
||||
TriggerKeyboardShortcutAnalytics();
|
||||
return true;
|
||||
|
||||
case Keys.Space:
|
||||
notification.InvokeAsyncSafe(() => notification.FreezeTimer = !notification.FreezeTimer);
|
||||
TriggerKeyboardShortcutAnalytics();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IKeyboardHandler.OnKeyEvent(IWebBrowser browserControl, IBrowser browser, KeyType type, int windowsKeyCode, int nativeKeyCode, CefEventFlags modifiers, bool isSystemKey){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,35 +0,0 @@
|
||||
using System.Collections.Specialized;
|
||||
using CefSharp;
|
||||
using CefSharp.Handler;
|
||||
using TweetDuck.Core.Handling.General;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Handling{
|
||||
class RequestHandlerBase : DefaultRequestHandler{
|
||||
private readonly bool autoReload;
|
||||
|
||||
public RequestHandlerBase(bool autoReload){
|
||||
this.autoReload = autoReload;
|
||||
}
|
||||
|
||||
public override bool OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture){
|
||||
return LifeSpanHandler.HandleLinkClick(browserControl, targetDisposition, targetUrl);
|
||||
}
|
||||
|
||||
public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){
|
||||
if (BrowserUtils.HasDevTools){
|
||||
NameValueCollection headers = request.Headers;
|
||||
headers.Remove("x-devtools-emulate-network-conditions-client-id");
|
||||
request.Headers = headers;
|
||||
}
|
||||
|
||||
return base.OnBeforeResourceLoad(browserControl, browser, frame, request, callback);
|
||||
}
|
||||
|
||||
public override void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status){
|
||||
if (autoReload){
|
||||
browser.Reload();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,96 +0,0 @@
|
||||
// Uncomment to force TweetDeck to load a predefined version of the vendor/bundle scripts
|
||||
// #define FREEZE_TWEETDECK_SCRIPTS
|
||||
|
||||
using System.Collections.Specialized;
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Handling.Filters;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
#if FREEZE_TWEETDECK_SCRIPTS
|
||||
using System.Collections.Generic;
|
||||
using System.Text.RegularExpressions;
|
||||
#endif
|
||||
|
||||
namespace TweetDuck.Core.Handling{
|
||||
sealed class RequestHandlerBrowser : RequestHandlerBase{
|
||||
public string BlockNextUserNavUrl { get; set; }
|
||||
|
||||
public RequestHandlerBrowser() : base(true){}
|
||||
|
||||
public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){
|
||||
if (request.ResourceType == ResourceType.Script && request.Url.Contains("analytics.")){
|
||||
callback.Dispose();
|
||||
return CefReturnValue.Cancel;
|
||||
}
|
||||
|
||||
return base.OnBeforeResourceLoad(browserControl, browser, frame, request, callback);
|
||||
}
|
||||
|
||||
public override bool OnBeforeBrowse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, bool userGesture, bool isRedirect){
|
||||
if (userGesture && request.TransitionType == TransitionType.LinkClicked){
|
||||
bool block = request.Url == BlockNextUserNavUrl;
|
||||
BlockNextUserNavUrl = string.Empty;
|
||||
return block;
|
||||
}
|
||||
|
||||
return base.OnBeforeBrowse(browserControl, browser, frame, request, userGesture, isRedirect);
|
||||
}
|
||||
|
||||
#if FREEZE_TWEETDECK_SCRIPTS
|
||||
private static readonly Regex TweetDeckScriptUrl = new Regex(@"/dist/(.*?)\.(.*?)\.js$", RegexOptions.Compiled);
|
||||
|
||||
private static readonly SortedList<string, string> TweetDeckHashes = new SortedList<string, string>(2){
|
||||
{ "vendor", "942c0a20e8" },
|
||||
{ "bundle", "1bd75b5854" }
|
||||
};
|
||||
#endif
|
||||
|
||||
public override bool OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response){
|
||||
if (request.ResourceType == ResourceType.Image && request.Url.Contains("/backgrounds/spinner_blue")){
|
||||
request.Url = TwitterUtils.LoadingSpinner.Url;
|
||||
return true;
|
||||
}
|
||||
#if FREEZE_TWEETDECK_SCRIPTS
|
||||
else if (request.ResourceType == ResourceType.Script){
|
||||
Match match = TweetDeckScriptUrl.Match(request.Url);
|
||||
|
||||
if (match.Success && TweetDeckHashes.TryGetValue(match.Groups[1].Value, out string hash)){
|
||||
if (match.Groups[2].Value == hash){
|
||||
System.Diagnostics.Debug.WriteLine($"accepting {request.Url}");
|
||||
}
|
||||
else{
|
||||
System.Diagnostics.Debug.WriteLine($"rewriting {request.Url} to {hash}");
|
||||
request.Url = TweetDeckScriptUrl.Replace(request.Url, "/dist/$1."+hash+".js");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
return base.OnResourceResponse(browserControl, browser, frame, request, response);
|
||||
}
|
||||
|
||||
public override IResponseFilter GetResourceResponseFilter(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response){
|
||||
if (request.ResourceType == ResourceType.Script && request.Url.Contains("/dist/vendor")){
|
||||
NameValueCollection headers = response.ResponseHeaders;
|
||||
|
||||
if (int.TryParse(headers["x-ton-expected-size"], out int totalBytes)){
|
||||
return new ResponseFilterVendor(totalBytes);
|
||||
}
|
||||
#if DEBUG
|
||||
else{
|
||||
System.Diagnostics.Debug.WriteLine($"Missing uncompressed size header in {request.Url}");
|
||||
|
||||
foreach(string key in headers){
|
||||
System.Diagnostics.Debug.WriteLine($" {key}: {headers[key]}");
|
||||
}
|
||||
|
||||
System.Diagnostics.Debugger.Break();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return base.GetResourceResponseFilter(browserControl, browser, frame, request, response);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,68 +0,0 @@
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Management{
|
||||
sealed class ContextInfo{
|
||||
public LinkInfo Link { get; private set; }
|
||||
public ChirpInfo Chirp { get; private set; }
|
||||
|
||||
public ContextInfo(){
|
||||
Reset();
|
||||
}
|
||||
|
||||
public void SetLink(string type, string url){
|
||||
Link = string.IsNullOrEmpty(url) ? new LinkInfo() : new LinkInfo(type, url);
|
||||
}
|
||||
|
||||
public void SetChirp(string tweetUrl, string quoteUrl, string chirpAuthors, string chirpImages){
|
||||
Chirp = new ChirpInfo(tweetUrl, quoteUrl, chirpAuthors, chirpImages);
|
||||
}
|
||||
|
||||
public void Reset(){
|
||||
Link = new LinkInfo();
|
||||
Chirp = new ChirpInfo();
|
||||
}
|
||||
|
||||
// Data structures
|
||||
|
||||
public struct LinkInfo{
|
||||
public bool IsLink => type == "link";
|
||||
public bool IsImage => type == "image";
|
||||
public bool IsVideo => type == "video";
|
||||
|
||||
public string GetUrl(IContextMenuParams parameters, bool safe){
|
||||
return IsLink ? url : (safe ? parameters.LinkUrl : parameters.UnfilteredLinkUrl);
|
||||
}
|
||||
|
||||
public string GetMediaSource(IContextMenuParams parameters){
|
||||
return IsImage || IsVideo ? url : parameters.SourceUrl;
|
||||
}
|
||||
|
||||
private readonly string type;
|
||||
private readonly string url;
|
||||
|
||||
public LinkInfo(string type, string url){
|
||||
this.type = type;
|
||||
this.url = url;
|
||||
}
|
||||
}
|
||||
|
||||
public struct ChirpInfo{
|
||||
public string TweetUrl { get; }
|
||||
public string QuoteUrl { get; }
|
||||
|
||||
public string[] Authors => chirpAuthors?.Split(';') ?? StringUtils.EmptyArray;
|
||||
public string[] Images => chirpImages?.Split(';') ?? StringUtils.EmptyArray;
|
||||
|
||||
private readonly string chirpAuthors;
|
||||
private readonly string chirpImages;
|
||||
|
||||
public ChirpInfo(string tweetUrl, string quoteUrl, string chirpAuthors, string chirpImages){
|
||||
this.TweetUrl = tweetUrl;
|
||||
this.QuoteUrl = quoteUrl;
|
||||
this.chirpAuthors = chirpAuthors;
|
||||
this.chirpImages = chirpImages;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,50 +0,0 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Other;
|
||||
using TweetDuck.Core.Other.Settings;
|
||||
|
||||
namespace TweetDuck.Core.Notification{
|
||||
static class SoundNotification{
|
||||
public const string SupportedFormats = "*.wav;*.ogg;*.mp3;*.flac;*.opus;*.weba;*.webm";
|
||||
|
||||
public static IResourceHandler CreateFileHandler(string path){
|
||||
string mimeType;
|
||||
|
||||
switch(Path.GetExtension(path)){
|
||||
case ".weba":
|
||||
case ".webm": mimeType = "audio/webm"; break;
|
||||
case ".wav": mimeType = "audio/wav"; break;
|
||||
case ".ogg": mimeType = "audio/ogg"; break;
|
||||
case ".mp3": mimeType = "audio/mp3"; break;
|
||||
case ".flac": mimeType = "audio/flac"; break;
|
||||
case ".opus": mimeType = "audio/ogg; codecs=opus"; break;
|
||||
default: mimeType = null; break;
|
||||
}
|
||||
|
||||
try{
|
||||
return ResourceHandler.FromFilePath(path, mimeType);
|
||||
}catch{
|
||||
FormBrowser browser = FormManager.TryFind<FormBrowser>();
|
||||
|
||||
browser?.InvokeAsyncSafe(() => {
|
||||
using(FormMessage form = new FormMessage("Sound Notification Error", "Could not find custom notification sound file:\n"+path, MessageBoxIcon.Error)){
|
||||
form.AddButton(FormMessage.Ignore, ControlType.Cancel | ControlType.Focused);
|
||||
|
||||
Button btnViewOptions = form.AddButton("View Options");
|
||||
btnViewOptions.Width += 16;
|
||||
btnViewOptions.Location = new Point(btnViewOptions.Location.X-16, btnViewOptions.Location.Y);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions){
|
||||
browser.OpenSettings(typeof(TabSettingsSounds));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,80 +0,0 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDuck.Core.Bridge;
|
||||
using TweetDuck.Data;
|
||||
using TweetDuck.Resources;
|
||||
|
||||
namespace TweetDuck.Core.Notification{
|
||||
sealed class TweetNotification{
|
||||
private const string DefaultHeadLayout = @"<html class=""scroll-v os-windows dark txt-size--14"" lang=""en-US"" id=""tduck"" data-td-font=""medium"" data-td-theme=""dark""><head><meta charset=""utf-8""><link href=""https://ton.twimg.com/tweetdeck-web/web/dist/bundle.4b1f87e09d.css"" rel=""stylesheet""><style type='text/css'>body { background: rgb(34, 36, 38) !important }</style>";
|
||||
public static readonly ResourceLink AppLogo = new ResourceLink("https://ton.twimg.com/tduck/avatar", ResourceHandler.FromByteArray(Properties.Resources.avatar, "image/png"));
|
||||
|
||||
public static TweetNotification Example(string html, int characters){
|
||||
return new TweetNotification(string.Empty, string.Empty, "Home", html, characters, string.Empty, string.Empty, true);
|
||||
}
|
||||
|
||||
public enum Position{
|
||||
TopLeft, TopRight, BottomLeft, BottomRight, Custom
|
||||
}
|
||||
|
||||
public enum Size{
|
||||
Auto, Custom
|
||||
}
|
||||
|
||||
public string ColumnId { get; }
|
||||
public string ChirpId { get; }
|
||||
|
||||
public string ColumnTitle { get; }
|
||||
public string TweetUrl { get; }
|
||||
public string QuoteUrl { get; }
|
||||
|
||||
private readonly string html;
|
||||
private readonly int characters;
|
||||
private readonly bool isExample;
|
||||
|
||||
public TweetNotification(string columnId, string chirpId, string title, string html, int characters, string tweetUrl, string quoteUrl) : this(columnId, chirpId, title, html, characters, tweetUrl, quoteUrl, false){}
|
||||
|
||||
private TweetNotification(string columnId, string chirpId, string title, string html, int characters, string tweetUrl, string quoteUrl, bool isExample){
|
||||
this.ColumnId = columnId;
|
||||
this.ChirpId = chirpId;
|
||||
|
||||
this.ColumnTitle = title;
|
||||
this.TweetUrl = tweetUrl;
|
||||
this.QuoteUrl = quoteUrl;
|
||||
|
||||
this.html = html;
|
||||
this.characters = characters;
|
||||
this.isExample = isExample;
|
||||
}
|
||||
|
||||
public int GetDisplayDuration(int value){
|
||||
return 2000+Math.Max(1000, value*characters);
|
||||
}
|
||||
|
||||
public string GenerateHtml(string bodyClasses, Control sync){
|
||||
StringBuilder build = new StringBuilder();
|
||||
build.Append("<!DOCTYPE html>");
|
||||
build.Append(TweetDeckBridge.NotificationHeadLayout ?? DefaultHeadLayout);
|
||||
build.Append("<style type='text/css'>").Append(ScriptLoader.LoadResource("styles/notification.css", sync) ?? string.Empty).Append("</style>");
|
||||
|
||||
if (!string.IsNullOrEmpty(Program.UserConfig.CustomNotificationCSS)){
|
||||
build.Append("<style type='text/css'>").Append(Program.UserConfig.CustomNotificationCSS).Append("</style>");
|
||||
}
|
||||
|
||||
build.Append("</head>");
|
||||
build.Append("<body class='scroll-styled-v");
|
||||
|
||||
if (!string.IsNullOrEmpty(bodyClasses)){
|
||||
build.Append(' ').Append(bodyClasses);
|
||||
}
|
||||
|
||||
build.Append('\'').Append(isExample ? " td-example-notification" : "").Append("><div class='column' style='width:100%!important;min-height:100vh!important;height:auto!important;overflow:initial!important;'>");
|
||||
build.Append(html);
|
||||
build.Append("</div></body>");
|
||||
build.Append("</html>");
|
||||
return build.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using CefSharp;
|
||||
|
||||
namespace TweetDuck.Core.Other.Interfaces{
|
||||
interface ITweetDeckBrowser{
|
||||
bool IsTweetDeckWebsite { get; }
|
||||
|
||||
void RegisterBridge(string name, object obj);
|
||||
void OnFrameLoaded(Action<IFrame> callback);
|
||||
void ExecuteFunction(string name, params object[] args);
|
||||
}
|
||||
}
|
@@ -1,41 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Configuration;
|
||||
|
||||
namespace TweetDuck.Core.Other.Settings{
|
||||
class BaseTabSettings : UserControl{
|
||||
protected static UserConfig Config => Program.UserConfig;
|
||||
|
||||
public IEnumerable<Control> InteractiveControls{
|
||||
get{
|
||||
IEnumerable<Control> FindInteractiveControls(Control parent){
|
||||
foreach(Control control in parent.Controls){
|
||||
if (control is Panel subPanel){
|
||||
foreach(Control subControl in FindInteractiveControls(subPanel)){
|
||||
yield return subControl;
|
||||
}
|
||||
}
|
||||
else{
|
||||
yield return control;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FindInteractiveControls(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected BaseTabSettings(){
|
||||
Padding = new Padding(6);
|
||||
}
|
||||
|
||||
public virtual void OnReady(){}
|
||||
public virtual void OnClosing(){}
|
||||
|
||||
protected static void PromptRestart(){
|
||||
if (FormMessage.Information("TweetDuck Options", "The application must restart for the option to take place. Do you want to restart now?", FormMessage.Yes, FormMessage.No)){
|
||||
Program.Restart();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
351
Core/Other/Settings/TabSettingsGeneral.Designer.cs
generated
351
Core/Other/Settings/TabSettingsGeneral.Designer.cs
generated
@@ -1,351 +0,0 @@
|
||||
namespace TweetDuck.Core.Other.Settings {
|
||||
partial class TabSettingsGeneral {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.checkExpandLinks = new System.Windows.Forms.CheckBox();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.checkUpdateNotifications = new System.Windows.Forms.CheckBox();
|
||||
this.btnCheckUpdates = new System.Windows.Forms.Button();
|
||||
this.labelZoomValue = new System.Windows.Forms.Label();
|
||||
this.checkBestImageQuality = new System.Windows.Forms.CheckBox();
|
||||
this.checkOpenSearchInFirstColumn = new System.Windows.Forms.CheckBox();
|
||||
this.trackBarZoom = new System.Windows.Forms.TrackBar();
|
||||
this.labelZoom = new System.Windows.Forms.Label();
|
||||
this.zoomUpdateTimer = new System.Windows.Forms.Timer(this.components);
|
||||
this.labelUI = new System.Windows.Forms.Label();
|
||||
this.panelZoom = new System.Windows.Forms.Panel();
|
||||
this.checkAnimatedAvatars = new System.Windows.Forms.CheckBox();
|
||||
this.labelUpdates = new System.Windows.Forms.Label();
|
||||
this.flowPanel = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.checkKeepLikeFollowDialogsOpen = new System.Windows.Forms.CheckBox();
|
||||
this.labelBrowserSettings = new System.Windows.Forms.Label();
|
||||
this.checkSmoothScrolling = new System.Windows.Forms.CheckBox();
|
||||
this.labelBrowserPath = new System.Windows.Forms.Label();
|
||||
this.comboBoxBrowserPath = new System.Windows.Forms.ComboBox();
|
||||
this.labelSearchEngine = new System.Windows.Forms.Label();
|
||||
this.comboBoxSearchEngine = new System.Windows.Forms.ComboBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarZoom)).BeginInit();
|
||||
this.panelZoom.SuspendLayout();
|
||||
this.flowPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// checkExpandLinks
|
||||
//
|
||||
this.checkExpandLinks.AutoSize = true;
|
||||
this.checkExpandLinks.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.checkExpandLinks.Location = new System.Drawing.Point(6, 26);
|
||||
this.checkExpandLinks.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2);
|
||||
this.checkExpandLinks.Name = "checkExpandLinks";
|
||||
this.checkExpandLinks.Size = new System.Drawing.Size(176, 19);
|
||||
this.checkExpandLinks.TabIndex = 1;
|
||||
this.checkExpandLinks.Text = "Expand Links When Hovered";
|
||||
this.checkExpandLinks.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkUpdateNotifications
|
||||
//
|
||||
this.checkUpdateNotifications.AutoSize = true;
|
||||
this.checkUpdateNotifications.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.checkUpdateNotifications.Location = new System.Drawing.Point(6, 427);
|
||||
this.checkUpdateNotifications.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2);
|
||||
this.checkUpdateNotifications.Name = "checkUpdateNotifications";
|
||||
this.checkUpdateNotifications.Size = new System.Drawing.Size(182, 19);
|
||||
this.checkUpdateNotifications.TabIndex = 15;
|
||||
this.checkUpdateNotifications.Text = "Check Updates Automatically";
|
||||
this.checkUpdateNotifications.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnCheckUpdates
|
||||
//
|
||||
this.btnCheckUpdates.AutoSize = true;
|
||||
this.btnCheckUpdates.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnCheckUpdates.Location = new System.Drawing.Point(5, 451);
|
||||
this.btnCheckUpdates.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.btnCheckUpdates.Name = "btnCheckUpdates";
|
||||
this.btnCheckUpdates.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnCheckUpdates.Size = new System.Drawing.Size(128, 25);
|
||||
this.btnCheckUpdates.TabIndex = 16;
|
||||
this.btnCheckUpdates.Text = "Check Updates Now";
|
||||
this.btnCheckUpdates.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelZoomValue
|
||||
//
|
||||
this.labelZoomValue.BackColor = System.Drawing.Color.Transparent;
|
||||
this.labelZoomValue.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelZoomValue.Location = new System.Drawing.Point(147, 4);
|
||||
this.labelZoomValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
|
||||
this.labelZoomValue.Name = "labelZoomValue";
|
||||
this.labelZoomValue.Size = new System.Drawing.Size(38, 13);
|
||||
this.labelZoomValue.TabIndex = 1;
|
||||
this.labelZoomValue.Text = "100%";
|
||||
this.labelZoomValue.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
//
|
||||
// checkBestImageQuality
|
||||
//
|
||||
this.checkBestImageQuality.AutoSize = true;
|
||||
this.checkBestImageQuality.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.checkBestImageQuality.Location = new System.Drawing.Point(6, 98);
|
||||
this.checkBestImageQuality.Margin = new System.Windows.Forms.Padding(6, 3, 3, 2);
|
||||
this.checkBestImageQuality.Name = "checkBestImageQuality";
|
||||
this.checkBestImageQuality.Size = new System.Drawing.Size(125, 19);
|
||||
this.checkBestImageQuality.TabIndex = 4;
|
||||
this.checkBestImageQuality.Text = "Best Image Quality";
|
||||
this.checkBestImageQuality.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkOpenSearchInFirstColumn
|
||||
//
|
||||
this.checkOpenSearchInFirstColumn.AutoSize = true;
|
||||
this.checkOpenSearchInFirstColumn.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.checkOpenSearchInFirstColumn.Location = new System.Drawing.Point(6, 50);
|
||||
this.checkOpenSearchInFirstColumn.Margin = new System.Windows.Forms.Padding(6, 3, 3, 2);
|
||||
this.checkOpenSearchInFirstColumn.Name = "checkOpenSearchInFirstColumn";
|
||||
this.checkOpenSearchInFirstColumn.Size = new System.Drawing.Size(245, 19);
|
||||
this.checkOpenSearchInFirstColumn.TabIndex = 2;
|
||||
this.checkOpenSearchInFirstColumn.Text = "Add Search Columns Before First Column";
|
||||
this.checkOpenSearchInFirstColumn.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// trackBarZoom
|
||||
//
|
||||
this.trackBarZoom.AutoSize = false;
|
||||
this.trackBarZoom.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.trackBarZoom.LargeChange = 25;
|
||||
this.trackBarZoom.Location = new System.Drawing.Point(3, 3);
|
||||
this.trackBarZoom.Maximum = 200;
|
||||
this.trackBarZoom.Minimum = 50;
|
||||
this.trackBarZoom.Name = "trackBarZoom";
|
||||
this.trackBarZoom.Size = new System.Drawing.Size(148, 30);
|
||||
this.trackBarZoom.SmallChange = 5;
|
||||
this.trackBarZoom.TabIndex = 0;
|
||||
this.trackBarZoom.TickFrequency = 25;
|
||||
this.trackBarZoom.Value = 100;
|
||||
//
|
||||
// labelZoom
|
||||
//
|
||||
this.labelZoom.AutoSize = true;
|
||||
this.labelZoom.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelZoom.Location = new System.Drawing.Point(3, 330);
|
||||
this.labelZoom.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelZoom.Name = "labelZoom";
|
||||
this.labelZoom.Size = new System.Drawing.Size(39, 15);
|
||||
this.labelZoom.TabIndex = 12;
|
||||
this.labelZoom.Text = "Zoom";
|
||||
//
|
||||
// zoomUpdateTimer
|
||||
//
|
||||
this.zoomUpdateTimer.Interval = 250;
|
||||
this.zoomUpdateTimer.Tick += new System.EventHandler(this.zoomUpdateTimer_Tick);
|
||||
//
|
||||
// labelUI
|
||||
//
|
||||
this.labelUI.AutoSize = true;
|
||||
this.labelUI.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelUI.Location = new System.Drawing.Point(0, 0);
|
||||
this.labelUI.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.labelUI.Name = "labelUI";
|
||||
this.labelUI.Size = new System.Drawing.Size(100, 20);
|
||||
this.labelUI.TabIndex = 0;
|
||||
this.labelUI.Text = "User Interface";
|
||||
//
|
||||
// panelZoom
|
||||
//
|
||||
this.panelZoom.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.panelZoom.Controls.Add(this.trackBarZoom);
|
||||
this.panelZoom.Controls.Add(this.labelZoomValue);
|
||||
this.panelZoom.Location = new System.Drawing.Point(0, 345);
|
||||
this.panelZoom.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.panelZoom.Name = "panelZoom";
|
||||
this.panelZoom.Size = new System.Drawing.Size(322, 36);
|
||||
this.panelZoom.TabIndex = 13;
|
||||
//
|
||||
// checkAnimatedAvatars
|
||||
//
|
||||
this.checkAnimatedAvatars.AutoSize = true;
|
||||
this.checkAnimatedAvatars.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.checkAnimatedAvatars.Location = new System.Drawing.Point(6, 122);
|
||||
this.checkAnimatedAvatars.Margin = new System.Windows.Forms.Padding(6, 3, 3, 2);
|
||||
this.checkAnimatedAvatars.Name = "checkAnimatedAvatars";
|
||||
this.checkAnimatedAvatars.Size = new System.Drawing.Size(158, 19);
|
||||
this.checkAnimatedAvatars.TabIndex = 5;
|
||||
this.checkAnimatedAvatars.Text = "Enable Animated Avatars";
|
||||
this.checkAnimatedAvatars.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelUpdates
|
||||
//
|
||||
this.labelUpdates.AutoSize = true;
|
||||
this.labelUpdates.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelUpdates.Location = new System.Drawing.Point(0, 401);
|
||||
this.labelUpdates.Margin = new System.Windows.Forms.Padding(0, 20, 0, 0);
|
||||
this.labelUpdates.Name = "labelUpdates";
|
||||
this.labelUpdates.Size = new System.Drawing.Size(64, 20);
|
||||
this.labelUpdates.TabIndex = 14;
|
||||
this.labelUpdates.Text = "Updates";
|
||||
//
|
||||
// flowPanel
|
||||
//
|
||||
this.flowPanel.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.flowPanel.Controls.Add(this.labelUI);
|
||||
this.flowPanel.Controls.Add(this.checkExpandLinks);
|
||||
this.flowPanel.Controls.Add(this.checkOpenSearchInFirstColumn);
|
||||
this.flowPanel.Controls.Add(this.checkKeepLikeFollowDialogsOpen);
|
||||
this.flowPanel.Controls.Add(this.checkBestImageQuality);
|
||||
this.flowPanel.Controls.Add(this.checkAnimatedAvatars);
|
||||
this.flowPanel.Controls.Add(this.labelBrowserSettings);
|
||||
this.flowPanel.Controls.Add(this.checkSmoothScrolling);
|
||||
this.flowPanel.Controls.Add(this.labelBrowserPath);
|
||||
this.flowPanel.Controls.Add(this.comboBoxBrowserPath);
|
||||
this.flowPanel.Controls.Add(this.labelSearchEngine);
|
||||
this.flowPanel.Controls.Add(this.comboBoxSearchEngine);
|
||||
this.flowPanel.Controls.Add(this.labelZoom);
|
||||
this.flowPanel.Controls.Add(this.panelZoom);
|
||||
this.flowPanel.Controls.Add(this.labelUpdates);
|
||||
this.flowPanel.Controls.Add(this.checkUpdateNotifications);
|
||||
this.flowPanel.Controls.Add(this.btnCheckUpdates);
|
||||
this.flowPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
||||
this.flowPanel.Location = new System.Drawing.Point(9, 9);
|
||||
this.flowPanel.Name = "flowPanel";
|
||||
this.flowPanel.Size = new System.Drawing.Size(322, 486);
|
||||
this.flowPanel.TabIndex = 0;
|
||||
this.flowPanel.WrapContents = false;
|
||||
//
|
||||
// checkKeepLikeFollowDialogsOpen
|
||||
//
|
||||
this.checkKeepLikeFollowDialogsOpen.AutoSize = true;
|
||||
this.checkKeepLikeFollowDialogsOpen.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.checkKeepLikeFollowDialogsOpen.Location = new System.Drawing.Point(6, 74);
|
||||
this.checkKeepLikeFollowDialogsOpen.Margin = new System.Windows.Forms.Padding(6, 3, 3, 2);
|
||||
this.checkKeepLikeFollowDialogsOpen.Name = "checkKeepLikeFollowDialogsOpen";
|
||||
this.checkKeepLikeFollowDialogsOpen.Size = new System.Drawing.Size(190, 19);
|
||||
this.checkKeepLikeFollowDialogsOpen.TabIndex = 3;
|
||||
this.checkKeepLikeFollowDialogsOpen.Text = "Keep Like/Follow Dialogs Open";
|
||||
this.checkKeepLikeFollowDialogsOpen.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelBrowserSettings
|
||||
//
|
||||
this.labelBrowserSettings.AutoSize = true;
|
||||
this.labelBrowserSettings.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelBrowserSettings.Location = new System.Drawing.Point(0, 163);
|
||||
this.labelBrowserSettings.Margin = new System.Windows.Forms.Padding(0, 20, 0, 0);
|
||||
this.labelBrowserSettings.Name = "labelBrowserSettings";
|
||||
this.labelBrowserSettings.Size = new System.Drawing.Size(119, 20);
|
||||
this.labelBrowserSettings.TabIndex = 6;
|
||||
this.labelBrowserSettings.Text = "Browser Settings";
|
||||
//
|
||||
// checkSmoothScrolling
|
||||
//
|
||||
this.checkSmoothScrolling.AutoSize = true;
|
||||
this.checkSmoothScrolling.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.checkSmoothScrolling.Location = new System.Drawing.Point(6, 189);
|
||||
this.checkSmoothScrolling.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2);
|
||||
this.checkSmoothScrolling.Name = "checkSmoothScrolling";
|
||||
this.checkSmoothScrolling.Size = new System.Drawing.Size(117, 19);
|
||||
this.checkSmoothScrolling.TabIndex = 7;
|
||||
this.checkSmoothScrolling.Text = "Smooth Scrolling";
|
||||
this.checkSmoothScrolling.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelBrowserPath
|
||||
//
|
||||
this.labelBrowserPath.AutoSize = true;
|
||||
this.labelBrowserPath.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelBrowserPath.Location = new System.Drawing.Point(3, 222);
|
||||
this.labelBrowserPath.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelBrowserPath.Name = "labelBrowserPath";
|
||||
this.labelBrowserPath.Size = new System.Drawing.Size(103, 15);
|
||||
this.labelBrowserPath.TabIndex = 8;
|
||||
this.labelBrowserPath.Text = "Open Links With...";
|
||||
//
|
||||
// comboBoxBrowserPath
|
||||
//
|
||||
this.comboBoxBrowserPath.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxBrowserPath.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.comboBoxBrowserPath.FormattingEnabled = true;
|
||||
this.comboBoxBrowserPath.Location = new System.Drawing.Point(5, 240);
|
||||
this.comboBoxBrowserPath.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.comboBoxBrowserPath.Name = "comboBoxBrowserPath";
|
||||
this.comboBoxBrowserPath.Size = new System.Drawing.Size(173, 23);
|
||||
this.comboBoxBrowserPath.TabIndex = 9;
|
||||
//
|
||||
// labelSearchEngine
|
||||
//
|
||||
this.labelSearchEngine.AutoSize = true;
|
||||
this.labelSearchEngine.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelSearchEngine.Location = new System.Drawing.Point(3, 276);
|
||||
this.labelSearchEngine.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelSearchEngine.Name = "labelSearchEngine";
|
||||
this.labelSearchEngine.Size = new System.Drawing.Size(81, 15);
|
||||
this.labelSearchEngine.TabIndex = 10;
|
||||
this.labelSearchEngine.Text = "Search Engine";
|
||||
//
|
||||
// comboBoxSearchEngine
|
||||
//
|
||||
this.comboBoxSearchEngine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSearchEngine.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.comboBoxSearchEngine.FormattingEnabled = true;
|
||||
this.comboBoxSearchEngine.Location = new System.Drawing.Point(5, 294);
|
||||
this.comboBoxSearchEngine.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.comboBoxSearchEngine.Name = "comboBoxSearchEngine";
|
||||
this.comboBoxSearchEngine.Size = new System.Drawing.Size(173, 23);
|
||||
this.comboBoxSearchEngine.TabIndex = 11;
|
||||
//
|
||||
// TabSettingsGeneral
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.flowPanel);
|
||||
this.Name = "TabSettingsGeneral";
|
||||
this.Size = new System.Drawing.Size(340, 504);
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarZoom)).EndInit();
|
||||
this.panelZoom.ResumeLayout(false);
|
||||
this.flowPanel.ResumeLayout(false);
|
||||
this.flowPanel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.CheckBox checkExpandLinks;
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
private System.Windows.Forms.CheckBox checkUpdateNotifications;
|
||||
private System.Windows.Forms.Button btnCheckUpdates;
|
||||
private System.Windows.Forms.Label labelZoom;
|
||||
private System.Windows.Forms.Label labelZoomValue;
|
||||
private System.Windows.Forms.TrackBar trackBarZoom;
|
||||
private System.Windows.Forms.Timer zoomUpdateTimer;
|
||||
private System.Windows.Forms.Label labelUI;
|
||||
private System.Windows.Forms.Panel panelZoom;
|
||||
private System.Windows.Forms.Label labelUpdates;
|
||||
private System.Windows.Forms.CheckBox checkBestImageQuality;
|
||||
private System.Windows.Forms.CheckBox checkOpenSearchInFirstColumn;
|
||||
private System.Windows.Forms.CheckBox checkAnimatedAvatars;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowPanel;
|
||||
private System.Windows.Forms.CheckBox checkKeepLikeFollowDialogsOpen;
|
||||
private System.Windows.Forms.Label labelBrowserPath;
|
||||
private System.Windows.Forms.ComboBox comboBoxBrowserPath;
|
||||
private System.Windows.Forms.Label labelBrowserSettings;
|
||||
private System.Windows.Forms.CheckBox checkSmoothScrolling;
|
||||
private System.Windows.Forms.Label labelSearchEngine;
|
||||
private System.Windows.Forms.ComboBox comboBoxSearchEngine;
|
||||
}
|
||||
}
|
@@ -1,253 +0,0 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Handling.General;
|
||||
using TweetDuck.Core.Other.Settings.Dialogs;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Updates;
|
||||
using TweetDuck.Updates.Events;
|
||||
|
||||
namespace TweetDuck.Core.Other.Settings{
|
||||
sealed partial class TabSettingsGeneral : BaseTabSettings{
|
||||
private readonly Action reloadColumns;
|
||||
|
||||
private readonly UpdateHandler updates;
|
||||
private int updateCheckEventId = -1;
|
||||
|
||||
private readonly int browserListIndexDefault;
|
||||
private readonly int browserListIndexCustom;
|
||||
|
||||
private readonly int searchEngineIndexDefault;
|
||||
private readonly int searchEngineIndexCustom;
|
||||
|
||||
public TabSettingsGeneral(Action reloadColumns, UpdateHandler updates){
|
||||
InitializeComponent();
|
||||
|
||||
this.reloadColumns = reloadColumns;
|
||||
|
||||
this.updates = updates;
|
||||
this.updates.CheckFinished += updates_CheckFinished;
|
||||
Disposed += (sender, args) => this.updates.CheckFinished -= updates_CheckFinished;
|
||||
|
||||
toolTip.SetToolTip(checkExpandLinks, "Expands links inside the tweets. If disabled,\r\nthe full links show up in a tooltip instead.");
|
||||
toolTip.SetToolTip(checkOpenSearchInFirstColumn, "By default, TweetDeck adds Search columns at the end.\r\nThis option makes them appear before the first column instead.");
|
||||
toolTip.SetToolTip(checkKeepLikeFollowDialogsOpen, "Allows liking and following from multiple accounts at once,\r\ninstead of automatically closing the dialog after taking an action.");
|
||||
toolTip.SetToolTip(checkBestImageQuality, "When right-clicking a tweet image, the context menu options\r\nwill use links to the original image size (:orig in the URL).");
|
||||
toolTip.SetToolTip(checkAnimatedAvatars, "Some old Twitter avatars could be uploaded as animated GIFs.");
|
||||
|
||||
toolTip.SetToolTip(checkSmoothScrolling, "Toggles smooth mouse wheel scrolling.");
|
||||
toolTip.SetToolTip(comboBoxBrowserPath, "Sets the default browser for opening links.");
|
||||
toolTip.SetToolTip(labelZoomValue, "Changes the zoom level.\r\nAlso affects notifications and screenshots.");
|
||||
toolTip.SetToolTip(trackBarZoom, toolTip.GetToolTip(labelZoomValue));
|
||||
|
||||
toolTip.SetToolTip(checkUpdateNotifications, "Checks for updates every hour.\r\nIf an update is dismissed, it will not appear again.");
|
||||
toolTip.SetToolTip(btnCheckUpdates, "Forces an update check, even for updates that had been dismissed.");
|
||||
|
||||
checkExpandLinks.Checked = Config.ExpandLinksOnHover;
|
||||
checkOpenSearchInFirstColumn.Checked = Config.OpenSearchInFirstColumn;
|
||||
checkKeepLikeFollowDialogsOpen.Checked = Config.KeepLikeFollowDialogsOpen;
|
||||
checkBestImageQuality.Checked = Config.BestImageQuality;
|
||||
checkAnimatedAvatars.Checked = Config.EnableAnimatedImages;
|
||||
|
||||
checkSmoothScrolling.Checked = Config.EnableSmoothScrolling;
|
||||
|
||||
foreach(WindowsUtils.Browser browserInfo in WindowsUtils.FindInstalledBrowsers()){
|
||||
comboBoxBrowserPath.Items.Add(browserInfo);
|
||||
}
|
||||
|
||||
browserListIndexDefault = comboBoxBrowserPath.Items.Add("(default browser)");
|
||||
browserListIndexCustom = comboBoxBrowserPath.Items.Add("(custom program...)");
|
||||
UpdateBrowserPathSelection();
|
||||
|
||||
comboBoxSearchEngine.Items.Add(new SearchEngine("DuckDuckGo", "https://duckduckgo.com/?q="));
|
||||
comboBoxSearchEngine.Items.Add(new SearchEngine("Google", "https://www.google.com/search?q="));
|
||||
comboBoxSearchEngine.Items.Add(new SearchEngine("Bing", "https://www.bing.com/search?q="));
|
||||
comboBoxSearchEngine.Items.Add(new SearchEngine("Yahoo", "https://search.yahoo.com/search?p="));
|
||||
searchEngineIndexDefault = comboBoxSearchEngine.Items.Add("(no engine set)");
|
||||
searchEngineIndexCustom = comboBoxSearchEngine.Items.Add("(custom url...)");
|
||||
UpdateSearchEngineSelection();
|
||||
|
||||
trackBarZoom.SetValueSafe(Config.ZoomLevel);
|
||||
labelZoomValue.Text = trackBarZoom.Value+"%";
|
||||
|
||||
checkUpdateNotifications.Checked = Config.EnableUpdateCheck;
|
||||
}
|
||||
|
||||
public override void OnReady(){
|
||||
checkExpandLinks.CheckedChanged += checkExpandLinks_CheckedChanged;
|
||||
checkOpenSearchInFirstColumn.CheckedChanged += checkOpenSearchInFirstColumn_CheckedChanged;
|
||||
checkKeepLikeFollowDialogsOpen.CheckedChanged += checkKeepLikeFollowDialogsOpen_CheckedChanged;
|
||||
checkBestImageQuality.CheckedChanged += checkBestImageQuality_CheckedChanged;
|
||||
checkAnimatedAvatars.CheckedChanged += checkAnimatedAvatars_CheckedChanged;
|
||||
|
||||
checkSmoothScrolling.CheckedChanged += checkSmoothScrolling_CheckedChanged;
|
||||
comboBoxBrowserPath.SelectedIndexChanged += comboBoxBrowserPath_SelectedIndexChanged;
|
||||
comboBoxSearchEngine.SelectedIndexChanged += comboBoxSearchEngine_SelectedIndexChanged;
|
||||
trackBarZoom.ValueChanged += trackBarZoom_ValueChanged;
|
||||
|
||||
checkUpdateNotifications.CheckedChanged += checkUpdateNotifications_CheckedChanged;
|
||||
btnCheckUpdates.Click += btnCheckUpdates_Click;
|
||||
}
|
||||
|
||||
public override void OnClosing(){
|
||||
Config.ZoomLevel = trackBarZoom.Value;
|
||||
}
|
||||
|
||||
private void checkExpandLinks_CheckedChanged(object sender, EventArgs e){
|
||||
Config.ExpandLinksOnHover = checkExpandLinks.Checked;
|
||||
}
|
||||
|
||||
private void checkOpenSearchInFirstColumn_CheckedChanged(object sender, EventArgs e){
|
||||
Config.OpenSearchInFirstColumn = checkOpenSearchInFirstColumn.Checked;
|
||||
}
|
||||
|
||||
private void checkKeepLikeFollowDialogsOpen_CheckedChanged(object sender, EventArgs e){
|
||||
Config.KeepLikeFollowDialogsOpen = checkKeepLikeFollowDialogsOpen.Checked;
|
||||
}
|
||||
|
||||
private void checkBestImageQuality_CheckedChanged(object sender, EventArgs e){
|
||||
Config.BestImageQuality = checkBestImageQuality.Checked;
|
||||
}
|
||||
|
||||
private void checkAnimatedAvatars_CheckedChanged(object sender, EventArgs e){
|
||||
Config.EnableAnimatedImages = checkAnimatedAvatars.Checked;
|
||||
BrowserProcessHandler.UpdatePrefs().ContinueWith(task => reloadColumns());
|
||||
}
|
||||
|
||||
private void checkSmoothScrolling_CheckedChanged(object sender, EventArgs e){
|
||||
Config.EnableSmoothScrolling = checkSmoothScrolling.Checked;
|
||||
PromptRestart();
|
||||
}
|
||||
|
||||
private void UpdateBrowserPathSelection(){
|
||||
if (string.IsNullOrEmpty(Config.BrowserPath) || !File.Exists(Config.BrowserPath)){
|
||||
comboBoxBrowserPath.SelectedIndex = browserListIndexDefault;
|
||||
}
|
||||
else{
|
||||
WindowsUtils.Browser browserInfo = comboBoxBrowserPath.Items.OfType<WindowsUtils.Browser>().FirstOrDefault(browser => browser.Path == Config.BrowserPath);
|
||||
|
||||
if (browserInfo == null){
|
||||
comboBoxBrowserPath.SelectedIndex = browserListIndexCustom;
|
||||
}
|
||||
else{
|
||||
comboBoxBrowserPath.SelectedItem = browserInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBoxBrowserPath_SelectedIndexChanged(object sender, EventArgs e){
|
||||
if (comboBoxBrowserPath.SelectedIndex == browserListIndexCustom){
|
||||
using(OpenFileDialog dialog = new OpenFileDialog{
|
||||
AutoUpgradeEnabled = true,
|
||||
DereferenceLinks = true,
|
||||
InitialDirectory = Path.GetDirectoryName(Config.BrowserPath), // returns null if argument is null
|
||||
Title = "Open Links With...",
|
||||
Filter = "Executables (*.exe;*.bat;*.cmd)|*.exe;*.bat;*.cmd|All Files (*.*)|*.*"
|
||||
}){
|
||||
if (dialog.ShowDialog() == DialogResult.OK){
|
||||
Config.BrowserPath = dialog.FileName;
|
||||
}
|
||||
}
|
||||
|
||||
comboBoxBrowserPath.SelectedIndexChanged -= comboBoxBrowserPath_SelectedIndexChanged;
|
||||
UpdateBrowserPathSelection();
|
||||
comboBoxBrowserPath.SelectedIndexChanged += comboBoxBrowserPath_SelectedIndexChanged;
|
||||
}
|
||||
else{
|
||||
Config.BrowserPath = (comboBoxBrowserPath.SelectedItem as WindowsUtils.Browser)?.Path; // default browser item is a string and casts to null
|
||||
}
|
||||
}
|
||||
|
||||
private void comboBoxSearchEngine_SelectedIndexChanged(object sender, EventArgs e){
|
||||
if (comboBoxSearchEngine.SelectedIndex == searchEngineIndexCustom){
|
||||
using(DialogSettingsSearchEngine dialog = new DialogSettingsSearchEngine()){
|
||||
if (dialog.ShowDialog() == DialogResult.OK){
|
||||
Config.SearchEngineUrl = dialog.Url.Trim();
|
||||
}
|
||||
}
|
||||
|
||||
comboBoxSearchEngine.SelectedIndexChanged -= comboBoxSearchEngine_SelectedIndexChanged;
|
||||
UpdateSearchEngineSelection();
|
||||
comboBoxSearchEngine.SelectedIndexChanged += comboBoxSearchEngine_SelectedIndexChanged;
|
||||
}
|
||||
else{
|
||||
Config.SearchEngineUrl = (comboBoxSearchEngine.SelectedItem as SearchEngine)?.Url; // default search engine item is a string and casts to null
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateSearchEngineSelection(){
|
||||
if (string.IsNullOrEmpty(Config.SearchEngineUrl)){
|
||||
comboBoxSearchEngine.SelectedIndex = searchEngineIndexDefault;
|
||||
}
|
||||
else{
|
||||
SearchEngine engineInfo = comboBoxSearchEngine.Items.OfType<SearchEngine>().FirstOrDefault(engine => engine.Url == Config.SearchEngineUrl);
|
||||
|
||||
if (engineInfo == null){
|
||||
comboBoxSearchEngine.SelectedIndex = searchEngineIndexCustom;
|
||||
}
|
||||
else{
|
||||
comboBoxSearchEngine.SelectedItem = engineInfo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void trackBarZoom_ValueChanged(object sender, EventArgs e){
|
||||
if (trackBarZoom.AlignValueToTick()){
|
||||
zoomUpdateTimer.Stop();
|
||||
zoomUpdateTimer.Start();
|
||||
labelZoomValue.Text = trackBarZoom.Value+"%";
|
||||
}
|
||||
}
|
||||
|
||||
private void checkUpdateNotifications_CheckedChanged(object sender, EventArgs e){
|
||||
Config.EnableUpdateCheck = checkUpdateNotifications.Checked;
|
||||
}
|
||||
|
||||
private void btnCheckUpdates_Click(object sender, EventArgs e){
|
||||
Config.DismissedUpdate = null;
|
||||
|
||||
btnCheckUpdates.Enabled = false;
|
||||
updateCheckEventId = updates.Check(true);
|
||||
|
||||
if (updateCheckEventId == UpdateHandler.CheckCodeNotOnTweetDeck){
|
||||
FormMessage.Error("Update Check", "Updates can only be checked once TweetDeck is fully loaded.", FormMessage.OK);
|
||||
btnCheckUpdates.Enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void updates_CheckFinished(object sender, UpdateCheckEventArgs e){
|
||||
if (e.EventId == updateCheckEventId){
|
||||
btnCheckUpdates.Enabled = true;
|
||||
|
||||
e.Result.Handle(update => {
|
||||
if (update.VersionTag == Program.VersionTag){
|
||||
FormMessage.Information("No Updates Available", "Your version of TweetDuck is up to date.", FormMessage.OK);
|
||||
}
|
||||
}, ex => {
|
||||
Program.Reporter.HandleException("Update Check Error", "An error occurred while checking for updates.", true, ex);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void zoomUpdateTimer_Tick(object sender, EventArgs e){
|
||||
Config.ZoomLevel = trackBarZoom.Value;
|
||||
zoomUpdateTimer.Stop();
|
||||
}
|
||||
|
||||
private sealed class SearchEngine{
|
||||
private string Name { get; }
|
||||
public string Url { get; }
|
||||
|
||||
public SearchEngine(string name, string url){
|
||||
Name = name;
|
||||
Url = url;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Name.GetHashCode();
|
||||
public override bool Equals(object obj) => obj is SearchEngine other && Name == other.Name;
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
}
|
||||
}
|
160
Core/Other/Settings/TabSettingsLocales.Designer.cs
generated
160
Core/Other/Settings/TabSettingsLocales.Designer.cs
generated
@@ -1,160 +0,0 @@
|
||||
namespace TweetDuck.Core.Other.Settings {
|
||||
partial class TabSettingsLocales {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.checkSpellCheck = new System.Windows.Forms.CheckBox();
|
||||
this.labelLocales = new System.Windows.Forms.Label();
|
||||
this.flowPanel = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.labelSpellCheckLanguage = new System.Windows.Forms.Label();
|
||||
this.comboBoxSpellCheckLanguage = new System.Windows.Forms.ComboBox();
|
||||
this.labelTranslations = new System.Windows.Forms.Label();
|
||||
this.labelTranslationTarget = new System.Windows.Forms.Label();
|
||||
this.comboBoxTranslationTarget = new System.Windows.Forms.ComboBox();
|
||||
this.flowPanel.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// checkSpellCheck
|
||||
//
|
||||
this.checkSpellCheck.AutoSize = true;
|
||||
this.checkSpellCheck.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.checkSpellCheck.Location = new System.Drawing.Point(6, 26);
|
||||
this.checkSpellCheck.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2);
|
||||
this.checkSpellCheck.Name = "checkSpellCheck";
|
||||
this.checkSpellCheck.Size = new System.Drawing.Size(125, 19);
|
||||
this.checkSpellCheck.TabIndex = 1;
|
||||
this.checkSpellCheck.Text = "Enable Spell Check";
|
||||
this.checkSpellCheck.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelLocales
|
||||
//
|
||||
this.labelLocales.AutoSize = true;
|
||||
this.labelLocales.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelLocales.Location = new System.Drawing.Point(0, 0);
|
||||
this.labelLocales.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.labelLocales.Name = "labelLocales";
|
||||
this.labelLocales.Size = new System.Drawing.Size(58, 20);
|
||||
this.labelLocales.TabIndex = 0;
|
||||
this.labelLocales.Text = "Locales";
|
||||
//
|
||||
// flowPanel
|
||||
//
|
||||
this.flowPanel.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.flowPanel.Controls.Add(this.labelLocales);
|
||||
this.flowPanel.Controls.Add(this.checkSpellCheck);
|
||||
this.flowPanel.Controls.Add(this.labelSpellCheckLanguage);
|
||||
this.flowPanel.Controls.Add(this.comboBoxSpellCheckLanguage);
|
||||
this.flowPanel.Controls.Add(this.labelTranslations);
|
||||
this.flowPanel.Controls.Add(this.labelTranslationTarget);
|
||||
this.flowPanel.Controls.Add(this.comboBoxTranslationTarget);
|
||||
this.flowPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
||||
this.flowPanel.Location = new System.Drawing.Point(9, 9);
|
||||
this.flowPanel.Name = "flowPanel";
|
||||
this.flowPanel.Size = new System.Drawing.Size(322, 201);
|
||||
this.flowPanel.TabIndex = 0;
|
||||
this.flowPanel.WrapContents = false;
|
||||
//
|
||||
// labelSpellCheckLanguage
|
||||
//
|
||||
this.labelSpellCheckLanguage.AutoSize = true;
|
||||
this.labelSpellCheckLanguage.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelSpellCheckLanguage.Location = new System.Drawing.Point(3, 59);
|
||||
this.labelSpellCheckLanguage.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelSpellCheckLanguage.Name = "labelSpellCheckLanguage";
|
||||
this.labelSpellCheckLanguage.Size = new System.Drawing.Size(123, 15);
|
||||
this.labelSpellCheckLanguage.TabIndex = 2;
|
||||
this.labelSpellCheckLanguage.Text = "Spell Check Language";
|
||||
//
|
||||
// comboBoxSpellCheckLanguage
|
||||
//
|
||||
this.comboBoxSpellCheckLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxSpellCheckLanguage.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.comboBoxSpellCheckLanguage.FormattingEnabled = true;
|
||||
this.comboBoxSpellCheckLanguage.Location = new System.Drawing.Point(5, 77);
|
||||
this.comboBoxSpellCheckLanguage.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.comboBoxSpellCheckLanguage.Name = "comboBoxSpellCheckLanguage";
|
||||
this.comboBoxSpellCheckLanguage.Size = new System.Drawing.Size(311, 23);
|
||||
this.comboBoxSpellCheckLanguage.TabIndex = 3;
|
||||
//
|
||||
// labelTranslations
|
||||
//
|
||||
this.labelTranslations.AutoSize = true;
|
||||
this.labelTranslations.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelTranslations.Location = new System.Drawing.Point(0, 123);
|
||||
this.labelTranslations.Margin = new System.Windows.Forms.Padding(0, 20, 0, 0);
|
||||
this.labelTranslations.Name = "labelTranslations";
|
||||
this.labelTranslations.Size = new System.Drawing.Size(109, 20);
|
||||
this.labelTranslations.TabIndex = 4;
|
||||
this.labelTranslations.Text = "Bing Translator";
|
||||
//
|
||||
// labelTranslationTarget
|
||||
//
|
||||
this.labelTranslationTarget.AutoSize = true;
|
||||
this.labelTranslationTarget.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelTranslationTarget.Location = new System.Drawing.Point(3, 155);
|
||||
this.labelTranslationTarget.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelTranslationTarget.Name = "labelTranslationTarget";
|
||||
this.labelTranslationTarget.Size = new System.Drawing.Size(96, 15);
|
||||
this.labelTranslationTarget.TabIndex = 5;
|
||||
this.labelTranslationTarget.Text = "Target Language";
|
||||
//
|
||||
// comboBoxTranslationTarget
|
||||
//
|
||||
this.comboBoxTranslationTarget.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxTranslationTarget.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.comboBoxTranslationTarget.FormattingEnabled = true;
|
||||
this.comboBoxTranslationTarget.Location = new System.Drawing.Point(5, 173);
|
||||
this.comboBoxTranslationTarget.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.comboBoxTranslationTarget.Name = "comboBoxTranslationTarget";
|
||||
this.comboBoxTranslationTarget.Size = new System.Drawing.Size(311, 23);
|
||||
this.comboBoxTranslationTarget.TabIndex = 6;
|
||||
//
|
||||
// TabSettingsLocales
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.flowPanel);
|
||||
this.Name = "TabSettingsLocales";
|
||||
this.Size = new System.Drawing.Size(340, 219);
|
||||
this.flowPanel.ResumeLayout(false);
|
||||
this.flowPanel.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
private System.Windows.Forms.CheckBox checkSpellCheck;
|
||||
private System.Windows.Forms.Label labelLocales;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowPanel;
|
||||
private System.Windows.Forms.ComboBox comboBoxTranslationTarget;
|
||||
private System.Windows.Forms.Label labelTranslationTarget;
|
||||
private System.Windows.Forms.ComboBox comboBoxSpellCheckLanguage;
|
||||
private System.Windows.Forms.Label labelTranslations;
|
||||
private System.Windows.Forms.Label labelSpellCheckLanguage;
|
||||
}
|
||||
}
|
@@ -1,53 +0,0 @@
|
||||
using System;
|
||||
using TweetDuck.Core.Handling.General;
|
||||
using TweetDuck.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Other.Settings{
|
||||
sealed partial class TabSettingsLocales : BaseTabSettings{
|
||||
public TabSettingsLocales(){
|
||||
InitializeComponent();
|
||||
|
||||
toolTip.SetToolTip(checkSpellCheck, "Underlines words that are spelled incorrectly.");
|
||||
toolTip.SetToolTip(comboBoxSpellCheckLanguage, "Language used for spell check.");
|
||||
toolTip.SetToolTip(comboBoxTranslationTarget, "Language tweets are translated into.");
|
||||
|
||||
checkSpellCheck.Checked = Config.EnableSpellCheck;
|
||||
|
||||
try{
|
||||
foreach(LocaleUtils.Item item in LocaleUtils.SpellCheckLanguages){
|
||||
comboBoxSpellCheckLanguage.Items.Add(item);
|
||||
}
|
||||
}catch{
|
||||
comboBoxSpellCheckLanguage.Items.Add(new LocaleUtils.Item("en-US"));
|
||||
}
|
||||
|
||||
comboBoxSpellCheckLanguage.SelectedItem = new LocaleUtils.Item(Config.SpellCheckLanguage);
|
||||
|
||||
foreach(LocaleUtils.Item item in LocaleUtils.TweetDeckTranslationLocales){
|
||||
comboBoxTranslationTarget.Items.Add(item);
|
||||
}
|
||||
|
||||
comboBoxTranslationTarget.SelectedItem = new LocaleUtils.Item(Config.TranslationTarget);
|
||||
}
|
||||
|
||||
public override void OnReady(){
|
||||
checkSpellCheck.CheckedChanged += checkSpellCheck_CheckedChanged;
|
||||
comboBoxSpellCheckLanguage.SelectedValueChanged += comboBoxSpellCheckLanguage_SelectedValueChanged;
|
||||
comboBoxTranslationTarget.SelectedValueChanged += comboBoxTranslationTarget_SelectedValueChanged;
|
||||
}
|
||||
|
||||
private void checkSpellCheck_CheckedChanged(object sender, EventArgs e){
|
||||
Config.EnableSpellCheck = checkSpellCheck.Checked;
|
||||
BrowserProcessHandler.UpdatePrefs();
|
||||
}
|
||||
|
||||
private void comboBoxSpellCheckLanguage_SelectedValueChanged(object sender, EventArgs e){
|
||||
Config.SpellCheckLanguage = (comboBoxSpellCheckLanguage.SelectedItem as LocaleUtils.Item)?.Code ?? "en-US";
|
||||
PromptRestart();
|
||||
}
|
||||
|
||||
private void comboBoxTranslationTarget_SelectedValueChanged(object sender, EventArgs e){
|
||||
Config.TranslationTarget = (comboBoxTranslationTarget.SelectedItem as LocaleUtils.Item)?.Code ?? "en";
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,208 +0,0 @@
|
||||
using CefSharp;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp.WinForms;
|
||||
using TweetDuck.Core.Other;
|
||||
using TweetDuck.Data;
|
||||
|
||||
namespace TweetDuck.Core.Utils{
|
||||
static class BrowserUtils{
|
||||
public static string UserAgentVanilla => Program.BrandName+" "+Application.ProductVersion;
|
||||
public static string UserAgentChrome => "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/"+Cef.ChromiumVersion+" Safari/537.36";
|
||||
|
||||
public static readonly bool HasDevTools = File.Exists(Path.Combine(Program.ProgramPath, "devtools_resources.pak"));
|
||||
|
||||
public static void SetupCefArgs(IDictionary<string, string> args){
|
||||
if (!Program.SystemConfig.HardwareAcceleration){
|
||||
args["disable-gpu"] = "1";
|
||||
args["disable-gpu-vsync"] = "1";
|
||||
}
|
||||
|
||||
if (!Program.UserConfig.EnableSmoothScrolling){
|
||||
args["disable-smooth-scrolling"] = "1";
|
||||
}
|
||||
|
||||
args["disable-pdf-extension"] = "1";
|
||||
args["disable-plugins-discovery"] = "1";
|
||||
args["enable-system-flash"] = "0";
|
||||
|
||||
if (args.TryGetValue("js-flags", out string jsFlags)){
|
||||
args["js-flags"] = "--expose-gc "+jsFlags;
|
||||
}
|
||||
else{
|
||||
args["js-flags"] = "--expose-gc";
|
||||
}
|
||||
}
|
||||
|
||||
public static ChromiumWebBrowser AsControl(this IWebBrowser browserControl){
|
||||
return (ChromiumWebBrowser)browserControl;
|
||||
}
|
||||
|
||||
public static void SetupResourceHandler(this ChromiumWebBrowser browser, string url, IResourceHandler handler){
|
||||
DefaultResourceHandlerFactory factory = (DefaultResourceHandlerFactory)browser.ResourceHandlerFactory;
|
||||
|
||||
if (handler == null){
|
||||
factory.UnregisterHandler(url);
|
||||
}
|
||||
else{
|
||||
factory.RegisterHandler(url, handler);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetupResourceHandler(this ChromiumWebBrowser browser, ResourceLink resource){
|
||||
browser.SetupResourceHandler(resource.Url, resource.Handler);
|
||||
}
|
||||
|
||||
private const string TwitterTrackingUrl = "t.co";
|
||||
|
||||
public enum UrlCheckResult{
|
||||
Invalid, Tracking, Fine
|
||||
}
|
||||
|
||||
public static UrlCheckResult CheckUrl(string url){
|
||||
if (Uri.TryCreate(url, UriKind.Absolute, out Uri uri)){
|
||||
string scheme = uri.Scheme;
|
||||
|
||||
if (scheme == Uri.UriSchemeHttps || scheme == Uri.UriSchemeHttp || scheme == Uri.UriSchemeFtp || scheme == Uri.UriSchemeMailto){
|
||||
return uri.Host == TwitterTrackingUrl ? UrlCheckResult.Tracking : UrlCheckResult.Fine;
|
||||
}
|
||||
}
|
||||
|
||||
return UrlCheckResult.Invalid;
|
||||
}
|
||||
|
||||
public static void OpenExternalBrowser(string url){
|
||||
if (string.IsNullOrWhiteSpace(url))return;
|
||||
|
||||
switch(CheckUrl(url)){
|
||||
case UrlCheckResult.Fine:
|
||||
if (FormGuide.CheckGuideUrl(url, out string hash)){
|
||||
FormGuide.Show(hash);
|
||||
}
|
||||
else{
|
||||
string browserPath = Program.UserConfig.BrowserPath;
|
||||
|
||||
if (browserPath == null || !File.Exists(browserPath)){
|
||||
WindowsUtils.OpenAssociatedProgram(url);
|
||||
}
|
||||
else{
|
||||
try{
|
||||
using(Process.Start(browserPath, url)){}
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Error Opening Browser", "Could not open the browser.", true, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UrlCheckResult.Tracking:
|
||||
if (Program.UserConfig.IgnoreTrackingUrlWarning){
|
||||
goto case UrlCheckResult.Fine;
|
||||
}
|
||||
|
||||
using(FormMessage form = new FormMessage("Blocked URL", "TweetDuck has blocked a tracking url due to privacy concerns. Do you want to visit it anyway?\n"+url, MessageBoxIcon.Warning)){
|
||||
form.AddButton(FormMessage.No, DialogResult.No, ControlType.Cancel | ControlType.Focused);
|
||||
form.AddButton(FormMessage.Yes, DialogResult.Yes, ControlType.Accept);
|
||||
form.AddButton("Always Visit", DialogResult.Ignore);
|
||||
|
||||
DialogResult result = form.ShowDialog();
|
||||
|
||||
if (result == DialogResult.Ignore){
|
||||
Program.UserConfig.IgnoreTrackingUrlWarning = true;
|
||||
Program.UserConfig.Save();
|
||||
}
|
||||
|
||||
if (result == DialogResult.Ignore || result == DialogResult.Yes){
|
||||
goto case UrlCheckResult.Fine;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case UrlCheckResult.Invalid:
|
||||
FormMessage.Warning("Blocked URL", "A potentially malicious URL was blocked from opening:\n"+url, FormMessage.OK);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static void OpenExternalSearch(string query){
|
||||
if (string.IsNullOrWhiteSpace(query))return;
|
||||
|
||||
string searchUrl = Program.UserConfig.SearchEngineUrl;
|
||||
|
||||
if (string.IsNullOrEmpty(searchUrl)){
|
||||
if (FormMessage.Question("Search Options", "You have not configured a default search engine yet, would you like to do it now?", FormMessage.Yes, FormMessage.No)){
|
||||
bool wereSettingsOpen = FormManager.TryFind<FormSettings>() != null;
|
||||
|
||||
FormManager.TryFind<FormBrowser>()?.OpenSettings();
|
||||
if (wereSettingsOpen)return;
|
||||
|
||||
FormSettings settings = FormManager.TryFind<FormSettings>();
|
||||
if (settings == null)return;
|
||||
|
||||
settings.FormClosed += (sender, args) => {
|
||||
if (args.CloseReason == CloseReason.UserClosing && Program.UserConfig.SearchEngineUrl != searchUrl){
|
||||
OpenExternalSearch(query);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
else{
|
||||
OpenExternalBrowser(searchUrl+Uri.EscapeUriString(query));
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetFileNameFromUrl(string url){
|
||||
string file = Path.GetFileName(new Uri(url).AbsolutePath);
|
||||
return string.IsNullOrEmpty(file) ? null : file;
|
||||
}
|
||||
|
||||
public static string GetErrorName(CefErrorCode code){
|
||||
return StringUtils.ConvertPascalCaseToScreamingSnakeCase(Enum.GetName(typeof(CefErrorCode), code) ?? string.Empty);
|
||||
}
|
||||
|
||||
public static WebClient CreateWebClient(){
|
||||
WindowsUtils.EnsureTLS12();
|
||||
|
||||
WebClient client = new WebClient{ Proxy = null };
|
||||
client.Headers[HttpRequestHeader.UserAgent] = UserAgentVanilla;
|
||||
return client;
|
||||
}
|
||||
|
||||
public static WebClient DownloadFileAsync(string url, string target, Action onSuccess, Action<Exception> onFailure){
|
||||
WebClient client = CreateWebClient();
|
||||
|
||||
client.DownloadFileCompleted += (sender, args) => {
|
||||
if (args.Cancelled){
|
||||
try{
|
||||
File.Delete(target);
|
||||
}catch{
|
||||
// didn't want it deleted anyways
|
||||
}
|
||||
}
|
||||
else if (args.Error != null){
|
||||
onFailure?.Invoke(args.Error);
|
||||
}
|
||||
else{
|
||||
onSuccess?.Invoke();
|
||||
}
|
||||
};
|
||||
|
||||
client.DownloadFileAsync(new Uri(url), target);
|
||||
return client;
|
||||
}
|
||||
|
||||
public static int Scale(int baseValue, double scaleFactor){
|
||||
return (int)Math.Round(baseValue*scaleFactor);
|
||||
}
|
||||
|
||||
public static void SetZoomLevel(IBrowser browser, int percentage){
|
||||
browser.GetHost().SetZoomLevel(Math.Log(percentage/100.0, 1.2));
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,136 +0,0 @@
|
||||
using System;
|
||||
using CefSharp;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Other;
|
||||
using TweetDuck.Data;
|
||||
|
||||
namespace TweetDuck.Core.Utils{
|
||||
static class TwitterUtils{
|
||||
public const string TweetDeckURL = "https://tweetdeck.twitter.com";
|
||||
|
||||
public static readonly Color BackgroundColor = Color.FromArgb(28, 99, 153);
|
||||
public const string BackgroundColorOverride = "setTimeout(function f(){let h=document.head;if(!h){setTimeout(f,5);return;}let e=document.createElement('style');e.innerHTML='body,body::before{background:#1c6399!important}';h.appendChild(e);},1)";
|
||||
|
||||
public static readonly ResourceLink LoadingSpinner = new ResourceLink("https://ton.twimg.com/tduck/spinner", ResourceHandler.FromByteArray(Properties.Resources.spinner, "image/apng"));
|
||||
|
||||
private static readonly Lazy<Regex> RegexAccountLazy = new Lazy<Regex>(() => new Regex(@"^https?://twitter\.com/(?!signup$|tos$|privacy$|search$|search-)([^/?]+)/?$", RegexOptions.Compiled), false);
|
||||
public static Regex RegexAccount => RegexAccountLazy.Value;
|
||||
|
||||
public static readonly string[] DictionaryWords = {
|
||||
"tweetdeck", "TweetDeck", "tweetduck", "TweetDuck", "TD"
|
||||
};
|
||||
|
||||
public static readonly string[] ValidImageExtensions = {
|
||||
".jpg", ".jpeg", ".png", ".gif"
|
||||
};
|
||||
|
||||
public enum ImageQuality{
|
||||
Default, Orig
|
||||
}
|
||||
|
||||
public static bool IsTweetDeckWebsite(IFrame frame){
|
||||
return frame.Url.Contains("//tweetdeck.twitter.com/");
|
||||
}
|
||||
|
||||
public static bool IsTwitterWebsite(IFrame frame){
|
||||
return frame.Url.Contains("//twitter.com/");
|
||||
}
|
||||
|
||||
private static string ExtractMediaBaseLink(string url){
|
||||
int slash = url.LastIndexOf('/');
|
||||
return slash == -1 ? url : StringUtils.ExtractBefore(url, ':', slash);
|
||||
}
|
||||
|
||||
public static string GetMediaLink(string url, ImageQuality quality){
|
||||
if (quality == ImageQuality.Orig){
|
||||
string result = ExtractMediaBaseLink(url);
|
||||
|
||||
if (result != url || url.Contains("//pbs.twimg.com/media/")){
|
||||
result += ":orig";
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
else{
|
||||
return url;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetImageFileName(string url){
|
||||
return BrowserUtils.GetFileNameFromUrl(ExtractMediaBaseLink(url));
|
||||
}
|
||||
|
||||
public static void DownloadImage(string url, string username, ImageQuality quality){
|
||||
DownloadImages(new string[]{ url }, username, quality);
|
||||
}
|
||||
|
||||
public static void DownloadImages(string[] urls, string username, ImageQuality quality){
|
||||
if (urls.Length == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
string firstImageLink = GetMediaLink(urls[0], quality);
|
||||
int qualityIndex = firstImageLink.IndexOf(':', firstImageLink.LastIndexOf('/'));
|
||||
|
||||
string file = GetImageFileName(firstImageLink);
|
||||
string ext = Path.GetExtension(file); // includes dot
|
||||
|
||||
string[] fileNameParts = qualityIndex == -1 ? new string[]{
|
||||
Path.ChangeExtension(file, null)
|
||||
} : new string[]{
|
||||
username,
|
||||
Path.ChangeExtension(file, null),
|
||||
firstImageLink.Substring(qualityIndex+1)
|
||||
};
|
||||
|
||||
using(SaveFileDialog dialog = new SaveFileDialog{
|
||||
AutoUpgradeEnabled = true,
|
||||
OverwritePrompt = urls.Length == 1,
|
||||
Title = "Save Image",
|
||||
FileName = $"{string.Join(" ", fileNameParts.Where(part => !string.IsNullOrEmpty(part)))}{ext}",
|
||||
Filter = (urls.Length == 1 ? "Image" : "Images")+(string.IsNullOrEmpty(ext) ? " (unknown)|*.*" : $" (*{ext})|*{ext}")
|
||||
}){
|
||||
if (dialog.ShowDialog() == DialogResult.OK){
|
||||
void OnFailure(Exception ex){
|
||||
FormMessage.Error("Image Download", "An error occurred while downloading the image: "+ex.Message, FormMessage.OK);
|
||||
}
|
||||
|
||||
if (urls.Length == 1){
|
||||
BrowserUtils.DownloadFileAsync(firstImageLink, dialog.FileName, null, OnFailure);
|
||||
}
|
||||
else{
|
||||
string pathBase = Path.ChangeExtension(dialog.FileName, null);
|
||||
string pathExt = Path.GetExtension(dialog.FileName);
|
||||
|
||||
for(int index = 0; index < urls.Length; index++){
|
||||
BrowserUtils.DownloadFileAsync(GetMediaLink(urls[index], quality), $"{pathBase} {index+1}{pathExt}", null, OnFailure);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void DownloadVideo(string url, string username){
|
||||
string filename = BrowserUtils.GetFileNameFromUrl(url);
|
||||
string ext = Path.GetExtension(filename);
|
||||
|
||||
using(SaveFileDialog dialog = new SaveFileDialog{
|
||||
AutoUpgradeEnabled = true,
|
||||
OverwritePrompt = true,
|
||||
Title = "Save Video",
|
||||
FileName = string.IsNullOrEmpty(username) ? filename : $"{username} {filename}",
|
||||
Filter = "Video"+(string.IsNullOrEmpty(ext) ? " (unknown)|*.*" : $" (*{ext})|*{ext}")
|
||||
}){
|
||||
if (dialog.ShowDialog() == DialogResult.OK){
|
||||
BrowserUtils.DownloadFileAsync(url, dialog.FileName, null, ex => {
|
||||
FormMessage.Error("Image Download", "An error occurred while downloading the image: "+ex.Message, FormMessage.OK);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,209 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace TweetDuck.Core.Utils{
|
||||
static class WindowsUtils{
|
||||
private static readonly Lazy<Regex> RegexStripHtmlStyles = new Lazy<Regex>(() => new Regex(@"\s?(?:style|class)="".*?"""), false);
|
||||
private static readonly Lazy<Regex> RegexOffsetClipboardHtml = new Lazy<Regex>(() => new Regex(@"(?<=EndHTML:|EndFragment:)(\d+)"), false);
|
||||
|
||||
private static readonly bool IsWindows8OrNewer;
|
||||
private static bool HasMicrosoftBeenBroughtTo2008Yet;
|
||||
|
||||
public static int CurrentProcessID { get; }
|
||||
public static bool ShouldAvoidToolWindow { get; }
|
||||
public static bool IsAeroEnabled => IsWindows8OrNewer || (NativeMethods.DwmIsCompositionEnabled(out bool isCompositionEnabled) == 0 && isCompositionEnabled);
|
||||
|
||||
static WindowsUtils(){
|
||||
using(Process me = Process.GetCurrentProcess()){
|
||||
CurrentProcessID = me.Id;
|
||||
}
|
||||
|
||||
Version ver = Environment.OSVersion.Version;
|
||||
IsWindows8OrNewer = ver.Major == 6 && ver.Minor == 2; // windows 8/10
|
||||
|
||||
ShouldAvoidToolWindow = IsWindows8OrNewer;
|
||||
}
|
||||
|
||||
public static void EnsureTLS12(){
|
||||
if (!HasMicrosoftBeenBroughtTo2008Yet){
|
||||
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls12;
|
||||
ServicePointManager.SecurityProtocol &= ~(SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls | SecurityProtocolType.Tls11);
|
||||
HasMicrosoftBeenBroughtTo2008Yet = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CreateDirectoryForFile(string file){
|
||||
string dir = Path.GetDirectoryName(file);
|
||||
|
||||
if (dir == null){
|
||||
throw new ArgumentException("Invalid file path: "+file);
|
||||
}
|
||||
else if (dir.Length > 0){
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CheckFolderWritePermission(string path){
|
||||
string testFile = Path.Combine(path, ".test");
|
||||
|
||||
try{
|
||||
Directory.CreateDirectory(path);
|
||||
|
||||
using(File.Create(testFile)){}
|
||||
File.Delete(testFile);
|
||||
return true;
|
||||
}catch{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool OpenAssociatedProgram(string file, string arguments = "", bool runElevated = false){
|
||||
try{
|
||||
using(Process.Start(new ProcessStartInfo{
|
||||
FileName = file,
|
||||
Arguments = arguments,
|
||||
Verb = runElevated ? "runas" : string.Empty,
|
||||
ErrorDialog = true
|
||||
})){
|
||||
return true;
|
||||
}
|
||||
}catch(Win32Exception e) when (e.NativeErrorCode == 0x000004C7){ // operation canceled by the user
|
||||
return false;
|
||||
}catch(Exception e){
|
||||
Program.Reporter.HandleException("Error Opening Program", "Could not open the associated program for "+file, true, e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool TrySleepUntil(Func<bool> test, int timeoutMillis, int timeStepMillis){
|
||||
for(int waited = 0; waited < timeoutMillis; waited += timeStepMillis){
|
||||
if (test()){
|
||||
return true;
|
||||
}
|
||||
|
||||
Thread.Sleep(timeStepMillis);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void TryDeleteFolderWhenAble(string path, int timeout){
|
||||
new Thread(() => {
|
||||
TrySleepUntil(() => {
|
||||
try{
|
||||
Directory.Delete(path, true);
|
||||
return true;
|
||||
}catch(DirectoryNotFoundException){
|
||||
return true;
|
||||
}catch{
|
||||
return false;
|
||||
}
|
||||
}, timeout, 500);
|
||||
}).Start();
|
||||
}
|
||||
|
||||
public static void ClipboardStripHtmlStyles(){
|
||||
if (!Clipboard.ContainsText(TextDataFormat.Html) || !Clipboard.ContainsText(TextDataFormat.UnicodeText)){
|
||||
return;
|
||||
}
|
||||
|
||||
string originalText = Clipboard.GetText(TextDataFormat.UnicodeText);
|
||||
string originalHtml = Clipboard.GetText(TextDataFormat.Html);
|
||||
|
||||
string updatedHtml = RegexStripHtmlStyles.Value.Replace(originalHtml, string.Empty);
|
||||
|
||||
int removed = originalHtml.Length-updatedHtml.Length;
|
||||
updatedHtml = RegexOffsetClipboardHtml.Value.Replace(updatedHtml, match => (int.Parse(match.Value)-removed).ToString().PadLeft(match.Value.Length, '0'));
|
||||
|
||||
DataObject obj = new DataObject();
|
||||
obj.SetText(originalText, TextDataFormat.UnicodeText);
|
||||
obj.SetText(updatedHtml, TextDataFormat.Html);
|
||||
SetClipboardData(obj);
|
||||
}
|
||||
|
||||
public static void SetClipboard(string text, TextDataFormat format){
|
||||
if (string.IsNullOrEmpty(text)){
|
||||
return;
|
||||
}
|
||||
|
||||
DataObject obj = new DataObject();
|
||||
obj.SetText(text, format);
|
||||
SetClipboardData(obj);
|
||||
}
|
||||
|
||||
private static void SetClipboardData(DataObject obj){
|
||||
try{
|
||||
Clipboard.SetDataObject(obj);
|
||||
}catch(ExternalException e){
|
||||
Program.Reporter.HandleException("Clipboard Error", "TweetDuck could not access the clipboard as it is currently used by another process.", true, e);
|
||||
}
|
||||
}
|
||||
|
||||
public static IEnumerable<Browser> FindInstalledBrowsers(){
|
||||
IEnumerable<Browser> ReadBrowsersFromKey(RegistryHive hive){
|
||||
using(RegistryKey root = RegistryKey.OpenBaseKey(hive, RegistryView.Default))
|
||||
using(RegistryKey browserList = root.OpenSubKey(@"SOFTWARE\Clients\StartMenuInternet", false)){
|
||||
if (browserList == null){
|
||||
yield break;
|
||||
}
|
||||
|
||||
foreach(string sub in browserList.GetSubKeyNames()){
|
||||
using(RegistryKey browserKey = browserList.OpenSubKey(sub, false))
|
||||
using(RegistryKey shellKey = browserKey?.OpenSubKey(@"shell\open\command")){
|
||||
if (shellKey == null){
|
||||
continue;
|
||||
}
|
||||
|
||||
string browserName = browserKey.GetValue(null) as string;
|
||||
string browserPath = shellKey.GetValue(null) as string;
|
||||
|
||||
if (string.IsNullOrEmpty(browserName) || string.IsNullOrEmpty(browserPath)){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (browserPath[0] == '"' && browserPath[browserPath.Length-1] == '"'){
|
||||
browserPath = browserPath.Substring(1, browserPath.Length-2);
|
||||
}
|
||||
|
||||
yield return new Browser(browserName, browserPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
HashSet<Browser> browsers = new HashSet<Browser>();
|
||||
|
||||
try{
|
||||
browsers.UnionWith(ReadBrowsersFromKey(RegistryHive.CurrentUser));
|
||||
browsers.UnionWith(ReadBrowsersFromKey(RegistryHive.LocalMachine));
|
||||
}catch{
|
||||
// oops I guess
|
||||
}
|
||||
|
||||
return browsers;
|
||||
}
|
||||
|
||||
public sealed class Browser{
|
||||
public string Name { get; }
|
||||
public string Path { get; }
|
||||
|
||||
public Browser(string name, string path){
|
||||
this.Name = name;
|
||||
this.Path = path;
|
||||
}
|
||||
|
||||
public override int GetHashCode() => Name.GetHashCode();
|
||||
public override bool Equals(object obj) => obj is Browser other && Name == other.Name;
|
||||
public override string ToString() => Name;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,8 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace TweetDuck.Data.Serialization{
|
||||
interface ITypeConverter{
|
||||
bool TryWriteType(Type type, object value, out string converted);
|
||||
bool TryReadType(Type type, string value, out object converted);
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Other {
|
||||
namespace TweetDuck.Dialogs {
|
||||
sealed partial class FormAbout {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -50,7 +50,7 @@ namespace TweetDuck.Core.Other {
|
||||
this.labelDescription.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.labelDescription.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelDescription.Font = new System.Drawing.Font("Segoe UI", 9.75F);
|
||||
this.labelDescription.Location = new System.Drawing.Point(114, 12);
|
||||
this.labelDescription.Name = "labelDescription";
|
||||
this.labelDescription.Size = new System.Drawing.Size(232, 113);
|
||||
@@ -59,7 +59,7 @@ namespace TweetDuck.Core.Other {
|
||||
// labelTips
|
||||
//
|
||||
this.labelTips.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.labelTips.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelTips.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular);
|
||||
this.labelTips.LinkArea = new System.Windows.Forms.LinkArea(0, 0);
|
||||
this.labelTips.Location = new System.Drawing.Point(117, 0);
|
||||
this.labelTips.Margin = new System.Windows.Forms.Padding(0);
|
||||
@@ -74,7 +74,7 @@ namespace TweetDuck.Core.Other {
|
||||
//
|
||||
this.labelWebsite.AutoSize = true;
|
||||
this.labelWebsite.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.labelWebsite.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelWebsite.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular);
|
||||
this.labelWebsite.LinkArea = new System.Windows.Forms.LinkArea(0, 0);
|
||||
this.labelWebsite.Location = new System.Drawing.Point(0, 0);
|
||||
this.labelWebsite.Margin = new System.Windows.Forms.Padding(0);
|
||||
@@ -106,7 +106,7 @@ namespace TweetDuck.Core.Other {
|
||||
// labelIssues
|
||||
//
|
||||
this.labelIssues.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.labelIssues.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelIssues.Font = new System.Drawing.Font("Segoe UI", 9.75F, System.Drawing.FontStyle.Regular);
|
||||
this.labelIssues.LinkArea = new System.Windows.Forms.LinkArea(0, 0);
|
||||
this.labelIssues.Location = new System.Drawing.Point(216, 0);
|
||||
this.labelIssues.Margin = new System.Windows.Forms.Padding(0);
|
@@ -2,9 +2,10 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Management;
|
||||
using TweetDuck.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Other{
|
||||
namespace TweetDuck.Dialogs{
|
||||
sealed partial class FormAbout : Form, FormManager.IAppDialog{
|
||||
private const string TipsLink = "https://github.com/chylex/TweetDuck/wiki";
|
||||
private const string IssuesLink = "https://github.com/chylex/TweetDuck/issues";
|
@@ -1,21 +1,10 @@
|
||||
namespace TweetDuck.Core.Other {
|
||||
namespace TweetDuck.Dialogs {
|
||||
partial class FormGuide {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
@@ -1,17 +1,18 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Drawing;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Handling;
|
||||
using TweetDuck.Core.Handling.General;
|
||||
using TweetDuck.Core.Utils;
|
||||
using System.Text.RegularExpressions;
|
||||
using TweetDuck.Data;
|
||||
using TweetDuck.Resources;
|
||||
using TweetDuck.Browser;
|
||||
using TweetDuck.Browser.Adapters;
|
||||
using TweetDuck.Browser.Data;
|
||||
using TweetDuck.Browser.Handling;
|
||||
using TweetDuck.Browser.Handling.General;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Management;
|
||||
using TweetDuck.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Other{
|
||||
namespace TweetDuck.Dialogs{
|
||||
sealed partial class FormGuide : Form, FormManager.IAppDialog{
|
||||
private const string GuideUrl = "https://tweetduck.chylex.com/guide/v2/";
|
||||
private const string GuidePathRegex = @"^guide(?:/v\d+)?(?:/(#.*))?";
|
||||
@@ -65,31 +66,36 @@ namespace TweetDuck.Core.Other{
|
||||
Size = new Size(owner.Size.Width * 3 / 4, owner.Size.Height * 3 / 4);
|
||||
VisibleChanged += (sender, args) => this.MoveToCenter(owner);
|
||||
|
||||
ResourceHandlerFactory resourceHandlerFactory = new ResourceHandlerFactory();
|
||||
resourceHandlerFactory.RegisterHandler(DummyPage);
|
||||
|
||||
this.browser = new ChromiumWebBrowser(url){
|
||||
MenuHandler = new ContextMenuGuide(owner),
|
||||
JsDialogHandler = new JavaScriptDialogHandler(),
|
||||
KeyboardHandler = new KeyboardHandlerBase(),
|
||||
LifeSpanHandler = new LifeSpanHandler(),
|
||||
RequestHandler = new RequestHandlerBase(true)
|
||||
RequestHandler = new RequestHandlerBase(true),
|
||||
ResourceHandlerFactory = resourceHandlerFactory
|
||||
};
|
||||
|
||||
browser.LoadingStateChanged += browser_LoadingStateChanged;
|
||||
browser.FrameLoadStart += browser_FrameLoadStart;
|
||||
browser.FrameLoadEnd += browser_FrameLoadEnd;
|
||||
|
||||
browser.BrowserSettings.BackgroundColor = (uint)BackColor.ToArgb();
|
||||
browser.Dock = DockStyle.None;
|
||||
browser.Location = ControlExtensions.InvisibleLocation;
|
||||
|
||||
browser.SetupResourceHandler(DummyPage);
|
||||
browser.SetupZoomEvents();
|
||||
|
||||
Controls.Add(browser);
|
||||
}
|
||||
|
||||
Disposed += (sender, args) => {
|
||||
Program.UserConfig.ZoomLevelChanged -= Config_ZoomLevelChanged;
|
||||
protected override void Dispose(bool disposing){
|
||||
if (disposing){
|
||||
components?.Dispose();
|
||||
browser.Dispose();
|
||||
};
|
||||
}
|
||||
|
||||
Program.UserConfig.ZoomLevelChanged += Config_ZoomLevelChanged;
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
private void Reload(string url){
|
||||
@@ -116,16 +122,8 @@ namespace TweetDuck.Core.Other{
|
||||
}
|
||||
}
|
||||
|
||||
private void browser_FrameLoadStart(object sender, FrameLoadStartEventArgs e){
|
||||
BrowserUtils.SetZoomLevel(browser.GetBrowser(), Program.UserConfig.ZoomLevel);
|
||||
}
|
||||
|
||||
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||
ScriptLoader.ExecuteScript(e.Frame, "Array.prototype.forEach.call(document.getElementsByTagName('A'), ele => ele.addEventListener('click', e => { e.preventDefault(); window.open(ele.getAttribute('href')); }))", "gen:links");
|
||||
}
|
||||
|
||||
private void Config_ZoomLevelChanged(object sender, EventArgs e){
|
||||
BrowserUtils.SetZoomLevel(browser.GetBrowser(), Program.UserConfig.ZoomLevel);
|
||||
CefScriptExecutor.RunScript(e.Frame, "Array.prototype.forEach.call(document.getElementsByTagName('A'), ele => ele.addEventListener('click', e => { e.preventDefault(); window.open(ele.getAttribute('href')); }))", "gen:links");
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Other {
|
||||
namespace TweetDuck.Dialogs {
|
||||
partial class FormMessage {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Other{
|
||||
namespace TweetDuck.Dialogs{
|
||||
[Flags]
|
||||
enum ControlType{
|
||||
None = 0,
|
||||
@@ -43,7 +43,8 @@ namespace TweetDuck.Core.Other{
|
||||
}
|
||||
|
||||
public static bool Show(string caption, string text, MessageBoxIcon icon, string buttonAccept, string buttonCancel){
|
||||
using(FormMessage message = new FormMessage(caption, text, icon)){
|
||||
using FormMessage message = new FormMessage(caption, text, icon);
|
||||
|
||||
if (buttonCancel == null){
|
||||
message.AddButton(buttonAccept, DialogResult.OK, ControlType.Cancel | ControlType.Focused);
|
||||
}
|
||||
@@ -54,7 +55,6 @@ namespace TweetDuck.Core.Other{
|
||||
|
||||
return message.ShowDialog() == DialogResult.OK;
|
||||
}
|
||||
}
|
||||
|
||||
// Instance
|
||||
|
@@ -1,4 +1,6 @@
|
||||
namespace TweetDuck.Core.Other {
|
||||
using TweetDuck.Controls;
|
||||
|
||||
namespace TweetDuck.Dialogs {
|
||||
partial class FormPlugins {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -27,7 +29,7 @@
|
||||
this.btnClose = new System.Windows.Forms.Button();
|
||||
this.btnReload = new System.Windows.Forms.Button();
|
||||
this.btnOpenFolder = new System.Windows.Forms.Button();
|
||||
this.flowLayoutPlugins = new TweetDuck.Plugins.Controls.PluginListFlowLayout();
|
||||
this.flowLayoutPlugins = new FlowLayoutPanelNoHScroll();
|
||||
this.timerLayout = new System.Windows.Forms.Timer(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -35,7 +37,7 @@
|
||||
//
|
||||
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnClose.AutoSize = true;
|
||||
this.btnClose.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnClose.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnClose.Location = new System.Drawing.Point(642, 433);
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -49,7 +51,7 @@
|
||||
//
|
||||
this.btnReload.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.btnReload.AutoSize = true;
|
||||
this.btnReload.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnReload.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnReload.Location = new System.Drawing.Point(141, 433);
|
||||
this.btnReload.Name = "btnReload";
|
||||
this.btnReload.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -63,7 +65,7 @@
|
||||
//
|
||||
this.btnOpenFolder.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.btnOpenFolder.AutoSize = true;
|
||||
this.btnOpenFolder.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnOpenFolder.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnOpenFolder.Location = new System.Drawing.Point(12, 433);
|
||||
this.btnOpenFolder.Name = "btnOpenFolder";
|
||||
this.btnOpenFolder.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -117,7 +119,7 @@
|
||||
private System.Windows.Forms.Button btnClose;
|
||||
private System.Windows.Forms.Button btnReload;
|
||||
private System.Windows.Forms.Button btnOpenFolder;
|
||||
private Plugins.Controls.PluginListFlowLayout flowLayoutPlugins;
|
||||
private FlowLayoutPanelNoHScroll flowLayoutPlugins;
|
||||
private System.Windows.Forms.Timer timerLayout;
|
||||
}
|
||||
}
|
@@ -1,13 +1,17 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Management;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Plugins.Controls;
|
||||
using TweetLib.Core;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
|
||||
namespace TweetDuck.Core.Other{
|
||||
namespace TweetDuck.Dialogs{
|
||||
sealed partial class FormPlugins : Form, FormManager.IAppDialog{
|
||||
private static UserConfig Config => Program.Config.User;
|
||||
|
||||
private readonly PluginManager pluginManager;
|
||||
|
||||
public FormPlugins(){
|
||||
@@ -19,8 +23,8 @@ namespace TweetDuck.Core.Other{
|
||||
public FormPlugins(PluginManager pluginManager) : this(){
|
||||
this.pluginManager = pluginManager;
|
||||
|
||||
if (!Program.UserConfig.PluginsWindowSize.IsEmpty){
|
||||
Size targetSize = Program.UserConfig.PluginsWindowSize;
|
||||
if (!Config.PluginsWindowSize.IsEmpty){
|
||||
Size targetSize = Config.PluginsWindowSize;
|
||||
Size = new Size(Math.Max(MinimumSize.Width, targetSize.Width), Math.Max(MinimumSize.Height, targetSize.Height));
|
||||
}
|
||||
|
||||
@@ -29,8 +33,8 @@ namespace TweetDuck.Core.Other{
|
||||
};
|
||||
|
||||
FormClosed += (sender, args) => {
|
||||
Program.UserConfig.PluginsWindowSize = Size;
|
||||
Program.UserConfig.Save();
|
||||
Config.PluginsWindowSize = Size;
|
||||
Config.Save();
|
||||
};
|
||||
|
||||
ResizeEnd += (sender, args) => {
|
||||
@@ -92,7 +96,7 @@ namespace TweetDuck.Core.Other{
|
||||
}
|
||||
|
||||
private void btnOpenFolder_Click(object sender, EventArgs e){
|
||||
using(Process.Start("explorer.exe", '"'+pluginManager.PathCustomPlugins+'"')){}
|
||||
App.SystemHandler.OpenFileExplorer(pluginManager.PathCustomPlugins);
|
||||
}
|
||||
|
||||
private void btnReload_Click(object sender, EventArgs e){
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Other {
|
||||
namespace TweetDuck.Dialogs {
|
||||
sealed partial class FormSettings {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -33,8 +33,8 @@
|
||||
//
|
||||
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnClose.AutoSize = true;
|
||||
this.btnClose.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnClose.Location = new System.Drawing.Point(448, 525);
|
||||
this.btnClose.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnClose.Location = new System.Drawing.Point(747, 500);
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnClose.Size = new System.Drawing.Size(50, 25);
|
||||
@@ -53,7 +53,7 @@
|
||||
this.panelContents.Location = new System.Drawing.Point(135, 12);
|
||||
this.panelContents.Margin = new System.Windows.Forms.Padding(0, 3, 3, 3);
|
||||
this.panelContents.Name = "panelContents";
|
||||
this.panelContents.Size = new System.Drawing.Size(363, 507);
|
||||
this.panelContents.Size = new System.Drawing.Size(662, 482);
|
||||
this.panelContents.TabIndex = 1;
|
||||
//
|
||||
// panelButtons
|
||||
@@ -64,15 +64,15 @@
|
||||
this.panelButtons.Location = new System.Drawing.Point(12, 12);
|
||||
this.panelButtons.Margin = new System.Windows.Forms.Padding(3, 3, 0, 3);
|
||||
this.panelButtons.Name = "panelButtons";
|
||||
this.panelButtons.Size = new System.Drawing.Size(124, 507);
|
||||
this.panelButtons.Size = new System.Drawing.Size(124, 482);
|
||||
this.panelButtons.TabIndex = 0;
|
||||
//
|
||||
// btnManageOptions
|
||||
//
|
||||
this.btnManageOptions.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.btnManageOptions.AutoSize = true;
|
||||
this.btnManageOptions.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnManageOptions.Location = new System.Drawing.Point(12, 525);
|
||||
this.btnManageOptions.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnManageOptions.Location = new System.Drawing.Point(12, 500);
|
||||
this.btnManageOptions.Name = "btnManageOptions";
|
||||
this.btnManageOptions.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnManageOptions.Size = new System.Drawing.Size(109, 25);
|
||||
@@ -85,7 +85,7 @@
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(510, 562);
|
||||
this.ClientSize = new System.Drawing.Size(809, 537);
|
||||
this.Controls.Add(this.btnManageOptions);
|
||||
this.Controls.Add(this.panelContents);
|
||||
this.Controls.Add(this.panelButtons);
|
@@ -2,28 +2,30 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Handling.General;
|
||||
using TweetDuck.Core.Notification.Example;
|
||||
using TweetDuck.Core.Other.Analytics;
|
||||
using TweetDuck.Core.Other.Settings;
|
||||
using TweetDuck.Core.Other.Settings.Dialogs;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Updates;
|
||||
using TweetDuck.Browser;
|
||||
using TweetDuck.Browser.Handling.General;
|
||||
using TweetDuck.Browser.Notification.Example;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Dialogs.Settings;
|
||||
using TweetDuck.Management;
|
||||
using TweetDuck.Management.Analytics;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
using TweetLib.Core.Features.Updates;
|
||||
|
||||
namespace TweetDuck.Core.Other{
|
||||
namespace TweetDuck.Dialogs{
|
||||
sealed partial class FormSettings : Form, FormManager.IAppDialog{
|
||||
public bool ShouldReloadBrowser { get; private set; }
|
||||
|
||||
private readonly FormBrowser browser;
|
||||
private readonly PluginManager plugins;
|
||||
|
||||
private readonly int buttonHeight;
|
||||
|
||||
private readonly Dictionary<Type, SettingsTab> tabs = new Dictionary<Type, SettingsTab>(4);
|
||||
private readonly Dictionary<Type, SettingsTab> tabs = new Dictionary<Type, SettingsTab>(8);
|
||||
private SettingsTab currentTab;
|
||||
|
||||
public bool ShouldReloadBrowser { get; private set; }
|
||||
|
||||
public FormSettings(FormBrowser browser, PluginManager plugins, UpdateHandler updates, AnalyticsManager analytics, Type startTab){
|
||||
InitializeComponent();
|
||||
|
||||
@@ -36,49 +38,68 @@ namespace TweetDuck.Core.Other{
|
||||
|
||||
this.buttonHeight = BrowserUtils.Scale(39, this.GetDPIScale()) | 1;
|
||||
|
||||
PrepareLoad();
|
||||
|
||||
AddButton("General", () => new TabSettingsGeneral(this.browser.ReloadColumns, updates));
|
||||
AddButton("Locales", () => new TabSettingsLocales());
|
||||
AddButton("System Tray", () => new TabSettingsTray());
|
||||
AddButton("Notifications", () => new TabSettingsNotifications(new FormNotificationExample(this.browser, this.plugins)));
|
||||
AddButton("Sounds", () => new TabSettingsSounds(this.browser.PlaySoundNotification));
|
||||
AddButton("Tray", () => new TabSettingsTray());
|
||||
AddButton("Feedback", () => new TabSettingsFeedback(analytics, AnalyticsReportGenerator.ExternalInfo.From(this.browser), this.plugins));
|
||||
AddButton("Advanced", () => new TabSettingsAdvanced(this.browser.ReinjectCustomCSS, this.browser.OpenDevTools));
|
||||
|
||||
SelectTab(tabs[startTab ?? typeof(TabSettingsGeneral)]);
|
||||
}
|
||||
|
||||
private void FormSettings_FormClosing(object sender, FormClosingEventArgs e){
|
||||
private void PrepareLoad(){
|
||||
Program.Config.ProgramRestartRequested += Config_ProgramRestartRequested;
|
||||
}
|
||||
|
||||
private void PrepareUnload(){ // TODO refactor this further later
|
||||
currentTab.Control.OnClosing();
|
||||
|
||||
Program.Config.ProgramRestartRequested -= Config_ProgramRestartRequested;
|
||||
Program.Config.SaveAll();
|
||||
}
|
||||
|
||||
private void Config_ProgramRestartRequested(object sender, EventArgs e){
|
||||
if (FormMessage.Information("TweetDuck Options", "The application must restart for the option to take place. Do you want to restart now?", FormMessage.Yes, FormMessage.No)){
|
||||
Program.Restart();
|
||||
}
|
||||
}
|
||||
|
||||
private void FormSettings_FormClosing(object sender, FormClosingEventArgs e){
|
||||
PrepareUnload();
|
||||
|
||||
foreach(SettingsTab tab in tabs.Values){
|
||||
if (tab.IsInitialized){
|
||||
tab.Control.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Program.UserConfig.Save();
|
||||
browser.ResumeNotification();
|
||||
}
|
||||
|
||||
private void btnManageOptions_Click(object sender, EventArgs e){
|
||||
currentTab.Control.OnClosing();
|
||||
PrepareUnload();
|
||||
|
||||
using(DialogSettingsManage dialog = new DialogSettingsManage(plugins)){
|
||||
using DialogSettingsManage dialog = new DialogSettingsManage(plugins);
|
||||
FormClosing -= FormSettings_FormClosing;
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK){
|
||||
if (!dialog.IsRestarting){
|
||||
browser.ResumeNotification();
|
||||
|
||||
if (dialog.ShouldReloadBrowser){
|
||||
BrowserProcessHandler.UpdatePrefs();
|
||||
ShouldReloadBrowser = dialog.ShouldReloadBrowser;
|
||||
ShouldReloadBrowser = true;
|
||||
}
|
||||
}
|
||||
|
||||
Close();
|
||||
}
|
||||
else{
|
||||
FormClosing += FormSettings_FormClosing;
|
||||
}
|
||||
PrepareLoad();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +107,7 @@ namespace TweetDuck.Core.Other{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void AddButton<T>(string title, Func<T> constructor) where T : BaseTabSettings{
|
||||
private void AddButton<T>(string title, Func<T> constructor) where T : BaseTab{
|
||||
FlatButton btn = new FlatButton{
|
||||
BackColor = SystemColors.Control,
|
||||
FlatStyle = FlatStyle.Flat,
|
||||
@@ -116,7 +137,7 @@ namespace TweetDuck.Core.Other{
|
||||
btn.Click += (sender, args) => SelectTab<T>();
|
||||
}
|
||||
|
||||
private void SelectTab<T>() where T : BaseTabSettings{
|
||||
private void SelectTab<T>() where T : BaseTab{
|
||||
SelectTab(tabs[typeof(T)]);
|
||||
}
|
||||
|
||||
@@ -138,6 +159,10 @@ namespace TweetDuck.Core.Other{
|
||||
}
|
||||
}
|
||||
|
||||
if (tab.Control.Height < panelContents.Height - 2){
|
||||
tab.Control.Height = panelContents.Height - 2; // fixes off-by-pixel error on high DPI
|
||||
}
|
||||
|
||||
tab.Control.OnReady();
|
||||
}
|
||||
|
||||
@@ -172,16 +197,47 @@ namespace TweetDuck.Core.Other{
|
||||
private sealed class SettingsTab{
|
||||
public Button Button { get; }
|
||||
|
||||
public BaseTabSettings Control => control ?? (control = constructor());
|
||||
public BaseTab Control => control ??= constructor();
|
||||
public bool IsInitialized => control != null;
|
||||
|
||||
private readonly Func<BaseTabSettings> constructor;
|
||||
private BaseTabSettings control;
|
||||
private readonly Func<BaseTab> constructor;
|
||||
private BaseTab control;
|
||||
|
||||
public SettingsTab(Button button, Func<BaseTabSettings> constructor){
|
||||
public SettingsTab(Button button, Func<BaseTab> constructor){
|
||||
this.Button = button;
|
||||
this.constructor = constructor;
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract class BaseTab : UserControl{
|
||||
protected static UserConfig Config => Program.Config.User;
|
||||
protected static SystemConfig SysConfig => Program.Config.System;
|
||||
|
||||
public IEnumerable<Control> InteractiveControls{
|
||||
get{
|
||||
static IEnumerable<Control> FindInteractiveControls(Control parent){
|
||||
foreach(Control control in parent.Controls){
|
||||
if (control is Panel subPanel){
|
||||
foreach(Control subControl in FindInteractiveControls(subPanel)){
|
||||
yield return subControl;
|
||||
}
|
||||
}
|
||||
else{
|
||||
yield return control;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return FindInteractiveControls(this);
|
||||
}
|
||||
}
|
||||
|
||||
protected BaseTab(){
|
||||
Padding = new Padding(6);
|
||||
}
|
||||
|
||||
public virtual void OnReady(){}
|
||||
public virtual void OnClosing(){}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs {
|
||||
namespace TweetDuck.Dialogs.Settings {
|
||||
partial class DialogSettingsAnalytics {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -33,7 +33,7 @@
|
||||
this.textBoxReport.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.textBoxReport.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.textBoxReport.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.textBoxReport.Location = new System.Drawing.Point(12, 45);
|
||||
this.textBoxReport.Multiline = true;
|
||||
this.textBoxReport.Name = "textBoxReport";
|
||||
@@ -46,7 +46,7 @@
|
||||
//
|
||||
this.btnClose.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnClose.AutoSize = true;
|
||||
this.btnClose.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnClose.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnClose.Location = new System.Drawing.Point(397, 525);
|
||||
this.btnClose.Name = "btnClose";
|
||||
this.btnClose.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -59,7 +59,7 @@
|
||||
// labelInfo
|
||||
//
|
||||
this.labelInfo.AutoSize = true;
|
||||
this.labelInfo.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelInfo.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.labelInfo.Location = new System.Drawing.Point(12, 9);
|
||||
this.labelInfo.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);
|
||||
this.labelInfo.Name = "labelInfo";
|
@@ -1,12 +1,10 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Other.Analytics;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Management.Analytics;
|
||||
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
namespace TweetDuck.Dialogs.Settings{
|
||||
sealed partial class DialogSettingsAnalytics : Form{
|
||||
public string CefArgs => textBoxReport.Text;
|
||||
|
||||
public DialogSettingsAnalytics(AnalyticsReport report){
|
||||
InitializeComponent();
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs {
|
||||
namespace TweetDuck.Dialogs.Settings {
|
||||
partial class DialogSettingsCSS {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -41,7 +41,7 @@
|
||||
// textBoxBrowserCSS
|
||||
//
|
||||
this.textBoxBrowserCSS.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.textBoxBrowserCSS.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.textBoxBrowserCSS.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.textBoxBrowserCSS.Location = new System.Drawing.Point(3, 3);
|
||||
this.textBoxBrowserCSS.Margin = new System.Windows.Forms.Padding(0, 3, 0, 0);
|
||||
this.textBoxBrowserCSS.Multiline = true;
|
||||
@@ -84,7 +84,7 @@
|
||||
// textBoxNotificationCSS
|
||||
//
|
||||
this.textBoxNotificationCSS.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.textBoxNotificationCSS.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.textBoxNotificationCSS.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.textBoxNotificationCSS.Location = new System.Drawing.Point(3, 3);
|
||||
this.textBoxNotificationCSS.Margin = new System.Windows.Forms.Padding(0, 3, 0, 0);
|
||||
this.textBoxNotificationCSS.Multiline = true;
|
||||
@@ -121,7 +121,7 @@
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tabPanel.Controls.Add(this.tabPageBrowser);
|
||||
this.tabPanel.Controls.Add(this.tabPageNotification);
|
||||
this.tabPanel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.tabPanel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.tabPanel.Location = new System.Drawing.Point(12, 12);
|
||||
this.tabPanel.Name = "tabPanel";
|
||||
this.tabPanel.SelectedIndex = 0;
|
@@ -2,10 +2,10 @@
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
namespace TweetDuck.Dialogs.Settings{
|
||||
sealed partial class DialogSettingsCSS : Form{
|
||||
public string BrowserCSS => textBoxBrowserCSS.Text;
|
||||
public string NotificationCSS => textBoxNotificationCSS.Text;
|
||||
@@ -13,7 +13,7 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
private readonly Action<string> reinjectBrowserCSS;
|
||||
private readonly Action openDevTools;
|
||||
|
||||
public DialogSettingsCSS(Action<string> reinjectBrowserCSS, Action openDevTools){
|
||||
public DialogSettingsCSS(string browserCSS, string notificationCSS, Action<string> reinjectBrowserCSS, Action openDevTools){
|
||||
InitializeComponent();
|
||||
|
||||
Text = Program.BrandName + " Options - CSS";
|
||||
@@ -22,10 +22,10 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
this.openDevTools = openDevTools;
|
||||
|
||||
textBoxBrowserCSS.EnableMultilineShortcuts();
|
||||
textBoxBrowserCSS.Text = Program.UserConfig.CustomBrowserCSS ?? "";
|
||||
textBoxBrowserCSS.Text = browserCSS ?? "";
|
||||
|
||||
textBoxNotificationCSS.EnableMultilineShortcuts();
|
||||
textBoxNotificationCSS.Text = Program.UserConfig.CustomNotificationCSS ?? "";
|
||||
textBoxNotificationCSS.Text = notificationCSS ?? "";
|
||||
|
||||
if (!BrowserUtils.HasDevTools){
|
||||
btnOpenDevTools.Enabled = false;
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs {
|
||||
namespace TweetDuck.Dialogs.Settings {
|
||||
partial class DialogSettingsCefArgs {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -35,7 +35,7 @@
|
||||
this.textBoxArgs.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.textBoxArgs.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.textBoxArgs.Font = new System.Drawing.Font("Courier New", 8.25F, System.Drawing.FontStyle.Regular);
|
||||
this.textBoxArgs.Location = new System.Drawing.Point(12, 30);
|
||||
this.textBoxArgs.Multiline = true;
|
||||
this.textBoxArgs.Name = "textBoxArgs";
|
||||
@@ -46,7 +46,7 @@
|
||||
//
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCancel.AutoSize = true;
|
||||
this.btnCancel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnCancel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnCancel.Location = new System.Drawing.Point(377, 225);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -60,7 +60,7 @@
|
||||
//
|
||||
this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnApply.AutoSize = true;
|
||||
this.btnApply.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnApply.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnApply.Location = new System.Drawing.Point(440, 225);
|
||||
this.btnApply.Name = "btnApply";
|
||||
this.btnApply.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -74,7 +74,7 @@
|
||||
//
|
||||
this.btnHelp.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.btnHelp.AutoSize = true;
|
||||
this.btnHelp.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnHelp.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnHelp.Location = new System.Drawing.Point(12, 225);
|
||||
this.btnHelp.Name = "btnHelp";
|
||||
this.btnHelp.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -87,7 +87,7 @@
|
||||
// labelWarning
|
||||
//
|
||||
this.labelWarning.AutoSize = true;
|
||||
this.labelWarning.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelWarning.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.labelWarning.Location = new System.Drawing.Point(12, 9);
|
||||
this.labelWarning.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);
|
||||
this.labelWarning.Name = "labelWarning";
|
@@ -1,20 +1,22 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Core.Controls;
|
||||
using TweetDuck.Core.Utils;
|
||||
using TweetDuck.Data;
|
||||
using TweetDuck.Controls;
|
||||
using TweetDuck.Utils;
|
||||
using TweetLib.Core.Collections;
|
||||
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
namespace TweetDuck.Dialogs.Settings{
|
||||
sealed partial class DialogSettingsCefArgs : Form{
|
||||
public string CefArgs => textBoxArgs.Text;
|
||||
|
||||
public DialogSettingsCefArgs(){
|
||||
private readonly string initialArgs;
|
||||
|
||||
public DialogSettingsCefArgs(string args){
|
||||
InitializeComponent();
|
||||
|
||||
Text = Program.BrandName + " Options - CEF Arguments";
|
||||
|
||||
textBoxArgs.EnableMultilineShortcuts();
|
||||
textBoxArgs.Text = Program.UserConfig.CustomCefArgs ?? "";
|
||||
textBoxArgs.Text = initialArgs = args ?? "";
|
||||
textBoxArgs.Select(textBoxArgs.Text.Length, 0);
|
||||
}
|
||||
|
||||
@@ -23,16 +25,14 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
}
|
||||
|
||||
private void btnApply_Click(object sender, EventArgs e){
|
||||
string prevArgs = Program.UserConfig.CustomCefArgs;
|
||||
|
||||
if (CefArgs == prevArgs){
|
||||
if (CefArgs == initialArgs){
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
return;
|
||||
}
|
||||
|
||||
int count = CommandLineArgs.ReadCefArguments(CefArgs).Count;
|
||||
string prompt = count == 0 && !string.IsNullOrWhiteSpace(prevArgs) ? "All current arguments will be removed. Continue?" : count+(count == 1 ? " argument was" : " arguments were")+" detected. Continue?";
|
||||
string prompt = count == 0 && !string.IsNullOrWhiteSpace(initialArgs) ? "All current arguments will be removed. Continue?" : count + (count == 1 ? " argument was" : " arguments were") + " detected. Continue?";
|
||||
|
||||
if (FormMessage.Question("Confirm CEF Arguments", prompt, FormMessage.OK, FormMessage.Cancel)){
|
||||
DialogResult = DialogResult.OK;
|
154
Dialogs/Settings/DialogSettingsExternalProgram.Designer.cs
generated
Normal file
154
Dialogs/Settings/DialogSettingsExternalProgram.Designer.cs
generated
Normal file
@@ -0,0 +1,154 @@
|
||||
namespace TweetDuck.Dialogs.Settings {
|
||||
partial class DialogSettingsExternalProgram {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.textBoxPath = new System.Windows.Forms.TextBox();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.btnApply = new System.Windows.Forms.Button();
|
||||
this.labelPath = new System.Windows.Forms.Label();
|
||||
this.labelArgs = new System.Windows.Forms.Label();
|
||||
this.textBoxArgs = new System.Windows.Forms.TextBox();
|
||||
this.btnBrowse = new System.Windows.Forms.Button();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// textBoxPath
|
||||
//
|
||||
this.textBoxPath.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.textBoxPath.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.textBoxPath.Location = new System.Drawing.Point(12, 30);
|
||||
this.textBoxPath.Name = "textBoxPath";
|
||||
this.textBoxPath.Size = new System.Drawing.Size(336, 23);
|
||||
this.textBoxPath.TabIndex = 1;
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCancel.AutoSize = true;
|
||||
this.btnCancel.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnCancel.Location = new System.Drawing.Point(307, 118);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnCancel.Size = new System.Drawing.Size(57, 25);
|
||||
this.btnCancel.TabIndex = 6;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// btnApply
|
||||
//
|
||||
this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnApply.AutoSize = true;
|
||||
this.btnApply.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnApply.Location = new System.Drawing.Point(370, 118);
|
||||
this.btnApply.Name = "btnApply";
|
||||
this.btnApply.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnApply.Size = new System.Drawing.Size(52, 25);
|
||||
this.btnApply.TabIndex = 5;
|
||||
this.btnApply.Text = "Apply";
|
||||
this.btnApply.UseVisualStyleBackColor = true;
|
||||
this.btnApply.Click += new System.EventHandler(this.btnApply_Click);
|
||||
//
|
||||
// labelPath
|
||||
//
|
||||
this.labelPath.AutoSize = true;
|
||||
this.labelPath.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.labelPath.Location = new System.Drawing.Point(12, 9);
|
||||
this.labelPath.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);
|
||||
this.labelPath.Name = "labelPath";
|
||||
this.labelPath.Size = new System.Drawing.Size(109, 15);
|
||||
this.labelPath.TabIndex = 0;
|
||||
this.labelPath.Text = "Path to Application";
|
||||
//
|
||||
// labelArgs
|
||||
//
|
||||
this.labelArgs.AutoSize = true;
|
||||
this.labelArgs.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.labelArgs.Location = new System.Drawing.Point(12, 68);
|
||||
this.labelArgs.Margin = new System.Windows.Forms.Padding(3, 12, 3, 3);
|
||||
this.labelArgs.Name = "labelArgs";
|
||||
this.labelArgs.Size = new System.Drawing.Size(124, 15);
|
||||
this.labelArgs.TabIndex = 3;
|
||||
this.labelArgs.Text = "Additional Arguments";
|
||||
//
|
||||
// textBoxArgs
|
||||
//
|
||||
this.textBoxArgs.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.textBoxArgs.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.textBoxArgs.Location = new System.Drawing.Point(12, 89);
|
||||
this.textBoxArgs.Name = "textBoxArgs";
|
||||
this.textBoxArgs.Size = new System.Drawing.Size(410, 23);
|
||||
this.textBoxArgs.TabIndex = 4;
|
||||
//
|
||||
// btnBrowse
|
||||
//
|
||||
this.btnBrowse.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnBrowse.AutoSize = true;
|
||||
this.btnBrowse.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnBrowse.Location = new System.Drawing.Point(354, 28);
|
||||
this.btnBrowse.Name = "btnBrowse";
|
||||
this.btnBrowse.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
this.btnBrowse.Size = new System.Drawing.Size(68, 25);
|
||||
this.btnBrowse.TabIndex = 2;
|
||||
this.btnBrowse.Text = "Browse...";
|
||||
this.btnBrowse.UseVisualStyleBackColor = true;
|
||||
this.btnBrowse.Click += new System.EventHandler(this.btnBrowse_Click);
|
||||
//
|
||||
// DialogSettingsExternalProgram
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(434, 155);
|
||||
this.Controls.Add(this.btnBrowse);
|
||||
this.Controls.Add(this.textBoxArgs);
|
||||
this.Controls.Add(this.labelArgs);
|
||||
this.Controls.Add(this.labelPath);
|
||||
this.Controls.Add(this.btnApply);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.Controls.Add(this.textBoxPath);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "DialogSettingsExternalProgram";
|
||||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox textBoxPath;
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.Button btnApply;
|
||||
private System.Windows.Forms.Label labelPath;
|
||||
private System.Windows.Forms.Label labelArgs;
|
||||
private System.Windows.Forms.TextBox textBoxArgs;
|
||||
private System.Windows.Forms.Button btnBrowse;
|
||||
}
|
||||
}
|
55
Dialogs/Settings/DialogSettingsExternalProgram.cs
Normal file
55
Dialogs/Settings/DialogSettingsExternalProgram.cs
Normal file
@@ -0,0 +1,55 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetLib.Core.Utils;
|
||||
using IOPath = System.IO.Path;
|
||||
|
||||
namespace TweetDuck.Dialogs.Settings{
|
||||
sealed partial class DialogSettingsExternalProgram : Form{
|
||||
public string Path{
|
||||
get => StringUtils.NullIfEmpty(textBoxPath.Text);
|
||||
set => textBoxPath.Text = value ?? string.Empty;
|
||||
}
|
||||
|
||||
public string Args{
|
||||
get => StringUtils.NullIfEmpty(textBoxArgs.Text);
|
||||
set => textBoxArgs.Text = value ?? string.Empty;
|
||||
}
|
||||
|
||||
private readonly string fileDialogTitle;
|
||||
|
||||
public DialogSettingsExternalProgram(string windowTitle, string fileDialogTitle){
|
||||
InitializeComponent();
|
||||
|
||||
Text = Program.BrandName + " Options - " + windowTitle;
|
||||
AcceptButton = btnApply;
|
||||
CancelButton = btnCancel;
|
||||
|
||||
this.fileDialogTitle = fileDialogTitle;
|
||||
}
|
||||
|
||||
private void btnBrowse_Click(object sender, EventArgs e){
|
||||
using OpenFileDialog dialog = new OpenFileDialog{
|
||||
AutoUpgradeEnabled = true,
|
||||
DereferenceLinks = true,
|
||||
InitialDirectory = IOPath.GetDirectoryName(Path), // returns null if argument is null
|
||||
Title = fileDialogTitle,
|
||||
Filter = "Executables (*.exe;*.bat;*.cmd)|*.exe;*.bat;*.cmd|All Files (*.*)|*.*"
|
||||
};
|
||||
|
||||
if (dialog.ShowDialog() == DialogResult.OK && Path != dialog.FileName){
|
||||
Path = dialog.FileName;
|
||||
Args = string.Empty;
|
||||
}
|
||||
}
|
||||
|
||||
private void btnApply_Click(object sender, EventArgs e){
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e){
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs {
|
||||
namespace TweetDuck.Dialogs.Settings {
|
||||
partial class DialogSettingsManage {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -44,7 +44,7 @@
|
||||
//
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCancel.AutoSize = true;
|
||||
this.btnCancel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnCancel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnCancel.Location = new System.Drawing.Point(165, 92);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -59,7 +59,7 @@
|
||||
this.btnContinue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnContinue.AutoSize = true;
|
||||
this.btnContinue.Enabled = false;
|
||||
this.btnContinue.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnContinue.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnContinue.Location = new System.Drawing.Point(114, 92);
|
||||
this.btnContinue.Name = "btnContinue";
|
||||
this.btnContinue.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -72,7 +72,7 @@
|
||||
// cbProgramConfig
|
||||
//
|
||||
this.cbProgramConfig.AutoSize = true;
|
||||
this.cbProgramConfig.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.cbProgramConfig.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.cbProgramConfig.Location = new System.Drawing.Point(3, 3);
|
||||
this.cbProgramConfig.Margin = new System.Windows.Forms.Padding(3, 3, 3, 2);
|
||||
this.cbProgramConfig.Name = "cbProgramConfig";
|
||||
@@ -86,7 +86,7 @@
|
||||
// cbSession
|
||||
//
|
||||
this.cbSession.AutoSize = true;
|
||||
this.cbSession.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.cbSession.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.cbSession.Location = new System.Drawing.Point(3, 51);
|
||||
this.cbSession.Margin = new System.Windows.Forms.Padding(3, 3, 3, 2);
|
||||
this.cbSession.Name = "cbSession";
|
||||
@@ -100,7 +100,7 @@
|
||||
// cbPluginData
|
||||
//
|
||||
this.cbPluginData.AutoSize = true;
|
||||
this.cbPluginData.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.cbPluginData.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.cbPluginData.Location = new System.Drawing.Point(3, 75);
|
||||
this.cbPluginData.Margin = new System.Windows.Forms.Padding(3, 3, 3, 2);
|
||||
this.cbPluginData.Name = "cbPluginData";
|
||||
@@ -114,7 +114,7 @@
|
||||
// cbSystemConfig
|
||||
//
|
||||
this.cbSystemConfig.AutoSize = true;
|
||||
this.cbSystemConfig.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.cbSystemConfig.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.cbSystemConfig.Location = new System.Drawing.Point(3, 27);
|
||||
this.cbSystemConfig.Margin = new System.Windows.Forms.Padding(3, 3, 3, 2);
|
||||
this.cbSystemConfig.Name = "cbSystemConfig";
|
||||
@@ -158,7 +158,7 @@
|
||||
// radioImport
|
||||
//
|
||||
this.radioImport.AutoSize = true;
|
||||
this.radioImport.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.radioImport.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.radioImport.Location = new System.Drawing.Point(3, 3);
|
||||
this.radioImport.Margin = new System.Windows.Forms.Padding(3, 3, 3, 2);
|
||||
this.radioImport.Name = "radioImport";
|
||||
@@ -172,7 +172,7 @@
|
||||
// radioExport
|
||||
//
|
||||
this.radioExport.AutoSize = true;
|
||||
this.radioExport.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.radioExport.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.radioExport.Location = new System.Drawing.Point(3, 27);
|
||||
this.radioExport.Margin = new System.Windows.Forms.Padding(3, 3, 3, 2);
|
||||
this.radioExport.Name = "radioExport";
|
||||
@@ -186,7 +186,7 @@
|
||||
// radioReset
|
||||
//
|
||||
this.radioReset.AutoSize = true;
|
||||
this.radioReset.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.radioReset.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.radioReset.Location = new System.Drawing.Point(3, 51);
|
||||
this.radioReset.Margin = new System.Windows.Forms.Padding(3, 3, 3, 2);
|
||||
this.radioReset.Name = "radioReset";
|
@@ -3,10 +3,11 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Core.Management;
|
||||
using TweetDuck.Plugins;
|
||||
using TweetDuck.Management;
|
||||
using TweetLib.Core.Features.Plugins;
|
||||
using TweetLib.Core.Utils;
|
||||
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
namespace TweetDuck.Dialogs.Settings{
|
||||
sealed partial class DialogSettingsManage : Form{
|
||||
private enum State{
|
||||
Deciding, Reset, Import, Export
|
||||
@@ -23,14 +24,20 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
}
|
||||
}
|
||||
|
||||
private bool SelectedItemsForceRestart{
|
||||
get => _selectedItems.HasFlag(ProfileManager.Items.Session);
|
||||
}
|
||||
|
||||
public bool IsRestarting { get; private set; }
|
||||
public bool ShouldReloadBrowser { get; private set; }
|
||||
|
||||
private readonly PluginManager plugins;
|
||||
private readonly Dictionary<CheckBox, ProfileManager.Items> checkBoxMap = new Dictionary<CheckBox, ProfileManager.Items>(4);
|
||||
private readonly bool openImportImmediately;
|
||||
|
||||
private State currentState;
|
||||
private ProfileManager importManager;
|
||||
private bool requestedRestartFromConfig;
|
||||
|
||||
private ProfileManager.Items _selectedItems = ProfileManager.Items.None;
|
||||
|
||||
@@ -45,6 +52,8 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
this.checkBoxMap[cbSession] = ProfileManager.Items.Session;
|
||||
this.checkBoxMap[cbPluginData] = ProfileManager.Items.PluginData;
|
||||
|
||||
this.openImportImmediately = openImportImmediately;
|
||||
|
||||
if (openImportImmediately){
|
||||
radioImport.Checked = true;
|
||||
btnContinue_Click(null, EventArgs.Empty);
|
||||
@@ -82,6 +91,10 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
Filter = "TweetDuck Profile (*.tdsettings)|*.tdsettings"
|
||||
}){
|
||||
if (dialog.ShowDialog() != DialogResult.OK){
|
||||
if (openImportImmediately){
|
||||
Close();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -116,37 +129,39 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
|
||||
case State.Reset:
|
||||
if (FormMessage.Warning("Reset TweetDuck Options", "This will reset the selected items. Are you sure you want to proceed?", FormMessage.Yes, FormMessage.No)){
|
||||
Program.Config.ProgramRestartRequested += Config_ProgramRestartRequested;
|
||||
|
||||
if (SelectedItems.HasFlag(ProfileManager.Items.UserConfig)){
|
||||
Program.UserConfig.Reset();
|
||||
Program.Config.User.Reset();
|
||||
}
|
||||
|
||||
if (SelectedItems.HasFlag(ProfileManager.Items.SystemConfig)){
|
||||
try{
|
||||
File.Delete(Program.SystemConfigFilePath);
|
||||
}catch(Exception ex){
|
||||
Program.Reporter.HandleException("System Config Reset Error", "Could not delete system config.", true, ex);
|
||||
}
|
||||
Program.Config.System.Reset();
|
||||
}
|
||||
|
||||
Program.Config.ProgramRestartRequested -= Config_ProgramRestartRequested;
|
||||
|
||||
if (SelectedItems.HasFlag(ProfileManager.Items.PluginData)){
|
||||
Program.Config.Plugins.Reset();
|
||||
|
||||
try{
|
||||
File.Delete(Program.PluginConfigFilePath);
|
||||
Directory.Delete(Program.PluginDataPath, true);
|
||||
}catch(Exception ex){
|
||||
Program.Reporter.HandleException("Plugin Data Reset Error", "Could not delete plugin data.", true, ex);
|
||||
Program.Reporter.HandleException("Profile Reset", "Could not delete plugin data.", true, ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (SelectedItems.HasFlag(ProfileManager.Items.Session)){
|
||||
RestartProgram(Arguments.ArgDeleteCookies);
|
||||
if (SelectedItemsForceRestart){
|
||||
RestartProgram(SelectedItems.HasFlag(ProfileManager.Items.Session) ? new string[]{ Arguments.ArgDeleteCookies } : StringUtils.EmptyArray);
|
||||
}
|
||||
else if (SelectedItems.HasFlag(ProfileManager.Items.SystemConfig)){
|
||||
else if (requestedRestartFromConfig){
|
||||
if (FormMessage.Information("Profile Reset", "The application must restart for some of the restored options to take place. Do you want to restart now?", FormMessage.Yes, FormMessage.No)){
|
||||
RestartProgram();
|
||||
}
|
||||
else{
|
||||
ShouldReloadBrowser = true;
|
||||
}
|
||||
|
||||
ShouldReloadBrowser = true;
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
@@ -155,20 +170,21 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
|
||||
case State.Import:
|
||||
if (importManager.Import(SelectedItems)){
|
||||
Program.UserConfig.Reload();
|
||||
Program.Config.ProgramRestartRequested += Config_ProgramRestartRequested;
|
||||
Program.Config.ReloadAll();
|
||||
Program.Config.ProgramRestartRequested -= Config_ProgramRestartRequested;
|
||||
|
||||
if (importManager.IsRestarting){
|
||||
if (SelectedItems.HasFlag(ProfileManager.Items.Session)){
|
||||
RestartProgram(Arguments.ArgImportCookies);
|
||||
if (SelectedItemsForceRestart){
|
||||
RestartProgram(SelectedItems.HasFlag(ProfileManager.Items.Session) ? new string[]{ Arguments.ArgImportCookies } : StringUtils.EmptyArray);
|
||||
}
|
||||
else if (SelectedItems.HasFlag(ProfileManager.Items.SystemConfig)){
|
||||
else if (requestedRestartFromConfig){
|
||||
if (FormMessage.Information("Profile Import", "The application must restart for some of the imported options to take place. Do you want to restart now?", FormMessage.Yes, FormMessage.No)){
|
||||
RestartProgram();
|
||||
}
|
||||
}
|
||||
else{
|
||||
}
|
||||
|
||||
ShouldReloadBrowser = true;
|
||||
}
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
@@ -191,9 +207,6 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
file = dialog.FileName;
|
||||
}
|
||||
|
||||
Program.UserConfig.Save();
|
||||
Program.SystemConfig.Save();
|
||||
|
||||
new ProfileManager(file, plugins).Export(SelectedItems);
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
@@ -207,15 +220,19 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Config_ProgramRestartRequested(object sender, EventArgs e){
|
||||
requestedRestartFromConfig = true;
|
||||
}
|
||||
|
||||
private void SetFlag(ProfileManager.Items flag, bool enable){
|
||||
_selectedItems = enable ? _selectedItems | flag : _selectedItems & ~flag;
|
||||
btnContinue.Enabled = _selectedItems != ProfileManager.Items.None;
|
||||
|
||||
if (currentState == State.Import){
|
||||
btnContinue.Text = _selectedItems.NeedsRestart() ? "Import && Restart" : "Import Profile";
|
||||
btnContinue.Text = SelectedItemsForceRestart ? "Import && Restart" : "Import Profile";
|
||||
}
|
||||
else if (currentState == State.Reset){
|
||||
btnContinue.Text = _selectedItems.NeedsRestart() ? "Restore && Restart" : "Restore Defaults";
|
||||
btnContinue.Text = SelectedItemsForceRestart ? "Restore && Restart" : "Restore Defaults";
|
||||
}
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs {
|
||||
namespace TweetDuck.Dialogs.Settings {
|
||||
partial class DialogSettingsRestart {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -40,7 +40,7 @@
|
||||
//
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCancel.AutoSize = true;
|
||||
this.btnCancel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnCancel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnCancel.Location = new System.Drawing.Point(215, 146);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -54,7 +54,7 @@
|
||||
//
|
||||
this.btnRestart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnRestart.AutoSize = true;
|
||||
this.btnRestart.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnRestart.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnRestart.Location = new System.Drawing.Point(152, 146);
|
||||
this.btnRestart.Name = "btnRestart";
|
||||
this.btnRestart.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -67,7 +67,7 @@
|
||||
// cbLogging
|
||||
//
|
||||
this.cbLogging.AutoSize = true;
|
||||
this.cbLogging.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.cbLogging.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.cbLogging.Location = new System.Drawing.Point(3, 3);
|
||||
this.cbLogging.Margin = new System.Windows.Forms.Padding(3, 3, 3, 2);
|
||||
this.cbLogging.Name = "cbLogging";
|
||||
@@ -79,7 +79,7 @@
|
||||
//
|
||||
// tbDataFolder
|
||||
//
|
||||
this.tbDataFolder.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.tbDataFolder.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.tbDataFolder.Location = new System.Drawing.Point(3, 54);
|
||||
this.tbDataFolder.Name = "tbDataFolder";
|
||||
this.tbDataFolder.Size = new System.Drawing.Size(260, 23);
|
||||
@@ -92,7 +92,7 @@
|
||||
this.tbShortcutTarget.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tbShortcutTarget.Cursor = System.Windows.Forms.Cursors.Hand;
|
||||
this.tbShortcutTarget.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.tbShortcutTarget.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.tbShortcutTarget.Location = new System.Drawing.Point(3, 110);
|
||||
this.tbShortcutTarget.Name = "tbShortcutTarget";
|
||||
this.tbShortcutTarget.ReadOnly = true;
|
||||
@@ -103,7 +103,7 @@
|
||||
// labelDataFolder
|
||||
//
|
||||
this.labelDataFolder.AutoSize = true;
|
||||
this.labelDataFolder.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelDataFolder.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.labelDataFolder.Location = new System.Drawing.Point(3, 36);
|
||||
this.labelDataFolder.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelDataFolder.Name = "labelDataFolder";
|
||||
@@ -114,7 +114,7 @@
|
||||
// labelShortcutTarget
|
||||
//
|
||||
this.labelShortcutTarget.AutoSize = true;
|
||||
this.labelShortcutTarget.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelShortcutTarget.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.labelShortcutTarget.Location = new System.Drawing.Point(3, 92);
|
||||
this.labelShortcutTarget.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelShortcutTarget.Name = "labelShortcutTarget";
|
@@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDuck.Configuration;
|
||||
using TweetDuck.Data;
|
||||
using TweetLib.Core.Collections;
|
||||
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
namespace TweetDuck.Dialogs.Settings{
|
||||
sealed partial class DialogSettingsRestart : Form{
|
||||
public CommandLineArgs Args { get; private set; }
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
tbDataFolder.Enabled = false;
|
||||
}
|
||||
else{
|
||||
tbDataFolder.Text = currentArgs.GetValue(Arguments.ArgDataFolder, string.Empty);
|
||||
tbDataFolder.Text = currentArgs.GetValue(Arguments.ArgDataFolder) ?? string.Empty;
|
||||
tbDataFolder.TextChanged += control_Change;
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
Args.SetValue(Arguments.ArgDataFolder, tbDataFolder.Text);
|
||||
}
|
||||
|
||||
tbShortcutTarget.Text = $@"""{Application.ExecutablePath}""{(Args.Count > 0 ? " " : "")}{Args}";
|
||||
tbShortcutTarget.Text = $@"""{Program.ExecutablePath}""{(Args.Count > 0 ? " " : "")}{Args}";
|
||||
tbShortcutTarget.Select(tbShortcutTarget.Text.Length, 0);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs {
|
||||
namespace TweetDuck.Dialogs.Settings {
|
||||
partial class DialogSettingsSearchEngine {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -34,7 +34,7 @@
|
||||
this.textBoxUrl.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.textBoxUrl.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.textBoxUrl.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.textBoxUrl.Location = new System.Drawing.Point(12, 30);
|
||||
this.textBoxUrl.Name = "textBoxUrl";
|
||||
this.textBoxUrl.Size = new System.Drawing.Size(310, 23);
|
||||
@@ -44,7 +44,7 @@
|
||||
//
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCancel.AutoSize = true;
|
||||
this.btnCancel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnCancel.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnCancel.Location = new System.Drawing.Point(207, 59);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -58,7 +58,7 @@
|
||||
//
|
||||
this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnApply.AutoSize = true;
|
||||
this.btnApply.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnApply.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.btnApply.Location = new System.Drawing.Point(270, 59);
|
||||
this.btnApply.Name = "btnApply";
|
||||
this.btnApply.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
|
||||
@@ -71,7 +71,7 @@
|
||||
// labelInfo
|
||||
//
|
||||
this.labelInfo.AutoSize = true;
|
||||
this.labelInfo.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelInfo.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular);
|
||||
this.labelInfo.Location = new System.Drawing.Point(12, 9);
|
||||
this.labelInfo.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);
|
||||
this.labelInfo.Name = "labelInfo";
|
@@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
namespace TweetDuck.Dialogs.Settings{
|
||||
sealed partial class DialogSettingsSearchEngine : Form{
|
||||
public string Url => textBoxUrl.Text;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace TweetDuck.Core.Other.Settings.Dialogs{
|
||||
|
||||
Text = Program.BrandName + " Options - Custom Search Engine";
|
||||
|
||||
textBoxUrl.Text = Program.UserConfig.SearchEngineUrl ?? "";
|
||||
textBoxUrl.Text = Program.Config.User.SearchEngineUrl ?? "";
|
||||
textBoxUrl.Select(textBoxUrl.Text.Length, 0);
|
||||
}
|
||||
|
@@ -1,4 +1,4 @@
|
||||
namespace TweetDuck.Core.Other.Settings {
|
||||
namespace TweetDuck.Dialogs.Settings {
|
||||
partial class TabSettingsAdvanced {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
@@ -25,7 +25,6 @@
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.btnClearCache = new System.Windows.Forms.Button();
|
||||
this.checkHardwareAcceleration = new System.Windows.Forms.CheckBox();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.btnEditCefArgs = new System.Windows.Forms.Button();
|
||||
this.btnEditCSS = new System.Windows.Forms.Button();
|
||||
@@ -33,16 +32,17 @@
|
||||
this.btnRestart = new System.Windows.Forms.Button();
|
||||
this.btnOpenAppFolder = new System.Windows.Forms.Button();
|
||||
this.btnOpenDataFolder = new System.Windows.Forms.Button();
|
||||
this.numClearCacheThreshold = new TweetDuck.Core.Controls.NumericUpDownEx();
|
||||
this.numClearCacheThreshold = new TweetDuck.Controls.NumericUpDownEx();
|
||||
this.checkClearCacheAuto = new System.Windows.Forms.CheckBox();
|
||||
this.labelApp = new System.Windows.Forms.Label();
|
||||
this.panelAppButtons = new System.Windows.Forms.Panel();
|
||||
this.labelPerformance = new System.Windows.Forms.Label();
|
||||
this.panelClearCacheAuto = new System.Windows.Forms.Panel();
|
||||
this.labelCache = new System.Windows.Forms.Label();
|
||||
this.panelClearCacheAuto = new System.Windows.Forms.Panel();
|
||||
this.panelConfiguration = new System.Windows.Forms.Panel();
|
||||
this.labelConfiguration = new System.Windows.Forms.Label();
|
||||
this.flowPanel = new System.Windows.Forms.FlowLayoutPanel();
|
||||
this.labelDevTools = new System.Windows.Forms.Label();
|
||||
this.checkDevToolsWindowOnTop = new System.Windows.Forms.CheckBox();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numClearCacheThreshold)).BeginInit();
|
||||
this.panelAppButtons.SuspendLayout();
|
||||
this.panelClearCacheAuto.SuspendLayout();
|
||||
@@ -52,99 +52,87 @@
|
||||
//
|
||||
// btnClearCache
|
||||
//
|
||||
this.btnClearCache.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnClearCache.Location = new System.Drawing.Point(5, 179);
|
||||
this.btnClearCache.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnClearCache.Location = new System.Drawing.Point(5, 135);
|
||||
this.btnClearCache.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.btnClearCache.Name = "btnClearCache";
|
||||
this.btnClearCache.Size = new System.Drawing.Size(144, 25);
|
||||
this.btnClearCache.TabIndex = 5;
|
||||
this.btnClearCache.Size = new System.Drawing.Size(143, 25);
|
||||
this.btnClearCache.TabIndex = 3;
|
||||
this.btnClearCache.Text = "Clear Cache (...)";
|
||||
this.btnClearCache.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkHardwareAcceleration
|
||||
//
|
||||
this.checkHardwareAcceleration.AutoSize = true;
|
||||
this.checkHardwareAcceleration.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.checkHardwareAcceleration.Location = new System.Drawing.Point(6, 128);
|
||||
this.checkHardwareAcceleration.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2);
|
||||
this.checkHardwareAcceleration.Name = "checkHardwareAcceleration";
|
||||
this.checkHardwareAcceleration.Size = new System.Drawing.Size(146, 19);
|
||||
this.checkHardwareAcceleration.TabIndex = 3;
|
||||
this.checkHardwareAcceleration.Text = "Hardware Acceleration";
|
||||
this.checkHardwareAcceleration.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnEditCefArgs
|
||||
//
|
||||
this.btnEditCefArgs.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnEditCefArgs.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnEditCefArgs.Location = new System.Drawing.Point(5, 3);
|
||||
this.btnEditCefArgs.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.btnEditCefArgs.Name = "btnEditCefArgs";
|
||||
this.btnEditCefArgs.Size = new System.Drawing.Size(144, 25);
|
||||
this.btnEditCefArgs.Size = new System.Drawing.Size(143, 25);
|
||||
this.btnEditCefArgs.TabIndex = 0;
|
||||
this.btnEditCefArgs.Text = "Edit CEF Arguments";
|
||||
this.btnEditCefArgs.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnEditCSS
|
||||
//
|
||||
this.btnEditCSS.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnEditCSS.Location = new System.Drawing.Point(155, 3);
|
||||
this.btnEditCSS.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnEditCSS.Location = new System.Drawing.Point(154, 3);
|
||||
this.btnEditCSS.Name = "btnEditCSS";
|
||||
this.btnEditCSS.Size = new System.Drawing.Size(144, 25);
|
||||
this.btnEditCSS.Size = new System.Drawing.Size(143, 25);
|
||||
this.btnEditCSS.TabIndex = 1;
|
||||
this.btnEditCSS.Text = "Edit CSS";
|
||||
this.btnEditCSS.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnRestartArgs
|
||||
//
|
||||
this.btnRestartArgs.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnRestartArgs.Location = new System.Drawing.Point(155, 32);
|
||||
this.btnRestartArgs.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnRestartArgs.Location = new System.Drawing.Point(154, 32);
|
||||
this.btnRestartArgs.Name = "btnRestartArgs";
|
||||
this.btnRestartArgs.Size = new System.Drawing.Size(144, 25);
|
||||
this.btnRestartArgs.Size = new System.Drawing.Size(143, 25);
|
||||
this.btnRestartArgs.TabIndex = 3;
|
||||
this.btnRestartArgs.Text = "Restart with Arguments";
|
||||
this.btnRestartArgs.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnRestart
|
||||
//
|
||||
this.btnRestart.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnRestart.Location = new System.Drawing.Point(155, 3);
|
||||
this.btnRestart.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnRestart.Location = new System.Drawing.Point(154, 3);
|
||||
this.btnRestart.Name = "btnRestart";
|
||||
this.btnRestart.Size = new System.Drawing.Size(144, 25);
|
||||
this.btnRestart.Size = new System.Drawing.Size(143, 25);
|
||||
this.btnRestart.TabIndex = 2;
|
||||
this.btnRestart.Text = "Restart the Program";
|
||||
this.btnRestart.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnOpenAppFolder
|
||||
//
|
||||
this.btnOpenAppFolder.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnOpenAppFolder.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnOpenAppFolder.Location = new System.Drawing.Point(5, 3);
|
||||
this.btnOpenAppFolder.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.btnOpenAppFolder.Name = "btnOpenAppFolder";
|
||||
this.btnOpenAppFolder.Size = new System.Drawing.Size(144, 25);
|
||||
this.btnOpenAppFolder.Size = new System.Drawing.Size(143, 25);
|
||||
this.btnOpenAppFolder.TabIndex = 0;
|
||||
this.btnOpenAppFolder.Text = "Open Program Folder";
|
||||
this.btnOpenAppFolder.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnOpenDataFolder
|
||||
//
|
||||
this.btnOpenDataFolder.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.btnOpenDataFolder.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.btnOpenDataFolder.Location = new System.Drawing.Point(5, 32);
|
||||
this.btnOpenDataFolder.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.btnOpenDataFolder.Name = "btnOpenDataFolder";
|
||||
this.btnOpenDataFolder.Size = new System.Drawing.Size(144, 25);
|
||||
this.btnOpenDataFolder.Size = new System.Drawing.Size(143, 25);
|
||||
this.btnOpenDataFolder.TabIndex = 1;
|
||||
this.btnOpenDataFolder.Text = "Open Data Folder";
|
||||
this.btnOpenDataFolder.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numClearCacheThreshold
|
||||
//
|
||||
this.numClearCacheThreshold.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.numClearCacheThreshold.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.numClearCacheThreshold.Increment = new decimal(new int[] {
|
||||
50,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numClearCacheThreshold.Location = new System.Drawing.Point(246, 5);
|
||||
this.numClearCacheThreshold.Location = new System.Drawing.Point(210, 5);
|
||||
this.numClearCacheThreshold.Maximum = new decimal(new int[] {
|
||||
1000,
|
||||
0,
|
||||
@@ -156,7 +144,7 @@
|
||||
0,
|
||||
0});
|
||||
this.numClearCacheThreshold.Name = "numClearCacheThreshold";
|
||||
this.numClearCacheThreshold.Size = new System.Drawing.Size(68, 23);
|
||||
this.numClearCacheThreshold.Size = new System.Drawing.Size(89, 23);
|
||||
this.numClearCacheThreshold.TabIndex = 1;
|
||||
this.numClearCacheThreshold.TextAlign = System.Windows.Forms.HorizontalAlignment.Right;
|
||||
this.numClearCacheThreshold.TextSuffix = " MB";
|
||||
@@ -169,29 +157,28 @@
|
||||
// checkClearCacheAuto
|
||||
//
|
||||
this.checkClearCacheAuto.AutoSize = true;
|
||||
this.checkClearCacheAuto.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.checkClearCacheAuto.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.checkClearCacheAuto.Location = new System.Drawing.Point(6, 6);
|
||||
this.checkClearCacheAuto.Margin = new System.Windows.Forms.Padding(6, 6, 0, 2);
|
||||
this.checkClearCacheAuto.Name = "checkClearCacheAuto";
|
||||
this.checkClearCacheAuto.Size = new System.Drawing.Size(237, 19);
|
||||
this.checkClearCacheAuto.Size = new System.Drawing.Size(201, 19);
|
||||
this.checkClearCacheAuto.TabIndex = 0;
|
||||
this.checkClearCacheAuto.Text = "Clear Cache Automatically When Above";
|
||||
this.checkClearCacheAuto.Text = "Clear Automatically When Above";
|
||||
this.checkClearCacheAuto.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelApp
|
||||
//
|
||||
this.labelApp.AutoSize = true;
|
||||
this.labelApp.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelApp.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
|
||||
this.labelApp.Location = new System.Drawing.Point(0, 0);
|
||||
this.labelApp.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.labelApp.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
|
||||
this.labelApp.Name = "labelApp";
|
||||
this.labelApp.Size = new System.Drawing.Size(37, 20);
|
||||
this.labelApp.Size = new System.Drawing.Size(97, 19);
|
||||
this.labelApp.TabIndex = 0;
|
||||
this.labelApp.Text = "App";
|
||||
this.labelApp.Text = "APPLICATION";
|
||||
//
|
||||
// panelAppButtons
|
||||
//
|
||||
this.panelAppButtons.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.panelAppButtons.Controls.Add(this.btnOpenDataFolder);
|
||||
this.panelAppButtons.Controls.Add(this.btnOpenAppFolder);
|
||||
this.panelAppButtons.Controls.Add(this.btnRestart);
|
||||
@@ -199,92 +186,101 @@
|
||||
this.panelAppButtons.Location = new System.Drawing.Point(0, 20);
|
||||
this.panelAppButtons.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.panelAppButtons.Name = "panelAppButtons";
|
||||
this.panelAppButtons.Size = new System.Drawing.Size(322, 62);
|
||||
this.panelAppButtons.Size = new System.Drawing.Size(300, 62);
|
||||
this.panelAppButtons.TabIndex = 1;
|
||||
//
|
||||
// labelPerformance
|
||||
//
|
||||
this.labelPerformance.AutoSize = true;
|
||||
this.labelPerformance.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelPerformance.Location = new System.Drawing.Point(0, 102);
|
||||
this.labelPerformance.Margin = new System.Windows.Forms.Padding(0, 20, 0, 0);
|
||||
this.labelPerformance.Name = "labelPerformance";
|
||||
this.labelPerformance.Size = new System.Drawing.Size(93, 20);
|
||||
this.labelPerformance.TabIndex = 2;
|
||||
this.labelPerformance.Text = "Performance";
|
||||
//
|
||||
// panelClearCacheAuto
|
||||
//
|
||||
this.panelClearCacheAuto.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.panelClearCacheAuto.Controls.Add(this.checkClearCacheAuto);
|
||||
this.panelClearCacheAuto.Controls.Add(this.numClearCacheThreshold);
|
||||
this.panelClearCacheAuto.Location = new System.Drawing.Point(0, 207);
|
||||
this.panelClearCacheAuto.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.panelClearCacheAuto.Name = "panelClearCacheAuto";
|
||||
this.panelClearCacheAuto.Size = new System.Drawing.Size(322, 28);
|
||||
this.panelClearCacheAuto.TabIndex = 6;
|
||||
//
|
||||
// labelCache
|
||||
//
|
||||
this.labelCache.AutoSize = true;
|
||||
this.labelCache.Font = new System.Drawing.Font("Segoe UI", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelCache.Location = new System.Drawing.Point(3, 161);
|
||||
this.labelCache.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelCache.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
|
||||
this.labelCache.Location = new System.Drawing.Point(0, 112);
|
||||
this.labelCache.Margin = new System.Windows.Forms.Padding(0, 30, 0, 1);
|
||||
this.labelCache.Name = "labelCache";
|
||||
this.labelCache.Size = new System.Drawing.Size(40, 15);
|
||||
this.labelCache.TabIndex = 4;
|
||||
this.labelCache.Text = "Cache";
|
||||
this.labelCache.Size = new System.Drawing.Size(123, 19);
|
||||
this.labelCache.TabIndex = 2;
|
||||
this.labelCache.Text = "BROWSER CACHE";
|
||||
//
|
||||
// panelClearCacheAuto
|
||||
//
|
||||
this.panelClearCacheAuto.Controls.Add(this.checkClearCacheAuto);
|
||||
this.panelClearCacheAuto.Controls.Add(this.numClearCacheThreshold);
|
||||
this.panelClearCacheAuto.Location = new System.Drawing.Point(0, 163);
|
||||
this.panelClearCacheAuto.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.panelClearCacheAuto.Name = "panelClearCacheAuto";
|
||||
this.panelClearCacheAuto.Size = new System.Drawing.Size(300, 28);
|
||||
this.panelClearCacheAuto.TabIndex = 4;
|
||||
//
|
||||
// panelConfiguration
|
||||
//
|
||||
this.panelConfiguration.Anchor = System.Windows.Forms.AnchorStyles.Top;
|
||||
this.panelConfiguration.Controls.Add(this.btnEditCSS);
|
||||
this.panelConfiguration.Controls.Add(this.btnEditCefArgs);
|
||||
this.panelConfiguration.Location = new System.Drawing.Point(0, 275);
|
||||
this.panelConfiguration.Location = new System.Drawing.Point(0, 241);
|
||||
this.panelConfiguration.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.panelConfiguration.Name = "panelConfiguration";
|
||||
this.panelConfiguration.Size = new System.Drawing.Size(322, 31);
|
||||
this.panelConfiguration.TabIndex = 8;
|
||||
this.panelConfiguration.Size = new System.Drawing.Size(300, 31);
|
||||
this.panelConfiguration.TabIndex = 6;
|
||||
//
|
||||
// labelConfiguration
|
||||
//
|
||||
this.labelConfiguration.AutoSize = true;
|
||||
this.labelConfiguration.Font = new System.Drawing.Font("Segoe UI", 11.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(238)));
|
||||
this.labelConfiguration.Location = new System.Drawing.Point(0, 255);
|
||||
this.labelConfiguration.Margin = new System.Windows.Forms.Padding(0, 20, 0, 0);
|
||||
this.labelConfiguration.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
|
||||
this.labelConfiguration.Location = new System.Drawing.Point(0, 221);
|
||||
this.labelConfiguration.Margin = new System.Windows.Forms.Padding(0, 30, 0, 1);
|
||||
this.labelConfiguration.Name = "labelConfiguration";
|
||||
this.labelConfiguration.Size = new System.Drawing.Size(100, 20);
|
||||
this.labelConfiguration.TabIndex = 7;
|
||||
this.labelConfiguration.Text = "Configuration";
|
||||
this.labelConfiguration.Size = new System.Drawing.Size(123, 19);
|
||||
this.labelConfiguration.TabIndex = 5;
|
||||
this.labelConfiguration.Text = "CONFIGURATION";
|
||||
//
|
||||
// flowPanel
|
||||
//
|
||||
this.flowPanel.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.flowPanel.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.flowPanel.Controls.Add(this.labelApp);
|
||||
this.flowPanel.Controls.Add(this.panelAppButtons);
|
||||
this.flowPanel.Controls.Add(this.labelPerformance);
|
||||
this.flowPanel.Controls.Add(this.checkHardwareAcceleration);
|
||||
this.flowPanel.Controls.Add(this.labelCache);
|
||||
this.flowPanel.Controls.Add(this.btnClearCache);
|
||||
this.flowPanel.Controls.Add(this.panelClearCacheAuto);
|
||||
this.flowPanel.Controls.Add(this.labelConfiguration);
|
||||
this.flowPanel.Controls.Add(this.panelConfiguration);
|
||||
this.flowPanel.Controls.Add(this.labelDevTools);
|
||||
this.flowPanel.Controls.Add(this.checkDevToolsWindowOnTop);
|
||||
this.flowPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
|
||||
this.flowPanel.Location = new System.Drawing.Point(9, 9);
|
||||
this.flowPanel.Name = "flowPanel";
|
||||
this.flowPanel.Size = new System.Drawing.Size(322, 307);
|
||||
this.flowPanel.Size = new System.Drawing.Size(300, 462);
|
||||
this.flowPanel.TabIndex = 0;
|
||||
this.flowPanel.WrapContents = false;
|
||||
//
|
||||
// labelDevTools
|
||||
//
|
||||
this.labelDevTools.AutoSize = true;
|
||||
this.labelDevTools.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
|
||||
this.labelDevTools.Location = new System.Drawing.Point(0, 302);
|
||||
this.labelDevTools.Margin = new System.Windows.Forms.Padding(0, 30, 0, 1);
|
||||
this.labelDevTools.Name = "labelDevTools";
|
||||
this.labelDevTools.Size = new System.Drawing.Size(156, 19);
|
||||
this.labelDevTools.TabIndex = 7;
|
||||
this.labelDevTools.Text = "DEVELOPMENT TOOLS";
|
||||
//
|
||||
// checkDevToolsWindowOnTop
|
||||
//
|
||||
this.checkDevToolsWindowOnTop.AutoSize = true;
|
||||
this.checkDevToolsWindowOnTop.Font = new System.Drawing.Font("Segoe UI", 9F);
|
||||
this.checkDevToolsWindowOnTop.Location = new System.Drawing.Point(6, 328);
|
||||
this.checkDevToolsWindowOnTop.Margin = new System.Windows.Forms.Padding(6, 6, 0, 2);
|
||||
this.checkDevToolsWindowOnTop.Name = "checkDevToolsWindowOnTop";
|
||||
this.checkDevToolsWindowOnTop.Size = new System.Drawing.Size(168, 19);
|
||||
this.checkDevToolsWindowOnTop.TabIndex = 8;
|
||||
this.checkDevToolsWindowOnTop.Text = "Dev Tools Window On Top";
|
||||
this.checkDevToolsWindowOnTop.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// TabSettingsAdvanced
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.flowPanel);
|
||||
this.Name = "TabSettingsAdvanced";
|
||||
this.Size = new System.Drawing.Size(340, 325);
|
||||
this.Size = new System.Drawing.Size(631, 480);
|
||||
((System.ComponentModel.ISupportInitialize)(this.numClearCacheThreshold)).EndInit();
|
||||
this.panelAppButtons.ResumeLayout(false);
|
||||
this.panelClearCacheAuto.ResumeLayout(false);
|
||||
@@ -299,7 +295,6 @@
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnClearCache;
|
||||
private System.Windows.Forms.CheckBox checkHardwareAcceleration;
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
private System.Windows.Forms.Button btnEditCefArgs;
|
||||
private System.Windows.Forms.Button btnEditCSS;
|
||||
@@ -309,13 +304,14 @@
|
||||
private System.Windows.Forms.Button btnOpenDataFolder;
|
||||
private System.Windows.Forms.Label labelApp;
|
||||
private System.Windows.Forms.Panel panelAppButtons;
|
||||
private System.Windows.Forms.Label labelPerformance;
|
||||
private System.Windows.Forms.Label labelCache;
|
||||
private System.Windows.Forms.Panel panelClearCacheAuto;
|
||||
private System.Windows.Forms.Panel panelConfiguration;
|
||||
private System.Windows.Forms.Label labelConfiguration;
|
||||
private System.Windows.Forms.Label labelCache;
|
||||
private Controls.NumericUpDownEx numClearCacheThreshold;
|
||||
private System.Windows.Forms.CheckBox checkClearCacheAuto;
|
||||
private System.Windows.Forms.FlowLayoutPanel flowPanel;
|
||||
private System.Windows.Forms.Label labelDevTools;
|
||||
private System.Windows.Forms.CheckBox checkDevToolsWindowOnTop;
|
||||
}
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user