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

Compare commits

...

47 Commits
1.18.3 ... 1.19

Author SHA1 Message Date
1c16187346 Release 1.19 2020-06-08 16:58:58 +02:00
2fe058d9cb Fix crash if reloading plugins reports errors before the main window appears 2020-06-08 09:03:22 +02:00
cefdadd53a Update installer to remove native_blob.bin 2020-06-07 18:01:40 +02:00
c21c10df63 Add a way to exclude <link> tags from being auto-added to notifications 2020-06-07 15:45:55 +02:00
b4d359d30c Add TDPF_createStorage as a plugin replacement for localStorage 2020-06-07 11:33:58 +02:00
1e8c62ac25 Add plugin object validation to TDPF functions 2020-06-07 10:28:55 +02:00
c578f36644 Block CSP reports 2020-06-06 10:00:25 +02:00
c973d0cff4 Fix missing resources from csproj & reorganize it 2020-06-06 09:10:54 +02:00
0c3d9ae46a Refactor main JS code & split code.js into multiple files 2020-06-06 09:01:50 +02:00
a834e8b6a2 Fix broken post-build script import handling 2020-06-06 07:36:03 +02:00
9f5580d983 Eliminate a few post-launch frames of misaligned TweetDeck load icon 2020-06-06 07:36:03 +02:00
e94e3cecf8 Let JS continue even if jQuery or bridge objects are missing 2020-06-06 07:36:02 +02:00
1991f7f50f Bypass 'tdp://' CORS without AddCrossOriginWhitelistEntry 2020-06-06 07:36:02 +02:00
9eb4e623e7 Work around broken smooth scrolling in notifications 2020-06-06 07:36:02 +02:00
ad28d2279f Fix runtime errors & minor tweaks after updating CefSharp 2020-06-05 06:20:19 +02:00
1e3de31fc3 Fix compile errors after updating CefSharp 2020-06-05 06:20:19 +02:00
f85bd41b96 Update CefSharp to 81 2020-06-05 06:20:19 +02:00
563124b68c Fix ResourceHandlerNotification buffer being unnecessarily large 2020-06-05 06:19:50 +02:00
63de08c635 Fix plugin code running in blank notifications from previous commit 2020-06-04 04:33:50 +02:00
8a0a215443 Reduce notification code hackery 2020-06-03 00:57:24 +02:00
f1b7cd633e Refactor WindowsUtils.OpenAssociatedProgram & update installer code 2020-06-02 23:56:03 +02:00
458eeeccda Add tdp:// scheme for plugins (with 'root/' to access root files) 2020-06-02 12:31:34 +02:00
464e758b94 Ensure window.jQuery is available alongside window.$ 2020-06-02 06:45:51 +02:00
4c61047e9b Fix large notification HTML overflowing CEF buffer and silently crashing 2020-06-02 04:05:29 +02:00
1bf9e7fb56 Release 1.18.6 2020-05-16 19:15:07 +02:00
ca69554f37 Fix docked composer not re-focusing after image upload 2020-05-16 18:08:51 +02:00
cf7029037e Fix twitter login page after it was migrated and broke detection 2020-05-16 18:02:37 +02:00
418388b0ab Merge branch 'master' of https://github.com/chylex/TweetDuck 2020-05-16 17:54:00 +02:00
a0f8689d4f Fix TweetDeck bug where docked composer loses focus after Alt+Tab
Closes #297
2020-05-16 17:53:50 +02:00
95007bdd26 Update FUNDING.yml 2020-05-13 23:23:34 +02:00
ab91540deb Move some TweetLib.Core files into different namespaces 2020-05-04 17:13:20 +02:00
b2ebb984f8 Release 1.18.5 2020-05-04 16:20:44 +02:00
f7e9ad74d1 Fix stuck processes after closing the app
Closes #294
2020-05-04 13:45:56 +02:00
d48da3d51c Add option for notification window opacity 2020-04-27 10:20:07 +02:00
76d22554c5 Make trackbars in settings wider 2020-04-27 10:03:51 +02:00
6eaafd883b Release 1.18.4 2020-04-25 06:35:43 +02:00
5961a80b23 Fix blank notifications on certain hardware configurations w/ disabled acceleration
Closes #274
2020-04-25 05:47:17 +02:00
f41c6fe533 Unify all exe & dll versions 2020-04-25 05:05:05 +02:00
65b8efe13c Fix non-quoted tweet links opening in browser despite also opening in the column
Closes #273
2020-04-25 03:48:20 +02:00
89529f9c96 Add $TD.makeGetRequest and fix template plugin AJAX
Closes #272
2020-04-25 03:15:52 +02:00
e90f6ebc63 Add 'Copy image' to context menu
Closes #287
2020-04-25 02:43:12 +02:00
5888d540a6 Move clipboard utils into ClipboardManager & add SetImage 2020-04-25 02:33:39 +02:00
ae8b740600 Reorganize namespaces in main project 2020-04-25 02:16:57 +02:00
ab4e2f5bda Add error message to template plugin when AJAX request fails 2020-04-25 00:19:29 +02:00
1091b6d232 Fix IDE warnings (dispose, lang features) & nullability settings 2020-04-24 23:14:22 +02:00
fc89744238 Apparently video duration minus 0.05 causes complete hangs in short videos... 2020-03-07 01:40:07 +01:00
34e049a002 Work around video player black screen when looping & reduce player polling 2020-03-05 13:26:08 +01:00
176 changed files with 3420 additions and 2761 deletions

3
.github/FUNDING.yml vendored
View File

@@ -1,4 +1,3 @@
# These are supported funding model platforms
github: chylex
patreon: chylex
ko_fi: chylex

View File

@@ -1,10 +1,10 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using TweetDuck.Core.Utils;
using TweetDuck.Utils;
using TweetLib.Core.Application;
namespace TweetDuck.Impl{
namespace TweetDuck.Application{
class LockHandler : IAppLockHandler{
private const int WaitRetryDelay = 250;
private const int RestoreFailTimeout = 2000;

View File

@@ -0,0 +1,28 @@
using System;
using System.Diagnostics;
using System.IO;
using TweetLib.Core.Application;
namespace TweetDuck.Application{
class SystemHandler : IAppSystemHandler{
void IAppSystemHandler.OpenAssociatedProgram(string path){
try{
using(Process.Start(new ProcessStartInfo{
FileName = path,
ErrorDialog = true
})){}
}catch(Exception e){
Program.Reporter.HandleException("Error Opening Program", "Could not open the associated program for " + path, true, e);
}
}
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('/', '\\') + '"')){}
}
}
}
}

View File

@@ -2,7 +2,7 @@
using CefSharp;
using TweetLib.Core.Browser;
namespace TweetDuck.Core.Adapters{
namespace TweetDuck.Browser.Adapters{
sealed class CefScriptExecutor : IScriptExecutor{
private readonly IWebBrowser browser;

View File

@@ -3,7 +3,7 @@ using TweetDuck.Configuration;
using TweetLib.Core;
using TweetLib.Core.Utils;
namespace TweetDuck.Core.Bridge{
namespace TweetDuck.Browser.Bridge{
static class PropertyBridge{
public enum Environment{
Browser, Notification

View File

@@ -1,14 +1,18 @@
using System.Diagnostics.CodeAnalysis;
using System;
using System.Diagnostics.CodeAnalysis;
using System.Threading.Tasks;
using System.Windows.Forms;
using CefSharp;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Handling;
using TweetDuck.Core.Notification;
using TweetDuck.Core.Other;
using TweetDuck.Core.Utils;
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 void ResetStaticProperties(){
@@ -38,9 +42,7 @@ 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){
@@ -110,13 +112,30 @@ namespace TweetDuck.Core.Bridge{
}
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();
}

View File

@@ -1,10 +1,10 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.Windows.Forms;
using TweetDuck.Core.Controls;
using TweetLib.Core.Features.Updates;
using TweetDuck.Controls;
using TweetLib.Core.Systems.Updates;
namespace TweetDuck.Core.Bridge{
namespace TweetDuck.Browser.Bridge{
[SuppressMessage("ReSharper", "UnusedMember.Global")]
class UpdateBridge{
private readonly UpdateHandler updates;

View File

@@ -2,7 +2,7 @@
using CefSharp;
using TweetLib.Core.Utils;
namespace TweetDuck.Core.Management{
namespace TweetDuck.Browser.Data{
sealed class ContextInfo{
private LinkInfo link;
private ChirpInfo? chirp;

View File

@@ -0,0 +1,38 @@
using System;
using System.Collections.Concurrent;
using CefSharp;
namespace TweetDuck.Browser.Data{
sealed class ResourceHandlers{
private readonly ConcurrentDictionary<string, IResourceHandler> handlers = new ConcurrentDictionary<string, IResourceHandler>(StringComparer.OrdinalIgnoreCase);
public bool HasHandler(IRequest request){
return handlers.ContainsKey(request.Url);
}
public IResourceHandler GetHandler(IRequest request){
return handlers.TryGetValue(request.Url, out var handler) ? handler : null;
}
public bool Register(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 Register(ResourceLink link){
return Register(link.Url, link.Handler);
}
public bool Unregister(string url){
return handlers.TryRemove(url, out IResourceHandler _);
}
public bool Unregister(ResourceLink link){
return Unregister(link.Url);
}
}
}

View File

@@ -1,6 +1,6 @@
using CefSharp;
namespace TweetDuck.Data{
namespace TweetDuck.Browser.Data{
sealed class ResourceLink{
public string Url { get; }
public IResourceHandler Handler { get; }

View File

@@ -1,10 +1,10 @@
using System.Drawing;
using System.Windows.Forms;
using TweetDuck.Core.Controls;
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;

View File

@@ -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;
}

View File

@@ -5,24 +5,25 @@ 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.Controls;
using TweetDuck.Dialogs;
using TweetDuck.Dialogs.Settings;
using TweetDuck.Management;
using TweetDuck.Management.Analytics;
using TweetDuck.Plugins;
using TweetDuck.Updates;
using TweetDuck.Utils;
using TweetLib.Core.Features.Plugins;
using TweetLib.Core.Features.Plugins.Events;
using TweetLib.Core.Features.Updates;
using TweetLib.Core.Systems.Updates;
namespace TweetDuck.Core{
namespace TweetDuck.Browser{
sealed partial class FormBrowser : Form, AnalyticsFile.IProvider{
private static UserConfig Config => Program.Config.User;
@@ -43,15 +44,18 @@ namespace TweetDuck.Core{
}
}
public string UpdateInstallerPath { get; private set; }
public UpdateInstaller UpdateInstaller { get; private set; }
private bool ignoreUpdateCheckError;
public AnalyticsFile AnalyticsFile => analytics?.File ?? AnalyticsFile.Dummy;
#pragma warning disable IDE0069 // Disposable fields should be disposed
private readonly TweetDeckBrowser browser;
private readonly FormNotificationTweet notification;
#pragma warning restore IDE0069 // Disposable fields should be disposed
private readonly PluginManager plugins;
private readonly UpdateHandler updates;
private readonly FormNotificationTweet notification;
private readonly ContextMenu contextMenu;
private readonly UpdateBridge updateBridge;
@@ -62,7 +66,7 @@ namespace TweetDuck.Core{
private VideoPlayer videoPlayer;
private AnalyticsManager analytics;
public FormBrowser(){
public FormBrowser(PluginSchemeFactory pluginScheme){
InitializeComponent();
Text = Program.BrandName;
@@ -71,6 +75,7 @@ namespace TweetDuck.Core{
this.plugins.Reloaded += plugins_Reloaded;
this.plugins.Executed += plugins_Executed;
this.plugins.Reload();
pluginScheme.Setup(plugins);
this.notification = new FormNotificationTweet(this, plugins);
this.notification.Show();
@@ -90,14 +95,7 @@ namespace TweetDuck.Core{
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;
@@ -119,6 +117,21 @@ namespace TweetDuck.Core{
RestoreWindow();
}
protected override void Dispose(bool disposing){
if (disposing){
components?.Dispose();
updates.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);
@@ -133,6 +146,8 @@ namespace TweetDuck.Core{
private void RestoreWindow(){
Config.BrowserWindow.Restore(this, true);
browser.PrepareSize(ClientSize);
prevState = WindowState;
isLoaded = true;
}
@@ -152,7 +167,9 @@ namespace TweetDuck.Core{
}
private void FormBrowser_Activated(object sender, EventArgs e){
if (!isLoaded)return;
if (!isLoaded){
return;
}
trayIcon.HasNotifications = false;
@@ -162,14 +179,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;
@@ -190,9 +211,12 @@ 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();
browser.PrepareSize(ClientSize); // needed to pre-size browser control when launched in maximized state
if (Location != ControlExtensions.InvisibleLocation){
Config.BrowserWindow.Save(this);
@@ -201,7 +225,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
@@ -210,7 +236,7 @@ namespace TweetDuck.Core{
}
private void FormBrowser_FormClosed(object sender, FormClosedEventArgs e){
if (isLoaded && UpdateInstallerPath == null){
if (isLoaded && UpdateInstaller == null){
updateBridge.Cleanup();
}
}
@@ -237,9 +263,7 @@ 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);
});
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){
@@ -288,7 +312,7 @@ namespace TweetDuck.Core{
UpdateDownloadStatus status = update.DownloadStatus;
if (status == UpdateDownloadStatus.Done){
UpdateInstallerPath = update.InstallerPath;
UpdateInstaller = new UpdateInstaller(update.InstallerPath);
ForceClose();
}
else if (status != UpdateDownloadStatus.Canceled && FormMessage.Error("Update Has Failed", "Could not automatically download the update: " + (update.DownloadError?.Message ?? "unknown error") + "\n\nWould you like to open the website and try downloading the update manually?", FormMessage.Yes, FormMessage.No)){
@@ -491,12 +515,12 @@ namespace TweetDuck.Core{
public void OpenProfileImport(){
FormManager.TryFind<FormSettings>()?.Close();
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
}
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
}
}
@@ -516,10 +540,7 @@ namespace TweetDuck.Core{
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();

View File

@@ -1,20 +1,21 @@
using System;
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.Browser.Adapters;
using TweetDuck.Browser.Data;
using TweetDuck.Browser.Notification;
using TweetDuck.Configuration;
using TweetDuck.Core.Adapters;
using TweetDuck.Core.Management;
using TweetDuck.Core.Notification;
using TweetDuck.Core.Other;
using TweetDuck.Core.Other.Analytics;
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{
public static ContextInfo CurrentInfo { get; } = new ContextInfo();
@@ -27,10 +28,11 @@ 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.ContextData Context { get; private set; }
@@ -84,6 +86,7 @@ namespace TweetDuck.Core.Handling{
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 (Context.Chirp.Images.Length > 1){
@@ -123,6 +126,16 @@ namespace TweetDuck.Core.Handling{
SetClipboardText(control, TwitterUrls.GetMediaLink(Context.MediaUrl, ImageQuality));
break;
case MenuCopyImage: {
string url = Context.MediaUrl;
control.InvokeAsyncSafe(() => {
TwitterUtils.CopyImage(url, ImageQuality);
});
break;
}
case MenuViewImage: {
string url = Context.MediaUrl;
@@ -202,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){

View File

@@ -1,10 +1,10 @@
using CefSharp;
using System.Windows.Forms;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Management;
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;

View File

@@ -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){}

View File

@@ -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;

View File

@@ -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;
@@ -30,6 +30,6 @@ namespace TweetDuck.Core.Handling{
return false;
}
public void OnDraggableRegionsChanged(IWebBrowser browserControl, IBrowser browser, IList<DraggableRegion> regions){}
public void OnDraggableRegionsChanged(IWebBrowser browserControl, IBrowser browser, IFrame frame, IList<DraggableRegion> regions){}
}
}

View File

@@ -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

View File

@@ -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);

View File

@@ -3,7 +3,7 @@ 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);

View File

@@ -4,7 +4,7 @@ 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){

View File

@@ -1,11 +1,11 @@
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;
@@ -82,7 +82,8 @@ namespace TweetDuck.Core.Handling.General{
return true;
}
bool IJsDialogHandler.OnJSBeforeUnload(IWebBrowser browserControl, IBrowser browser, string message, bool isReload, IJsDialogCallback callback){
bool IJsDialogHandler.OnBeforeUnloadDialog(IWebBrowser browserControl, IBrowser browser, string messageText, bool isReload, IJsDialogCallback callback){
callback.Dispose();
return false;
}

View File

@@ -1,8 +1,8 @@
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?");

View File

@@ -1,10 +1,10 @@
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{
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){
@@ -33,7 +33,7 @@ namespace TweetDuck.Core.Handling{
}
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://")){
if (type == KeyType.RawKeyDown && !browser.FocusedFrame.Url.StartsWith("devtools://")){
return HandleRawKey(browserControl, browser, (Keys)windowsKeyCode, modifiers);
}

View File

@@ -1,7 +1,7 @@
using System.Windows.Forms;
using CefSharp;
namespace TweetDuck.Core.Handling{
namespace TweetDuck.Browser.Handling{
sealed class KeyboardHandlerBrowser : KeyboardHandlerBase{
private readonly FormBrowser form;

View File

@@ -1,9 +1,9 @@
using CefSharp;
using System.Windows.Forms;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Notification;
using System.Windows.Forms;
using CefSharp;
using TweetDuck.Browser.Notification;
using TweetDuck.Controls;
namespace TweetDuck.Core.Handling {
namespace TweetDuck.Browser.Handling{
sealed class KeyboardHandlerNotification : KeyboardHandlerBase{
private readonly FormNotificationBase notification;

View File

@@ -0,0 +1,23 @@
using CefSharp;
using CefSharp.Handler;
using TweetDuck.Browser.Handling.General;
namespace TweetDuck.Browser.Handling{
class RequestHandlerBase : RequestHandler{
private readonly bool autoReload;
public RequestHandlerBase(bool autoReload){
this.autoReload = autoReload;
}
protected override bool OnOpenUrlFromTab(IWebBrowser browserControl, IBrowser browser, IFrame frame, string targetUrl, WindowOpenDisposition targetDisposition, bool userGesture){
return LifeSpanHandler.HandleLinkClick(browserControl, targetDisposition, targetUrl);
}
protected override void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status){
if (autoReload){
browser.Reload();
}
}
}
}

View File

@@ -0,0 +1,23 @@
using CefSharp;
using TweetLib.Core.Features.Twitter;
namespace TweetDuck.Browser.Handling{
sealed class RequestHandlerBrowser : RequestHandlerBase{
public string BlockNextUserNavUrl { get; set; }
public RequestHandlerBrowser() : base(true){}
protected 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);
}
}
}

View File

@@ -1,9 +1,11 @@
using CefSharp;
using System;
using System.Collections.Specialized;
using System.IO;
using System.Text;
using CefSharp;
using CefSharp.Callback;
namespace TweetDuck.Core.Handling{
namespace TweetDuck.Browser.Handling{
sealed class ResourceHandlerNotification : IResourceHandler{
private readonly NameValueCollection headers = new NameValueCollection(0);
private MemoryStream dataIn;
@@ -20,8 +22,14 @@ namespace TweetDuck.Core.Handling{
}
}
bool IResourceHandler.ProcessRequest(IRequest request, ICallback callback){
callback.Continue();
bool IResourceHandler.Open(IRequest request, out bool handleRequest, ICallback callback){
callback.Dispose();
handleRequest = true;
if (dataIn != null){
dataIn.Position = 0;
}
return true;
}
@@ -31,31 +39,39 @@ namespace TweetDuck.Core.Handling{
response.MimeType = "text/html";
response.StatusCode = 200;
response.StatusText = "OK";
response.ResponseHeaders = headers;
responseLength = dataIn?.Length ?? -1;
response.Headers = headers;
responseLength = dataIn?.Length ?? 0;
}
bool IResourceHandler.Read(Stream dataOut, out int bytesRead, IResourceReadCallback callback){
callback?.Dispose(); // TODO unnecessary null check once ReadResponse is removed
try{
byte[] buffer = new byte[Math.Min(dataIn.Length - dataIn.Position, dataOut.Length)];
int length = buffer.Length;
dataIn.Read(buffer, 0, length);
dataOut.Write(buffer, 0, length);
bytesRead = length;
}catch{ // catch IOException, possibly NullReferenceException if dataIn is null
bytesRead = 0;
}
return bytesRead > 0;
}
bool IResourceHandler.Skip(long bytesToSkip, out long bytesSkipped, IResourceSkipCallback callback){
bytesSkipped = -2; // ERR_FAILED
callback.Dispose();
return false;
}
bool IResourceHandler.ProcessRequest(IRequest request, ICallback callback){
return ((IResourceHandler)this).Open(request, out bool _, callback);
}
bool IResourceHandler.ReadResponse(Stream dataOut, out int bytesRead, ICallback callback){
callback.Dispose();
try{
int length = (int)dataIn.Length;
dataIn.CopyTo(dataOut, length);
bytesRead = length;
return true;
}catch{ // catch IOException, possibly NullReferenceException if dataIn is null
bytesRead = 0;
return false;
}
}
bool IResourceHandler.CanGetCookie(Cookie cookie){
return true;
}
bool IResourceHandler.CanSetCookie(Cookie cookie){
return true;
return ((IResourceHandler)this).Read(dataOut, out bytesRead, null);
}
void IResourceHandler.Cancel(){}

View File

@@ -0,0 +1,35 @@
using System.Diagnostics.CodeAnalysis;
using CefSharp;
using TweetDuck.Browser.Data;
namespace TweetDuck.Browser.Handling{
abstract class ResourceRequestHandler : CefSharp.Handler.ResourceRequestHandler{
private class SelfFactoryImpl : IResourceRequestHandlerFactory{
private readonly ResourceRequestHandler me;
public SelfFactoryImpl(ResourceRequestHandler me){
this.me = me;
}
bool IResourceRequestHandlerFactory.HasHandlers { get; } = true;
[SuppressMessage("ReSharper", "RedundantAssignment")]
IResourceRequestHandler IResourceRequestHandlerFactory.GetResourceRequestHandler(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, bool isNavigation, bool isDownload, string requestInitiator, ref bool disableDefaultHandling){
disableDefaultHandling = me.ResourceHandlers.HasHandler(request);
return me;
}
}
public IResourceRequestHandlerFactory SelfFactory { get; }
public ResourceHandlers ResourceHandlers { get; }
protected ResourceRequestHandler(){
this.SelfFactory = new SelfFactoryImpl(this);
this.ResourceHandlers = new ResourceHandlers();
}
protected override IResourceHandler GetResourceHandler(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request){
return ResourceHandlers.GetHandler(request);
}
}
}

View File

@@ -4,13 +4,11 @@ using System.Collections.Specialized;
using System.Linq;
using System.Text.RegularExpressions;
using CefSharp;
using CefSharp.Handler;
using TweetDuck.Core.Handling.General;
using TweetDuck.Core.Utils;
using TweetDuck.Utils;
using TweetLib.Core.Utils;
namespace TweetDuck.Core.Handling{
class RequestHandlerBase : DefaultRequestHandler{
namespace TweetDuck.Browser.Handling{
class ResourceRequestHandlerBase : ResourceRequestHandler{
private static readonly Regex TweetDeckResourceUrl = new Regex(@"/dist/(.*?)\.(.*?)\.(css|js)$");
private static readonly SortedList<string, string> TweetDeckHashes = new SortedList<string, string>(4);
@@ -33,17 +31,12 @@ namespace TweetDuck.Core.Handling{
}
}
private readonly bool autoReload;
protected override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){
if (request.ResourceType == ResourceType.CspReport){
callback.Dispose();
return CefReturnValue.Cancel;
}
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");
@@ -53,7 +46,7 @@ namespace TweetDuck.Core.Handling{
return base.OnBeforeResourceLoad(browserControl, browser, frame, request, callback);
}
public override bool OnResourceResponse(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IResponse response){
protected 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);
@@ -72,11 +65,5 @@ namespace TweetDuck.Core.Handling{
return base.OnResourceResponse(browserControl, browser, frame, request, response);
}
public override void OnRenderProcessTerminated(IWebBrowser browserControl, IBrowser browser, CefTerminationStatus status){
if (autoReload){
browser.Reload();
}
}
}
}

View File

@@ -0,0 +1,52 @@
using CefSharp;
using TweetDuck.Browser.Handling.Filters;
using TweetDuck.Utils;
using TweetLib.Core.Features.Twitter;
namespace TweetDuck.Browser.Handling{
class ResourceRequestHandlerBrowser : ResourceRequestHandlerBase{
private const string UrlVendorResource = "/dist/vendor";
private const string UrlLoadingSpinner = "/backgrounds/spinner_blue";
private const string UrlVersionCheck = "/web/dist/version.json";
protected 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.Image){
if (request.Url.Contains(UrlLoadingSpinner)){
request.Url = TwitterUtils.LoadingSpinner.Url;
}
}
else if (request.ResourceType == ResourceType.Script){
string url = request.Url;
if (url.Contains("analytics.")){
callback.Dispose();
return CefReturnValue.Cancel;
}
else if (url.Contains(UrlVendorResource)){
request.SetHeaderByName("Accept-Encoding", "identity", overwrite: true);
}
}
else if (request.ResourceType == ResourceType.Xhr){
if (request.Url.Contains(UrlVersionCheck)){
callback.Dispose();
return CefReturnValue.Cancel;
}
}
return base.OnBeforeResourceLoad(browserControl, browser, frame, request, callback);
}
protected 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.Headers["Content-Length"], out int totalBytes)){
return new ResponseFilterVendor(totalBytes);
}
return base.GetResourceResponseFilter(browserControl, browser, frame, request, response);
}
}
}

View File

@@ -1,11 +1,11 @@
using System;
using System.Windows.Forms;
using CefSharp;
using TweetDuck.Core.Controls;
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 => Config.NotificationPosition == DesktopNotification.Position.Custom;

View File

@@ -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";

View File

@@ -1,21 +1,23 @@
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.Controls;
using TweetDuck.Core.Handling;
using TweetDuck.Core.Handling.General;
using TweetDuck.Core.Other.Analytics;
using TweetDuck.Core.Utils;
using TweetDuck.Data;
using TweetDuck.Controls;
using TweetDuck.Management.Analytics;
using TweetDuck.Utils;
using TweetLib.Core.Features.Notifications;
using TweetLib.Core.Features.Twitter;
namespace TweetDuck.Core.Notification{
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"));
protected const string BlankURL = TwitterUrls.TweetDeck + "/?blank";
public static string FontSize = null;
public static string HeadLayout = null;
@@ -103,8 +105,11 @@ namespace TweetDuck.Core.Notification{
protected double SizeScale => DpiScale * Config.ZoomLevel / 100.0;
protected readonly FormBrowser owner;
#pragma warning disable IDE0069 // Disposable fields should be disposed
protected readonly ChromiumWebBrowser browser;
#pragma warning restore IDE0069 // Disposable fields should be disposed
private readonly ResourceHandlerNotification resourceHandler = new ResourceHandlerNotification();
private DesktopNotification currentNotification;
@@ -126,17 +131,20 @@ namespace TweetDuck.Core.Notification{
this.owner = owner;
this.owner.FormClosed += owner_FormClosed;
var resourceRequestHandler = new ResourceRequestHandlerBase();
var resourceHandlers = resourceRequestHandler.ResourceHandlers;
ResourceHandlerFactory resourceHandlerFactory = new ResourceHandlerFactory();
resourceHandlerFactory.RegisterHandler(TwitterUrls.TweetDeck, this.resourceHandler);
resourceHandlerFactory.RegisterHandler(AppLogo);
resourceHandlers.Register(BlankURL, ResourceHandler.FromString(string.Empty));
resourceHandlers.Register(TwitterUrls.TweetDeck, this.resourceHandler);
resourceHandlers.Register(AppLogo);
this.browser = new ChromiumWebBrowser("about:blank"){
this.browser = new ChromiumWebBrowser(BlankURL){
MenuHandler = new ContextMenuNotification(this, enableContextMenu),
JsDialogHandler = new JavaScriptDialogHandler(),
LifeSpanHandler = new LifeSpanHandler(),
RequestHandler = new RequestHandlerBase(false),
ResourceHandlerFactory = resourceHandlerFactory
ResourceRequestHandlerFactory = resourceRequestHandler.SelfFactory
};
this.browser.Dock = DockStyle.None;
@@ -146,8 +154,8 @@ namespace TweetDuck.Core.Notification{
Controls.Add(browser);
Disposed += (sender, args) => {
this.browser.Dispose();
this.owner.FormClosed -= owner_FormClosed;
this.browser.Dispose();
};
DpiScale = this.GetDPIScale();
@@ -156,6 +164,15 @@ namespace TweetDuck.Core.Notification{
UpdateTitle();
}
protected override void Dispose(bool disposing){
if (disposing){
components?.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;
@@ -173,7 +190,7 @@ namespace TweetDuck.Core.Notification{
// notification methods
public virtual void HideNotification(){
browser.Load("about:blank");
browser.Load(BlankURL);
DisplayTooltip(null);
Location = ControlExtensions.InvisibleLocation;

View File

@@ -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

View File

@@ -1,19 +1,20 @@
using CefSharp;
using System;
using System;
using System.Drawing;
using System.Windows.Forms;
using TweetDuck.Core.Adapters;
using TweetDuck.Core.Bridge;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Handling;
using TweetDuck.Core.Utils;
using CefSharp;
using TweetDuck.Browser.Adapters;
using TweetDuck.Browser.Bridge;
using TweetDuck.Browser.Handling;
using TweetDuck.Controls;
using TweetDuck.Plugins;
using TweetDuck.Utils;
using TweetLib.Core.Data;
using TweetLib.Core.Features.Notifications;
using TweetLib.Core.Features.Plugins;
using TweetLib.Core.Features.Plugins.Enums;
using TweetLib.Core.Features.Twitter;
namespace TweetDuck.Core.Notification{
namespace TweetDuck.Browser.Notification{
abstract partial class FormNotificationMain : FormNotificationBase{
private readonly PluginManager plugins;
private readonly int timerBarHeight;
@@ -25,6 +26,8 @@ namespace TweetDuck.Core.Notification{
private IntPtr mouseHook;
private bool blockXButtonUp;
private int currentOpacity;
private bool? prevDisplayTimer;
private int? prevFontSize;
@@ -70,17 +73,26 @@ namespace TweetDuck.Core.Notification{
this.timerBarHeight = BrowserUtils.Scale(4, DpiScale);
browser.KeyboardHandler = new KeyboardHandlerNotification(this);
browser.RegisterAsyncJsObject("$TD", new TweetDeckBridge.Notification(owner, this));
browser.RegisterJsBridge("$TD", new TweetDeckBridge.Notification(owner, this));
browser.LoadingStateChanged += Browser_LoadingStateChanged;
browser.FrameLoadEnd += Browser_FrameLoadEnd;
plugins.Register(PluginEnvironment.Notification, new PluginDispatcher(browser));
plugins.Register(PluginEnvironment.Notification, new PluginDispatcher(browser, url => TwitterUrls.IsTweetDeck(url) && url != BlankURL));
mouseHookDelegate = MouseHookProc;
Disposed += (sender, args) => StopMouseHook(true);
}
// helpers
private void SetOpacity(int opacity){
if (currentOpacity != opacity){
currentOpacity = opacity;
Opacity = opacity / 100.0;
}
}
// mouse wheel hook
private void StartMouseHook(){
@@ -102,7 +114,15 @@ namespace TweetDuck.Core.Notification{
int eventType = wParam.ToInt32();
if (eventType == NativeMethods.WM_MOUSEWHEEL && IsCursorOverBrowser){
browser.SendMouseWheelEvent(0, 0, 0, BrowserUtils.Scale(NativeMethods.GetMouseHookData(lParam), Config.NotificationScrollSpeed * 0.01), CefEventFlags.None);
int delta = BrowserUtils.Scale(NativeMethods.GetMouseHookData(lParam), Config.NotificationScrollSpeed * 0.01);
if (Config.EnableSmoothScrolling){
browser.ExecuteScriptAsync("window.TDGF_scrollSmoothly", (int)Math.Round(-delta / 0.6));
}
else{
browser.SendMouseWheelEvent(0, 0, 0, delta, CefEventFlags.None);
}
return NativeMethods.HOOK_HANDLED;
}
else if (eventType == NativeMethods.WM_XBUTTONDOWN && DesktopBounds.Contains(Cursor.Position)){
@@ -143,7 +163,7 @@ namespace TweetDuck.Core.Notification{
}
private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){
if (!e.IsLoading && browser.Address != "about:blank"){
if (!e.IsLoading && browser.Address != BlankURL){
this.InvokeSafe(() => {
Visible = true; // ensures repaint before moving the window to a visible location
timerDisplayDelay.Start();
@@ -154,7 +174,7 @@ namespace TweetDuck.Core.Notification{
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
IFrame frame = e.Frame;
if (frame.IsMain && browser.Address != "about:blank"){
if (frame.IsMain && browser.Address != BlankURL){
frame.ExecuteJavaScriptAsync(PropertyBridge.GenerateScript(PropertyBridge.Environment.Notification));
CefScriptExecutor.RunFile(frame, "notification.js");
}
@@ -170,9 +190,11 @@ namespace TweetDuck.Core.Notification{
if (isCursorInside){
StartMouseHook();
SetOpacity(100);
}
else{
StopMouseHook(false);
SetOpacity(Config.NotificationWindowOpacity);
}
if (isCursorInside || FreezeTimer || ContextMenuOpen){
@@ -264,7 +286,8 @@ namespace TweetDuck.Core.Notification{
RequiresResize = false;
SetNotificationSize(BaseClientWidth, BaseClientHeight);
}
SetOpacity(IsCursorOverBrowser ? 100 : Config.NotificationWindowOpacity);
MoveToVisibleLocation();
}

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Notification {
namespace TweetDuck.Browser.Notification {
partial class FormNotificationTweet {
/// <summary>
/// Required designer variable.

View File

@@ -2,11 +2,11 @@
using System.Collections.Generic;
using System.Drawing;
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;

View File

@@ -3,15 +3,15 @@ using System.Drawing;
using System.Drawing.Imaging;
using System.Windows.Forms;
using CefSharp;
using TweetDuck.Core.Adapters;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Other;
using TweetDuck.Core.Utils;
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;
@@ -23,7 +23,7 @@ namespace TweetDuck.Core.Notification.Screenshot{
int realWidth = BrowserUtils.Scale(width, DpiScale);
browser.RegisterAsyncJsObject("$TD_NotificationScreenshot", new ScreenshotBridge(this, SetScreenshotHeight, callback));
browser.RegisterJsBridge("$TD_NotificationScreenshot", new ScreenshotBridge(this, SetScreenshotHeight, callback));
browser.LoadingStateChanged += (sender, args) => {
if (args.IsLoading){
@@ -82,16 +82,16 @@ namespace TweetDuck.Core.Notification.Screenshot{
return false;
}
else{
using(Bitmap bmp = new Bitmap(ClientSize.Width, Math.Max(1, height), PixelFormat.Format32bppRgb)){
try{
NativeMethods.RenderSourceIntoBitmap(context, bmp);
}finally{
NativeMethods.ReleaseDC(this.Handle, context);
}
using Bitmap bmp = new Bitmap(ClientSize.Width, Math.Max(1, height), PixelFormat.Format32bppRgb);
Clipboard.SetImage(bmp);
return true;
try{
NativeMethods.RenderSourceIntoBitmap(context, bmp);
}finally{
NativeMethods.ReleaseDC(this.Handle, context);
}
Clipboard.SetImage(bmp);
return true;
}
}
}

View File

@@ -1,9 +1,9 @@
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;

View File

@@ -8,7 +8,7 @@
using System;
using System.Windows.Forms;
using TweetDuck.Core.Controls;
using TweetDuck.Controls;
using TweetLib.Core.Features.Plugins;
#if GEN_SCREENSHOT_FRAMES
@@ -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;

View File

@@ -2,11 +2,12 @@
using System.IO;
using System.Windows.Forms;
using CefSharp;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Other;
using TweetDuck.Core.Other.Settings;
using TweetDuck.Controls;
using TweetDuck.Dialogs;
using TweetDuck.Dialogs.Settings;
using TweetDuck.Management;
namespace TweetDuck.Core.Notification{
namespace TweetDuck.Browser.Notification{
static class SoundNotification{
public const string SupportedFormats = "*.wav;*.ogg;*.mp3;*.flac;*.opus;*.weba;*.webm";
@@ -28,16 +29,15 @@ namespace TweetDuck.Core.Notification{
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);
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);
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));
}
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions){
browser.OpenSettings(typeof(TabSettingsSounds));
}
});

View File

@@ -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>

View File

@@ -4,7 +4,7 @@ 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
@@ -63,6 +63,15 @@ namespace TweetDuck.Core.Other{
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;

View File

@@ -4,21 +4,22 @@ using System.Text;
using System.Windows.Forms;
using CefSharp;
using CefSharp.WinForms;
using TweetDuck.Browser.Adapters;
using TweetDuck.Browser.Bridge;
using TweetDuck.Browser.Data;
using TweetDuck.Browser.Handling;
using TweetDuck.Browser.Handling.General;
using TweetDuck.Browser.Notification;
using TweetDuck.Configuration;
using TweetDuck.Core.Adapters;
using TweetDuck.Core.Bridge;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Handling;
using TweetDuck.Core.Handling.General;
using TweetDuck.Core.Notification;
using TweetDuck.Core.Utils;
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.Core{
namespace TweetDuck.Browser{
sealed class TweetDeckBrowser : IDisposable{
private static UserConfig Config => Program.Config.User;
@@ -44,13 +45,16 @@ namespace TweetDuck.Core{
}
private readonly ChromiumWebBrowser browser;
private readonly ResourceHandlerFactory resourceHandlerFactory = new ResourceHandlerFactory();
private readonly ResourceHandlers resourceHandlers;
private string prevSoundNotificationPath = null;
public TweetDeckBrowser(FormBrowser owner, PluginManager plugins, TweetDeckBridge tdBridge, UpdateBridge updateBridge){
resourceHandlerFactory.RegisterHandler(FormNotificationBase.AppLogo);
resourceHandlerFactory.RegisterHandler(TwitterUtils.LoadingSpinner);
var resourceRequestHandler = new ResourceRequestHandlerBrowser();
resourceHandlers = resourceRequestHandler.ResourceHandlers;
resourceHandlers.Register(FormNotificationBase.AppLogo);
resourceHandlers.Register(TwitterUtils.LoadingSpinner);
RequestHandlerBrowser requestHandler = new RequestHandlerBrowser();
@@ -62,7 +66,7 @@ namespace TweetDuck.Core{
KeyboardHandler = new KeyboardHandlerBrowser(owner),
LifeSpanHandler = new LifeSpanHandler(),
RequestHandler = requestHandler,
ResourceHandlerFactory = resourceHandlerFactory
ResourceRequestHandlerFactory = resourceRequestHandler.SelfFactory
};
this.browser.LoadingStateChanged += browser_LoadingStateChanged;
@@ -70,8 +74,8 @@ namespace TweetDuck.Core{
this.browser.FrameLoadEnd += browser_FrameLoadEnd;
this.browser.LoadError += browser_LoadError;
this.browser.RegisterAsyncJsObject("$TD", tdBridge);
this.browser.RegisterAsyncJsObject("$TDU", updateBridge);
this.browser.RegisterJsBridge("$TD", tdBridge);
this.browser.RegisterJsBridge("$TDU", updateBridge);
this.browser.BrowserSettings.BackgroundColor = (uint)TwitterUtils.BackgroundColor.ToArgb();
this.browser.Dock = DockStyle.None;
@@ -79,7 +83,7 @@ namespace TweetDuck.Core{
this.browser.SetupZoomEvents();
owner.Controls.Add(browser);
plugins.Register(PluginEnvironment.Browser, new PluginDispatcher(browser));
plugins.Register(PluginEnvironment.Browser, new PluginDispatcher(browser, TwitterUrls.IsTweetDeck));
Config.MuteToggled += Config_MuteToggled;
Config.SoundNotificationChanged += Config_SoundNotificationInfoChanged;
@@ -87,6 +91,12 @@ namespace TweetDuck.Core{
// setup and management
public void PrepareSize(Size size){
if (!Ready){
browser.Size = size;
}
}
private void OnBrowserReady(){
if (!Ready){
browser.Location = Point.Empty;
@@ -127,7 +137,7 @@ namespace TweetDuck.Core{
if (TwitterUrls.IsTwitter(url)){
string css = Program.Resources.Load("styles/twitter.css");
resourceHandlerFactory.RegisterHandler(TwitterStyleUrl, ResourceHandler.FromString(css, mimeType: "text/css"));
resourceHandlers.Register(TwitterStyleUrl, ResourceHandler.FromString(css, mimeType: "text/css"));
CefScriptExecutor.RunFile(frame, "twitter.js");
}
@@ -166,7 +176,7 @@ namespace TweetDuck.Core{
}
if (url == ErrorUrl){
resourceHandlerFactory.UnregisterHandler(ErrorUrl);
resourceHandlers.Unregister(ErrorUrl);
}
}
@@ -182,7 +192,7 @@ namespace TweetDuck.Core{
string errorName = Enum.GetName(typeof(CefErrorCode), e.ErrorCode);
string errorTitle = StringUtils.ConvertPascalCaseToScreamingSnakeCase(errorName ?? string.Empty);
resourceHandlerFactory.RegisterHandler(ErrorUrl, ResourceHandler.FromString(errorPage.Replace("{err}", errorTitle)));
resourceHandlers.Register(ErrorUrl, ResourceHandler.FromString(errorPage.Replace("{err}", errorTitle)));
browser.Load(ErrorUrl);
}
}
@@ -202,10 +212,10 @@ namespace TweetDuck.Core{
prevSoundNotificationPath = newNotificationPath;
if (hasCustomSound){
resourceHandlerFactory.RegisterHandler(soundUrl, SoundNotification.CreateFileHandler(newNotificationPath));
resourceHandlers.Register(soundUrl, SoundNotification.CreateFileHandler(newNotificationPath));
}
else{
resourceHandlerFactory.UnregisterHandler(soundUrl);
resourceHandlers.Unregister(soundUrl);
}
}

View File

@@ -1,9 +1,9 @@
using System;
using System.Drawing;
using TweetDuck.Data;
using TweetLib.Core.Features.Configuration;
using TweetDuck.Browser.Data;
using TweetLib.Core.Features.Plugins.Config;
using TweetLib.Core.Serialization.Converters;
using TweetLib.Core.Systems.Configuration;
using TweetLib.Core.Utils;
namespace TweetDuck.Configuration{

View File

@@ -1,9 +1,9 @@
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;
using TweetLib.Core.Systems.Configuration;
namespace TweetDuck.Configuration{
sealed class PluginConfig : BaseConfig, IPluginConfig{

View File

@@ -1,4 +1,4 @@
using TweetLib.Core.Features.Configuration;
using TweetLib.Core.Systems.Configuration;
namespace TweetDuck.Configuration{
sealed class SystemConfig : BaseConfig{

View File

@@ -1,11 +1,11 @@
using System;
using System.Drawing;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Other;
using TweetDuck.Data;
using TweetLib.Core.Features.Configuration;
using TweetDuck.Browser;
using TweetDuck.Browser.Data;
using TweetDuck.Controls;
using TweetLib.Core.Features.Notifications;
using TweetLib.Core.Features.Twitter;
using TweetLib.Core.Systems.Configuration;
namespace TweetDuck.Configuration{
sealed class UserConfig : BaseConfig{
@@ -65,6 +65,7 @@ namespace TweetDuck.Configuration{
public Point CustomNotificationPosition { get; set; } = ControlExtensions.InvisibleLocation;
public int NotificationDisplay { get; set; } = 0;
public int NotificationEdgeDistance { get; set; } = 8;
public int NotificationWindowOpacity { get; set; } = 100;
public DesktopNotification.Size NotificationSize { get; set; } = DesktopNotification.Size.Auto;
public Size CustomNotificationSize { get; set; } = Size.Empty;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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;

View File

@@ -1,7 +1,7 @@
using System.Windows.Forms;
using TweetDuck.Core.Utils;
using TweetDuck.Utils;
namespace TweetDuck.Core.Controls{
namespace TweetDuck.Controls{
sealed class FlowLayoutPanelNoHScroll : FlowLayoutPanel{
protected override void WndProc(ref Message m){
if (m.Msg == 0x85){ // WM_NCPAINT

View File

@@ -2,7 +2,7 @@
using System.Drawing;
using System.Windows.Forms;
namespace TweetDuck.Core.Controls{
namespace TweetDuck.Controls{
sealed class LabelVertical : Label{
public int LineHeight { get; set; }

View File

@@ -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 ; }

View File

@@ -1,69 +0,0 @@
using System.Collections.Specialized;
using CefSharp;
using TweetDuck.Core.Handling.Filters;
using TweetDuck.Core.Utils;
using TweetLib.Core.Features.Twitter;
namespace TweetDuck.Core.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);
}
}
}

View File

@@ -1,43 +0,0 @@
using System;
using System.Collections.Concurrent;
using CefSharp;
using TweetDuck.Data;
namespace TweetDuck.Core.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);
}
}
}

View File

@@ -1,36 +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.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 BaseTabSettings(){
Padding = new Padding(6);
}
public virtual void OnReady(){}
public virtual void OnClosing(){}
}
}

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other {
namespace TweetDuck.Dialogs {
sealed partial class FormAbout {
/// <summary>
/// Required designer variable.

View File

@@ -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";

View File

@@ -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>

View File

@@ -1,16 +1,18 @@
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.Core.Adapters;
using TweetDuck.Data;
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+)?(?:/(#.*))?";
@@ -54,7 +56,10 @@ namespace TweetDuck.Core.Other{
}
}
#pragma warning disable IDE0069 // Disposable fields should be disposed
private readonly ChromiumWebBrowser browser;
#pragma warning restore IDE0069 // Disposable fields should be disposed
private string nextUrl;
private FormGuide(string url, FormBrowser owner){
@@ -64,8 +69,8 @@ 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);
var resourceRequestHandler = new ResourceRequestHandlerBase();
resourceRequestHandler.ResourceHandlers.Register(DummyPage);
this.browser = new ChromiumWebBrowser(url){
MenuHandler = new ContextMenuGuide(owner),
@@ -73,7 +78,7 @@ namespace TweetDuck.Core.Other{
KeyboardHandler = new KeyboardHandlerBase(),
LifeSpanHandler = new LifeSpanHandler(),
RequestHandler = new RequestHandlerBase(true),
ResourceHandlerFactory = resourceHandlerFactory
ResourceRequestHandlerFactory = resourceRequestHandler.SelfFactory
};
browser.LoadingStateChanged += browser_LoadingStateChanged;
@@ -85,10 +90,15 @@ namespace TweetDuck.Core.Other{
browser.SetupZoomEvents();
Controls.Add(browser);
Disposed += (sender, args) => browser.Dispose();
}
Disposed += (sender, args) => {
browser.Dispose();
};
protected override void Dispose(bool disposing){
if (disposing){
components?.Dispose();
}
base.Dispose(disposing);
}
private void Reload(string url){

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other {
namespace TweetDuck.Dialogs {
partial class FormMessage {
/// <summary>
/// Required designer variable.

View File

@@ -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,17 +43,17 @@ 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)){
if (buttonCancel == null){
message.AddButton(buttonAccept, DialogResult.OK, ControlType.Cancel | ControlType.Focused);
}
else{
message.AddButton(buttonCancel, DialogResult.Cancel, ControlType.Cancel);
message.AddButton(buttonAccept, DialogResult.OK, ControlType.Accept | ControlType.Focused);
}
using FormMessage message = new FormMessage(caption, text, icon);
return message.ShowDialog() == DialogResult.OK;
if (buttonCancel == null){
message.AddButton(buttonAccept, DialogResult.OK, ControlType.Cancel | ControlType.Focused);
}
else{
message.AddButton(buttonCancel, DialogResult.Cancel, ControlType.Cancel);
message.AddButton(buttonAccept, DialogResult.OK, ControlType.Accept | ControlType.Focused);
}
return message.ShowDialog() == DialogResult.OK;
}
// Instance

View File

@@ -1,6 +1,6 @@
using TweetDuck.Core.Controls;
using TweetDuck.Controls;
namespace TweetDuck.Core.Other {
namespace TweetDuck.Dialogs {
partial class FormPlugins {
/// <summary>
/// Required designer variable.

View File

@@ -3,11 +3,12 @@ using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using TweetDuck.Configuration;
using TweetDuck.Management;
using TweetDuck.Plugins;
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;

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other {
namespace TweetDuck.Dialogs {
sealed partial class FormSettings {
/// <summary>
/// Required designer variable.

View File

@@ -2,17 +2,19 @@
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.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;
using TweetLib.Core.Systems.Updates;
namespace TweetDuck.Core.Other{
namespace TweetDuck.Dialogs{
sealed partial class FormSettings : Form, FormManager.IAppDialog{
public bool ShouldReloadBrowser { get; private set; }
@@ -80,25 +82,24 @@ namespace TweetDuck.Core.Other{
private void btnManageOptions_Click(object sender, EventArgs e){
PrepareUnload();
using(DialogSettingsManage dialog = new DialogSettingsManage(plugins)){
FormClosing -= FormSettings_FormClosing;
if (dialog.ShowDialog() == DialogResult.OK){
if (!dialog.IsRestarting){
browser.ResumeNotification();
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 = true;
}
if (dialog.ShouldReloadBrowser){
BrowserProcessHandler.UpdatePrefs();
ShouldReloadBrowser = true;
}
}
Close();
}
else{
FormClosing += FormSettings_FormClosing;
PrepareLoad();
}
Close();
}
else{
FormClosing += FormSettings_FormClosing;
PrepareLoad();
}
}
@@ -106,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,
@@ -136,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)]);
}
@@ -196,16 +197,47 @@ namespace TweetDuck.Core.Other{
private sealed class SettingsTab{
public Button Button { get; }
public BaseTabSettings 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(){}
}
}
}

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings.Dialogs {
namespace TweetDuck.Dialogs.Settings {
partial class DialogSettingsAnalytics {
/// <summary>
/// Required designer variable.

View File

@@ -1,9 +1,9 @@
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 DialogSettingsAnalytics(AnalyticsReport report){
InitializeComponent();

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings.Dialogs {
namespace TweetDuck.Dialogs.Settings {
partial class DialogSettingsCSS {
/// <summary>
/// Required designer variable.

View File

@@ -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;

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings.Dialogs {
namespace TweetDuck.Dialogs.Settings {
partial class DialogSettingsCefArgs {
/// <summary>
/// Required designer variable.

View File

@@ -1,10 +1,10 @@
using System;
using System.Windows.Forms;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Utils;
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;

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings.Dialogs {
namespace TweetDuck.Dialogs.Settings {
partial class DialogSettingsExternalProgram {
/// <summary>
/// Required designer variable.

View File

@@ -3,7 +3,7 @@ using System.Windows.Forms;
using TweetLib.Core.Utils;
using IOPath = System.IO.Path;
namespace TweetDuck.Core.Other.Settings.Dialogs{
namespace TweetDuck.Dialogs.Settings{
sealed partial class DialogSettingsExternalProgram : Form{
public string Path{
get => StringUtils.NullIfEmpty(textBoxPath.Text);

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings.Dialogs {
namespace TweetDuck.Dialogs.Settings {
partial class DialogSettingsManage {
/// <summary>
/// Required designer variable.

View File

@@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using TweetDuck.Configuration;
using TweetDuck.Core.Management;
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

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings.Dialogs {
namespace TweetDuck.Dialogs.Settings {
partial class DialogSettingsRestart {
/// <summary>
/// Required designer variable.

View File

@@ -3,7 +3,7 @@ using System.Windows.Forms;
using TweetDuck.Configuration;
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; }
@@ -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);
}

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings.Dialogs {
namespace TweetDuck.Dialogs.Settings {
partial class DialogSettingsSearchEngine {
/// <summary>
/// Required designer variable.

View File

@@ -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;

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings {
namespace TweetDuck.Dialogs.Settings {
partial class TabSettingsAdvanced {
/// <summary>
/// Required designer variable.
@@ -32,7 +32,7 @@
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();

View File

@@ -2,14 +2,13 @@
using System.Threading.Tasks;
using System.Windows.Forms;
using TweetDuck.Configuration;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Management;
using TweetDuck.Core.Other.Settings.Dialogs;
using TweetDuck.Core.Utils;
using TweetDuck.Controls;
using TweetDuck.Management;
using TweetDuck.Utils;
using TweetLib.Core;
namespace TweetDuck.Core.Other.Settings{
sealed partial class TabSettingsAdvanced : BaseTabSettings{
namespace TweetDuck.Dialogs.Settings{
sealed partial class TabSettingsAdvanced : FormSettings.BaseTab{
private readonly Action<string> reinjectBrowserCSS;
private readonly Action openDevTools;
@@ -91,10 +90,10 @@ namespace TweetDuck.Core.Other.Settings{
}
private void btnRestartArgs_Click(object sender, EventArgs e){
using(DialogSettingsRestart dialog = new DialogSettingsRestart(Arguments.GetCurrentClean())){
if (dialog.ShowDialog() == DialogResult.OK){
Program.RestartWithArgs(dialog.Args);
}
using DialogSettingsRestart dialog = new DialogSettingsRestart(Arguments.GetCurrentClean());
if (dialog.ShowDialog() == DialogResult.OK){
Program.RestartWithArgs(dialog.Args);
}
}

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings {
namespace TweetDuck.Dialogs.Settings {
partial class TabSettingsFeedback {
/// <summary>
/// Required designer variable.

View File

@@ -1,12 +1,11 @@
using System;
using System.Windows.Forms;
using TweetDuck.Core.Other.Analytics;
using TweetDuck.Core.Other.Settings.Dialogs;
using TweetDuck.Core.Utils;
using TweetDuck.Management.Analytics;
using TweetDuck.Utils;
using TweetLib.Core.Features.Plugins;
namespace TweetDuck.Core.Other.Settings{
sealed partial class TabSettingsFeedback : BaseTabSettings{
namespace TweetDuck.Dialogs.Settings{
sealed partial class TabSettingsFeedback : FormSettings.BaseTab{
private readonly AnalyticsFile analyticsFile;
private readonly AnalyticsReportGenerator.ExternalInfo analyticsInfo;
private readonly PluginManager plugins;
@@ -50,9 +49,8 @@ namespace TweetDuck.Core.Other.Settings{
}
private void btnViewReport_Click(object sender, EventArgs e){
using(DialogSettingsAnalytics dialog = new DialogSettingsAnalytics(AnalyticsReportGenerator.Create(analyticsFile, analyticsInfo, plugins))){
dialog.ShowDialog();
}
using DialogSettingsAnalytics dialog = new DialogSettingsAnalytics(AnalyticsReportGenerator.Create(analyticsFile, analyticsInfo, plugins));
dialog.ShowDialog();
}
#endregion

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings {
namespace TweetDuck.Dialogs.Settings {
partial class TabSettingsGeneral {
/// <summary>
/// Required designer variable.
@@ -115,7 +115,7 @@
//
this.labelZoomValue.BackColor = System.Drawing.Color.Transparent;
this.labelZoomValue.Font = new System.Drawing.Font("Segoe UI", 9F);
this.labelZoomValue.Location = new System.Drawing.Point(147, 4);
this.labelZoomValue.Location = new System.Drawing.Point(176, 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);
@@ -156,7 +156,7 @@
this.trackBarZoom.Maximum = 200;
this.trackBarZoom.Minimum = 50;
this.trackBarZoom.Name = "trackBarZoom";
this.trackBarZoom.Size = new System.Drawing.Size(148, 30);
this.trackBarZoom.Size = new System.Drawing.Size(177, 30);
this.trackBarZoom.SmallChange = 5;
this.trackBarZoom.TabIndex = 0;
this.trackBarZoom.TickFrequency = 25;

View File

@@ -2,15 +2,14 @@
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 TweetLib.Core.Features.Updates;
using TweetDuck.Browser.Handling.General;
using TweetDuck.Controls;
using TweetDuck.Utils;
using TweetLib.Core.Systems.Updates;
using TweetLib.Core.Utils;
namespace TweetDuck.Core.Other.Settings{
sealed partial class TabSettingsGeneral : BaseTabSettings{
namespace TweetDuck.Dialogs.Settings{
sealed partial class TabSettingsGeneral : FormSettings.BaseTab{
private readonly Action reloadColumns;
private readonly UpdateHandler updates;

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings {
namespace TweetDuck.Dialogs.Settings {
partial class TabSettingsNotifications {
/// <summary>
/// Required designer variable.
@@ -35,9 +35,9 @@
this.radioLocTL = new System.Windows.Forms.RadioButton();
this.trackBarEdgeDistance = new System.Windows.Forms.TrackBar();
this.tableLayoutDurationButtons = new System.Windows.Forms.TableLayoutPanel();
this.btnDurationMedium = new TweetDuck.Core.Controls.FlatButton();
this.btnDurationLong = new TweetDuck.Core.Controls.FlatButton();
this.btnDurationShort = new TweetDuck.Core.Controls.FlatButton();
this.btnDurationMedium = new TweetDuck.Controls.FlatButton();
this.btnDurationLong = new TweetDuck.Controls.FlatButton();
this.btnDurationShort = new TweetDuck.Controls.FlatButton();
this.labelDurationValue = new System.Windows.Forms.Label();
this.trackBarDuration = new System.Windows.Forms.TrackBar();
this.checkSkipOnLinkClick = new System.Windows.Forms.CheckBox();
@@ -65,6 +65,10 @@
this.panelSize = new System.Windows.Forms.Panel();
this.durationUpdateTimer = new System.Windows.Forms.Timer(this.components);
this.flowPanelLeft = new System.Windows.Forms.FlowLayoutPanel();
this.labelOpacity = new System.Windows.Forms.Label();
this.panelOpacity = new System.Windows.Forms.Panel();
this.labelOpacityValue = new System.Windows.Forms.Label();
this.trackBarOpacity = new System.Windows.Forms.TrackBar();
this.panelScrollSpeed = new System.Windows.Forms.Panel();
this.flowPanelRight = new System.Windows.Forms.FlowLayoutPanel();
this.panelSeparator = new System.Windows.Forms.Panel();
@@ -77,6 +81,8 @@
this.panelTimer.SuspendLayout();
this.panelSize.SuspendLayout();
this.flowPanelLeft.SuspendLayout();
this.panelOpacity.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarOpacity)).BeginInit();
this.panelScrollSpeed.SuspendLayout();
this.flowPanelRight.SuspendLayout();
this.SuspendLayout();
@@ -84,7 +90,7 @@
// labelEdgeDistanceValue
//
this.labelEdgeDistanceValue.Font = new System.Drawing.Font("Segoe UI", 9F);
this.labelEdgeDistanceValue.Location = new System.Drawing.Point(145, 4);
this.labelEdgeDistanceValue.Location = new System.Drawing.Point(175, 4);
this.labelEdgeDistanceValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelEdgeDistanceValue.Name = "labelEdgeDistanceValue";
this.labelEdgeDistanceValue.Size = new System.Drawing.Size(40, 15);
@@ -193,7 +199,7 @@
this.trackBarEdgeDistance.Maximum = 40;
this.trackBarEdgeDistance.Minimum = 8;
this.trackBarEdgeDistance.Name = "trackBarEdgeDistance";
this.trackBarEdgeDistance.Size = new System.Drawing.Size(148, 30);
this.trackBarEdgeDistance.Size = new System.Drawing.Size(177, 30);
this.trackBarEdgeDistance.SmallChange = 2;
this.trackBarEdgeDistance.TabIndex = 0;
this.trackBarEdgeDistance.TickFrequency = 4;
@@ -208,12 +214,12 @@
this.tableLayoutDurationButtons.Controls.Add(this.btnDurationMedium, 0, 0);
this.tableLayoutDurationButtons.Controls.Add(this.btnDurationLong, 1, 0);
this.tableLayoutDurationButtons.Controls.Add(this.btnDurationShort, 0, 0);
this.tableLayoutDurationButtons.Location = new System.Drawing.Point(3, 353);
this.tableLayoutDurationButtons.Location = new System.Drawing.Point(3, 401);
this.tableLayoutDurationButtons.Name = "tableLayoutDurationButtons";
this.tableLayoutDurationButtons.RowCount = 1;
this.tableLayoutDurationButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.tableLayoutDurationButtons.Size = new System.Drawing.Size(180, 27);
this.tableLayoutDurationButtons.TabIndex = 12;
this.tableLayoutDurationButtons.TabIndex = 14;
//
// btnDurationMedium
//
@@ -267,7 +273,7 @@
//
this.labelDurationValue.BackColor = System.Drawing.Color.Transparent;
this.labelDurationValue.Font = new System.Drawing.Font("Segoe UI", 9F);
this.labelDurationValue.Location = new System.Drawing.Point(147, 4);
this.labelDurationValue.Location = new System.Drawing.Point(177, 4);
this.labelDurationValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelDurationValue.Name = "labelDurationValue";
this.labelDurationValue.Size = new System.Drawing.Size(52, 15);
@@ -282,7 +288,7 @@
this.trackBarDuration.Maximum = 60;
this.trackBarDuration.Minimum = 10;
this.trackBarDuration.Name = "trackBarDuration";
this.trackBarDuration.Size = new System.Drawing.Size(148, 30);
this.trackBarDuration.Size = new System.Drawing.Size(177, 30);
this.trackBarDuration.TabIndex = 0;
this.trackBarDuration.TickFrequency = 5;
this.trackBarDuration.Value = 25;
@@ -349,11 +355,11 @@
//
this.checkTimerCountDown.AutoSize = true;
this.checkTimerCountDown.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkTimerCountDown.Location = new System.Drawing.Point(6, 266);
this.checkTimerCountDown.Location = new System.Drawing.Point(6, 314);
this.checkTimerCountDown.Margin = new System.Windows.Forms.Padding(6, 3, 3, 2);
this.checkTimerCountDown.Name = "checkTimerCountDown";
this.checkTimerCountDown.Size = new System.Drawing.Size(132, 19);
this.checkTimerCountDown.TabIndex = 9;
this.checkTimerCountDown.TabIndex = 11;
this.checkTimerCountDown.Text = "Timer Counts Down";
this.checkTimerCountDown.UseVisualStyleBackColor = true;
//
@@ -361,11 +367,11 @@
//
this.checkNotificationTimer.AutoSize = true;
this.checkNotificationTimer.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkNotificationTimer.Location = new System.Drawing.Point(6, 242);
this.checkNotificationTimer.Location = new System.Drawing.Point(6, 290);
this.checkNotificationTimer.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2);
this.checkNotificationTimer.Name = "checkNotificationTimer";
this.checkNotificationTimer.Size = new System.Drawing.Size(164, 19);
this.checkNotificationTimer.TabIndex = 8;
this.checkNotificationTimer.TabIndex = 10;
this.checkNotificationTimer.Text = "Display Notification Timer";
this.checkNotificationTimer.UseVisualStyleBackColor = true;
//
@@ -429,7 +435,7 @@
// labelScrollSpeedValue
//
this.labelScrollSpeedValue.Font = new System.Drawing.Font("Segoe UI", 9F);
this.labelScrollSpeedValue.Location = new System.Drawing.Point(145, 4);
this.labelScrollSpeedValue.Location = new System.Drawing.Point(176, 4);
this.labelScrollSpeedValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelScrollSpeedValue.Name = "labelScrollSpeedValue";
this.labelScrollSpeedValue.Size = new System.Drawing.Size(38, 15);
@@ -445,7 +451,7 @@
this.trackBarScrollSpeed.Maximum = 200;
this.trackBarScrollSpeed.Minimum = 25;
this.trackBarScrollSpeed.Name = "trackBarScrollSpeed";
this.trackBarScrollSpeed.Size = new System.Drawing.Size(148, 30);
this.trackBarScrollSpeed.Size = new System.Drawing.Size(177, 30);
this.trackBarScrollSpeed.SmallChange = 5;
this.trackBarScrollSpeed.TabIndex = 0;
this.trackBarScrollSpeed.TickFrequency = 25;
@@ -490,32 +496,32 @@
//
this.panelTimer.Controls.Add(this.labelDurationValue);
this.panelTimer.Controls.Add(this.trackBarDuration);
this.panelTimer.Location = new System.Drawing.Point(0, 315);
this.panelTimer.Location = new System.Drawing.Point(0, 363);
this.panelTimer.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0);
this.panelTimer.Name = "panelTimer";
this.panelTimer.Size = new System.Drawing.Size(300, 35);
this.panelTimer.TabIndex = 11;
this.panelTimer.TabIndex = 13;
//
// labelDuration
//
this.labelDuration.AutoSize = true;
this.labelDuration.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold);
this.labelDuration.Location = new System.Drawing.Point(3, 299);
this.labelDuration.Location = new System.Drawing.Point(3, 347);
this.labelDuration.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelDuration.Name = "labelDuration";
this.labelDuration.Size = new System.Drawing.Size(54, 15);
this.labelDuration.TabIndex = 10;
this.labelDuration.TabIndex = 12;
this.labelDuration.Text = "Duration";
//
// labelTimer
//
this.labelTimer.AutoSize = true;
this.labelTimer.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
this.labelTimer.Location = new System.Drawing.Point(0, 216);
this.labelTimer.Margin = new System.Windows.Forms.Padding(0, 40, 0, 1);
this.labelTimer.Location = new System.Drawing.Point(0, 264);
this.labelTimer.Margin = new System.Windows.Forms.Padding(0, 25, 0, 1);
this.labelTimer.Name = "labelTimer";
this.labelTimer.Size = new System.Drawing.Size(50, 19);
this.labelTimer.TabIndex = 7;
this.labelTimer.TabIndex = 9;
this.labelTimer.Text = "TIMER";
//
// labelSize
@@ -555,6 +561,8 @@
this.flowPanelLeft.Controls.Add(this.checkNonIntrusive);
this.flowPanelLeft.Controls.Add(this.labelIdlePause);
this.flowPanelLeft.Controls.Add(this.comboBoxIdlePause);
this.flowPanelLeft.Controls.Add(this.labelOpacity);
this.flowPanelLeft.Controls.Add(this.panelOpacity);
this.flowPanelLeft.Controls.Add(this.labelTimer);
this.flowPanelLeft.Controls.Add(this.checkNotificationTimer);
this.flowPanelLeft.Controls.Add(this.checkTimerCountDown);
@@ -568,6 +576,52 @@
this.flowPanelLeft.TabIndex = 0;
this.flowPanelLeft.WrapContents = false;
//
// labelOpacity
//
this.labelOpacity.AutoSize = true;
this.labelOpacity.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold);
this.labelOpacity.Location = new System.Drawing.Point(3, 188);
this.labelOpacity.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelOpacity.Name = "labelOpacity";
this.labelOpacity.Size = new System.Drawing.Size(48, 15);
this.labelOpacity.TabIndex = 7;
this.labelOpacity.Text = "Opacity";
//
// panelOpacity
//
this.panelOpacity.Controls.Add(this.labelOpacityValue);
this.panelOpacity.Controls.Add(this.trackBarOpacity);
this.panelOpacity.Location = new System.Drawing.Point(0, 204);
this.panelOpacity.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0);
this.panelOpacity.Name = "panelOpacity";
this.panelOpacity.Size = new System.Drawing.Size(300, 35);
this.panelOpacity.TabIndex = 8;
//
// labelOpacityValue
//
this.labelOpacityValue.BackColor = System.Drawing.SystemColors.Control;
this.labelOpacityValue.Font = new System.Drawing.Font("Segoe UI", 9F);
this.labelOpacityValue.Location = new System.Drawing.Point(176, 4);
this.labelOpacityValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelOpacityValue.Name = "labelOpacityValue";
this.labelOpacityValue.Size = new System.Drawing.Size(38, 15);
this.labelOpacityValue.TabIndex = 1;
this.labelOpacityValue.Text = "100%";
this.labelOpacityValue.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// trackBarOpacity
//
this.trackBarOpacity.AutoSize = false;
this.trackBarOpacity.Location = new System.Drawing.Point(3, 3);
this.trackBarOpacity.Maximum = 100;
this.trackBarOpacity.Minimum = 20;
this.trackBarOpacity.Name = "trackBarOpacity";
this.trackBarOpacity.Size = new System.Drawing.Size(177, 30);
this.trackBarOpacity.SmallChange = 5;
this.trackBarOpacity.TabIndex = 0;
this.trackBarOpacity.TickFrequency = 10;
this.trackBarOpacity.Value = 100;
//
// panelScrollSpeed
//
this.panelScrollSpeed.Controls.Add(this.trackBarScrollSpeed);
@@ -630,6 +684,8 @@
this.panelSize.ResumeLayout(false);
this.flowPanelLeft.ResumeLayout(false);
this.flowPanelLeft.PerformLayout();
this.panelOpacity.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.trackBarOpacity)).EndInit();
this.panelScrollSpeed.ResumeLayout(false);
this.flowPanelRight.ResumeLayout(false);
this.flowPanelRight.PerformLayout();
@@ -652,9 +708,9 @@
private System.Windows.Forms.Label labelDurationValue;
private System.Windows.Forms.TrackBar trackBarDuration;
private System.Windows.Forms.TableLayoutPanel tableLayoutDurationButtons;
private TweetDuck.Core.Controls.FlatButton btnDurationMedium;
private TweetDuck.Core.Controls.FlatButton btnDurationLong;
private TweetDuck.Core.Controls.FlatButton btnDurationShort;
private TweetDuck.Controls.FlatButton btnDurationMedium;
private TweetDuck.Controls.FlatButton btnDurationLong;
private TweetDuck.Controls.FlatButton btnDurationShort;
private System.Windows.Forms.CheckBox checkNonIntrusive;
private System.Windows.Forms.Label labelIdlePause;
private System.Windows.Forms.ComboBox comboBoxIdlePause;
@@ -682,5 +738,9 @@
private System.Windows.Forms.Panel panelScrollSpeed;
private System.Windows.Forms.FlowLayoutPanel flowPanelRight;
private System.Windows.Forms.Panel panelSeparator;
private System.Windows.Forms.Label labelOpacity;
private System.Windows.Forms.Panel panelOpacity;
private System.Windows.Forms.Label labelOpacityValue;
private System.Windows.Forms.TrackBar trackBarOpacity;
}
}

View File

@@ -1,11 +1,11 @@
using System;
using System.Windows.Forms;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Notification.Example;
using TweetDuck.Browser.Notification.Example;
using TweetDuck.Controls;
using TweetLib.Core.Features.Notifications;
namespace TweetDuck.Core.Other.Settings{
sealed partial class TabSettingsNotifications : BaseTabSettings{
namespace TweetDuck.Dialogs.Settings{
sealed partial class TabSettingsNotifications : FormSettings.BaseTab{
private static readonly int[] IdlePauseSeconds = { 0, 30, 60, 120, 300 };
private readonly FormNotificationExample notification;
@@ -23,7 +23,6 @@ namespace TweetDuck.Core.Other.Settings{
});
};
this.notification.Activated += notification_Activated;
this.notification.Show();
Disposed += (sender, args) => this.notification.Dispose();
@@ -48,6 +47,9 @@ namespace TweetDuck.Core.Other.Settings{
comboBoxIdlePause.Items.Add("5 minutes");
comboBoxIdlePause.SelectedIndex = Math.Max(0, Array.FindIndex(IdlePauseSeconds, val => val == Config.NotificationIdlePauseSeconds));
trackBarOpacity.SetValueSafe(Config.NotificationWindowOpacity);
labelOpacityValue.Text = Config.NotificationWindowOpacity + "%";
// timer
toolTip.SetToolTip(checkTimerCountDown, "The notification timer counts down instead of up.");
@@ -105,6 +107,7 @@ namespace TweetDuck.Core.Other.Settings{
checkSkipOnLinkClick.CheckedChanged += checkSkipOnLinkClick_CheckedChanged;
checkNonIntrusive.CheckedChanged += checkNonIntrusive_CheckedChanged;
comboBoxIdlePause.SelectedValueChanged += comboBoxIdlePause_SelectedValueChanged;
trackBarOpacity.ValueChanged += trackBarOpacity_ValueChanged;
checkNotificationTimer.CheckedChanged += checkNotificationTimer_CheckedChanged;
checkTimerCountDown.CheckedChanged += checkTimerCountDown_CheckedChanged;
@@ -135,11 +138,6 @@ namespace TweetDuck.Core.Other.Settings{
}
}
private void notification_Activated(object sender, EventArgs e){
notification.Hide();
notification.Activated -= notification_Activated;
}
private void notification_Move(object sender, EventArgs e){
if (radioLocCustom.Checked && notification.Location != ControlExtensions.InvisibleLocation){
Config.CustomNotificationPosition = notification.Location;
@@ -176,6 +174,13 @@ namespace TweetDuck.Core.Other.Settings{
Config.NotificationIdlePauseSeconds = IdlePauseSeconds[comboBoxIdlePause.SelectedIndex];
}
private void trackBarOpacity_ValueChanged(object sender, EventArgs e){
if (trackBarOpacity.AlignValueToTick()){
Config.NotificationWindowOpacity = trackBarOpacity.Value;
labelOpacityValue.Text = Config.NotificationWindowOpacity + "%";
}
}
#endregion
#region Timer
@@ -219,10 +224,18 @@ namespace TweetDuck.Core.Other.Settings{
#region Location
private void radioLoc_CheckedChanged(object sender, EventArgs e){
if (radioLocTL.Checked)Config.NotificationPosition = DesktopNotification.Position.TopLeft;
else if (radioLocTR.Checked)Config.NotificationPosition = DesktopNotification.Position.TopRight;
else if (radioLocBL.Checked)Config.NotificationPosition = DesktopNotification.Position.BottomLeft;
else if (radioLocBR.Checked)Config.NotificationPosition = DesktopNotification.Position.BottomRight;
if (radioLocTL.Checked){
Config.NotificationPosition = DesktopNotification.Position.TopLeft;
}
else if (radioLocTR.Checked){
Config.NotificationPosition = DesktopNotification.Position.TopRight;
}
else if (radioLocBL.Checked){
Config.NotificationPosition = DesktopNotification.Position.BottomLeft;
}
else if (radioLocBR.Checked){
Config.NotificationPosition = DesktopNotification.Position.BottomRight;
}
comboBoxDisplay.Enabled = trackBarEdgeDistance.Enabled = true;
notification.ShowExampleNotification(false);

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings {
namespace TweetDuck.Dialogs.Settings {
partial class TabSettingsSounds {
/// <summary>
/// Required designer variable.
@@ -57,7 +57,7 @@
//
this.labelVolumeValue.BackColor = System.Drawing.Color.Transparent;
this.labelVolumeValue.Font = new System.Drawing.Font("Segoe UI", 9F);
this.labelVolumeValue.Location = new System.Drawing.Point(147, 4);
this.labelVolumeValue.Location = new System.Drawing.Point(176, 4);
this.labelVolumeValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelVolumeValue.Name = "labelVolumeValue";
this.labelVolumeValue.Size = new System.Drawing.Size(38, 15);
@@ -144,7 +144,7 @@
this.trackBarVolume.Location = new System.Drawing.Point(3, 3);
this.trackBarVolume.Maximum = 100;
this.trackBarVolume.Name = "trackBarVolume";
this.trackBarVolume.Size = new System.Drawing.Size(148, 30);
this.trackBarVolume.Size = new System.Drawing.Size(177, 30);
this.trackBarVolume.TabIndex = 0;
this.trackBarVolume.TickFrequency = 10;
this.trackBarVolume.Value = 100;

View File

@@ -2,12 +2,12 @@
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Notification;
using TweetDuck.Core.Utils;
using TweetDuck.Browser.Notification;
using TweetDuck.Controls;
using TweetDuck.Utils;
namespace TweetDuck.Core.Other.Settings{
sealed partial class TabSettingsSounds : BaseTabSettings{
namespace TweetDuck.Dialogs.Settings{
sealed partial class TabSettingsSounds : FormSettings.BaseTab{
private readonly Action playSoundNotification;
public TabSettingsSounds(Action playSoundNotification){
@@ -64,15 +64,15 @@ namespace TweetDuck.Core.Other.Settings{
}
private void btnBrowseSound_Click(object sender, EventArgs e){
using(OpenFileDialog dialog = new OpenFileDialog{
using OpenFileDialog dialog = new OpenFileDialog{
AutoUpgradeEnabled = true,
DereferenceLinks = true,
Title = "Custom Notification Sound",
Filter = $"Sound file ({SoundNotification.SupportedFormats})|{SoundNotification.SupportedFormats}|All files (*.*)|*.*"
}){
if (dialog.ShowDialog() == DialogResult.OK){
tbCustomSound.Text = dialog.FileName;
}
};
if (dialog.ShowDialog() == DialogResult.OK){
tbCustomSound.Text = dialog.FileName;
}
}

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Core.Other.Settings {
namespace TweetDuck.Dialogs.Settings {
partial class TabSettingsTray {
/// <summary>
/// Required designer variable.

View File

@@ -1,7 +1,8 @@
using System;
using TweetDuck.Browser;
namespace TweetDuck.Core.Other.Settings{
sealed partial class TabSettingsTray : BaseTabSettings{
namespace TweetDuck.Dialogs.Settings{
sealed partial class TabSettingsTray : FormSettings.BaseTab{
public TabSettingsTray(){
InitializeComponent();

View File

@@ -1,16 +0,0 @@
using System.Diagnostics;
using System.IO;
using TweetLib.Core.Application;
namespace TweetDuck.Impl{
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('/', '\\') + '"')){}
}
}
}
}

View File

@@ -5,7 +5,7 @@ using System.Reflection;
using TweetLib.Core.Serialization;
using TweetLib.Core.Serialization.Converters;
namespace TweetDuck.Core.Other.Analytics{
namespace TweetDuck.Management.Analytics{
[SuppressMessage("ReSharper", "AutoPropertyCanBeMadeGetOnly.Local")]
sealed class AnalyticsFile{
private static readonly FileSerializer<AnalyticsFile> Serializer = new FileSerializer<AnalyticsFile>();

View File

@@ -6,13 +6,14 @@ using System;
using System.Net;
using System.Threading.Tasks;
using System.Timers;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Utils;
using TweetDuck.Browser;
using TweetDuck.Controls;
using TweetDuck.Utils;
using TweetLib.Core;
using TweetLib.Core.Features.Plugins;
using TweetLib.Core.Utils;
namespace TweetDuck.Core.Other.Analytics{
namespace TweetDuck.Management.Analytics{
sealed class AnalyticsManager : IDisposable{
private static readonly TimeSpan CollectionInterval = TimeSpan.FromDays(14);
@@ -138,8 +139,7 @@ namespace TweetDuck.Core.Other.Analytics{
break;
case WebExceptionStatus.ProtocolError:
HttpWebResponse response = e.Response as HttpWebResponse;
message = "HTTP Error " + (response != null ? $"{(int)response.StatusCode} ({response.StatusDescription})" : "(unknown code)");
message = "HTTP Error " + (e.Response is HttpWebResponse response ? $"{(int)response.StatusCode} ({response.StatusDescription})" : "(unknown code)");
break;
}

Some files were not shown because too many files have changed in this diff Show More