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

Compare commits

..

1 Commits

Author SHA1 Message Date
9238410756 WIP? 2019-05-09 11:54:38 +02:00
237 changed files with 3667 additions and 4952 deletions

3
.github/FUNDING.yml vendored
View File

@@ -1,3 +0,0 @@
github: chylex
patreon: chylex
ko_fi: chylex

View File

@@ -1,58 +0,0 @@
using System;
using System.ComponentModel;
using System.Diagnostics;
using TweetDuck.Utils;
using TweetLib.Core.Application;
namespace TweetDuck.Application{
class LockHandler : IAppLockHandler{
private const int WaitRetryDelay = 250;
private const int RestoreFailTimeout = 2000;
private const int CloseNaturallyTimeout = 10000;
private const int CloseKillTimeout = 5000;
bool IAppLockHandler.RestoreProcess(Process process){
if (process.MainWindowHandle == IntPtr.Zero){ // restore if the original process is in tray
NativeMethods.BroadcastMessage(Program.WindowRestoreMessage, (uint)process.Id, 0);
if (WindowsUtils.TrySleepUntil(() => CheckProcessExited(process) || (process.MainWindowHandle != IntPtr.Zero && process.Responding), RestoreFailTimeout, WaitRetryDelay)){
return true;
}
}
return false;
}
bool IAppLockHandler.CloseProcess(Process process){
try{
if (process.CloseMainWindow()){
// ReSharper disable once AccessToDisposedClosure
WindowsUtils.TrySleepUntil(() => CheckProcessExited(process), CloseNaturallyTimeout, WaitRetryDelay);
}
if (!process.HasExited){
process.Kill();
// ReSharper disable once AccessToDisposedClosure
WindowsUtils.TrySleepUntil(() => CheckProcessExited(process), CloseKillTimeout, WaitRetryDelay);
}
if (process.HasExited){
process.Dispose();
return true;
}
else{
return false;
}
}catch(Exception ex) when (ex is InvalidOperationException || ex is Win32Exception){
bool hasExited = CheckProcessExited(process);
process.Dispose();
return hasExited;
}
}
private static bool CheckProcessExited(Process process){
process.Refresh();
return process.HasExited;
}
}
}

View File

@@ -1,16 +0,0 @@
using System.Diagnostics;
using System.IO;
using TweetLib.Core.Application;
namespace TweetDuck.Application{
class SystemHandler : IAppSystemHandler{
void IAppSystemHandler.OpenFileExplorer(string path){
if (File.Exists(path)){
using(Process.Start("explorer.exe", "/select,\"" + path.Replace('/', '\\') + "\"")){}
}
else if (Directory.Exists(path)){
using(Process.Start("explorer.exe", '"' + path.Replace('/', '\\') + '"')){}
}
}
}
}

View File

@@ -1,41 +0,0 @@
using System.IO;
using CefSharp;
using TweetLib.Core.Browser;
namespace TweetDuck.Browser.Adapters{
sealed class CefScriptExecutor : IScriptExecutor{
private readonly IWebBrowser browser;
public CefScriptExecutor(IWebBrowser browser){
this.browser = browser;
}
public void RunFunction(string name, params object[] args){
browser.ExecuteScriptAsync(name, args);
}
public void RunScript(string identifier, string script){
using IFrame frame = browser.GetMainFrame();
RunScript(frame, script, identifier);
}
public bool RunFile(string file){
using IFrame frame = browser.GetMainFrame();
return RunFile(frame, file);
}
// Helpers
public static void RunScript(IFrame frame, string script, string identifier){
if (script != null){
frame.ExecuteJavaScriptAsync(script, identifier, 1);
}
}
public static bool RunFile(IFrame frame, string file){
string script = Program.Resources.Load(file);
RunScript(frame, script, "root:" + Path.GetFileNameWithoutExtension(file));
return script != null;
}
}
}

View File

@@ -1,48 +0,0 @@
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using CefSharp;
using TweetDuck.Controls;
using TweetDuck.Dialogs;
using TweetDuck.Dialogs.Settings;
using TweetDuck.Management;
namespace TweetDuck.Browser.Notification{
static class SoundNotification{
public const string SupportedFormats = "*.wav;*.ogg;*.mp3;*.flac;*.opus;*.weba;*.webm";
public static IResourceHandler CreateFileHandler(string path){
string mimeType = Path.GetExtension(path) switch{
".weba" => "audio/webm",
".webm" => "audio/webm",
".wav" => "audio/wav",
".ogg" => "audio/ogg",
".mp3" => "audio/mp3",
".flac" => "audio/flac",
".opus" => "audio/ogg; codecs=opus",
_ => null
};
try{
return ResourceHandler.FromFilePath(path, mimeType);
}catch{
FormBrowser browser = FormManager.TryFind<FormBrowser>();
browser?.InvokeAsyncSafe(() => {
using FormMessage form = new FormMessage("Sound Notification Error", "Could not find custom notification sound file:\n" + path, MessageBoxIcon.Error);
form.AddButton(FormMessage.Ignore, ControlType.Cancel | ControlType.Focused);
Button btnViewOptions = form.AddButton("View Options");
btnViewOptions.Width += 16;
btnViewOptions.Location = new Point(btnViewOptions.Location.X - 16, btnViewOptions.Location.Y);
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions){
browser.OpenSettings(typeof(TabSettingsSounds));
}
});
return null;
}
}
}
}

View File

@@ -1,5 +1,5 @@
using System; using System;
using TweetLib.Core.Collections; using TweetDuck.Data;
namespace TweetDuck.Configuration{ namespace TweetDuck.Configuration{
static class Arguments{ static class Arguments{
@@ -22,8 +22,8 @@ namespace TweetDuck.Configuration{
return Current.HasFlag(flag); return Current.HasFlag(flag);
} }
public static string GetValue(string key){ public static string GetValue(string key, string defaultValue){
return Current.GetValue(key); return Current.GetValue(key, defaultValue);
} }
public static CommandLineArgs GetCurrentClean(){ public static CommandLineArgs GetCurrentClean(){

View File

@@ -1,13 +1,13 @@
using System; using System;
using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using TweetDuck.Browser.Data; using TweetDuck.Configuration.Instance;
using TweetLib.Core.Features.Plugins.Config; using TweetDuck.Core.Utils;
using TweetLib.Core.Serialization.Converters; using TweetDuck.Data;
using TweetLib.Core.Systems.Configuration; using TweetDuck.Data.Serialization;
using TweetLib.Core.Utils;
namespace TweetDuck.Configuration{ namespace TweetDuck.Configuration{
sealed class ConfigManager : IConfigManager{ sealed class ConfigManager{
public UserConfig User { get; } public UserConfig User { get; }
public SystemConfig System { get; } public SystemConfig System { get; }
public PluginConfig Plugins { get; } public PluginConfig Plugins { get; }
@@ -16,7 +16,7 @@ namespace TweetDuck.Configuration{
private readonly FileConfigInstance<UserConfig> infoUser; private readonly FileConfigInstance<UserConfig> infoUser;
private readonly FileConfigInstance<SystemConfig> infoSystem; private readonly FileConfigInstance<SystemConfig> infoSystem;
private readonly PluginConfigInstance<PluginConfig> infoPlugins; private readonly PluginConfigInstance infoPlugins;
private readonly IConfigInstance<BaseConfig>[] infoList; private readonly IConfigInstance<BaseConfig>[] infoList;
@@ -28,7 +28,7 @@ namespace TweetDuck.Configuration{
infoList = new IConfigInstance<BaseConfig>[]{ infoList = new IConfigInstance<BaseConfig>[]{
infoUser = new FileConfigInstance<UserConfig>(Program.UserConfigFilePath, User, "program options"), infoUser = new FileConfigInstance<UserConfig>(Program.UserConfigFilePath, User, "program options"),
infoSystem = new FileConfigInstance<SystemConfig>(Program.SystemConfigFilePath, System, "system options"), infoSystem = new FileConfigInstance<SystemConfig>(Program.SystemConfigFilePath, System, "system options"),
infoPlugins = new PluginConfigInstance<PluginConfig>(Program.PluginConfigFilePath, Plugins) infoPlugins = new PluginConfigInstance(Program.PluginConfigFilePath, Plugins)
}; };
// TODO refactor further // TODO refactor further
@@ -70,13 +70,59 @@ namespace TweetDuck.Configuration{
infoPlugins.Reload(); infoPlugins.Reload();
} }
void IConfigManager.TriggerProgramRestartRequested(){ private void TriggerProgramRestartRequested(){
ProgramRestartRequested?.Invoke(this, EventArgs.Empty); ProgramRestartRequested?.Invoke(this, EventArgs.Empty);
} }
IConfigInstance<BaseConfig> IConfigManager.GetInstanceInfo(BaseConfig instance){ private IConfigInstance<BaseConfig> GetInstanceInfo(BaseConfig instance){
Type instanceType = instance.GetType(); Type instanceType = instance.GetType();
return Array.Find(infoList, info => info.Instance.GetType() == instanceType); // TODO handle null return Array.Find(infoList, info => info.Instance.GetType() == instanceType); // TODO handle null
} }
public abstract class BaseConfig{
private readonly ConfigManager configManager;
protected BaseConfig(ConfigManager configManager){
this.configManager = configManager;
}
// Management
public void Save(){
configManager.GetInstanceInfo(this).Save();
}
public void Reload(){
configManager.GetInstanceInfo(this).Reload();
}
public void Reset(){
configManager.GetInstanceInfo(this).Reset();
}
// Construction methods
public T ConstructWithDefaults<T>() where T : BaseConfig{
return ConstructWithDefaults(configManager) as T;
}
protected abstract BaseConfig ConstructWithDefaults(ConfigManager configManager);
// Utility methods
protected void UpdatePropertyWithEvent<T>(ref T field, T value, EventHandler eventHandler){
if (!EqualityComparer<T>.Default.Equals(field, value)){
field = value;
eventHandler?.Invoke(this, EventArgs.Empty);
}
}
protected void UpdatePropertyWithRestartRequest<T>(ref T field, T value){
if (!EqualityComparer<T>.Default.Equals(field, value)){
field = value;
configManager.TriggerProgramRestartRequested();
}
}
}
} }
} }

View File

@@ -1,20 +1,22 @@
using System; using System;
using System.IO; using System.IO;
using TweetLib.Core.Serialization; using TweetDuck.Data.Serialization;
namespace TweetDuck.Configuration.Instance{
sealed class FileConfigInstance<T> : IConfigInstance<T> where T : ConfigManager.BaseConfig{
private const string ErrorTitle = "Configuration Error";
namespace TweetLib.Core.Systems.Configuration{
public sealed class FileConfigInstance<T> : IConfigInstance<T> where T : BaseConfig{
public T Instance { get; } public T Instance { get; }
public FileSerializer<T> Serializer { get; } public FileSerializer<T> Serializer { get; }
private readonly string filenameMain; private readonly string filenameMain;
private readonly string filenameBackup; private readonly string filenameBackup;
private readonly string identifier; private readonly string errorIdentifier;
public FileConfigInstance(string filename, T instance, string identifier){ public FileConfigInstance(string filename, T instance, string errorIdentifier){
this.filenameMain = filename; this.filenameMain = filename;
this.filenameBackup = filename+".bak"; this.filenameBackup = filename+".bak";
this.identifier = identifier; this.errorIdentifier = errorIdentifier;
this.Instance = instance; this.Instance = instance;
this.Serializer = new FileSerializer<T>(); this.Serializer = new FileSerializer<T>();
@@ -25,14 +27,14 @@ namespace TweetLib.Core.Systems.Configuration{
} }
public void Load(){ public void Load(){
Exception? firstException = null; Exception firstException = null;
for(int attempt = 0; attempt < 2; attempt++){ for(int attempt = 0; attempt < 2; attempt++){
try{ try{
LoadInternal(attempt > 0); LoadInternal(attempt > 0);
if (firstException != null){ // silently log exception that caused a backup restore if (firstException != null){ // silently log exception that caused a backup restore
App.ErrorHandler.Log(firstException.ToString()); Program.Reporter.LogImportant(firstException.ToString());
} }
return; return;
@@ -47,13 +49,13 @@ namespace TweetLib.Core.Systems.Configuration{
} }
if (firstException is FormatException){ if (firstException is FormatException){
OnException($"The configuration file for {identifier} is outdated or corrupted. If you continue, your {identifier} will be reset.", firstException); Program.Reporter.HandleException(ErrorTitle, "The configuration file for "+errorIdentifier+" is outdated or corrupted. If you continue, your "+errorIdentifier+" will be reset.", true, firstException);
} }
else if (firstException is SerializationSoftException sse){ else if (firstException is SerializationSoftException sse){
OnException($"{sse.Errors.Count} error{(sse.Errors.Count == 1 ? " was" : "s were")} encountered while loading the configuration file for {identifier}. If you continue, some of your {identifier} will be reset.", firstException); Program.Reporter.HandleException(ErrorTitle, $"{sse.Errors.Count} error{(sse.Errors.Count == 1 ? " was" : "s were")} encountered while loading the configuration file for "+errorIdentifier+". If you continue, some of your "+errorIdentifier+" will be reset.", true, firstException);
} }
else if (firstException != null){ else if (firstException != null){
OnException($"Could not open the configuration file for {identifier}. If you continue, your {identifier} will be reset.", firstException); Program.Reporter.HandleException(ErrorTitle, "Could not open the configuration file for "+errorIdentifier+". If you continue, your "+errorIdentifier+" will be reset.", true, firstException);
} }
} }
@@ -66,9 +68,9 @@ namespace TweetLib.Core.Systems.Configuration{
Serializer.Write(filenameMain, Instance); Serializer.Write(filenameMain, Instance);
}catch(SerializationSoftException e){ }catch(SerializationSoftException e){
OnException($"{e.Errors.Count} error{(e.Errors.Count == 1 ? " was" : "s were")} encountered while saving the configuration file for {identifier}.", e); Program.Reporter.HandleException(ErrorTitle, $"{e.Errors.Count} error{(e.Errors.Count == 1 ? " was" : "s were")} encountered while saving the configuration file for "+errorIdentifier+".", true, e);
}catch(Exception e){ }catch(Exception e){
OnException($"Could not save the configuration file for {identifier}.", e); Program.Reporter.HandleException(ErrorTitle, "Could not save the configuration file for "+errorIdentifier+".", true, e);
} }
} }
@@ -80,10 +82,10 @@ namespace TweetLib.Core.Systems.Configuration{
Serializer.Write(filenameMain, Instance.ConstructWithDefaults<T>()); Serializer.Write(filenameMain, Instance.ConstructWithDefaults<T>());
LoadInternal(false); LoadInternal(false);
}catch(Exception e){ }catch(Exception e){
OnException($"Could not regenerate the configuration file for {identifier}.", e); Program.Reporter.HandleException(ErrorTitle, "Could not regenerate the configuration file for "+errorIdentifier+".", true, e);
} }
}catch(Exception e){ }catch(Exception e){
OnException($"Could not reload the configuration file for {identifier}.", e); Program.Reporter.HandleException(ErrorTitle, "Could not reload the configuration file for "+errorIdentifier+".", true, e);
} }
} }
@@ -92,15 +94,11 @@ namespace TweetLib.Core.Systems.Configuration{
File.Delete(filenameMain); File.Delete(filenameMain);
File.Delete(filenameBackup); File.Delete(filenameBackup);
}catch(Exception e){ }catch(Exception e){
OnException($"Could not delete configuration files to reset {identifier}.", e); Program.Reporter.HandleException(ErrorTitle, "Could not delete configuration files to reset "+errorIdentifier+".", true, e);
return; return;
} }
Reload(); Reload();
} }
private static void OnException(string message, Exception e){
App.ErrorHandler.HandleException("Configuration Error", message, true, e);
}
} }
} }

View File

@@ -1,5 +1,5 @@
namespace TweetLib.Core.Systems.Configuration{ namespace TweetDuck.Configuration.Instance{
public interface IConfigInstance<out T>{ interface IConfigInstance<out T>{
T Instance { get; } T Instance { get; }
void Save(); void Save();

View File

@@ -0,0 +1,69 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace TweetDuck.Configuration.Instance{
class PluginConfigInstance : IConfigInstance<PluginConfig>{
public PluginConfig Instance { get; }
private readonly string filename;
public PluginConfigInstance(string filename, PluginConfig instance){
this.filename = filename;
this.Instance = instance;
}
public void Load(){
try{
using(StreamReader reader = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read), Encoding.UTF8)){
string line = reader.ReadLine();
if (line == "#Disabled"){
HashSet<string> newDisabled = new HashSet<string>();
while((line = reader.ReadLine()) != null){
newDisabled.Add(line);
}
Instance.ReloadSilently(newDisabled);
}
}
}catch(FileNotFoundException){
}catch(DirectoryNotFoundException){
}catch(Exception e){
Program.Reporter.HandleException("Plugin Configuration Error", "Could not read the plugin configuration file. If you continue, the list of disabled plugins will be reset to default.", true, e);
}
}
public void Save(){
try{
using(StreamWriter writer = new StreamWriter(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None), Encoding.UTF8)){
writer.WriteLine("#Disabled");
foreach(string identifier in Instance.DisabledPlugins){
writer.WriteLine(identifier);
}
}
}catch(Exception e){
Program.Reporter.HandleException("Plugin Configuration Error", "Could not save the plugin configuration file.", true, e);
}
}
public void Reload(){
Load();
}
public void Reset(){
try{
File.Delete(filename);
Instance.ReloadSilently(Instance.ConstructWithDefaults<PluginConfig>().DisabledPlugins);
}catch(Exception e){
Program.Reporter.HandleException("Plugin Configuration Error", "Could not delete the plugin configuration file.", true, e);
return;
}
Reload();
}
}
}

View File

@@ -1,11 +1,12 @@
using System; using System;
using System.ComponentModel;
using System.Diagnostics; using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Threading; using System.Threading;
using TweetDuck.Core.Utils;
namespace TweetLib.Core.Systems.Startup{ namespace TweetDuck.Configuration{
public sealed class LockManager{ sealed class LockManager{
private const int RetryDelay = 250; private const int RetryDelay = 250;
public enum Result{ public enum Result{
@@ -13,8 +14,8 @@ namespace TweetLib.Core.Systems.Startup{
} }
private readonly string file; private readonly string file;
private FileStream? lockStream; private FileStream lockStream;
private Process? lockingProcess; private Process lockingProcess;
public LockManager(string file){ public LockManager(string file){
this.file = file; this.file = file;
@@ -36,7 +37,7 @@ namespace TweetLib.Core.Systems.Startup{
private Result TryCreateLockFile(){ private Result TryCreateLockFile(){
void CreateLockFileStream(){ void CreateLockFileStream(){
lockStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.Read); lockStream = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.Read);
lockStream.Write(BitConverter.GetBytes(CurrentProcessID), 0, sizeof(int)); lockStream.Write(BitConverter.GetBytes(WindowsUtils.CurrentProcessID), 0, sizeof(int));
lockStream.Flush(true); lockStream.Flush(true);
} }
@@ -81,12 +82,14 @@ namespace TweetLib.Core.Systems.Startup{
try{ try{
Process foundProcess = Process.GetProcessById(pid); Process foundProcess = Process.GetProcessById(pid);
if (MatchesCurrentProcess(foundProcess)){ using(Process currentProcess = Process.GetCurrentProcess()){
if (foundProcess.MainModule.FileVersionInfo.InternalName == currentProcess.MainModule.FileVersionInfo.InternalName){
lockingProcess = foundProcess; lockingProcess = foundProcess;
} }
else{ else{
foundProcess.Close(); foundProcess.Close();
} }
}
}catch{ }catch{
// GetProcessById throws ArgumentException if the process is missing // GetProcessById throws ArgumentException if the process is missing
// Process.MainModule can throw exceptions in some cases // Process.MainModule can throw exceptions in some cases
@@ -121,7 +124,7 @@ namespace TweetLib.Core.Systems.Startup{
try{ try{
File.Delete(file); File.Delete(file);
}catch(Exception e){ }catch(Exception e){
App.ErrorHandler.Log(e.ToString()); Program.Reporter.LogImportant(e.ToString());
return false; return false;
} }
} }
@@ -131,32 +134,50 @@ namespace TweetLib.Core.Systems.Startup{
// Locking process // Locking process
public bool RestoreLockingProcess(){ public bool RestoreLockingProcess(int failTimeout){
return lockingProcess != null && App.LockHandler.RestoreProcess(lockingProcess); if (lockingProcess != null && lockingProcess.MainWindowHandle == IntPtr.Zero){ // restore if the original process is in tray
} NativeMethods.BroadcastMessage(Program.WindowRestoreMessage, (uint)lockingProcess.Id, 0);
public bool CloseLockingProcess(){ if (WindowsUtils.TrySleepUntil(() => CheckLockingProcessExited() || (lockingProcess.MainWindowHandle != IntPtr.Zero && lockingProcess.Responding), failTimeout, RetryDelay)){
if (lockingProcess != null && App.LockHandler.CloseProcess(lockingProcess)){
lockingProcess = null;
return true; return true;
} }
}
return false; return false;
} }
// Utilities public bool CloseLockingProcess(int closeTimeout, int killTimeout){
if (lockingProcess != null){
try{
if (lockingProcess.CloseMainWindow()){
WindowsUtils.TrySleepUntil(CheckLockingProcessExited, closeTimeout, RetryDelay);
}
private static int CurrentProcessID{ if (!lockingProcess.HasExited){
get{ lockingProcess.Kill();
using Process me = Process.GetCurrentProcess(); WindowsUtils.TrySleepUntil(CheckLockingProcessExited, killTimeout, RetryDelay);
return me.Id; }
if (lockingProcess.HasExited){
lockingProcess.Dispose();
lockingProcess = null;
return true;
}
}catch(Exception ex) when (ex is InvalidOperationException || ex is Win32Exception){
if (lockingProcess != null){
bool hasExited = CheckLockingProcessExited();
lockingProcess.Dispose();
return hasExited;
}
} }
} }
[SuppressMessage("ReSharper", "PossibleNullReferenceException")] return false;
private static bool MatchesCurrentProcess(Process process){ }
using Process current = Process.GetCurrentProcess();
return current.MainModule.FileVersionInfo.InternalName == process.MainModule.FileVersionInfo.InternalName; private bool CheckLockingProcessExited(){
lockingProcess.Refresh();
return lockingProcess.HasExited;
} }
} }
} }

View File

@@ -1,42 +1,21 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using TweetLib.Core.Features.Plugins; using TweetDuck.Plugins;
using TweetLib.Core.Features.Plugins.Config; using TweetDuck.Plugins.Events;
using TweetLib.Core.Features.Plugins.Events;
using TweetLib.Core.Systems.Configuration;
namespace TweetDuck.Configuration{ namespace TweetDuck.Configuration{
sealed class PluginConfig : BaseConfig, IPluginConfig{ sealed class PluginConfig : ConfigManager.BaseConfig, IPluginConfig{
private static readonly string[] DefaultDisabled = { private static readonly string[] DefaultDisabled = {
"official/clear-columns", "official/clear-columns",
"official/reply-account" "official/reply-account"
}; };
// CONFIGURATION DATA // CONFIGURATION
private readonly HashSet<string> disabled = new HashSet<string>(DefaultDisabled); public IEnumerable<string> DisabledPlugins => disabled;
// EVENTS
public event EventHandler<PluginChangedStateEventArgs> PluginChangedState; public event EventHandler<PluginChangedStateEventArgs> PluginChangedState;
// END OF CONFIG
public PluginConfig(IConfigManager configManager) : base(configManager){}
protected override BaseConfig ConstructWithDefaults(IConfigManager configManager){
return new PluginConfig(configManager);
}
// INTERFACE IMPLEMENTATION
IEnumerable<string> IPluginConfig.DisabledPlugins => disabled;
void IPluginConfig.Reset(IEnumerable<string> newDisabledPlugins){
disabled.Clear();
disabled.UnionWith(newDisabledPlugins);
}
public void SetEnabled(Plugin plugin, bool enabled){ public void SetEnabled(Plugin plugin, bool enabled){
if ((enabled && disabled.Remove(plugin.Identifier)) || (!enabled && disabled.Add(plugin.Identifier))){ if ((enabled && disabled.Remove(plugin.Identifier)) || (!enabled && disabled.Add(plugin.Identifier))){
PluginChangedState?.Invoke(this, new PluginChangedStateEventArgs(plugin, enabled)); PluginChangedState?.Invoke(this, new PluginChangedStateEventArgs(plugin, enabled));
@@ -47,5 +26,20 @@ namespace TweetDuck.Configuration{
public bool IsEnabled(Plugin plugin){ public bool IsEnabled(Plugin plugin){
return !disabled.Contains(plugin.Identifier); return !disabled.Contains(plugin.Identifier);
} }
public void ReloadSilently(IEnumerable<string> newDisabled){
disabled.Clear();
disabled.UnionWith(newDisabled);
}
private readonly HashSet<string> disabled = new HashSet<string>(DefaultDisabled);
// END OF CONFIG
public PluginConfig(ConfigManager configManager) : base(configManager){}
protected override ConfigManager.BaseConfig ConstructWithDefaults(ConfigManager configManager){
return new PluginConfig(configManager);
}
} }
} }

View File

@@ -1,7 +1,5 @@
using TweetLib.Core.Systems.Configuration; namespace TweetDuck.Configuration{
sealed class SystemConfig : ConfigManager.BaseConfig{
namespace TweetDuck.Configuration{
sealed class SystemConfig : BaseConfig{
// CONFIGURATION DATA // CONFIGURATION DATA
@@ -19,9 +17,9 @@ namespace TweetDuck.Configuration{
// END OF CONFIG // END OF CONFIG
public SystemConfig(IConfigManager configManager) : base(configManager){} public SystemConfig(ConfigManager configManager) : base(configManager){}
protected override BaseConfig ConstructWithDefaults(IConfigManager configManager){ protected override ConfigManager.BaseConfig ConstructWithDefaults(ConfigManager configManager){
return new SystemConfig(configManager); return new SystemConfig(configManager);
} }
} }

View File

@@ -1,14 +1,13 @@
using System; using System;
using System.Drawing; using System.Drawing;
using TweetDuck.Browser; using TweetDuck.Core.Controls;
using TweetDuck.Browser.Data; using TweetDuck.Core.Notification;
using TweetDuck.Controls; using TweetDuck.Core.Other;
using TweetLib.Core.Features.Notifications; using TweetDuck.Core.Utils;
using TweetLib.Core.Features.Twitter; using TweetDuck.Data;
using TweetLib.Core.Systems.Configuration;
namespace TweetDuck.Configuration{ namespace TweetDuck.Configuration{
sealed class UserConfig : BaseConfig{ sealed class UserConfig : ConfigManager.BaseConfig{
// CONFIGURATION DATA // CONFIGURATION DATA
@@ -30,20 +29,16 @@ namespace TweetDuck.Configuration{
private string _customCefArgs = null; private string _customCefArgs = null;
public string BrowserPath { get; set; } = null; public string BrowserPath { get; set; } = null;
public string BrowserPathArgs { get; set; } = null;
public bool IgnoreTrackingUrlWarning { get; set; } = false; public bool IgnoreTrackingUrlWarning { get; set; } = false;
public string SearchEngineUrl { get; set; } = null; public string SearchEngineUrl { get; set; } = null;
private int _zoomLevel = 100; private int _zoomLevel = 100;
public string VideoPlayerPath { get; set; } = null;
public string VideoPlayerPathArgs { get; set; } = null;
public int VideoPlayerVolume { get; set; } = 50; public int VideoPlayerVolume { get; set; } = 50;
public bool EnableSpellCheck { get; set; } = false; public bool EnableSpellCheck { get; set; } = false;
private string _spellCheckLanguage = "en-US"; private string _spellCheckLanguage = "en-US";
public string TranslationTarget { get; set; } = "en"; public string TranslationTarget { get; set; } = "en";
public int CalendarFirstDay { get; set; } = -1;
private TrayIcon.Behavior _trayBehavior = TrayIcon.Behavior.Disabled; private TrayIcon.Behavior _trayBehavior = TrayIcon.Behavior.Disabled;
public bool EnableTrayHighlight { get; set; } = true; public bool EnableTrayHighlight { get; set; } = true;
@@ -61,13 +56,12 @@ namespace TweetDuck.Configuration{
public bool NotificationTimerCountDown { get; set; } = false; public bool NotificationTimerCountDown { get; set; } = false;
public int NotificationDurationValue { get; set; } = 25; public int NotificationDurationValue { get; set; } = 25;
public DesktopNotification.Position NotificationPosition { get; set; } = DesktopNotification.Position.TopRight; public TweetNotification.Position NotificationPosition { get; set; } = TweetNotification.Position.TopRight;
public Point CustomNotificationPosition { get; set; } = ControlExtensions.InvisibleLocation; public Point CustomNotificationPosition { get; set; } = ControlExtensions.InvisibleLocation;
public int NotificationDisplay { get; set; } = 0; public int NotificationDisplay { get; set; } = 0;
public int NotificationEdgeDistance { get; set; } = 8; public int NotificationEdgeDistance { get; set; } = 8;
public int NotificationWindowOpacity { get; set; } = 100;
public DesktopNotification.Size NotificationSize { get; set; } = DesktopNotification.Size.Auto; public TweetNotification.Size NotificationSize { get; set; } = TweetNotification.Size.Auto;
public Size CustomNotificationSize { get; set; } = Size.Empty; public Size CustomNotificationSize { get; set; } = Size.Empty;
public int NotificationScrollSpeed { get; set; } = 100; public int NotificationScrollSpeed { get; set; } = 100;
@@ -79,15 +73,13 @@ namespace TweetDuck.Configuration{
public string CustomBrowserCSS { get; set; } = null; public string CustomBrowserCSS { get; set; } = null;
public string CustomNotificationCSS { get; set; } = null; public string CustomNotificationCSS { get; set; } = null;
public bool DevToolsWindowOnTop { get; set; } = true;
// SPECIAL PROPERTIES // SPECIAL PROPERTIES
public bool IsCustomNotificationPositionSet => CustomNotificationPosition != ControlExtensions.InvisibleLocation; public bool IsCustomNotificationPositionSet => CustomNotificationPosition != ControlExtensions.InvisibleLocation;
public bool IsCustomNotificationSizeSet => CustomNotificationSize != Size.Empty; public bool IsCustomNotificationSizeSet => CustomNotificationSize != Size.Empty;
public bool IsCustomSoundNotificationSet => NotificationSoundPath != string.Empty; public bool IsCustomSoundNotificationSet => NotificationSoundPath != string.Empty;
public ImageQuality TwitterImageQuality => BestImageQuality ? ImageQuality.Best : ImageQuality.Default; public TwitterUtils.ImageQuality TwitterImageQuality => BestImageQuality ? TwitterUtils.ImageQuality.Orig : TwitterUtils.ImageQuality.Default;
public string NotificationSoundPath{ public string NotificationSoundPath{
get => _notificationSoundPath ?? string.Empty; get => _notificationSoundPath ?? string.Empty;
@@ -143,9 +135,9 @@ namespace TweetDuck.Configuration{
// END OF CONFIG // END OF CONFIG
public UserConfig(IConfigManager configManager) : base(configManager){} public UserConfig(ConfigManager configManager) : base(configManager){}
protected override BaseConfig ConstructWithDefaults(IConfigManager configManager){ protected override ConfigManager.BaseConfig ConstructWithDefaults(ConfigManager configManager){
return new UserConfig(configManager); return new UserConfig(configManager);
} }
} }

View File

@@ -1,22 +0,0 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace TweetDuck.Controls{
sealed class LabelVertical : Label{
public int LineHeight { get; set; }
protected override void OnPaint(PaintEventArgs e){
int y = (int)Math.Floor((ClientRectangle.Height - Text.Length * LineHeight) / 2F) - 1;
using Brush brush = new SolidBrush(ForeColor);
foreach(char chr in Text){
string str = chr.ToString();
float x = (ClientRectangle.Width - e.Graphics.MeasureString(str, Font).Width) / 2F;
e.Graphics.DrawString(str, Font, brush, x, y);
y += LineHeight;
}
}
}
}

View File

@@ -1,20 +1,18 @@
using System.Text; using System.Text;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetLib.Core;
using TweetLib.Core.Utils;
namespace TweetDuck.Browser.Bridge{ namespace TweetDuck.Core.Bridge{
static class PropertyBridge{ static class PropertyBridge{
public enum Environment{ public enum Environment{
Browser, Notification Browser, Notification
} }
public static string GenerateScript(Environment environment){ public static string GenerateScript(Environment environment){
static string Bool(bool value) => value ? "true;" : "false;"; string Bool(bool value) => value ? "true;" : "false;";
static string Str(string value) => $"\"{value}\";"; string Str(string value) => '"'+value+"\";";
UserConfig config = Program.Config.User; UserConfig config = Program.Config.User;
StringBuilder build = new StringBuilder(384).Append("(function(x){"); StringBuilder build = new StringBuilder(128).Append("(function(x){");
build.Append("x.expandLinksOnHover=").Append(Bool(config.ExpandLinksOnHover)); build.Append("x.expandLinksOnHover=").Append(Bool(config.ExpandLinksOnHover));
@@ -25,14 +23,13 @@ namespace TweetDuck.Browser.Bridge{
build.Append("x.muteNotifications=").Append(Bool(config.MuteNotifications)); build.Append("x.muteNotifications=").Append(Bool(config.MuteNotifications));
build.Append("x.notificationMediaPreviews=").Append(Bool(config.NotificationMediaPreviews)); build.Append("x.notificationMediaPreviews=").Append(Bool(config.NotificationMediaPreviews));
build.Append("x.translationTarget=").Append(Str(config.TranslationTarget)); build.Append("x.translationTarget=").Append(Str(config.TranslationTarget));
build.Append("x.firstDayOfWeek=").Append(config.CalendarFirstDay == -1 ? LocaleUtils.GetJQueryDayOfWeek(Lib.Culture.DateTimeFormat.FirstDayOfWeek) : config.CalendarFirstDay);
} }
if (environment == Environment.Notification){ if (environment == Environment.Notification){
build.Append("x.skipOnLinkClick=").Append(Bool(config.NotificationSkipOnLinkClick)); build.Append("x.skipOnLinkClick=").Append(Bool(config.NotificationSkipOnLinkClick));
} }
return build.Append("})(window.$TDX=window.$TDX||{});if(window.TDGF_onPropertiesUpdated)window.TDGF_onPropertiesUpdated()").ToString(); return build.Append("})(window.$TDX=window.$TDX||{})").ToString();
} }
} }
} }

View File

@@ -1,23 +1,18 @@
using System; using System.Windows.Forms;
using System.Diagnostics.CodeAnalysis; using TweetDuck.Core.Controls;
using System.Threading.Tasks; using TweetDuck.Core.Management;
using System.Windows.Forms; using TweetDuck.Core.Notification;
using CefSharp; using TweetDuck.Core.Other;
using TweetDuck.Browser.Handling; using TweetDuck.Core.Utils;
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.Browser.Bridge{ namespace TweetDuck.Core.Bridge{
[SuppressMessage("ReSharper", "UnusedMember.Global")]
class TweetDeckBridge{ class TweetDeckBridge{
public static string FontSize { get; private set; }
public static string NotificationHeadLayout { get; private set; }
public static readonly ContextInfo ContextInfo = new ContextInfo();
public static void ResetStaticProperties(){ public static void ResetStaticProperties(){
FormNotificationBase.FontSize = null; FontSize = NotificationHeadLayout = null;
FormNotificationBase.HeadLayout = null;
} }
private readonly FormBrowser form; private readonly FormBrowser form;
@@ -42,22 +37,24 @@ namespace TweetDuck.Browser.Bridge{
} }
public void OnIntroductionClosed(bool showGuide, bool allowDataCollection){ 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){ public void LoadNotificationLayout(string fontSize, string headLayout){
form.InvokeAsyncSafe(() => { form.InvokeAsyncSafe(() => {
FormNotificationBase.FontSize = fontSize; FontSize = fontSize;
FormNotificationBase.HeadLayout = headLayout; NotificationHeadLayout = headLayout;
}); });
} }
public void SetRightClickedLink(string type, string url){ public void SetRightClickedLink(string type, string url){
ContextMenuBase.CurrentInfo.SetLink(type, url); ContextInfo.SetLink(type, url);
} }
public void SetRightClickedChirp(string tweetUrl, string quoteUrl, string chirpAuthors, string chirpImages){ public void SetRightClickedChirp(string tweetUrl, string quoteUrl, string chirpAuthors, string chirpImages){
ContextMenuBase.CurrentInfo.SetChirp(tweetUrl, quoteUrl, chirpAuthors, chirpImages); ContextInfo.SetChirp(tweetUrl, quoteUrl, chirpAuthors, chirpImages);
} }
public void DisplayTooltip(string text){ public void DisplayTooltip(string text){
@@ -88,7 +85,7 @@ namespace TweetDuck.Browser.Bridge{
public void OnTweetPopup(string columnId, string chirpId, string columnName, string tweetHtml, int tweetCharacters, string tweetUrl, string quoteUrl){ public void OnTweetPopup(string columnId, string chirpId, string columnName, string tweetHtml, int tweetCharacters, string tweetUrl, string quoteUrl){
notification.InvokeAsyncSafe(() => { notification.InvokeAsyncSafe(() => {
form.OnTweetNotification(); form.OnTweetNotification();
notification.ShowNotification(new DesktopNotification(columnId, chirpId, columnName, tweetHtml, tweetCharacters, tweetUrl, quoteUrl)); notification.ShowNotification(new TweetNotification(columnId, chirpId, columnName, tweetHtml, tweetCharacters, tweetUrl, quoteUrl));
}); });
} }
@@ -103,50 +100,31 @@ namespace TweetDuck.Browser.Bridge{
form.InvokeAsyncSafe(() => form.OnTweetScreenshotReady(html, width)); form.InvokeAsyncSafe(() => form.OnTweetScreenshotReady(html, width));
} }
public void PlayVideo(string videoUrl, string tweetUrl, string username, IJavascriptCallback callShowOverlay){ public void PlayVideo(string url, string username){
form.InvokeAsyncSafe(() => form.PlayVideo(videoUrl, tweetUrl, username, callShowOverlay)); form.InvokeAsyncSafe(() => form.PlayVideo(url, username));
}
public void StopVideo(){
form.InvokeAsyncSafe(form.StopVideo);
} }
public void FixClipboard(){ public void FixClipboard(){
form.InvokeAsyncSafe(ClipboardManager.StripHtmlStyles); form.InvokeAsyncSafe(WindowsUtils.ClipboardStripHtmlStyles);
} }
public void OpenBrowser(string url){ public void OpenBrowser(string url){
form.InvokeAsyncSafe(() => BrowserUtils.OpenExternalBrowser(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(){ public int GetIdleSeconds(){
return NativeMethods.GetIdleSeconds(); return NativeMethods.GetIdleSeconds();
} }
public void Alert(string type, string contents){ public void Alert(string type, string contents){
MessageBoxIcon icon = type switch{ MessageBoxIcon icon;
"error" => MessageBoxIcon.Error,
"warning" => MessageBoxIcon.Warning, switch(type){
"info" => MessageBoxIcon.Information, case "error": icon = MessageBoxIcon.Error; break;
_ => MessageBoxIcon.None case "warning": icon = MessageBoxIcon.Warning; break;
}; case "info": icon = MessageBoxIcon.Information; break;
default: icon = MessageBoxIcon.None; break;
}
FormMessage.Show("TweetDuck Browser Message", contents, icon, FormMessage.OK); FormMessage.Show("TweetDuck Browser Message", contents, icon, FormMessage.OK);
} }

View File

@@ -1,11 +1,9 @@
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetLib.Core.Systems.Updates; using TweetDuck.Updates;
namespace TweetDuck.Browser.Bridge{ namespace TweetDuck.Core.Bridge{
[SuppressMessage("ReSharper", "UnusedMember.Global")]
class UpdateBridge{ class UpdateBridge{
private readonly UpdateHandler updates; private readonly UpdateHandler updates;
private readonly Control sync; private readonly Control sync;
@@ -13,6 +11,7 @@ namespace TweetDuck.Browser.Bridge{
private UpdateInfo nextUpdate = null; private UpdateInfo nextUpdate = null;
public event EventHandler<UpdateInfo> UpdateAccepted; public event EventHandler<UpdateInfo> UpdateAccepted;
public event EventHandler<UpdateInfo> UpdateDelayed;
public event EventHandler<UpdateInfo> UpdateDismissed; public event EventHandler<UpdateInfo> UpdateDismissed;
public UpdateBridge(UpdateHandler updates, Control sync){ public UpdateBridge(UpdateHandler updates, Control sync){
@@ -55,6 +54,10 @@ namespace TweetDuck.Browser.Bridge{
HandleInteractionEvent(UpdateAccepted); HandleInteractionEvent(UpdateAccepted);
} }
public void OnUpdateDelayed(){
HandleInteractionEvent(UpdateDelayed);
}
public void OnUpdateDismissed(){ public void OnUpdateDismissed(){
HandleInteractionEvent(UpdateDismissed); HandleInteractionEvent(UpdateDismissed);

View File

@@ -3,7 +3,7 @@ using System.Drawing;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDuck.Controls{ namespace TweetDuck.Core.Controls{
static class ControlExtensions{ static class ControlExtensions{
public static readonly Point InvisibleLocation = new Point(-32000, -32000); public static readonly Point InvisibleLocation = new Point(-32000, -32000);
@@ -21,16 +21,17 @@ namespace TweetDuck.Controls{
} }
public static float GetDPIScale(this Control control){ public static float GetDPIScale(this Control control){
using Graphics graphics = control.CreateGraphics(); using(Graphics graphics = control.CreateGraphics()){
return graphics.DpiY/96F; return graphics.DpiY/96F;
} }
}
public static bool IsFullyOutsideView(this Form form){ public static bool IsFullyOutsideView(this Form form){
return !Screen.AllScreens.Any(screen => screen.WorkingArea.IntersectsWith(form.Bounds)); return !Screen.AllScreens.Any(screen => screen.WorkingArea.IntersectsWith(form.Bounds));
} }
public static void MoveToCenter(this Form targetForm, Form parentForm){ public static void MoveToCenter(this Form targetForm, Form parentForm){
targetForm.Location = new Point(parentForm.Location.X + (parentForm.Width / 2) - (targetForm.Width / 2), parentForm.Location.Y + (parentForm.Height / 2) - (targetForm.Height / 2)); targetForm.Location = new Point(parentForm.Location.X+parentForm.Width/2-targetForm.Width/2, parentForm.Location.Y+parentForm.Height/2-targetForm.Height/2);
} }
public static void SetValueInstant(this ProgressBar bar, int value){ public static void SetValueInstant(this ProgressBar bar, int value){
@@ -62,8 +63,7 @@ namespace TweetDuck.Controls{
trackBar.Value = trackBar.SmallChange*(int)Math.Floor(((double)trackBar.Value/trackBar.SmallChange)+0.5); trackBar.Value = trackBar.SmallChange*(int)Math.Floor(((double)trackBar.Value/trackBar.SmallChange)+0.5);
return false; return false;
} }
else return true;
return true;
} }
public static void EnableMultilineShortcuts(this TextBox textBox){ public static void EnableMultilineShortcuts(this TextBox textBox){

View File

@@ -1,7 +1,7 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDuck.Controls{ namespace TweetDuck.Core.Controls{
sealed class FlatButton : Button{ sealed class FlatButton : Button{
protected override bool ShowFocusCues => false; protected override bool ShowFocusCues => false;

View File

@@ -2,7 +2,7 @@
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDuck.Controls{ namespace TweetDuck.Core.Controls{
sealed class FlatProgressBar : ProgressBar{ sealed class FlatProgressBar : ProgressBar{
private readonly SolidBrush brush; private readonly SolidBrush brush;

View File

@@ -0,0 +1,23 @@
using System;
using System.Drawing;
using System.Windows.Forms;
namespace TweetDuck.Core.Controls{
sealed class LabelVertical : Label{
public int LineHeight { get; set; }
protected override void OnPaint(PaintEventArgs e){
int y = (int)Math.Floor((ClientRectangle.Height-Text.Length*LineHeight)/2F)-1;
using(Brush brush = new SolidBrush(ForeColor)){
foreach(char chr in Text){
string str = chr.ToString();
float x = (ClientRectangle.Width-e.Graphics.MeasureString(str, Font).Width)/2F;
e.Graphics.DrawString(str, Font, brush, x, y);
y += LineHeight;
}
}
}
}
}

View File

@@ -1,7 +1,7 @@
using System.ComponentModel; using System.ComponentModel;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDuck.Controls{ namespace TweetDuck.Core.Controls{
sealed class NumericUpDownEx : NumericUpDown{ sealed class NumericUpDownEx : NumericUpDown{
public string TextSuffix { get; set ; } public string TextSuffix { get; set ; }

View File

@@ -1,10 +1,21 @@
namespace TweetDuck.Browser { namespace TweetDuck.Core {
sealed partial class FormBrowser { sealed partial class FormBrowser {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; 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 #region Windows Form Designer generated code
/// <summary> /// <summary>
@@ -13,7 +24,7 @@
/// </summary> /// </summary>
private void InitializeComponent() { private void InitializeComponent() {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.trayIcon = new TrayIcon(this.components); this.trayIcon = new TweetDuck.Core.Other.TrayIcon(this.components);
this.toolTip = new System.Windows.Forms.ToolTip(this.components); this.toolTip = new System.Windows.Forms.ToolTip(this.components);
this.timerResize = new System.Windows.Forms.Timer(this.components); this.timerResize = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout(); this.SuspendLayout();
@@ -27,10 +38,10 @@
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = TweetDuck.Utils.TwitterUtils.BackgroundColor; this.BackColor = TweetDuck.Core.Utils.TwitterUtils.BackgroundColor;
this.ClientSize = new System.Drawing.Size(1008, 730); this.ClientSize = new System.Drawing.Size(1008, 730);
this.Icon = Properties.Resources.icon; this.Icon = Properties.Resources.icon;
this.Location = TweetDuck.Controls.ControlExtensions.InvisibleLocation; this.Location = TweetDuck.Core.Controls.ControlExtensions.InvisibleLocation;
this.MinimumSize = new System.Drawing.Size(348, 424); this.MinimumSize = new System.Drawing.Size(348, 424);
this.Name = "FormBrowser"; this.Name = "FormBrowser";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual; this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
@@ -46,7 +57,7 @@
#endregion #endregion
private TrayIcon trayIcon; private TweetDuck.Core.Other.TrayIcon trayIcon;
private System.Windows.Forms.ToolTip toolTip; private System.Windows.Forms.ToolTip toolTip;
private System.Windows.Forms.Timer timerResize; private System.Windows.Forms.Timer timerResize;
} }

View File

@@ -1,28 +1,25 @@
using System; using System;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp; using Microsoft.WindowsAPICodePack.Taskbar;
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.Configuration;
using TweetDuck.Controls; using TweetDuck.Core.Bridge;
using TweetDuck.Dialogs; using TweetDuck.Core.Controls;
using TweetDuck.Dialogs.Settings; using TweetDuck.Core.Handling;
using TweetDuck.Management; using TweetDuck.Core.Handling.General;
using TweetDuck.Management.Analytics; using TweetDuck.Core.Management;
using TweetDuck.Core.Notification;
using TweetDuck.Core.Notification.Screenshot;
using TweetDuck.Core.Other;
using TweetDuck.Core.Other.Analytics;
using TweetDuck.Core.Other.Settings.Dialogs;
using TweetDuck.Core.Utils;
using TweetDuck.Plugins;
using TweetDuck.Plugins.Events;
using TweetDuck.Resources;
using TweetDuck.Updates; using TweetDuck.Updates;
using TweetDuck.Utils;
using TweetLib.Core.Features.Plugins;
using TweetLib.Core.Features.Plugins.Events;
using TweetLib.Core.Systems.Updates;
namespace TweetDuck.Browser{ namespace TweetDuck.Core{
sealed partial class FormBrowser : Form, AnalyticsFile.IProvider{ sealed partial class FormBrowser : Form, AnalyticsFile.IProvider{
private static UserConfig Config => Program.Config.User; private static UserConfig Config => Program.Config.User;
@@ -48,15 +45,13 @@ namespace TweetDuck.Browser{
public AnalyticsFile AnalyticsFile => analytics?.File ?? AnalyticsFile.Dummy; public AnalyticsFile AnalyticsFile => analytics?.File ?? AnalyticsFile.Dummy;
#pragma warning disable IDE0069 // Disposable fields should be disposed
private readonly TweetDeckBrowser browser; private readonly TweetDeckBrowser browser;
private readonly FormNotificationTweet notification;
#pragma warning restore IDE0069 // Disposable fields should be disposed
private readonly PluginManager plugins; private readonly PluginManager plugins;
private readonly UpdateHandler updates; private readonly UpdateHandler updates;
private readonly FormNotificationTweet notification;
private readonly ContextMenu contextMenu; private readonly ContextMenu contextMenu;
private readonly UpdateBridge updateBridge; private readonly UpdateBridge updateBridge;
private readonly TaskbarIcon taskbarIcon;
private bool isLoaded; private bool isLoaded;
private FormWindowState prevState; private FormWindowState prevState;
@@ -70,7 +65,7 @@ namespace TweetDuck.Browser{
Text = Program.BrandName; Text = Program.BrandName;
this.plugins = new PluginManager(Program.Config.Plugins, Program.PluginPath, Program.PluginDataPath); this.plugins = new PluginManager(Program.Config.Plugins, Program.PluginPath);
this.plugins.Reloaded += plugins_Reloaded; this.plugins.Reloaded += plugins_Reloaded;
this.plugins.Executed += plugins_Executed; this.plugins.Executed += plugins_Executed;
this.plugins.Reload(); this.plugins.Reload();
@@ -78,11 +73,12 @@ namespace TweetDuck.Browser{
this.notification = new FormNotificationTweet(this, plugins); this.notification = new FormNotificationTweet(this, plugins);
this.notification.Show(); this.notification.Show();
this.updates = new UpdateHandler(new UpdateCheckClient(Program.InstallerPath), TaskScheduler.FromCurrentSynchronizationContext()); this.updates = new UpdateHandler(Program.InstallerPath);
this.updates.CheckFinished += updates_CheckFinished; this.updates.CheckFinished += updates_CheckFinished;
this.updateBridge = new UpdateBridge(updates, this); this.updateBridge = new UpdateBridge(updates, this);
this.updateBridge.UpdateAccepted += updateBridge_UpdateAccepted; this.updateBridge.UpdateAccepted += updateBridge_UpdateAccepted;
this.updateBridge.UpdateDelayed += updateBridge_UpdateDelayed;
this.updateBridge.UpdateDismissed += updateBridge_UpdateDismissed; this.updateBridge.UpdateDismissed += updateBridge_UpdateDismissed;
this.browser = new TweetDeckBrowser(this, plugins, new TweetDeckBridge.Browser(this, notification), updateBridge); this.browser = new TweetDeckBrowser(this, plugins, new TweetDeckBridge.Browser(this, notification), updateBridge);
@@ -90,10 +86,21 @@ namespace TweetDuck.Browser{
Controls.Add(new MenuStrip{ Visible = false }); // fixes Alt freezing the program in Win 10 Anniversary Update Controls.Add(new MenuStrip{ Visible = false }); // fixes Alt freezing the program in Win 10 Anniversary Update
this.taskbarIcon = new TaskbarIcon();
Shown += (sender, args) => taskbarIcon.UpdateIcon();
Disposed += (sender, args) => { Disposed += (sender, args) => {
Config.MuteToggled -= Config_MuteToggled; Config.MuteToggled -= Config_MuteToggled;
Config.TrayBehaviorChanged -= Config_TrayBehaviorChanged; Config.TrayBehaviorChanged -= Config_TrayBehaviorChanged;
browser.Dispose(); browser.Dispose();
updates.Dispose();
contextMenu.Dispose();
taskbarIcon.Dispose();
notificationScreenshotManager?.Dispose();
videoPlayer?.Dispose();
analytics?.Dispose();
}; };
Config.MuteToggled += Config_MuteToggled; Config.MuteToggled += Config_MuteToggled;
@@ -104,10 +111,6 @@ namespace TweetDuck.Browser{
UpdateTray(); UpdateTray();
if (Config.MuteNotifications){
UpdateFormIcon();
}
if (Config.AllowDataCollection){ if (Config.AllowDataCollection){
analytics = new AnalyticsManager(this, plugins, Program.AnalyticsFilePath); analytics = new AnalyticsManager(this, plugins, Program.AnalyticsFilePath);
} }
@@ -115,21 +118,6 @@ namespace TweetDuck.Browser{
RestoreWindow(); 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){ private void ShowChildForm(Form form){
form.VisibleChanged += (sender, args) => form.MoveToCenter(this); form.VisibleChanged += (sender, args) => form.MoveToCenter(this);
form.Show(this); form.Show(this);
@@ -148,10 +136,6 @@ namespace TweetDuck.Browser{
isLoaded = true; isLoaded = true;
} }
private void UpdateFormIcon(){ // TODO fix to show icon in taskbar too
Icon = Config.MuteNotifications ? Properties.Resources.icon_muted : Properties.Resources.icon;
}
private void UpdateTray(){ private void UpdateTray(){
trayIcon.Visible = Config.TrayBehavior.ShouldDisplayIcon(); trayIcon.Visible = Config.TrayBehavior.ShouldDisplayIcon();
} }
@@ -163,11 +147,10 @@ namespace TweetDuck.Browser{
} }
private void FormBrowser_Activated(object sender, EventArgs e){ private void FormBrowser_Activated(object sender, EventArgs e){
if (!isLoaded){ if (!isLoaded)return;
return;
}
trayIcon.HasNotifications = false; trayIcon.HasNotifications = false;
taskbarIcon.HasNotifications = false;
if (!browser.Enabled){ // when taking a screenshot, the window is unfocused and if (!browser.Enabled){ // when taking a screenshot, the window is unfocused and
browser.Enabled = true; // the browser is disabled; if the user clicks back into browser.Enabled = true; // the browser is disabled; if the user clicks back into
@@ -175,18 +158,14 @@ namespace TweetDuck.Browser{
} }
private void FormBrowser_LocationChanged(object sender, EventArgs e){ private void FormBrowser_LocationChanged(object sender, EventArgs e){
if (!isLoaded){ if (!isLoaded)return;
return;
}
timerResize.Stop(); timerResize.Stop();
timerResize.Start(); timerResize.Start();
} }
private void FormBrowser_Resize(object sender, EventArgs e){ private void FormBrowser_Resize(object sender, EventArgs e){
if (!isLoaded){ if (!isLoaded)return;
return;
}
if (WindowState != prevState){ if (WindowState != prevState){
prevState = WindowState; prevState = WindowState;
@@ -207,9 +186,7 @@ namespace TweetDuck.Browser{
} }
private void FormBrowser_ResizeEnd(object sender, EventArgs e){ // also triggers when the window moves private void FormBrowser_ResizeEnd(object sender, EventArgs e){ // also triggers when the window moves
if (!isLoaded){ if (!isLoaded)return;
return;
}
timerResize.Stop(); timerResize.Stop();
@@ -220,9 +197,7 @@ namespace TweetDuck.Browser{
} }
private void FormBrowser_FormClosing(object sender, FormClosingEventArgs e){ private void FormBrowser_FormClosing(object sender, FormClosingEventArgs e){
if (!isLoaded){ if (!isLoaded)return;
return;
}
if (Config.TrayBehavior.ShouldHideOnClose() && trayIcon.Visible && e.CloseReason == CloseReason.UserClosing){ if (Config.TrayBehavior.ShouldHideOnClose() && trayIcon.Visible && e.CloseReason == CloseReason.UserClosing){
Hide(); // hides taskbar too?! welp that works I guess Hide(); // hides taskbar too?! welp that works I guess
@@ -237,7 +212,6 @@ namespace TweetDuck.Browser{
} }
private void Config_MuteToggled(object sender, EventArgs e){ private void Config_MuteToggled(object sender, EventArgs e){
UpdateFormIcon();
AnalyticsFile.NotificationMutes.Trigger(); AnalyticsFile.NotificationMutes.Trigger();
} }
@@ -258,9 +232,7 @@ namespace TweetDuck.Browser{
private void plugins_Reloaded(object sender, PluginErrorEventArgs e){ private void plugins_Reloaded(object sender, PluginErrorEventArgs e){
if (e.HasErrors){ 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){ if (isLoaded){
@@ -268,11 +240,9 @@ namespace TweetDuck.Browser{
} }
} }
private void plugins_Executed(object sender, PluginErrorEventArgs e){ private static void plugins_Executed(object sender, PluginErrorEventArgs e){
if (e.HasErrors){ if (e.HasErrors){
this.InvokeAsyncSafe(() => {
FormMessage.Error("Error Executing Plugins", "Failed to execute the following plugins:\n\n"+string.Join("\n\n", e.Errors), FormMessage.OK); FormMessage.Error("Error Executing Plugins", "Failed to execute the following plugins:\n\n"+string.Join("\n\n", e.Errors), FormMessage.OK);
});
} }
} }
@@ -345,6 +315,10 @@ namespace TweetDuck.Browser{
} }
} }
private void updateBridge_UpdateDelayed(object sender, UpdateInfo update){
// stops the timer
}
private void updateBridge_UpdateDismissed(object sender, UpdateInfo update){ private void updateBridge_UpdateDismissed(object sender, UpdateInfo update){
Config.DismissedUpdate = update.VersionTag; Config.DismissedUpdate = update.VersionTag;
Config.Save(); Config.Save();
@@ -352,9 +326,7 @@ namespace TweetDuck.Browser{
protected override void WndProc(ref Message m){ protected override void WndProc(ref Message m){
if (isLoaded && m.Msg == Program.WindowRestoreMessage){ if (isLoaded && m.Msg == Program.WindowRestoreMessage){
using Process me = Process.GetCurrentProcess(); if (WindowsUtils.CurrentProcessID == m.WParam.ToInt32()){
if (me.Id == m.WParam.ToInt32()){
trayIcon_ClickRestore(trayIcon, EventArgs.Empty); trayIcon_ClickRestore(trayIcon, EventArgs.Empty);
} }
@@ -391,7 +363,14 @@ namespace TweetDuck.Browser{
} }
public void ReloadToTweetDeck(){ public void ReloadToTweetDeck(){
Program.Resources.OnReloadTriggered(); #if DEBUG
ScriptLoader.HotSwap();
#else
if (ModifierKeys.HasFlag(Keys.Shift)){
ScriptLoader.ClearCache();
}
#endif
ignoreUpdateCheckError = false; ignoreUpdateCheckError = false;
browser.ReloadToTweetDeck(); browser.ReloadToTweetDeck();
AnalyticsFile.BrowserReloads.Trigger(); AnalyticsFile.BrowserReloads.Trigger();
@@ -512,59 +491,47 @@ namespace TweetDuck.Browser{
public void OpenProfileImport(){ public void OpenProfileImport(){
FormManager.TryFind<FormSettings>()?.Close(); FormManager.TryFind<FormSettings>()?.Close();
using DialogSettingsManage dialog = new DialogSettingsManage(plugins, true); 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 if (!dialog.IsDisposed && dialog.ShowDialog() == DialogResult.OK && !dialog.IsRestarting){ // needs disposal check because the dialog may be closed in constructor
BrowserProcessHandler.UpdatePrefs(); BrowserProcessHandler.UpdatePrefs();
FormManager.TryFind<FormPlugins>()?.Close(); FormManager.TryFind<FormPlugins>()?.Close();
plugins.Reload(); // also reloads the browser plugins.Reload(); // also reloads the browser
} }
} }
}
public void OnTweetNotification(){ // may be called multiple times, once for each type of notification public void OnTweetNotification(){ // may be called multiple times, once for each type of notification
if (Config.EnableTrayHighlight && !ContainsFocus){ if (!ContainsFocus){
if (Config.EnableTrayHighlight){
trayIcon.HasNotifications = true; trayIcon.HasNotifications = true;
} }
taskbarIcon.HasNotifications = false;
}
} }
public void OnTweetSound(){ public void OnTweetSound(){
AnalyticsFile.SoundNotifications.Trigger(); AnalyticsFile.SoundNotifications.Trigger();
} }
public void PlayVideo(string videoUrl, string tweetUrl, string username, IJavascriptCallback callShowOverlay){ public void PlayVideo(string url, string username){
string playerPath = Config.VideoPlayerPath; if (string.IsNullOrEmpty(url)){
videoPlayer?.Close();
return;
}
if (playerPath == null || !File.Exists(playerPath)){
if (videoPlayer == null){ if (videoPlayer == null){
videoPlayer = new VideoPlayer(this); videoPlayer = new VideoPlayer(this);
videoPlayer.ProcessExited += (sender, args) => browser.HideVideoOverlay(true);
} videoPlayer.ProcessExited += (sender, args) => {
browser.HideVideoOverlay(true);
callShowOverlay.ExecuteAsync(); };
callShowOverlay.Dispose();
videoPlayer.Launch(videoUrl, tweetUrl, username);
}
else{
callShowOverlay.Dispose();
string quotedUrl = '"' + videoUrl + '"';
string playerArgs = Config.VideoPlayerPathArgs == null ? quotedUrl : Config.VideoPlayerPathArgs + ' ' + quotedUrl;
try{
using(Process.Start(playerPath, playerArgs)){}
}catch(Exception e){
Program.Reporter.HandleException("Error Opening Video Player", "Could not open the video player.", true, e);
}
} }
videoPlayer.Launch(url, username);
AnalyticsFile.VideoPlays.Trigger(); AnalyticsFile.VideoPlays.Trigger();
} }
public void StopVideo(){
videoPlayer?.Close();
}
public bool ProcessBrowserKey(Keys key){ public bool ProcessBrowserKey(Keys key){
if (videoPlayer != null && videoPlayer.Running){ if (videoPlayer != null && videoPlayer.Running){
videoPlayer.SendKeyEvent(key); videoPlayer.SendKeyEvent(key);

View File

@@ -1,12 +1,10 @@
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDuck.Management{ namespace TweetDuck.Core{
static class FormManager{ static class FormManager{
private static FormCollection OpenForms => System.Windows.Forms.Application.OpenForms;
public static T TryFind<T>() where T : Form{ public static T TryFind<T>() where T : Form{
return OpenForms.OfType<T>().FirstOrDefault(); return Application.OpenForms.OfType<T>().FirstOrDefault();
} }
public static bool TryBringToFront<T>() where T : Form{ public static bool TryBringToFront<T>() where T : Form{
@@ -16,13 +14,13 @@ namespace TweetDuck.Management{
form.BringToFront(); form.BringToFront();
return true; return true;
} }
else{ else return false;
return false;
}
} }
public static bool HasAnyDialogs => Application.OpenForms.OfType<IAppDialog>().Any();
public static void CloseAllDialogs(){ public static void CloseAllDialogs(){
foreach(IAppDialog dialog in OpenForms.OfType<IAppDialog>().Reverse()){ foreach(IAppDialog dialog in Application.OpenForms.OfType<IAppDialog>().Reverse()){
((Form)dialog).Close(); ((Form)dialog).Close();
} }
} }

View File

@@ -1,26 +1,23 @@
using System; using System;
using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp; using CefSharp;
using TweetDuck.Browser.Adapters; using TweetDuck.Core.Controls;
using TweetDuck.Browser.Data; using TweetDuck.Core.Utils;
using TweetDuck.Browser.Notification; using System.Linq;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetDuck.Controls; using TweetDuck.Core.Bridge;
using TweetDuck.Dialogs; using TweetDuck.Core.Management;
using TweetDuck.Management; using TweetDuck.Core.Notification;
using TweetDuck.Management.Analytics; using TweetDuck.Core.Other;
using TweetDuck.Utils; using TweetDuck.Core.Other.Analytics;
using TweetLib.Core.Features.Twitter; using TweetDuck.Resources;
using TweetLib.Core.Utils;
namespace TweetDuck.Browser.Handling{ namespace TweetDuck.Core.Handling{
abstract class ContextMenuBase : IContextMenuHandler{ abstract class ContextMenuBase : IContextMenuHandler{
public static ContextInfo CurrentInfo { get; } = new ContextInfo();
protected static UserConfig Config => Program.Config.User; protected static UserConfig Config => Program.Config.User;
private static ImageQuality ImageQuality => Config.TwitterImageQuality;
private static TwitterUtils.ImageQuality ImageQuality => Config.TwitterImageQuality;
private const CefMenuCommand MenuOpenLinkUrl = (CefMenuCommand)26500; private const CefMenuCommand MenuOpenLinkUrl = (CefMenuCommand)26500;
private const CefMenuCommand MenuCopyLinkUrl = (CefMenuCommand)26501; private const CefMenuCommand MenuCopyLinkUrl = (CefMenuCommand)26501;
@@ -28,11 +25,10 @@ namespace TweetDuck.Browser.Handling{
private const CefMenuCommand MenuViewImage = (CefMenuCommand)26503; private const CefMenuCommand MenuViewImage = (CefMenuCommand)26503;
private const CefMenuCommand MenuOpenMediaUrl = (CefMenuCommand)26504; private const CefMenuCommand MenuOpenMediaUrl = (CefMenuCommand)26504;
private const CefMenuCommand MenuCopyMediaUrl = (CefMenuCommand)26505; private const CefMenuCommand MenuCopyMediaUrl = (CefMenuCommand)26505;
private const CefMenuCommand MenuCopyImage = (CefMenuCommand)26506; private const CefMenuCommand MenuSaveMedia = (CefMenuCommand)26506;
private const CefMenuCommand MenuSaveMedia = (CefMenuCommand)26507; private const CefMenuCommand MenuSaveTweetImages = (CefMenuCommand)26507;
private const CefMenuCommand MenuSaveTweetImages = (CefMenuCommand)26508; private const CefMenuCommand MenuSearchInBrowser = (CefMenuCommand)26508;
private const CefMenuCommand MenuSearchInBrowser = (CefMenuCommand)26509; private const CefMenuCommand MenuReadApplyROT13 = (CefMenuCommand)26509;
private const CefMenuCommand MenuReadApplyROT13 = (CefMenuCommand)26510;
private const CefMenuCommand MenuOpenDevTools = (CefMenuCommand)26599; private const CefMenuCommand MenuOpenDevTools = (CefMenuCommand)26599;
protected ContextInfo.ContextData Context { get; private set; } protected ContextInfo.ContextData Context { get; private set; }
@@ -44,11 +40,11 @@ namespace TweetDuck.Browser.Handling{
} }
public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model){ public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model){
if (!TwitterUrls.IsTweetDeck(frame.Url) || browser.IsLoading){ if (!TwitterUtils.IsTweetDeckWebsite(frame) || browser.IsLoading){
Context = CurrentInfo.Reset(); Context = TweetDeckBridge.ContextInfo.Reset();
} }
else{ else{
Context = CurrentInfo.Create(parameters); Context = TweetDeckBridge.ContextInfo.Create(parameters);
} }
if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection) && !parameters.TypeFlags.HasFlag(ContextMenuType.Editable)){ if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection) && !parameters.TypeFlags.HasFlag(ContextMenuType.Editable)){
@@ -58,12 +54,12 @@ namespace TweetDuck.Browser.Handling{
model.AddSeparator(); model.AddSeparator();
} }
static string TextOpen(string name) => "Open " + name + " in browser"; string TextOpen(string name) => "Open "+name+" in browser";
static string TextCopy(string name) => "Copy " + name + " address"; string TextCopy(string name) => "Copy "+name+" address";
static string TextSave(string name) => "Save " + name + " as..."; string TextSave(string name) => "Save "+name+" as...";
if (Context.Types.HasFlag(ContextInfo.ContextType.Link) && !Context.UnsafeLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal)){ if (Context.Types.HasFlag(ContextInfo.ContextType.Link) && !Context.UnsafeLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal)){
if (TwitterUrls.RegexAccount.IsMatch(Context.UnsafeLinkUrl)){ if (TwitterUtils.RegexAccount.IsMatch(Context.UnsafeLinkUrl)){
model.AddItem(MenuOpenLinkUrl, TextOpen("account")); model.AddItem(MenuOpenLinkUrl, TextOpen("account"));
model.AddItem(MenuCopyLinkUrl, TextCopy("account")); model.AddItem(MenuCopyLinkUrl, TextCopy("account"));
model.AddItem(MenuCopyUsername, "Copy account username"); model.AddItem(MenuCopyUsername, "Copy account username");
@@ -82,11 +78,10 @@ namespace TweetDuck.Browser.Handling{
model.AddItem(MenuSaveMedia, TextSave("video")); model.AddItem(MenuSaveMedia, TextSave("video"));
model.AddSeparator(); model.AddSeparator();
} }
else if (Context.Types.HasFlag(ContextInfo.ContextType.Image) && Context.MediaUrl != FormNotificationBase.AppLogo.Url){ else if (Context.Types.HasFlag(ContextInfo.ContextType.Image) && Context.MediaUrl != TweetNotification.AppLogo.Url){
model.AddItem(MenuViewImage, "View image in photo viewer"); model.AddItem(MenuViewImage, "View image in photo viewer");
model.AddItem(MenuOpenMediaUrl, TextOpen("image")); model.AddItem(MenuOpenMediaUrl, TextOpen("image"));
model.AddItem(MenuCopyMediaUrl, TextCopy("image")); model.AddItem(MenuCopyMediaUrl, TextCopy("image"));
model.AddItem(MenuCopyImage, "Copy image");
model.AddItem(MenuSaveMedia, TextSave("image")); model.AddItem(MenuSaveMedia, TextSave("image"));
if (Context.Chirp.Images.Length > 1){ if (Context.Chirp.Images.Length > 1){
@@ -111,7 +106,7 @@ namespace TweetDuck.Browser.Handling{
case MenuCopyUsername: { case MenuCopyUsername: {
string url = Context.UnsafeLinkUrl; string url = Context.UnsafeLinkUrl;
Match match = TwitterUrls.RegexAccount.Match(url); Match match = TwitterUtils.RegexAccount.Match(url);
SetClipboardText(control, match.Success ? match.Groups[1].Value : url); SetClipboardText(control, match.Success ? match.Groups[1].Value : url);
control.InvokeAsyncSafe(analytics.AnalyticsFile.CopiedUsernames.Trigger); control.InvokeAsyncSafe(analytics.AnalyticsFile.CopiedUsernames.Trigger);
@@ -119,23 +114,13 @@ namespace TweetDuck.Browser.Handling{
} }
case MenuOpenMediaUrl: case MenuOpenMediaUrl:
OpenBrowser(control, TwitterUrls.GetMediaLink(Context.MediaUrl, ImageQuality)); OpenBrowser(control, TwitterUtils.GetMediaLink(Context.MediaUrl, ImageQuality));
break; break;
case MenuCopyMediaUrl: case MenuCopyMediaUrl:
SetClipboardText(control, TwitterUrls.GetMediaLink(Context.MediaUrl, ImageQuality)); SetClipboardText(control, TwitterUtils.GetMediaLink(Context.MediaUrl, ImageQuality));
break; break;
case MenuCopyImage: {
string url = Context.MediaUrl;
control.InvokeAsyncSafe(() => {
TwitterUtils.CopyImage(url, ImageQuality);
});
break;
}
case MenuViewImage: { case MenuViewImage: {
string url = Context.MediaUrl; string url = Context.MediaUrl;
@@ -191,7 +176,7 @@ namespace TweetDuck.Browser.Handling{
break; break;
case MenuOpenDevTools: case MenuOpenDevTools:
browserControl.OpenDevToolsCustom(); browserControl.ShowDevTools();
break; break;
} }
@@ -199,7 +184,7 @@ namespace TweetDuck.Browser.Handling{
} }
public virtual void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame){ public virtual void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame){
Context = CurrentInfo.Reset(); Context = TweetDeckBridge.ContextInfo.Reset();
} }
public virtual bool RunContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback){ public virtual bool RunContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model, IRunContextMenuCallback callback){
@@ -207,7 +192,7 @@ namespace TweetDuck.Browser.Handling{
} }
protected static void DeselectAll(IFrame frame){ protected static void DeselectAll(IFrame frame){
CefScriptExecutor.RunScript(frame, "window.getSelection().removeAllRanges()", "gen:deselect"); ScriptLoader.ExecuteScript(frame, "window.getSelection().removeAllRanges()", "gen:deselect");
} }
protected static void OpenBrowser(Control control, string url){ protected static void OpenBrowser(Control control, string url){
@@ -215,7 +200,7 @@ namespace TweetDuck.Browser.Handling{
} }
protected static void SetClipboardText(Control control, string text){ protected static void SetClipboardText(Control control, string text){
control.InvokeAsyncSafe(() => ClipboardManager.SetText(text, TextDataFormat.UnicodeText)); control.InvokeAsyncSafe(() => WindowsUtils.SetClipboard(text, TextDataFormat.UnicodeText));
} }
protected static void InsertSelectionSearchItem(IMenuModel model, CefMenuCommand insertCommand, string insertLabel){ protected static void InsertSelectionSearchItem(IMenuModel model, CefMenuCommand insertCommand, string insertLabel){

View File

@@ -1,10 +1,10 @@
using System.Windows.Forms; using CefSharp;
using CefSharp; using System.Windows.Forms;
using TweetDuck.Browser.Data; using TweetDuck.Core.Controls;
using TweetDuck.Controls; using TweetDuck.Core.Management;
using TweetLib.Core.Features.Twitter; using TweetDuck.Core.Utils;
namespace TweetDuck.Browser.Handling{ namespace TweetDuck.Core.Handling{
sealed class ContextMenuBrowser : ContextMenuBase{ sealed class ContextMenuBrowser : ContextMenuBase{
private const CefMenuCommand MenuGlobal = (CefMenuCommand)26600; private const CefMenuCommand MenuGlobal = (CefMenuCommand)26600;
private const CefMenuCommand MenuMute = (CefMenuCommand)26601; private const CefMenuCommand MenuMute = (CefMenuCommand)26601;
@@ -53,7 +53,7 @@ namespace TweetDuck.Browser.Handling{
base.OnBeforeContextMenu(browserControl, browser, frame, parameters, model); base.OnBeforeContextMenu(browserControl, browser, frame, parameters, model);
if (isSelecting && !isEditing && TwitterUrls.IsTweetDeck(frame.Url)){ if (isSelecting && !isEditing && TwitterUtils.IsTweetDeckWebsite(frame)){
InsertSelectionSearchItem(model, MenuSearchInColumn, "Search in a column"); InsertSelectionSearchItem(model, MenuSearchInColumn, "Search in a column");
} }

View File

@@ -1,7 +1,7 @@
using CefSharp; using CefSharp;
using TweetDuck.Management.Analytics; using TweetDuck.Core.Other.Analytics;
namespace TweetDuck.Browser.Handling{ namespace TweetDuck.Core.Handling{
sealed class ContextMenuGuide : ContextMenuBase{ sealed class ContextMenuGuide : ContextMenuBase{
public ContextMenuGuide(AnalyticsFile.IProvider analytics) : base(analytics){} public ContextMenuGuide(AnalyticsFile.IProvider analytics) : base(analytics){}

View File

@@ -1,8 +1,8 @@
using CefSharp; using CefSharp;
using TweetDuck.Browser.Notification; using TweetDuck.Core.Controls;
using TweetDuck.Controls; using TweetDuck.Core.Notification;
namespace TweetDuck.Browser.Handling{ namespace TweetDuck.Core.Handling{
sealed class ContextMenuNotification : ContextMenuBase{ sealed class ContextMenuNotification : ContextMenuBase{
private const CefMenuCommand MenuViewDetail = (CefMenuCommand)26600; private const CefMenuCommand MenuViewDetail = (CefMenuCommand)26600;
private const CefMenuCommand MenuSkipTweet = (CefMenuCommand)26601; private const CefMenuCommand MenuSkipTweet = (CefMenuCommand)26601;

View File

@@ -2,7 +2,7 @@
using CefSharp; using CefSharp;
using CefSharp.Enums; using CefSharp.Enums;
namespace TweetDuck.Browser.Handling{ namespace TweetDuck.Core.Handling{
sealed class DragHandlerBrowser : IDragHandler{ sealed class DragHandlerBrowser : IDragHandler{
private readonly RequestHandlerBrowser requestHandler; private readonly RequestHandlerBrowser requestHandler;

View File

@@ -3,7 +3,7 @@ using System.IO;
using System.Text; using System.Text;
using CefSharp; using CefSharp;
namespace TweetDuck.Browser.Handling.Filters{ namespace TweetDuck.Core.Handling.Filters{
abstract class ResponseFilterBase : IResponseFilter{ abstract class ResponseFilterBase : IResponseFilter{
private enum State{ private enum State{
Reading, Writing, Done Reading, Writing, Done

View File

@@ -1,7 +1,7 @@
using System.Text; using System.Text;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
namespace TweetDuck.Browser.Handling.Filters{ namespace TweetDuck.Core.Handling.Filters{
sealed class ResponseFilterVendor : ResponseFilterBase{ sealed class ResponseFilterVendor : ResponseFilterBase{
private static readonly Regex RegexRestoreJQuery = new Regex(@"(\w+)\.fn=\1\.prototype", RegexOptions.Compiled); 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 CefSharp;
using TweetDuck.Configuration; using TweetDuck.Configuration;
namespace TweetDuck.Browser.Handling.General{ namespace TweetDuck.Core.Handling.General{
sealed class BrowserProcessHandler : IBrowserProcessHandler{ sealed class BrowserProcessHandler : IBrowserProcessHandler{
public static Task UpdatePrefs(){ public static Task UpdatePrefs(){
return Cef.UIThreadTaskFactory.StartNew(UpdatePrefsInternal); return Cef.UIThreadTaskFactory.StartNew(UpdatePrefsInternal);
@@ -11,12 +11,13 @@ namespace TweetDuck.Browser.Handling.General{
private static void UpdatePrefsInternal(){ private static void UpdatePrefsInternal(){
UserConfig config = Program.Config.User; UserConfig config = Program.Config.User;
using IRequestContext ctx = Cef.GetGlobalRequestContext();
using(IRequestContext ctx = Cef.GetGlobalRequestContext()){
ctx.SetPreference("browser.enable_spellchecking", config.EnableSpellCheck, out string _); ctx.SetPreference("browser.enable_spellchecking", config.EnableSpellCheck, out string _);
ctx.SetPreference("spellcheck.dictionary", config.SpellCheckLanguage, out string _); ctx.SetPreference("spellcheck.dictionary", config.SpellCheckLanguage, out string _);
ctx.SetPreference("settings.a11y.animation_policy", config.EnableAnimatedImages ? "allowed" : "none", out string _); ctx.SetPreference("settings.a11y.animation_policy", config.EnableAnimatedImages ? "allowed" : "none", out string _);
} }
}
void IBrowserProcessHandler.OnContextInitialized(){ void IBrowserProcessHandler.OnContextInitialized(){
UpdatePrefsInternal(); UpdatePrefsInternal();

View File

@@ -1,14 +1,15 @@
using System.Collections.Generic; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp; using CefSharp;
namespace TweetDuck.Browser.Handling.General{ namespace TweetDuck.Core.Handling.General{
sealed class FileDialogHandler : IDialogHandler{ 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){ 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){ if (mode == CefFileDialogMode.Open || mode == CefFileDialogMode.OpenMultiple){
string allFilters = string.Join(";", acceptFilters.SelectMany(ParseFileType).Where(filter => !string.IsNullOrEmpty(filter)).Select(filter => "*" + filter)); string allFilters = string.Join(";", acceptFilters.Select(filter => "*"+filter));
using(OpenFileDialog dialog = new OpenFileDialog{ using(OpenFileDialog dialog = new OpenFileDialog{
AutoUpgradeEnabled = true, AutoUpgradeEnabled = true,
@@ -18,8 +19,8 @@ namespace TweetDuck.Browser.Handling.General{
Filter = $"All Supported Formats ({allFilters})|{allFilters}|All Files (*.*)|*.*" Filter = $"All Supported Formats ({allFilters})|{allFilters}|All Files (*.*)|*.*"
}){ }){
if (dialog.ShowDialog() == DialogResult.OK){ if (dialog.ShowDialog() == DialogResult.OK){
string ext = Path.GetExtension(dialog.FileName)?.ToLower(); string ext = Path.GetExtension(dialog.FileName);
callback.Continue(acceptFilters.FindIndex(filter => ParseFileType(filter).Contains(ext)), dialog.FileNames.ToList()); callback.Continue(acceptFilters.FindIndex(filter => filter.Equals(ext, StringComparison.OrdinalIgnoreCase)), dialog.FileNames.ToList());
} }
else{ else{
callback.Cancel(); callback.Cancel();
@@ -35,27 +36,5 @@ namespace TweetDuck.Browser.Handling.General{
return false; return false;
} }
} }
private static IEnumerable<string> ParseFileType(string type){
if (string.IsNullOrEmpty(type)){
return new string[0];
}
if (type[0] == '.'){
return new string[]{ type };
}
switch(type){
case "image/jpeg": return new string[]{ ".jpg", ".jpeg" };
case "image/png": return new string[]{ ".png" };
case "image/gif": return new string[]{ ".gif" };
case "image/webp": return new string[]{ ".webp" };
case "video/mp4": return new string[]{ ".mp4" };
case "video/quicktime": return new string[]{ ".mov", ".qt" };
}
System.Diagnostics.Debugger.Break();
return new string[0];
}
} }
} }

View File

@@ -1,28 +1,26 @@
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp; using CefSharp;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetDuck.Dialogs; using TweetDuck.Core.Other;
using TweetDuck.Utils; using TweetDuck.Core.Utils;
namespace TweetDuck.Browser.Handling.General{ namespace TweetDuck.Core.Handling.General{
sealed class JavaScriptDialogHandler : IJsDialogHandler{ sealed class JavaScriptDialogHandler : IJsDialogHandler{
private static FormMessage CreateMessageForm(string caption, string text){ private static FormMessage CreateMessageForm(string caption, string text){
MessageBoxIcon icon = MessageBoxIcon.None; MessageBoxIcon icon = MessageBoxIcon.None;
int pipe = text.IndexOf('|'); int pipe = text.IndexOf('|');
if (pipe != -1){ if (pipe != -1){
icon = text.Substring(0, pipe) switch{ switch(text.Substring(0, pipe)){
"error" => MessageBoxIcon.Error, case "error": icon = MessageBoxIcon.Error; break;
"warning" => MessageBoxIcon.Warning, case "warning": icon = MessageBoxIcon.Warning; break;
"info" => MessageBoxIcon.Information, case "info": icon = MessageBoxIcon.Information; break;
"question" => MessageBoxIcon.Question, case "question": icon = MessageBoxIcon.Question; break;
_ => MessageBoxIcon.None default: return new FormMessage(caption, text, icon);
};
if (icon != MessageBoxIcon.None){
text = text.Substring(pipe + 1);
} }
text = text.Substring(pipe+1);
} }
return new FormMessage(caption, text, icon); return new FormMessage(caption, text, icon);

View File

@@ -1,18 +1,14 @@
using CefSharp; using CefSharp;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetDuck.Utils; using TweetDuck.Core.Utils;
namespace TweetDuck.Browser.Handling.General{ namespace TweetDuck.Core.Handling.General{
sealed class LifeSpanHandler : ILifeSpanHandler{ sealed class LifeSpanHandler : ILifeSpanHandler{
private static bool IsPopupAllowed(string url){
return url.StartsWith("https://twitter.com/teams/authorize?");
}
public static bool HandleLinkClick(IWebBrowser browserControl, WindowOpenDisposition targetDisposition, string targetUrl){ public static bool HandleLinkClick(IWebBrowser browserControl, WindowOpenDisposition targetDisposition, string targetUrl){
switch(targetDisposition){ switch(targetDisposition){
case WindowOpenDisposition.NewBackgroundTab: case WindowOpenDisposition.NewBackgroundTab:
case WindowOpenDisposition.NewForegroundTab: case WindowOpenDisposition.NewForegroundTab:
case WindowOpenDisposition.NewPopup when !IsPopupAllowed(targetUrl): case WindowOpenDisposition.NewPopup:
case WindowOpenDisposition.NewWindow: case WindowOpenDisposition.NewWindow:
browserControl.AsControl().InvokeAsyncSafe(() => BrowserUtils.OpenExternalBrowser(targetUrl)); browserControl.AsControl().InvokeAsyncSafe(() => BrowserUtils.OpenExternalBrowser(targetUrl));
return true; return true;

View File

@@ -1,15 +1,15 @@
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp; using CefSharp;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetDuck.Dialogs; using TweetDuck.Core.Other;
using TweetDuck.Utils; using TweetDuck.Core.Utils;
namespace TweetDuck.Browser.Handling{ namespace TweetDuck.Core.Handling{
class KeyboardHandlerBase : IKeyboardHandler{ class KeyboardHandlerBase : IKeyboardHandler{
protected virtual bool HandleRawKey(IWebBrowser browserControl, IBrowser browser, Keys key, CefEventFlags modifiers){ protected virtual bool HandleRawKey(IWebBrowser browserControl, IBrowser browser, Keys key, CefEventFlags modifiers){
if (modifiers == (CefEventFlags.ControlDown | CefEventFlags.ShiftDown) && key == Keys.I){ if (modifiers == (CefEventFlags.ControlDown | CefEventFlags.ShiftDown) && key == Keys.I){
if (BrowserUtils.HasDevTools){ if (BrowserUtils.HasDevTools){
browserControl.OpenDevToolsCustom(); browser.ShowDevTools();
} }
else{ else{
browserControl.AsControl().InvokeSafe(() => { browserControl.AsControl().InvokeSafe(() => {

View File

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

View File

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

View File

@@ -5,13 +5,12 @@ using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using CefSharp; using CefSharp;
using CefSharp.Handler; using CefSharp.Handler;
using TweetDuck.Browser.Handling.General; using TweetDuck.Core.Handling.General;
using TweetDuck.Utils; using TweetDuck.Core.Utils;
using TweetLib.Core.Utils;
namespace TweetDuck.Browser.Handling{ namespace TweetDuck.Core.Handling{
class RequestHandlerBase : DefaultRequestHandler{ class RequestHandlerBase : DefaultRequestHandler{
private static readonly Regex TweetDeckResourceUrl = new Regex(@"/dist/(.*?)\.(.*?)\.(css|js)$"); private static readonly Regex TweetDeckResourceUrl = new Regex(@"/dist/(.*?)\.(.*?)\.(css|js)$", RegexOptions.Compiled);
private static readonly SortedList<string, string> TweetDeckHashes = new SortedList<string, string>(4); private static readonly SortedList<string, string> TweetDeckHashes = new SortedList<string, string>(4);
public static void LoadResourceRewriteRules(string rules){ public static void LoadResourceRewriteRules(string rules){
@@ -22,7 +21,11 @@ namespace TweetDuck.Browser.Handling{
TweetDeckHashes.Clear(); TweetDeckHashes.Clear();
foreach(string rule in rules.Replace(" ", "").ToLower().Split(',')){ foreach(string rule in rules.Replace(" ", "").ToLower().Split(',')){
var (key, hash) = StringUtils.SplitInTwo(rule, '=') ?? throw new ArgumentException("A rule must have one '=' character: " + rule); string[] split = rule.Split('=');
if (split.Length == 2){
string key = split[0];
string hash = split[1];
if (hash.All(chr => char.IsDigit(chr) || (chr >= 'a' && chr <= 'f'))){ if (hash.All(chr => char.IsDigit(chr) || (chr >= 'a' && chr <= 'f'))){
TweetDeckHashes.Add(key, hash); TweetDeckHashes.Add(key, hash);
@@ -31,6 +34,10 @@ namespace TweetDuck.Browser.Handling{
throw new ArgumentException("Invalid hash characters: "+rule); throw new ArgumentException("Invalid hash characters: "+rule);
} }
} }
else{
throw new ArgumentException("A rule must have exactly one '=' character: "+rule);
}
}
} }
private readonly bool autoReload; private readonly bool autoReload;

View File

@@ -1,10 +1,9 @@
using System.Collections.Specialized; using System.Collections.Specialized;
using CefSharp; using CefSharp;
using TweetDuck.Browser.Handling.Filters; using TweetDuck.Core.Handling.Filters;
using TweetDuck.Utils; using TweetDuck.Core.Utils;
using TweetLib.Core.Features.Twitter;
namespace TweetDuck.Browser.Handling{ namespace TweetDuck.Core.Handling{
sealed class RequestHandlerBrowser : RequestHandlerBase{ sealed class RequestHandlerBrowser : RequestHandlerBase{
private const string UrlVendorResource = "/dist/vendor"; private const string UrlVendorResource = "/dist/vendor";
private const string UrlLoadingSpinner = "/backgrounds/spinner_blue"; private const string UrlLoadingSpinner = "/backgrounds/spinner_blue";
@@ -16,7 +15,7 @@ namespace TweetDuck.Browser.Handling{
public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){ public override CefReturnValue OnBeforeResourceLoad(IWebBrowser browserControl, IBrowser browser, IFrame frame, IRequest request, IRequestCallback callback){
if (request.ResourceType == ResourceType.MainFrame){ if (request.ResourceType == ResourceType.MainFrame){
if (request.Url.EndsWith("//twitter.com/")){ if (request.Url.EndsWith("//twitter.com/")){
request.Url = TwitterUrls.TweetDeck; // redirect plain twitter.com requests, fixes bugs with login 2FA request.Url = TwitterUtils.TweetDeckURL; // redirect plain twitter.com requests, fixes bugs with login 2FA
} }
} }
else if (request.ResourceType == ResourceType.Script){ else if (request.ResourceType == ResourceType.Script){
@@ -42,9 +41,6 @@ namespace TweetDuck.Browser.Handling{
BlockNextUserNavUrl = string.Empty; BlockNextUserNavUrl = string.Empty;
return block; return block;
} }
else if (request.TransitionType.HasFlag(TransitionType.ForwardBack) && TwitterUrls.IsTweetDeck(frame.Url)){
return true;
}
return base.OnBeforeBrowse(browserControl, browser, frame, request, userGesture, isRedirect); return base.OnBeforeBrowse(browserControl, browser, frame, request, userGesture, isRedirect);
} }

View File

@@ -1,9 +1,9 @@
using System; using System;
using System.Collections.Concurrent; using System.Collections.Concurrent;
using CefSharp; using CefSharp;
using TweetDuck.Browser.Data; using TweetDuck.Data;
namespace TweetDuck.Browser.Handling{ namespace TweetDuck.Core.Handling{
sealed class ResourceHandlerFactory : IResourceHandlerFactory{ sealed class ResourceHandlerFactory : IResourceHandlerFactory{
public bool HasHandlers => !handlers.IsEmpty; public bool HasHandlers => !handlers.IsEmpty;

View File

@@ -1,9 +1,9 @@
using System.Collections.Specialized; using CefSharp;
using System.Collections.Specialized;
using System.IO; using System.IO;
using System.Text; using System.Text;
using CefSharp;
namespace TweetDuck.Browser.Handling{ namespace TweetDuck.Core.Handling{
sealed class ResourceHandlerNotification : IResourceHandler{ sealed class ResourceHandlerNotification : IResourceHandler{
private readonly NameValueCollection headers = new NameValueCollection(0); private readonly NameValueCollection headers = new NameValueCollection(0);
private MemoryStream dataIn; private MemoryStream dataIn;

View File

@@ -4,7 +4,7 @@ using System.Linq;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
namespace TweetDuck.Management{ namespace TweetDuck.Core.Management{
static class BrowserCache{ static class BrowserCache{
public static string CacheFolder => Path.Combine(Program.StoragePath, "Cache"); public static string CacheFolder => Path.Combine(Program.StoragePath, "Cache");

View File

@@ -1,8 +1,8 @@
using System; using System;
using CefSharp; using CefSharp;
using TweetLib.Core.Utils; using TweetDuck.Core.Utils;
namespace TweetDuck.Browser.Data{ namespace TweetDuck.Core.Management{
sealed class ContextInfo{ sealed class ContextInfo{
private LinkInfo link; private LinkInfo link;
private ChirpInfo? chirp; private ChirpInfo? chirp;
@@ -107,7 +107,7 @@ namespace TweetDuck.Browser.Data{
private string unsafeLinkUrl = string.Empty; private string unsafeLinkUrl = string.Empty;
private string mediaUrl = string.Empty; private string mediaUrl = string.Empty;
private ChirpInfo chirp = default; private ChirpInfo chirp = default(ChirpInfo);
public void AddContext(IContextMenuParams parameters){ public void AddContext(IContextMenuParams parameters){
ContextMenuType flags = parameters.TypeFlags; ContextMenuType flags = parameters.TypeFlags;

View File

@@ -2,12 +2,12 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using TweetDuck.Dialogs; using TweetDuck.Core.Other;
using TweetLib.Core.Data; using TweetDuck.Data;
using TweetLib.Core.Features.Plugins; using TweetDuck.Plugins;
using TweetLib.Core.Features.Plugins.Enums; using TweetDuck.Plugins.Enums;
namespace TweetDuck.Management{ namespace TweetDuck.Core.Management{
sealed class ProfileManager{ sealed class ProfileManager{
private static readonly string CookiesPath = Path.Combine(Program.StoragePath, "Cookies"); private static readonly string CookiesPath = Path.Combine(Program.StoragePath, "Cookies");
private static readonly string TempCookiesPath = Path.Combine(Program.StoragePath, "CookiesTmp"); private static readonly string TempCookiesPath = Path.Combine(Program.StoragePath, "CookiesTmp");
@@ -73,7 +73,7 @@ namespace TweetDuck.Management{
Items items = Items.None; Items items = Items.None;
try{ try{
using CombinedFileStream stream = new CombinedFileStream(new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.None)); using(CombinedFileStream stream = new CombinedFileStream(new FileStream(file, FileMode.Open, FileAccess.Read, FileShare.None))){
string key; string key;
while((key = stream.SkipFile()) != null){ while((key = stream.SkipFile()) != null){
@@ -96,6 +96,7 @@ namespace TweetDuck.Management{
break; break;
} }
} }
}
}catch(Exception){ }catch(Exception){
items = Items.None; items = Items.None;
} }
@@ -139,7 +140,7 @@ namespace TweetDuck.Management{
entry.WriteToFile(Path.Combine(Program.PluginDataPath, value[0], value[1]), true); entry.WriteToFile(Path.Combine(Program.PluginDataPath, value[0], value[1]), true);
if (!plugins.Plugins.Any(plugin => plugin.Identifier.Equals(value[0]))){ if (!plugins.IsPluginInstalled(value[0])){
missingPlugins.Add(value[0]); missingPlugins.Add(value[0]);
} }
} }

View File

@@ -2,14 +2,13 @@
using System.Diagnostics; using System.Diagnostics;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Browser;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetDuck.Dialogs; using TweetDuck.Core.Other;
using TweetDuck.Utils; using TweetDuck.Core.Utils;
using TweetLib.Communication; using TweetLib.Communication;
namespace TweetDuck.Management{ namespace TweetDuck.Core.Management{
sealed class VideoPlayer : IDisposable{ sealed class VideoPlayer : IDisposable{
private static UserConfig Config => Program.Config.User; private static UserConfig Config => Program.Config.User;
@@ -27,7 +26,7 @@ namespace TweetDuck.Management{
this.owner.FormClosing += owner_FormClosing; this.owner.FormClosing += owner_FormClosing;
} }
public void Launch(string videoUrl, string tweetUrl, string username){ public void Launch(string url, string username){
if (Running){ if (Running){
Destroy(); Destroy();
isClosing = false; isClosing = false;
@@ -41,11 +40,11 @@ namespace TweetDuck.Management{
if ((process = Process.Start(new ProcessStartInfo{ if ((process = Process.Start(new ProcessStartInfo{
FileName = Path.Combine(Program.ProgramPath, "TweetDuck.Video.exe"), FileName = Path.Combine(Program.ProgramPath, "TweetDuck.Video.exe"),
Arguments = $"{owner.Handle} {(int)Math.Floor(100F * owner.GetDPIScale())} {Config.VideoPlayerVolume} \"{videoUrl}\" \"{pipe.GenerateToken()}\"", Arguments = $"{owner.Handle} {(int)Math.Floor(100F*owner.GetDPIScale())} {Config.VideoPlayerVolume} \"{url}\" \"{pipe.GenerateToken()}\"",
UseShellExecute = false, UseShellExecute = false,
RedirectStandardOutput = true RedirectStandardOutput = true
})) != null){ })) != null){
currentInstance = new Instance(process, pipe, videoUrl, tweetUrl, username); currentInstance = new Instance(process, pipe, url, username);
process.EnableRaisingEvents = true; process.EnableRaisingEvents = true;
process.Exited += process_Exited; process.Exited += process_Exited;
@@ -82,7 +81,7 @@ namespace TweetDuck.Management{
case "download": case "download":
if (currentInstance != null){ if (currentInstance != null){
owner.AnalyticsFile.DownloadedVideos.Trigger(); owner.AnalyticsFile.DownloadedVideos.Trigger();
TwitterUtils.DownloadVideo(currentInstance.VideoUrl, currentInstance.Username); TwitterUtils.DownloadVideo(currentInstance.Url, currentInstance.Username);
} }
break; break;
@@ -146,7 +145,7 @@ namespace TweetDuck.Management{
} }
int exitCode = currentInstance.Process.ExitCode; int exitCode = currentInstance.Process.ExitCode;
string tweetUrl = currentInstance.TweetUrl; string url = currentInstance.Url;
currentInstance.Dispose(); currentInstance.Dispose();
currentInstance = null; currentInstance = null;
@@ -154,14 +153,14 @@ namespace TweetDuck.Management{
switch(exitCode){ switch(exitCode){
case 3: // CODE_LAUNCH_FAIL case 3: // CODE_LAUNCH_FAIL
if (FormMessage.Error("Video Playback Error", "Error launching video player, this may be caused by missing Windows Media Player. Do you want to open the video in your browser?", FormMessage.Yes, FormMessage.No)){ if (FormMessage.Error("Video Playback Error", "Error launching video player, this may be caused by missing Windows Media Player. Do you want to open the video in your browser?", FormMessage.Yes, FormMessage.No)){
BrowserUtils.OpenExternalBrowser(tweetUrl); BrowserUtils.OpenExternalBrowser(url);
} }
break; break;
case 4: // CODE_MEDIA_ERROR case 4: // CODE_MEDIA_ERROR
if (FormMessage.Error("Video Playback Error", "The video could not be loaded, most likely due to unknown format. Do you want to open the video in your browser?", FormMessage.Yes, FormMessage.No)){ if (FormMessage.Error("Video Playback Error", "The video could not be loaded, most likely due to unknown format. Do you want to open the video in your browser?", FormMessage.Yes, FormMessage.No)){
BrowserUtils.OpenExternalBrowser(tweetUrl); BrowserUtils.OpenExternalBrowser(url);
} }
break; break;
@@ -185,15 +184,13 @@ namespace TweetDuck.Management{
public Process Process { get; } public Process Process { get; }
public DuplexPipe.Server Pipe { get; } public DuplexPipe.Server Pipe { get; }
public string VideoUrl { get; } public string Url { get; }
public string TweetUrl { get; }
public string Username { get; } public string Username { get; }
public Instance(Process process, DuplexPipe.Server pipe, string videoUrl, string tweetUrl, string username){ public Instance(Process process, DuplexPipe.Server pipe, string url, string username){
this.Process = process; this.Process = process;
this.Pipe = pipe; this.Pipe = pipe;
this.VideoUrl = videoUrl; this.Url = url;
this.TweetUrl = tweetUrl;
this.Username = username; this.Username = username;
} }

View File

@@ -1,18 +1,18 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp; using CefSharp;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetLib.Core.Features.Notifications; using TweetDuck.Plugins;
using TweetLib.Core.Features.Plugins; using TweetDuck.Resources;
namespace TweetDuck.Browser.Notification.Example{ namespace TweetDuck.Core.Notification.Example{
sealed class FormNotificationExample : FormNotificationMain{ sealed class FormNotificationExample : FormNotificationMain{
public override bool RequiresResize => true; public override bool RequiresResize => true;
protected override bool CanDragWindow => Config.NotificationPosition == DesktopNotification.Position.Custom; protected override bool CanDragWindow => Config.NotificationPosition == TweetNotification.Position.Custom;
protected override FormBorderStyle NotificationBorderStyle{ protected override FormBorderStyle NotificationBorderStyle{
get{ get{
if (Config.NotificationSize == DesktopNotification.Size.Custom){ if (Config.NotificationSize == TweetNotification.Size.Custom){
switch(base.NotificationBorderStyle){ switch(base.NotificationBorderStyle){
case FormBorderStyle.FixedSingle: return FormBorderStyle.Sizable; case FormBorderStyle.FixedSingle: return FormBorderStyle.Sizable;
case FormBorderStyle.FixedToolWindow: return FormBorderStyle.SizableToolWindow; case FormBorderStyle.FixedToolWindow: return FormBorderStyle.SizableToolWindow;
@@ -27,18 +27,18 @@ namespace TweetDuck.Browser.Notification.Example{
public event EventHandler Ready; public event EventHandler Ready;
private readonly DesktopNotification exampleNotification; private readonly TweetNotification exampleNotification;
public FormNotificationExample(FormBrowser owner, PluginManager pluginManager) : base(owner, pluginManager, false){ public FormNotificationExample(FormBrowser owner, PluginManager pluginManager) : base(owner, pluginManager, false){
browser.LoadingStateChanged += browser_LoadingStateChanged; browser.LoadingStateChanged += browser_LoadingStateChanged;
string exampleTweetHTML = Program.Resources.LoadSilent("pages/example.html")?.Replace("{avatar}", AppLogo.Url) ?? string.Empty; string exampleTweetHTML = ScriptLoader.LoadResourceSilent("pages/example.html")?.Replace("{avatar}", TweetNotification.AppLogo.Url) ?? string.Empty;
#if DEBUG #if DEBUG
exampleTweetHTML = exampleTweetHTML.Replace("</p>", @"</p><div style='margin-top:256px'>Scrollbar test padding...</div>"); exampleTweetHTML = exampleTweetHTML.Replace("</p>", @"</p><div style='margin-top:256px'>Scrollbar test padding...</div>");
#endif #endif
exampleNotification = new DesktopNotification(string.Empty, string.Empty, "Home", exampleTweetHTML, 176, string.Empty, string.Empty); exampleNotification = new TweetNotification(string.Empty, string.Empty, "Home", exampleTweetHTML, 176, string.Empty, string.Empty);
} }
private void browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){ private void browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){

View File

@@ -1,10 +1,21 @@
namespace TweetDuck.Browser.Notification { namespace TweetDuck.Core.Notification {
partial class FormNotificationBase { partial class FormNotificationBase {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; 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 #region Windows Form Designer generated code
/// <summary> /// <summary>
@@ -23,7 +34,7 @@
this.BackColor = System.Drawing.SystemColors.Control; this.BackColor = System.Drawing.SystemColors.Control;
this.ClientSize = new System.Drawing.Size(284, 122); this.ClientSize = new System.Drawing.Size(284, 122);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Location = TweetDuck.Controls.ControlExtensions.InvisibleLocation; this.Location = TweetDuck.Core.Controls.ControlExtensions.InvisibleLocation;
this.MaximizeBox = false; this.MaximizeBox = false;
this.MinimizeBox = false; this.MinimizeBox = false;
this.Name = "FormNotification"; this.Name = "FormNotification";

View File

@@ -1,34 +1,28 @@
using System.Drawing; using CefSharp.WinForms;
using System.Drawing;
using System.Windows.Forms; 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.Configuration;
using TweetDuck.Controls; using TweetDuck.Core.Bridge;
using TweetDuck.Management.Analytics; using TweetDuck.Core.Controls;
using TweetDuck.Utils; using TweetDuck.Core.Handling;
using TweetLib.Core.Features.Notifications; using TweetDuck.Core.Handling.General;
using TweetLib.Core.Features.Twitter; using TweetDuck.Core.Other.Analytics;
using TweetDuck.Core.Utils;
namespace TweetDuck.Browser.Notification{ namespace TweetDuck.Core.Notification{
abstract partial class FormNotificationBase : Form, AnalyticsFile.IProvider{ abstract partial class FormNotificationBase : Form, AnalyticsFile.IProvider{
public static readonly ResourceLink AppLogo = new ResourceLink("https://ton.twimg.com/tduck/avatar", ResourceHandler.FromByteArray(Properties.Resources.avatar, "image/png"));
public static string FontSize = null;
public static string HeadLayout = null;
protected static UserConfig Config => Program.Config.User; protected static UserConfig Config => Program.Config.User;
protected static int FontSizeLevel{ protected static int FontSizeLevel{
get => FontSize switch{ get{
"largest" => 4, switch(TweetDeckBridge.FontSize){
"large" => 3, case "largest": return 4;
"small" => 1, case "large": return 3;
"smallest" => 0, case "small": return 1;
_ => 2 case "smallest": return 0;
}; default: return 2;
}
}
} }
protected virtual Point PrimaryLocation{ protected virtual Point PrimaryLocation{
@@ -45,19 +39,19 @@ namespace TweetDuck.Browser.Notification{
int edgeDist = Config.NotificationEdgeDistance; int edgeDist = Config.NotificationEdgeDistance;
switch(Config.NotificationPosition){ switch(Config.NotificationPosition){
case DesktopNotification.Position.TopLeft: case TweetNotification.Position.TopLeft:
return new Point(screen.WorkingArea.X+edgeDist, screen.WorkingArea.Y+edgeDist); return new Point(screen.WorkingArea.X+edgeDist, screen.WorkingArea.Y+edgeDist);
case DesktopNotification.Position.TopRight: case TweetNotification.Position.TopRight:
return new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+edgeDist); return new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+edgeDist);
case DesktopNotification.Position.BottomLeft: case TweetNotification.Position.BottomLeft:
return new Point(screen.WorkingArea.X+edgeDist, screen.WorkingArea.Y+screen.WorkingArea.Height-edgeDist-Height); return new Point(screen.WorkingArea.X+edgeDist, screen.WorkingArea.Y+screen.WorkingArea.Height-edgeDist-Height);
case DesktopNotification.Position.BottomRight: case TweetNotification.Position.BottomRight:
return new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+screen.WorkingArea.Height-edgeDist-Height); return new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+screen.WorkingArea.Height-edgeDist-Height);
case DesktopNotification.Position.Custom: case TweetNotification.Position.Custom:
if (!Config.IsCustomNotificationPositionSet){ if (!Config.IsCustomNotificationPositionSet){
Config.CustomNotificationPosition = new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+edgeDist); Config.CustomNotificationPosition = new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+edgeDist);
Config.Save(); Config.Save();
@@ -103,14 +97,11 @@ namespace TweetDuck.Browser.Notification{
protected double SizeScale => DpiScale*Config.ZoomLevel/100.0; protected double SizeScale => DpiScale*Config.ZoomLevel/100.0;
protected readonly FormBrowser owner; protected readonly FormBrowser owner;
#pragma warning disable IDE0069 // Disposable fields should be disposed
protected readonly ChromiumWebBrowser browser; protected readonly ChromiumWebBrowser browser;
#pragma warning restore IDE0069 // Disposable fields should be disposed
private readonly ResourceHandlerNotification resourceHandler = new ResourceHandlerNotification(); private readonly ResourceHandlerNotification resourceHandler = new ResourceHandlerNotification();
private DesktopNotification currentNotification; private TweetNotification currentNotification;
private int pauseCounter; private int pauseCounter;
public string CurrentTweetUrl => currentNotification?.TweetUrl; public string CurrentTweetUrl => currentNotification?.TweetUrl;
@@ -131,8 +122,8 @@ namespace TweetDuck.Browser.Notification{
this.owner.FormClosed += owner_FormClosed; this.owner.FormClosed += owner_FormClosed;
ResourceHandlerFactory resourceHandlerFactory = new ResourceHandlerFactory(); ResourceHandlerFactory resourceHandlerFactory = new ResourceHandlerFactory();
resourceHandlerFactory.RegisterHandler(TwitterUrls.TweetDeck, this.resourceHandler); resourceHandlerFactory.RegisterHandler(TwitterUtils.TweetDeckURL, this.resourceHandler);
resourceHandlerFactory.RegisterHandler(AppLogo); resourceHandlerFactory.RegisterHandler(TweetNotification.AppLogo);
this.browser = new ChromiumWebBrowser("about:blank"){ this.browser = new ChromiumWebBrowser("about:blank"){
MenuHandler = new ContextMenuNotification(this, enableContextMenu), MenuHandler = new ContextMenuNotification(this, enableContextMenu),
@@ -149,8 +140,8 @@ namespace TweetDuck.Browser.Notification{
Controls.Add(browser); Controls.Add(browser);
Disposed += (sender, args) => { Disposed += (sender, args) => {
this.owner.FormClosed -= owner_FormClosed;
this.browser.Dispose(); this.browser.Dispose();
this.owner.FormClosed -= owner_FormClosed;
}; };
DpiScale = this.GetDPIScale(); DpiScale = this.GetDPIScale();
@@ -159,15 +150,6 @@ namespace TweetDuck.Browser.Notification{
UpdateTitle(); UpdateTitle();
} }
protected override void Dispose(bool disposing){
if (disposing){
components?.Dispose();
resourceHandler.Dispose();
}
base.Dispose(disposing);
}
protected override void WndProc(ref Message m){ protected override void WndProc(ref Message m){
if (m.Msg == 0x0112 && (m.WParam.ToInt32() & 0xFFF0) == 0xF010 && !CanDragWindow){ // WM_SYSCOMMAND, SC_MOVE if (m.Msg == 0x0112 && (m.WParam.ToInt32() & 0xFFF0) == 0xF010 && !CanDragWindow){ // WM_SYSCOMMAND, SC_MOVE
return; return;
@@ -206,13 +188,13 @@ namespace TweetDuck.Browser.Notification{
} }
} }
protected abstract string GetTweetHTML(DesktopNotification tweet); protected abstract string GetTweetHTML(TweetNotification tweet);
protected virtual void LoadTweet(DesktopNotification tweet){ protected virtual void LoadTweet(TweetNotification tweet){
currentNotification = tweet; currentNotification = tweet;
resourceHandler.SetHTML(GetTweetHTML(tweet)); resourceHandler.SetHTML(GetTweetHTML(tweet));
browser.Load(TwitterUrls.TweetDeck); browser.Load(TwitterUtils.TweetDeckURL);
DisplayTooltip(null); DisplayTooltip(null);
} }

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Browser.Notification { namespace TweetDuck.Core.Notification {
partial class FormNotificationMain { partial class FormNotificationMain {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -26,7 +26,7 @@
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
this.timerDisplayDelay = new System.Windows.Forms.Timer(this.components); this.timerDisplayDelay = new System.Windows.Forms.Timer(this.components);
this.timerProgress = new System.Windows.Forms.Timer(this.components); this.timerProgress = new System.Windows.Forms.Timer(this.components);
this.progressBarTimer = new TweetDuck.Controls.FlatProgressBar(); this.progressBarTimer = new TweetDuck.Core.Controls.FlatProgressBar();
this.SuspendLayout(); this.SuspendLayout();
// //
// timerDisplayDelay // timerDisplayDelay

View File

@@ -1,19 +1,17 @@
using System; using CefSharp;
using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp; using TweetDuck.Core.Bridge;
using TweetDuck.Browser.Adapters; using TweetDuck.Core.Controls;
using TweetDuck.Browser.Bridge; using TweetDuck.Core.Handling;
using TweetDuck.Browser.Handling; using TweetDuck.Core.Utils;
using TweetDuck.Controls; using TweetDuck.Data;
using TweetDuck.Plugins; using TweetDuck.Plugins;
using TweetDuck.Utils; using TweetDuck.Plugins.Enums;
using TweetLib.Core.Data; using TweetDuck.Resources;
using TweetLib.Core.Features.Notifications;
using TweetLib.Core.Features.Plugins;
using TweetLib.Core.Features.Plugins.Enums;
namespace TweetDuck.Browser.Notification{ namespace TweetDuck.Core.Notification{
abstract partial class FormNotificationMain : FormNotificationBase{ abstract partial class FormNotificationMain : FormNotificationBase{
private readonly PluginManager plugins; private readonly PluginManager plugins;
private readonly int timerBarHeight; private readonly int timerBarHeight;
@@ -25,8 +23,6 @@ namespace TweetDuck.Browser.Notification{
private IntPtr mouseHook; private IntPtr mouseHook;
private bool blockXButtonUp; private bool blockXButtonUp;
private int currentOpacity;
private bool? prevDisplayTimer; private bool? prevDisplayTimer;
private int? prevFontSize; private int? prevFontSize;
@@ -48,17 +44,27 @@ namespace TweetDuck.Browser.Notification{
} }
private int BaseClientWidth{ private int BaseClientWidth{
get => Config.NotificationSize switch{ get{
DesktopNotification.Size.Custom => Config.CustomNotificationSize.Width, switch(Config.NotificationSize){
_ => BrowserUtils.Scale(284, SizeScale * (1.0 + 0.05 * FontSizeLevel)) default:
}; return BrowserUtils.Scale(284, SizeScale*(1.0+0.05*FontSizeLevel));
case TweetNotification.Size.Custom:
return Config.CustomNotificationSize.Width;
}
}
} }
private int BaseClientHeight{ private int BaseClientHeight{
get => Config.NotificationSize switch{ get{
DesktopNotification.Size.Custom => Config.CustomNotificationSize.Height, switch(Config.NotificationSize){
_ => BrowserUtils.Scale(122, SizeScale * (1.0 + 0.08 * FontSizeLevel)) default:
}; return BrowserUtils.Scale(122, SizeScale*(1.0+0.08*FontSizeLevel));
case TweetNotification.Size.Custom:
return Config.CustomNotificationSize.Height;
}
}
} }
protected virtual string BodyClasses => IsCursorOverBrowser ? "td-notification td-hover" : "td-notification"; protected virtual string BodyClasses => IsCursorOverBrowser ? "td-notification td-hover" : "td-notification";
@@ -77,21 +83,12 @@ namespace TweetDuck.Browser.Notification{
browser.LoadingStateChanged += Browser_LoadingStateChanged; browser.LoadingStateChanged += Browser_LoadingStateChanged;
browser.FrameLoadEnd += Browser_FrameLoadEnd; browser.FrameLoadEnd += Browser_FrameLoadEnd;
plugins.Register(PluginEnvironment.Notification, new PluginDispatcher(browser)); plugins.Register(browser, PluginEnvironment.Notification, this);
mouseHookDelegate = MouseHookProc; mouseHookDelegate = MouseHookProc;
Disposed += (sender, args) => StopMouseHook(true); Disposed += (sender, args) => StopMouseHook(true);
} }
// helpers
private void SetOpacity(int opacity){
if (currentOpacity != opacity){
currentOpacity = opacity;
Opacity = opacity / 100.0;
}
}
// mouse wheel hook // mouse wheel hook
private void StartMouseHook(){ private void StartMouseHook(){
@@ -167,7 +164,7 @@ namespace TweetDuck.Browser.Notification{
if (frame.IsMain && browser.Address != "about:blank"){ if (frame.IsMain && browser.Address != "about:blank"){
frame.ExecuteJavaScriptAsync(PropertyBridge.GenerateScript(PropertyBridge.Environment.Notification)); frame.ExecuteJavaScriptAsync(PropertyBridge.GenerateScript(PropertyBridge.Environment.Notification));
CefScriptExecutor.RunFile(frame, "notification.js"); ScriptLoader.ExecuteFile(frame, "notification.js", this);
} }
} }
@@ -177,18 +174,7 @@ namespace TweetDuck.Browser.Notification{
} }
private void timerHideProgress_Tick(object sender, EventArgs e){ private void timerHideProgress_Tick(object sender, EventArgs e){
bool isCursorInside = Bounds.Contains(Cursor.Position); if (Bounds.Contains(Cursor.Position) || FreezeTimer || ContextMenuOpen){
if (isCursorInside){
StartMouseHook();
SetOpacity(100);
}
else{
StopMouseHook(false);
SetOpacity(Config.NotificationWindowOpacity);
}
if (isCursorInside || FreezeTimer || ContextMenuOpen){
return; return;
} }
@@ -204,7 +190,7 @@ namespace TweetDuck.Browser.Notification{
// notification methods // notification methods
public virtual void ShowNotification(DesktopNotification notification){ public virtual void ShowNotification(TweetNotification notification){
LoadTweet(notification); LoadTweet(notification);
} }
@@ -241,8 +227,8 @@ namespace TweetDuck.Browser.Notification{
} }
} }
protected override string GetTweetHTML(DesktopNotification tweet){ protected override string GetTweetHTML(TweetNotification tweet){
string html = tweet.GenerateHtml(BodyClasses, HeadLayout, Config.CustomNotificationCSS); string html = tweet.GenerateHtml(BodyClasses, this);
foreach(InjectedHTML injection in plugins.NotificationInjections){ foreach(InjectedHTML injection in plugins.NotificationInjections){
html = injection.InjectInto(html); html = injection.InjectInto(html);
@@ -251,7 +237,7 @@ namespace TweetDuck.Browser.Notification{
return html; return html;
} }
protected override void LoadTweet(DesktopNotification tweet){ protected override void LoadTweet(TweetNotification tweet){
timerProgress.Stop(); timerProgress.Stop();
totalTime = timeLeft = tweet.GetDisplayDuration(Config.NotificationDurationValue); totalTime = timeLeft = tweet.GetDisplayDuration(Config.NotificationDurationValue);
progressBarTimer.Value = Config.NotificationTimerCountDown ? progressBarTimer.Maximum : progressBarTimer.Minimum; progressBarTimer.Value = Config.NotificationTimerCountDown ? progressBarTimer.Maximum : progressBarTimer.Minimum;
@@ -278,8 +264,8 @@ namespace TweetDuck.Browser.Notification{
SetNotificationSize(BaseClientWidth, BaseClientHeight); SetNotificationSize(BaseClientWidth, BaseClientHeight);
} }
SetOpacity(IsCursorOverBrowser ? 100 : Config.NotificationWindowOpacity);
MoveToVisibleLocation(); MoveToVisibleLocation();
StartMouseHook();
} }
protected virtual void OnNotificationReady(){ protected virtual void OnNotificationReady(){

View File

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

View File

@@ -1,12 +1,11 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using TweetDuck.Plugins;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Utils; using TweetDuck.Core.Utils;
using TweetLib.Core.Features.Notifications;
using TweetLib.Core.Features.Plugins;
namespace TweetDuck.Browser.Notification{ namespace TweetDuck.Core.Notification{
sealed partial class FormNotificationTweet : FormNotificationMain{ sealed partial class FormNotificationTweet : FormNotificationMain{
private const int NonIntrusiveIdleLimit = 30; private const int NonIntrusiveIdleLimit = 30;
private const int TrimMinimum = 32; private const int TrimMinimum = 32;
@@ -26,7 +25,7 @@ namespace TweetDuck.Browser.Notification{
} }
} }
private readonly Queue<DesktopNotification> tweetQueue = new Queue<DesktopNotification>(4); private readonly Queue<TweetNotification> tweetQueue = new Queue<TweetNotification>(4);
private bool needsTrim; private bool needsTrim;
private bool hasTemporarilyMoved; private bool hasTemporarilyMoved;
@@ -82,7 +81,7 @@ namespace TweetDuck.Browser.Notification{
// notification methods // notification methods
public override void ShowNotification(DesktopNotification notification){ public override void ShowNotification(TweetNotification notification){
tweetQueue.Enqueue(notification); tweetQueue.Enqueue(notification);
if (!IsPaused){ if (!IsPaused){

View File

@@ -3,15 +3,14 @@ using System.Drawing;
using System.Drawing.Imaging; using System.Drawing.Imaging;
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp; using CefSharp;
using TweetDuck.Browser.Adapters; using TweetDuck.Core.Controls;
using TweetDuck.Controls; using TweetDuck.Core.Other;
using TweetDuck.Dialogs; using TweetDuck.Core.Utils;
using TweetDuck.Utils; using TweetDuck.Data;
using TweetLib.Core.Data; using TweetDuck.Plugins;
using TweetLib.Core.Features.Notifications; using TweetDuck.Resources;
using TweetLib.Core.Features.Plugins;
namespace TweetDuck.Browser.Notification.Screenshot{ namespace TweetDuck.Core.Notification.Screenshot{
sealed class FormNotificationScreenshotable : FormNotificationBase{ sealed class FormNotificationScreenshotable : FormNotificationBase{
protected override bool CanDragWindow => false; protected override bool CanDragWindow => false;
@@ -30,23 +29,24 @@ namespace TweetDuck.Browser.Notification.Screenshot{
return; return;
} }
string script = Program.Resources.LoadSilent("screenshot.js"); string script = ScriptLoader.LoadResourceSilent("screenshot.js");
if (script == null){ if (script == null){
this.InvokeAsyncSafe(callback); this.InvokeAsyncSafe(callback);
return; return;
} }
using IFrame frame = args.Browser.MainFrame; using(IFrame frame = args.Browser.MainFrame){
CefScriptExecutor.RunScript(frame, script.Replace("{width}", realWidth.ToString()).Replace("{frames}", TweetScreenshotManager.WaitFrames.ToString()), "gen:screenshot"); ScriptLoader.ExecuteScript(frame, script.Replace("{width}", realWidth.ToString()).Replace("{frames}", TweetScreenshotManager.WaitFrames.ToString()), "gen:screenshot");
}
}; };
SetNotificationSize(realWidth, 1024); SetNotificationSize(realWidth, 1024);
LoadTweet(new DesktopNotification(string.Empty, string.Empty, string.Empty, html, 0, string.Empty, string.Empty)); LoadTweet(new TweetNotification(string.Empty, string.Empty, string.Empty, html, 0, string.Empty, string.Empty));
} }
protected override string GetTweetHTML(DesktopNotification tweet){ protected override string GetTweetHTML(TweetNotification tweet){
string html = tweet.GenerateHtml("td-screenshot", HeadLayout, Config.CustomNotificationCSS); string html = tweet.GenerateHtml("td-screenshot", this);
foreach(InjectedHTML injection in plugins.NotificationInjections){ foreach(InjectedHTML injection in plugins.NotificationInjections){
html = injection.InjectInto(html); html = injection.InjectInto(html);
@@ -82,8 +82,7 @@ namespace TweetDuck.Browser.Notification.Screenshot{
return false; return false;
} }
else{ else{
using Bitmap bmp = new Bitmap(ClientSize.Width, Math.Max(1, height), PixelFormat.Format32bppRgb); using(Bitmap bmp = new Bitmap(ClientSize.Width, Math.Max(1, height), PixelFormat.Format32bppRgb)){
try{ try{
NativeMethods.RenderSourceIntoBitmap(context, bmp); NativeMethods.RenderSourceIntoBitmap(context, bmp);
}finally{ }finally{
@@ -96,3 +95,4 @@ namespace TweetDuck.Browser.Notification.Screenshot{
} }
} }
} }
}

View File

@@ -1,10 +1,8 @@
using System; using System;
using System.Diagnostics.CodeAnalysis;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
namespace TweetDuck.Browser.Notification.Screenshot{ namespace TweetDuck.Core.Notification.Screenshot{
[SuppressMessage("ReSharper", "UnusedMember.Global")]
sealed class ScreenshotBridge{ sealed class ScreenshotBridge{
private readonly Control owner; private readonly Control owner;

View File

@@ -8,8 +8,8 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetLib.Core.Features.Plugins; using TweetDuck.Plugins;
#if GEN_SCREENSHOT_FRAMES #if GEN_SCREENSHOT_FRAMES
using System.Drawing.Imaging; using System.Drawing.Imaging;
@@ -17,7 +17,7 @@ using System.IO;
using TweetDuck.Core.Utils; using TweetDuck.Core.Utils;
#endif #endif
namespace TweetDuck.Browser.Notification.Screenshot{ namespace TweetDuck.Core.Notification.Screenshot{
sealed class TweetScreenshotManager : IDisposable{ sealed class TweetScreenshotManager : IDisposable{
private readonly FormBrowser owner; private readonly FormBrowser owner;
private readonly PluginManager plugins; private readonly PluginManager plugins;

View File

@@ -0,0 +1,50 @@
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using CefSharp;
using TweetDuck.Core.Controls;
using TweetDuck.Core.Other;
using TweetDuck.Core.Other.Settings;
namespace TweetDuck.Core.Notification{
static class SoundNotification{
public const string SupportedFormats = "*.wav;*.ogg;*.mp3;*.flac;*.opus;*.weba;*.webm";
public static IResourceHandler CreateFileHandler(string path){
string mimeType;
switch(Path.GetExtension(path)){
case ".weba":
case ".webm": mimeType = "audio/webm"; break;
case ".wav": mimeType = "audio/wav"; break;
case ".ogg": mimeType = "audio/ogg"; break;
case ".mp3": mimeType = "audio/mp3"; break;
case ".flac": mimeType = "audio/flac"; break;
case ".opus": mimeType = "audio/ogg; codecs=opus"; break;
default: mimeType = null; break;
}
try{
return ResourceHandler.FromFilePath(path, mimeType);
}catch{
FormBrowser browser = FormManager.TryFind<FormBrowser>();
browser?.InvokeAsyncSafe(() => {
using(FormMessage form = new FormMessage("Sound Notification Error", "Could not find custom notification sound file:\n"+path, MessageBoxIcon.Error)){
form.AddButton(FormMessage.Ignore, ControlType.Cancel | ControlType.Focused);
Button btnViewOptions = form.AddButton("View Options");
btnViewOptions.Width += 16;
btnViewOptions.Location = new Point(btnViewOptions.Location.X-16, btnViewOptions.Location.Y);
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions){
browser.OpenSettings(typeof(TabSettingsSounds));
}
}
});
return null;
}
}
}
}

View File

@@ -1,9 +1,15 @@
using System; using System;
using System.Text; using System.Text;
using System.Windows.Forms;
using CefSharp;
using TweetDuck.Core.Bridge;
using TweetDuck.Data;
using TweetDuck.Resources;
namespace TweetLib.Core.Features.Notifications{ namespace TweetDuck.Core.Notification{
public sealed class DesktopNotification{ sealed class TweetNotification{
private const string DefaultHeadLayout = @"<html class=""scroll-v os-windows dark txt-size--14"" lang=""en-US"" id=""tduck"" data-td-font=""medium"" data-td-theme=""dark""><head><meta charset=""utf-8""><link href=""https://ton.twimg.com/tweetdeck-web/web/dist/bundle.4b1f87e09d.css"" rel=""stylesheet""><style type='text/css'>body { background: rgb(34, 36, 38) !important }</style>"; private const string DefaultHeadLayout = @"<html class=""scroll-v os-windows dark txt-size--14"" lang=""en-US"" id=""tduck"" data-td-font=""medium"" data-td-theme=""dark""><head><meta charset=""utf-8""><link href=""https://ton.twimg.com/tweetdeck-web/web/dist/bundle.4b1f87e09d.css"" rel=""stylesheet""><style type='text/css'>body { background: rgb(34, 36, 38) !important }</style>";
public static readonly ResourceLink AppLogo = new ResourceLink("https://ton.twimg.com/tduck/avatar", ResourceHandler.FromByteArray(Properties.Resources.avatar, "image/png"));
public enum Position{ public enum Position{
TopLeft, TopRight, BottomLeft, BottomRight, Custom TopLeft, TopRight, BottomLeft, BottomRight, Custom
@@ -23,7 +29,7 @@ namespace TweetLib.Core.Features.Notifications{
private readonly string html; private readonly string html;
private readonly int characters; private readonly int characters;
public DesktopNotification(string columnId, string chirpId, string title, string html, int characters, string tweetUrl, string quoteUrl){ public TweetNotification(string columnId, string chirpId, string title, string html, int characters, string tweetUrl, string quoteUrl){
this.ColumnId = columnId; this.ColumnId = columnId;
this.ChirpId = chirpId; this.ChirpId = chirpId;
@@ -39,19 +45,18 @@ namespace TweetLib.Core.Features.Notifications{
return 2000+Math.Max(1000, value*characters); return 2000+Math.Max(1000, value*characters);
} }
public string GenerateHtml(string bodyClasses, string? headLayout, string? customStyles){ // TODO public string GenerateHtml(string bodyClasses, Control sync){
headLayout ??= DefaultHeadLayout; string headLayout = TweetDeckBridge.NotificationHeadLayout ?? DefaultHeadLayout;
customStyles ??= string.Empty; string mainCSS = ScriptLoader.LoadResource("styles/notification.css", sync) ?? string.Empty;
string customCSS = Program.Config.User.CustomNotificationCSS ?? string.Empty;
string mainCSS = App.ResourceHandler.Load("styles/notification.css") ?? string.Empty; StringBuilder build = new StringBuilder(320 + headLayout.Length + mainCSS.Length + customCSS.Length + html.Length);
StringBuilder build = new StringBuilder(320 + headLayout.Length + mainCSS.Length + customStyles.Length + html.Length);
build.Append("<!DOCTYPE html>"); build.Append("<!DOCTYPE html>");
build.Append(headLayout); build.Append(headLayout);
build.Append("<style type='text/css'>").Append(mainCSS).Append("</style>"); build.Append("<style type='text/css'>").Append(mainCSS).Append("</style>");
if (!string.IsNullOrWhiteSpace(customStyles)){ if (!string.IsNullOrWhiteSpace(customCSS)){
build.Append("<style type='text/css'>").Append(customStyles).Append("</style>"); build.Append("<style type='text/css'>").Append(customCSS).Append("</style>");
} }
build.Append("</head><body class='scroll-styled-v"); build.Append("</head><body class='scroll-styled-v");

View File

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

View File

@@ -6,14 +6,11 @@ using System;
using System.Net; using System.Net;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Timers; using System.Timers;
using TweetDuck.Browser; using TweetDuck.Core.Controls;
using TweetDuck.Controls; using TweetDuck.Core.Utils;
using TweetDuck.Utils; using TweetDuck.Plugins;
using TweetLib.Core;
using TweetLib.Core.Features.Plugins;
using TweetLib.Core.Utils;
namespace TweetDuck.Management.Analytics{ namespace TweetDuck.Core.Other.Analytics{
sealed class AnalyticsManager : IDisposable{ sealed class AnalyticsManager : IDisposable{
private static readonly TimeSpan CollectionInterval = TimeSpan.FromDays(14); private static readonly TimeSpan CollectionInterval = TimeSpan.FromDays(14);
@@ -83,7 +80,7 @@ namespace TweetDuck.Management.Analytics{
private void SetLastDataCollectionTime(DateTime dt, string message = null){ private void SetLastDataCollectionTime(DateTime dt, string message = null){
File.LastDataCollection = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, 0, dt.Kind); File.LastDataCollection = new DateTime(dt.Year, dt.Month, dt.Day, dt.Hour, dt.Minute, 0, dt.Kind);
File.LastCollectionVersion = Program.VersionTag; File.LastCollectionVersion = Program.VersionTag;
File.LastCollectionMessage = message ?? dt.ToString("g", Lib.Culture); File.LastCollectionMessage = message ?? dt.ToString("g", Program.Culture);
File.Save(); File.Save();
RestartTimer(); RestartTimer();
@@ -120,7 +117,7 @@ namespace TweetDuck.Management.Analytics{
System.Diagnostics.Debugger.Break(); System.Diagnostics.Debugger.Break();
#endif #endif
WebUtils.NewClient(BrowserUtils.UserAgentVanilla).UploadValues(CollectionUrl, "POST", report.ToNameValueCollection()); BrowserUtils.CreateWebClient().UploadValues(CollectionUrl, "POST", report.ToNameValueCollection());
}).ContinueWith(task => browser.InvokeAsyncSafe(() => { }).ContinueWith(task => browser.InvokeAsyncSafe(() => {
if (task.Status == TaskStatus.RanToCompletion){ if (task.Status == TaskStatus.RanToCompletion){
SetLastDataCollectionTime(DateTime.Now); SetLastDataCollectionTime(DateTime.Now);
@@ -139,7 +136,8 @@ namespace TweetDuck.Management.Analytics{
break; break;
case WebExceptionStatus.ProtocolError: case WebExceptionStatus.ProtocolError:
message = "HTTP Error " + (e.Response is HttpWebResponse response ? $"{(int)response.StatusCode} ({response.StatusDescription})" : "(unknown code)"); HttpWebResponse response = e.Response as HttpWebResponse;
message = "HTTP Error "+(response != null ? $"{(int)response.StatusCode} ({response.StatusDescription})" : "(unknown code)");
break; break;
} }

View File

@@ -2,7 +2,7 @@
using System.Collections.Specialized; using System.Collections.Specialized;
using System.Text; using System.Text;
namespace TweetDuck.Management.Analytics{ namespace TweetDuck.Core.Other.Analytics{
sealed class AnalyticsReport : IEnumerable{ sealed class AnalyticsReport : IEnumerable{
private OrderedDictionary data = new OrderedDictionary(32); private OrderedDictionary data = new OrderedDictionary(32);
private int separators; private int separators;

View File

@@ -2,21 +2,18 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Windows.Forms;
using Microsoft.Win32;
using TweetDuck.Configuration;
using System.Linq; using System.Linq;
using System.Management; using System.Management;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using TweetDuck.Core.Notification;
using Microsoft.Win32; using TweetDuck.Core.Utils;
using TweetDuck.Browser; using TweetDuck.Plugins;
using TweetDuck.Configuration; using TweetDuck.Plugins.Enums;
using TweetDuck.Utils;
using TweetLib.Core;
using TweetLib.Core.Features.Notifications;
using TweetLib.Core.Features.Plugins;
using TweetLib.Core.Features.Plugins.Enums;
using TweetLib.Core.Utils;
namespace TweetDuck.Management.Analytics{ namespace TweetDuck.Core.Other.Analytics{
static class AnalyticsReportGenerator{ static class AnalyticsReportGenerator{
public static AnalyticsReport Create(AnalyticsFile file, ExternalInfo info, PluginManager plugins){ public static AnalyticsReport Create(AnalyticsFile file, ExternalInfo info, PluginManager plugins){
Dictionary<string, string> editLayoutDesign = EditLayoutDesignPluginData; Dictionary<string, string> editLayoutDesign = EditLayoutDesignPluginData;
@@ -30,7 +27,7 @@ namespace TweetDuck.Management.Analytics{
{ "System Edition" , SystemEdition }, { "System Edition" , SystemEdition },
{ "System Environment" , Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit" }, { "System Environment" , Environment.Is64BitOperatingSystem ? "64-bit" : "32-bit" },
{ "System Build" , SystemBuild }, { "System Build" , SystemBuild },
{ "System Locale" , Lib.Culture.Name.ToLower() }, { "System Locale" , Program.Culture.Name.ToLower() },
0, 0,
{ "RAM" , Exact(RamSize) }, { "RAM" , Exact(RamSize) },
{ "GPU" , GpuVendor }, { "GPU" , GpuVendor },
@@ -82,7 +79,7 @@ namespace TweetDuck.Management.Analytics{
{ "Custom Notification CSS" , RoundUp((UserConfig.CustomNotificationCSS ?? string.Empty).Length, 50) }, { "Custom Notification CSS" , RoundUp((UserConfig.CustomNotificationCSS ?? string.Empty).Length, 50) },
0, 0,
{ "Plugins All" , List(plugins.Plugins.Select(Plugin)) }, { "Plugins All" , List(plugins.Plugins.Select(Plugin)) },
{ "Plugins Enabled" , List(plugins.Plugins.Where(plugins.Config.IsEnabled).Select(Plugin)) }, { "Plugins Enabled" , List(plugins.Plugins.Where(plugin => plugins.Config.IsEnabled(plugin)).Select(Plugin)) },
0, 0,
{ "Theme" , Dict(editLayoutDesign, "_theme", "light/def") }, { "Theme" , Dict(editLayoutDesign, "_theme", "light/def") },
{ "Column Width" , Dict(editLayoutDesign, "columnWidth", "310px/def") }, { "Column Width" , Dict(editLayoutDesign, "columnWidth", "310px/def") },
@@ -144,8 +141,7 @@ namespace TweetDuck.Management.Analytics{
string osName, osEdition, osBuild; string osName, osEdition, osBuild;
try{ try{
using RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", false); using(RegistryKey key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows NT\CurrentVersion", false)){
// ReSharper disable once PossibleNullReferenceException // ReSharper disable once PossibleNullReferenceException
osName = key.GetValue("ProductName") as string; osName = key.GetValue("ProductName") as string;
osBuild = key.GetValue("CurrentBuild") as string; osBuild = key.GetValue("CurrentBuild") as string;
@@ -159,6 +155,7 @@ namespace TweetDuck.Management.Analytics{
osEdition = match.Groups[2].Value; osEdition = match.Groups[2].Value;
} }
} }
}
}catch{ }catch{
osName = osEdition = osBuild = null; osName = osEdition = osBuild = null;
} }
@@ -168,11 +165,11 @@ namespace TweetDuck.Management.Analytics{
SystemBuild = osBuild ?? "(unknown)"; SystemBuild = osBuild ?? "(unknown)";
try{ try{
using ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Capacity FROM Win32_PhysicalMemory"); using(ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Capacity FROM Win32_PhysicalMemory")){
foreach(ManagementBaseObject obj in searcher.Get()){ foreach(ManagementBaseObject obj in searcher.Get()){
RamSize += (int)((ulong)obj["Capacity"]/(1024L*1024L)); RamSize += (int)((ulong)obj["Capacity"]/(1024L*1024L));
} }
}
}catch{ }catch{
RamSize = 0; RamSize = 0;
} }
@@ -180,8 +177,7 @@ namespace TweetDuck.Management.Analytics{
string gpu = null; string gpu = null;
try{ try{
using ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_VideoController"); using(ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Caption FROM Win32_VideoController")){
foreach(ManagementBaseObject obj in searcher.Get()){ foreach(ManagementBaseObject obj in searcher.Get()){
string vendor = obj["Caption"] as string; string vendor = obj["Caption"] as string;
@@ -189,6 +185,7 @@ namespace TweetDuck.Management.Analytics{
gpu = vendor; gpu = vendor;
} }
} }
}
}catch{ }catch{
// rip // rip
} }
@@ -207,30 +204,36 @@ namespace TweetDuck.Management.Analytics{
} }
private static string TrayMode{ private static string TrayMode{
get => UserConfig.TrayBehavior switch{ get{
TrayIcon.Behavior.DisplayOnly => "icon", switch(UserConfig.TrayBehavior){
TrayIcon.Behavior.MinimizeToTray => "minimize", case TrayIcon.Behavior.DisplayOnly: return "icon";
TrayIcon.Behavior.CloseToTray => "close", case TrayIcon.Behavior.MinimizeToTray: return "minimize";
TrayIcon.Behavior.Combined => "combined", case TrayIcon.Behavior.CloseToTray: return "close";
_ => "off" case TrayIcon.Behavior.Combined: return "combined";
}; default: return "off";
}
}
} }
private static string NotificationPosition{ private static string NotificationPosition{
get => UserConfig.NotificationPosition switch{ get{
DesktopNotification.Position.TopLeft => "top left", switch(UserConfig.NotificationPosition){
DesktopNotification.Position.TopRight => "top right", case TweetNotification.Position.TopLeft: return "top left";
DesktopNotification.Position.BottomLeft => "bottom left", case TweetNotification.Position.TopRight: return "top right";
DesktopNotification.Position.BottomRight => "bottom right", case TweetNotification.Position.BottomLeft: return "bottom left";
_ => "custom" case TweetNotification.Position.BottomRight: return "bottom right";
}; default: return "custom";
}
}
} }
private static string NotificationSize{ private static string NotificationSize{
get => UserConfig.NotificationSize switch{ get{
DesktopNotification.Size.Auto => "auto", switch(UserConfig.NotificationSize){
_ => RoundUp(UserConfig.CustomNotificationSize.Width, 20) + "x" + RoundUp(UserConfig.CustomNotificationSize.Height, 20) case TweetNotification.Size.Auto: return "auto";
}; default: return RoundUp(UserConfig.CustomNotificationSize.Width, 20)+"x"+RoundUp(UserConfig.CustomNotificationSize.Height, 20);
}
}
} }
private static string NotificationTimer{ private static string NotificationTimer{

View File

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

View File

@@ -2,10 +2,9 @@
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Management; using TweetDuck.Core.Utils;
using TweetDuck.Utils;
namespace TweetDuck.Dialogs{ namespace TweetDuck.Core.Other{
sealed partial class FormAbout : Form, FormManager.IAppDialog{ sealed partial class FormAbout : Form, FormManager.IAppDialog{
private const string TipsLink = "https://github.com/chylex/TweetDuck/wiki"; private const string TipsLink = "https://github.com/chylex/TweetDuck/wiki";
private const string IssuesLink = "https://github.com/chylex/TweetDuck/issues"; private const string IssuesLink = "https://github.com/chylex/TweetDuck/issues";

View File

@@ -1,10 +1,21 @@
namespace TweetDuck.Dialogs { namespace TweetDuck.Core.Other {
partial class FormGuide { partial class FormGuide {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; 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 #region Windows Form Designer generated code
/// <summary> /// <summary>

View File

@@ -1,18 +1,16 @@
using System.Drawing; using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using CefSharp; using CefSharp;
using CefSharp.WinForms; using CefSharp.WinForms;
using TweetDuck.Browser; using TweetDuck.Core.Controls;
using TweetDuck.Browser.Adapters; using TweetDuck.Core.Handling;
using TweetDuck.Browser.Data; using TweetDuck.Core.Handling.General;
using TweetDuck.Browser.Handling; using TweetDuck.Core.Utils;
using TweetDuck.Browser.Handling.General; using System.Text.RegularExpressions;
using TweetDuck.Controls; using TweetDuck.Data;
using TweetDuck.Management; using TweetDuck.Resources;
using TweetDuck.Utils;
namespace TweetDuck.Dialogs{ namespace TweetDuck.Core.Other{
sealed partial class FormGuide : Form, FormManager.IAppDialog{ sealed partial class FormGuide : Form, FormManager.IAppDialog{
private const string GuideUrl = "https://tweetduck.chylex.com/guide/v2/"; private const string GuideUrl = "https://tweetduck.chylex.com/guide/v2/";
private const string GuidePathRegex = @"^guide(?:/v\d+)?(?:/(#.*))?"; private const string GuidePathRegex = @"^guide(?:/v\d+)?(?:/(#.*))?";
@@ -56,10 +54,7 @@ namespace TweetDuck.Dialogs{
} }
} }
#pragma warning disable IDE0069 // Disposable fields should be disposed
private readonly ChromiumWebBrowser browser; private readonly ChromiumWebBrowser browser;
#pragma warning restore IDE0069 // Disposable fields should be disposed
private string nextUrl; private string nextUrl;
private FormGuide(string url, FormBrowser owner){ private FormGuide(string url, FormBrowser owner){
@@ -90,15 +85,10 @@ namespace TweetDuck.Dialogs{
browser.SetupZoomEvents(); browser.SetupZoomEvents();
Controls.Add(browser); Controls.Add(browser);
Disposed += (sender, args) => browser.Dispose();
}
protected override void Dispose(bool disposing){ Disposed += (sender, args) => {
if (disposing){ browser.Dispose();
components?.Dispose(); };
}
base.Dispose(disposing);
} }
private void Reload(string url){ private void Reload(string url){
@@ -126,7 +116,7 @@ namespace TweetDuck.Dialogs{
} }
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){ private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
CefScriptExecutor.RunScript(e.Frame, "Array.prototype.forEach.call(document.getElementsByTagName('A'), ele => ele.addEventListener('click', e => { e.preventDefault(); window.open(ele.getAttribute('href')); }))", "gen:links"); ScriptLoader.ExecuteScript(e.Frame, "Array.prototype.forEach.call(document.getElementsByTagName('A'), ele => ele.addEventListener('click', e => { e.preventDefault(); window.open(ele.getAttribute('href')); }))", "gen:links");
} }
} }
} }

View File

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

View File

@@ -1,10 +1,10 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetDuck.Utils; using TweetDuck.Core.Utils;
namespace TweetDuck.Dialogs{ namespace TweetDuck.Core.Other{
[Flags] [Flags]
enum ControlType{ enum ControlType{
None = 0, None = 0,
@@ -43,8 +43,7 @@ namespace TweetDuck.Dialogs{
} }
public static bool Show(string caption, string text, MessageBoxIcon icon, string buttonAccept, string buttonCancel){ public static bool Show(string caption, string text, MessageBoxIcon icon, string buttonAccept, string buttonCancel){
using FormMessage message = new FormMessage(caption, text, icon); using(FormMessage message = new FormMessage(caption, text, icon)){
if (buttonCancel == null){ if (buttonCancel == null){
message.AddButton(buttonAccept, DialogResult.OK, ControlType.Cancel | ControlType.Focused); message.AddButton(buttonAccept, DialogResult.OK, ControlType.Cancel | ControlType.Focused);
} }
@@ -55,6 +54,7 @@ namespace TweetDuck.Dialogs{
return message.ShowDialog() == DialogResult.OK; return message.ShowDialog() == DialogResult.OK;
} }
}
// Instance // Instance

View File

@@ -1,6 +1,4 @@
using TweetDuck.Controls; namespace TweetDuck.Core.Other {
namespace TweetDuck.Dialogs {
partial class FormPlugins { partial class FormPlugins {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -29,7 +27,7 @@ namespace TweetDuck.Dialogs {
this.btnClose = new System.Windows.Forms.Button(); this.btnClose = new System.Windows.Forms.Button();
this.btnReload = new System.Windows.Forms.Button(); this.btnReload = new System.Windows.Forms.Button();
this.btnOpenFolder = new System.Windows.Forms.Button(); this.btnOpenFolder = new System.Windows.Forms.Button();
this.flowLayoutPlugins = new FlowLayoutPanelNoHScroll(); this.flowLayoutPlugins = new TweetDuck.Plugins.Controls.PluginListFlowLayout();
this.timerLayout = new System.Windows.Forms.Timer(this.components); this.timerLayout = new System.Windows.Forms.Timer(this.components);
this.SuspendLayout(); this.SuspendLayout();
// //
@@ -119,7 +117,7 @@ namespace TweetDuck.Dialogs {
private System.Windows.Forms.Button btnClose; private System.Windows.Forms.Button btnClose;
private System.Windows.Forms.Button btnReload; private System.Windows.Forms.Button btnReload;
private System.Windows.Forms.Button btnOpenFolder; private System.Windows.Forms.Button btnOpenFolder;
private FlowLayoutPanelNoHScroll flowLayoutPlugins; private Plugins.Controls.PluginListFlowLayout flowLayoutPlugins;
private System.Windows.Forms.Timer timerLayout; private System.Windows.Forms.Timer timerLayout;
} }
} }

View File

@@ -1,14 +1,13 @@
using System; using System;
using System.Diagnostics;
using System.Drawing; using System.Drawing;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetDuck.Management;
using TweetDuck.Plugins; using TweetDuck.Plugins;
using TweetLib.Core; using TweetDuck.Plugins.Controls;
using TweetLib.Core.Features.Plugins;
namespace TweetDuck.Dialogs{ namespace TweetDuck.Core.Other{
sealed partial class FormPlugins : Form, FormManager.IAppDialog{ sealed partial class FormPlugins : Form, FormManager.IAppDialog{
private static UserConfig Config => Program.Config.User; private static UserConfig Config => Program.Config.User;
@@ -96,7 +95,7 @@ namespace TweetDuck.Dialogs{
} }
private void btnOpenFolder_Click(object sender, EventArgs e){ private void btnOpenFolder_Click(object sender, EventArgs e){
App.SystemHandler.OpenFileExplorer(pluginManager.PathCustomPlugins); using(Process.Start("explorer.exe", '"'+pluginManager.PathCustomPlugins+'"')){}
} }
private void btnReload_Click(object sender, EventArgs e){ private void btnReload_Click(object sender, EventArgs e){

View File

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

View File

@@ -2,19 +2,17 @@
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Browser; using TweetDuck.Core.Controls;
using TweetDuck.Browser.Handling.General; using TweetDuck.Core.Handling.General;
using TweetDuck.Browser.Notification.Example; using TweetDuck.Core.Notification.Example;
using TweetDuck.Configuration; using TweetDuck.Core.Other.Analytics;
using TweetDuck.Controls; using TweetDuck.Core.Other.Settings;
using TweetDuck.Dialogs.Settings; using TweetDuck.Core.Other.Settings.Dialogs;
using TweetDuck.Management; using TweetDuck.Core.Utils;
using TweetDuck.Management.Analytics; using TweetDuck.Plugins;
using TweetDuck.Utils; using TweetDuck.Updates;
using TweetLib.Core.Features.Plugins;
using TweetLib.Core.Systems.Updates;
namespace TweetDuck.Dialogs{ namespace TweetDuck.Core.Other{
sealed partial class FormSettings : Form, FormManager.IAppDialog{ sealed partial class FormSettings : Form, FormManager.IAppDialog{
public bool ShouldReloadBrowser { get; private set; } public bool ShouldReloadBrowser { get; private set; }
@@ -43,7 +41,6 @@ namespace TweetDuck.Dialogs{
AddButton("General", () => new TabSettingsGeneral(this.browser.ReloadColumns, updates)); AddButton("General", () => new TabSettingsGeneral(this.browser.ReloadColumns, updates));
AddButton("Notifications", () => new TabSettingsNotifications(new FormNotificationExample(this.browser, this.plugins))); AddButton("Notifications", () => new TabSettingsNotifications(new FormNotificationExample(this.browser, this.plugins)));
AddButton("Sounds", () => new TabSettingsSounds(this.browser.PlaySoundNotification)); AddButton("Sounds", () => new TabSettingsSounds(this.browser.PlaySoundNotification));
AddButton("Tray", () => new TabSettingsTray());
AddButton("Feedback", () => new TabSettingsFeedback(analytics, AnalyticsReportGenerator.ExternalInfo.From(this.browser), this.plugins)); AddButton("Feedback", () => new TabSettingsFeedback(analytics, AnalyticsReportGenerator.ExternalInfo.From(this.browser), this.plugins));
AddButton("Advanced", () => new TabSettingsAdvanced(this.browser.ReinjectCustomCSS, this.browser.OpenDevTools)); AddButton("Advanced", () => new TabSettingsAdvanced(this.browser.ReinjectCustomCSS, this.browser.OpenDevTools));
@@ -82,7 +79,7 @@ namespace TweetDuck.Dialogs{
private void btnManageOptions_Click(object sender, EventArgs e){ private void btnManageOptions_Click(object sender, EventArgs e){
PrepareUnload(); PrepareUnload();
using DialogSettingsManage dialog = new DialogSettingsManage(plugins); using(DialogSettingsManage dialog = new DialogSettingsManage(plugins)){
FormClosing -= FormSettings_FormClosing; FormClosing -= FormSettings_FormClosing;
if (dialog.ShowDialog() == DialogResult.OK){ if (dialog.ShowDialog() == DialogResult.OK){
@@ -102,12 +99,13 @@ namespace TweetDuck.Dialogs{
PrepareLoad(); PrepareLoad();
} }
} }
}
private void btnClose_Click(object sender, EventArgs e){ private void btnClose_Click(object sender, EventArgs e){
Close(); Close();
} }
private void AddButton<T>(string title, Func<T> constructor) where T : BaseTab{ private void AddButton<T>(string title, Func<T> constructor) where T : BaseTabSettings{
FlatButton btn = new FlatButton{ FlatButton btn = new FlatButton{
BackColor = SystemColors.Control, BackColor = SystemColors.Control,
FlatStyle = FlatStyle.Flat, FlatStyle = FlatStyle.Flat,
@@ -137,7 +135,7 @@ namespace TweetDuck.Dialogs{
btn.Click += (sender, args) => SelectTab<T>(); btn.Click += (sender, args) => SelectTab<T>();
} }
private void SelectTab<T>() where T : BaseTab{ private void SelectTab<T>() where T : BaseTabSettings{
SelectTab(tabs[typeof(T)]); SelectTab(tabs[typeof(T)]);
} }
@@ -197,47 +195,16 @@ namespace TweetDuck.Dialogs{
private sealed class SettingsTab{ private sealed class SettingsTab{
public Button Button { get; } public Button Button { get; }
public BaseTab Control => control ??= constructor(); public BaseTabSettings Control => control ?? (control = constructor());
public bool IsInitialized => control != null; public bool IsInitialized => control != null;
private readonly Func<BaseTab> constructor; private readonly Func<BaseTabSettings> constructor;
private BaseTab control; private BaseTabSettings control;
public SettingsTab(Button button, Func<BaseTab> constructor){ public SettingsTab(Button button, Func<BaseTabSettings> constructor){
this.Button = button; this.Button = button;
this.constructor = constructor; 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

@@ -0,0 +1,36 @@
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{
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.Dialogs.Settings { namespace TweetDuck.Core.Other.Settings.Dialogs {
partial class DialogSettingsAnalytics { partial class DialogSettingsAnalytics {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.

View File

@@ -1,10 +1,12 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetDuck.Management.Analytics; using TweetDuck.Core.Other.Analytics;
namespace TweetDuck.Dialogs.Settings{ namespace TweetDuck.Core.Other.Settings.Dialogs{
sealed partial class DialogSettingsAnalytics : Form{ sealed partial class DialogSettingsAnalytics : Form{
public string CefArgs => textBoxReport.Text;
public DialogSettingsAnalytics(AnalyticsReport report){ public DialogSettingsAnalytics(AnalyticsReport report){
InitializeComponent(); InitializeComponent();

View File

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

View File

@@ -2,10 +2,10 @@
using System.Linq; using System.Linq;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetDuck.Utils; using TweetDuck.Core.Utils;
namespace TweetDuck.Dialogs.Settings{ namespace TweetDuck.Core.Other.Settings.Dialogs{
sealed partial class DialogSettingsCSS : Form{ sealed partial class DialogSettingsCSS : Form{
public string BrowserCSS => textBoxBrowserCSS.Text; public string BrowserCSS => textBoxBrowserCSS.Text;
public string NotificationCSS => textBoxNotificationCSS.Text; public string NotificationCSS => textBoxNotificationCSS.Text;

View File

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

View File

@@ -1,10 +1,10 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetDuck.Utils; using TweetDuck.Core.Utils;
using TweetLib.Core.Collections; using TweetDuck.Data;
namespace TweetDuck.Dialogs.Settings{ namespace TweetDuck.Core.Other.Settings.Dialogs{
sealed partial class DialogSettingsCefArgs : Form{ sealed partial class DialogSettingsCefArgs : Form{
public string CefArgs => textBoxArgs.Text; public string CefArgs => textBoxArgs.Text;

View File

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

View File

@@ -3,11 +3,11 @@ using System.Collections.Generic;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetDuck.Management; using TweetDuck.Core.Management;
using TweetLib.Core.Features.Plugins; using TweetDuck.Core.Utils;
using TweetLib.Core.Utils; using TweetDuck.Plugins;
namespace TweetDuck.Dialogs.Settings{ namespace TweetDuck.Core.Other.Settings.Dialogs{
sealed partial class DialogSettingsManage : Form{ sealed partial class DialogSettingsManage : Form{
private enum State{ private enum State{
Deciding, Reset, Import, Export Deciding, Reset, Import, Export

View File

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

View File

@@ -1,9 +1,9 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetLib.Core.Collections; using TweetDuck.Data;
namespace TweetDuck.Dialogs.Settings{ namespace TweetDuck.Core.Other.Settings.Dialogs{
sealed partial class DialogSettingsRestart : Form{ sealed partial class DialogSettingsRestart : Form{
public CommandLineArgs Args { get; private set; } public CommandLineArgs Args { get; private set; }
@@ -18,7 +18,7 @@ namespace TweetDuck.Dialogs.Settings{
tbDataFolder.Enabled = false; tbDataFolder.Enabled = false;
} }
else{ else{
tbDataFolder.Text = currentArgs.GetValue(Arguments.ArgDataFolder) ?? string.Empty; tbDataFolder.Text = currentArgs.GetValue(Arguments.ArgDataFolder, string.Empty);
tbDataFolder.TextChanged += control_Change; tbDataFolder.TextChanged += control_Change;
} }
@@ -38,7 +38,7 @@ namespace TweetDuck.Dialogs.Settings{
Args.SetValue(Arguments.ArgDataFolder, tbDataFolder.Text); Args.SetValue(Arguments.ArgDataFolder, tbDataFolder.Text);
} }
tbShortcutTarget.Text = $@"""{Program.ExecutablePath}""{(Args.Count > 0 ? " " : "")}{Args}"; tbShortcutTarget.Text = $@"""{Application.ExecutablePath}""{(Args.Count > 0 ? " " : "")}{Args}";
tbShortcutTarget.Select(tbShortcutTarget.Text.Length, 0); tbShortcutTarget.Select(tbShortcutTarget.Text.Length, 0);
} }

View File

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

View File

@@ -1,7 +1,7 @@
using System; using System;
using System.Windows.Forms; using System.Windows.Forms;
namespace TweetDuck.Dialogs.Settings{ namespace TweetDuck.Core.Other.Settings.Dialogs{
sealed partial class DialogSettingsSearchEngine : Form{ sealed partial class DialogSettingsSearchEngine : Form{
public string Url => textBoxUrl.Text; public string Url => textBoxUrl.Text;

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Dialogs.Settings { namespace TweetDuck.Core.Other.Settings {
partial class TabSettingsAdvanced { partial class TabSettingsAdvanced {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -32,7 +32,7 @@
this.btnRestart = new System.Windows.Forms.Button(); this.btnRestart = new System.Windows.Forms.Button();
this.btnOpenAppFolder = new System.Windows.Forms.Button(); this.btnOpenAppFolder = new System.Windows.Forms.Button();
this.btnOpenDataFolder = new System.Windows.Forms.Button(); this.btnOpenDataFolder = new System.Windows.Forms.Button();
this.numClearCacheThreshold = new TweetDuck.Controls.NumericUpDownEx(); this.numClearCacheThreshold = new TweetDuck.Core.Controls.NumericUpDownEx();
this.checkClearCacheAuto = new System.Windows.Forms.CheckBox(); this.checkClearCacheAuto = new System.Windows.Forms.CheckBox();
this.labelApp = new System.Windows.Forms.Label(); this.labelApp = new System.Windows.Forms.Label();
this.panelAppButtons = new System.Windows.Forms.Panel(); this.panelAppButtons = new System.Windows.Forms.Panel();
@@ -41,8 +41,6 @@
this.panelConfiguration = new System.Windows.Forms.Panel(); this.panelConfiguration = new System.Windows.Forms.Panel();
this.labelConfiguration = new System.Windows.Forms.Label(); this.labelConfiguration = new System.Windows.Forms.Label();
this.flowPanel = new System.Windows.Forms.FlowLayoutPanel(); this.flowPanel = new System.Windows.Forms.FlowLayoutPanel();
this.labelDevTools = new System.Windows.Forms.Label();
this.checkDevToolsWindowOnTop = new System.Windows.Forms.CheckBox();
((System.ComponentModel.ISupportInitialize)(this.numClearCacheThreshold)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.numClearCacheThreshold)).BeginInit();
this.panelAppButtons.SuspendLayout(); this.panelAppButtons.SuspendLayout();
this.panelClearCacheAuto.SuspendLayout(); this.panelClearCacheAuto.SuspendLayout();
@@ -242,8 +240,6 @@
this.flowPanel.Controls.Add(this.panelClearCacheAuto); this.flowPanel.Controls.Add(this.panelClearCacheAuto);
this.flowPanel.Controls.Add(this.labelConfiguration); this.flowPanel.Controls.Add(this.labelConfiguration);
this.flowPanel.Controls.Add(this.panelConfiguration); this.flowPanel.Controls.Add(this.panelConfiguration);
this.flowPanel.Controls.Add(this.labelDevTools);
this.flowPanel.Controls.Add(this.checkDevToolsWindowOnTop);
this.flowPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; this.flowPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowPanel.Location = new System.Drawing.Point(9, 9); this.flowPanel.Location = new System.Drawing.Point(9, 9);
this.flowPanel.Name = "flowPanel"; this.flowPanel.Name = "flowPanel";
@@ -251,29 +247,6 @@
this.flowPanel.TabIndex = 0; this.flowPanel.TabIndex = 0;
this.flowPanel.WrapContents = false; this.flowPanel.WrapContents = false;
// //
// labelDevTools
//
this.labelDevTools.AutoSize = true;
this.labelDevTools.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
this.labelDevTools.Location = new System.Drawing.Point(0, 302);
this.labelDevTools.Margin = new System.Windows.Forms.Padding(0, 30, 0, 1);
this.labelDevTools.Name = "labelDevTools";
this.labelDevTools.Size = new System.Drawing.Size(156, 19);
this.labelDevTools.TabIndex = 7;
this.labelDevTools.Text = "DEVELOPMENT TOOLS";
//
// checkDevToolsWindowOnTop
//
this.checkDevToolsWindowOnTop.AutoSize = true;
this.checkDevToolsWindowOnTop.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkDevToolsWindowOnTop.Location = new System.Drawing.Point(6, 328);
this.checkDevToolsWindowOnTop.Margin = new System.Windows.Forms.Padding(6, 6, 0, 2);
this.checkDevToolsWindowOnTop.Name = "checkDevToolsWindowOnTop";
this.checkDevToolsWindowOnTop.Size = new System.Drawing.Size(168, 19);
this.checkDevToolsWindowOnTop.TabIndex = 8;
this.checkDevToolsWindowOnTop.Text = "Dev Tools Window On Top";
this.checkDevToolsWindowOnTop.UseVisualStyleBackColor = true;
//
// TabSettingsAdvanced // TabSettingsAdvanced
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -311,7 +284,5 @@
private Controls.NumericUpDownEx numClearCacheThreshold; private Controls.NumericUpDownEx numClearCacheThreshold;
private System.Windows.Forms.CheckBox checkClearCacheAuto; private System.Windows.Forms.CheckBox checkClearCacheAuto;
private System.Windows.Forms.FlowLayoutPanel flowPanel; private System.Windows.Forms.FlowLayoutPanel flowPanel;
private System.Windows.Forms.Label labelDevTools;
private System.Windows.Forms.CheckBox checkDevToolsWindowOnTop;
} }
} }

View File

@@ -1,14 +1,15 @@
using System; using System;
using System.Diagnostics;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Configuration; using TweetDuck.Configuration;
using TweetDuck.Controls; using TweetDuck.Core.Controls;
using TweetDuck.Management; using TweetDuck.Core.Management;
using TweetDuck.Utils; using TweetDuck.Core.Other.Settings.Dialogs;
using TweetLib.Core; using TweetDuck.Core.Utils;
namespace TweetDuck.Dialogs.Settings{ namespace TweetDuck.Core.Other.Settings{
sealed partial class TabSettingsAdvanced : FormSettings.BaseTab{ sealed partial class TabSettingsAdvanced : BaseTabSettings{
private readonly Action<string> reinjectBrowserCSS; private readonly Action<string> reinjectBrowserCSS;
private readonly Action openDevTools; private readonly Action openDevTools;
@@ -43,16 +44,6 @@ namespace TweetDuck.Dialogs.Settings{
toolTip.SetToolTip(btnEditCefArgs, "Set custom command line arguments for Chromium Embedded Framework."); toolTip.SetToolTip(btnEditCefArgs, "Set custom command line arguments for Chromium Embedded Framework.");
toolTip.SetToolTip(btnEditCSS, "Set custom CSS for browser and notification windows."); toolTip.SetToolTip(btnEditCSS, "Set custom CSS for browser and notification windows.");
// development tools
toolTip.SetToolTip(checkDevToolsWindowOnTop, "Sets whether dev tool windows appears on top of other windows.");
checkDevToolsWindowOnTop.Checked = Config.DevToolsWindowOnTop;
if (!BrowserUtils.HasDevTools){
checkDevToolsWindowOnTop.Enabled = false;
}
} }
public override void OnReady(){ public override void OnReady(){
@@ -66,8 +57,6 @@ namespace TweetDuck.Dialogs.Settings{
btnEditCefArgs.Click += btnEditCefArgs_Click; btnEditCefArgs.Click += btnEditCefArgs_Click;
btnEditCSS.Click += btnEditCSS_Click; btnEditCSS.Click += btnEditCSS_Click;
checkDevToolsWindowOnTop.CheckedChanged += checkDevToolsWindowOnTop_CheckedChanged;
} }
public override void OnClosing(){ public override void OnClosing(){
@@ -78,11 +67,11 @@ namespace TweetDuck.Dialogs.Settings{
#region Application #region Application
private void btnOpenAppFolder_Click(object sender, EventArgs e){ private void btnOpenAppFolder_Click(object sender, EventArgs e){
App.SystemHandler.OpenFileExplorer(Program.ProgramPath); using(Process.Start("explorer.exe", "\""+Program.ProgramPath+"\"")){}
} }
private void btnOpenDataFolder_Click(object sender, EventArgs e){ private void btnOpenDataFolder_Click(object sender, EventArgs e){
App.SystemHandler.OpenFileExplorer(Program.StoragePath); using(Process.Start("explorer.exe", "\""+Program.StoragePath+"\"")){}
} }
private void btnRestart_Click(object sender, EventArgs e){ private void btnRestart_Click(object sender, EventArgs e){
@@ -90,12 +79,12 @@ namespace TweetDuck.Dialogs.Settings{
} }
private void btnRestartArgs_Click(object sender, EventArgs e){ private void btnRestartArgs_Click(object sender, EventArgs e){
using DialogSettingsRestart dialog = new DialogSettingsRestart(Arguments.GetCurrentClean()); using(DialogSettingsRestart dialog = new DialogSettingsRestart(Arguments.GetCurrentClean())){
if (dialog.ShowDialog() == DialogResult.OK){ if (dialog.ShowDialog() == DialogResult.OK){
Program.RestartWithArgs(dialog.Args); Program.RestartWithArgs(dialog.Args);
} }
} }
}
#endregion #endregion
#region Browser Cache #region Browser Cache
@@ -163,13 +152,6 @@ namespace TweetDuck.Dialogs.Settings{
} }
} }
#endregion
#region Development Tools
private void checkDevToolsWindowOnTop_CheckedChanged(object sender, EventArgs e){
Config.DevToolsWindowOnTop = checkDevToolsWindowOnTop.Checked;
}
#endregion #endregion
} }
} }

View File

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

View File

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

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Dialogs.Settings { namespace TweetDuck.Core.Other.Settings {
partial class TabSettingsGeneral { partial class TabSettingsGeneral {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -41,37 +41,30 @@
this.flowPanelLeft = new System.Windows.Forms.FlowLayoutPanel(); this.flowPanelLeft = new System.Windows.Forms.FlowLayoutPanel();
this.checkFocusDmInput = new System.Windows.Forms.CheckBox(); this.checkFocusDmInput = new System.Windows.Forms.CheckBox();
this.checkKeepLikeFollowDialogsOpen = new System.Windows.Forms.CheckBox(); this.checkKeepLikeFollowDialogsOpen = new System.Windows.Forms.CheckBox();
this.labelTray = new System.Windows.Forms.Label();
this.comboBoxTrayType = new System.Windows.Forms.ComboBox();
this.labelTrayIcon = new System.Windows.Forms.Label();
this.checkTrayHighlight = new System.Windows.Forms.CheckBox();
this.labelBrowserSettings = new System.Windows.Forms.Label(); this.labelBrowserSettings = new System.Windows.Forms.Label();
this.checkSmoothScrolling = new System.Windows.Forms.CheckBox(); this.checkSmoothScrolling = new System.Windows.Forms.CheckBox();
this.checkTouchAdjustment = new System.Windows.Forms.CheckBox(); this.checkTouchAdjustment = new System.Windows.Forms.CheckBox();
this.checkHardwareAcceleration = new System.Windows.Forms.CheckBox();
this.labelBrowserPath = new System.Windows.Forms.Label(); this.labelBrowserPath = new System.Windows.Forms.Label();
this.comboBoxCustomBrowser = new System.Windows.Forms.ComboBox(); this.comboBoxBrowserPath = new System.Windows.Forms.ComboBox();
this.labelSearchEngine = new System.Windows.Forms.Label(); this.labelSearchEngine = new System.Windows.Forms.Label();
this.comboBoxSearchEngine = new System.Windows.Forms.ComboBox(); this.comboBoxSearchEngine = new System.Windows.Forms.ComboBox();
this.flowPanelRight = new System.Windows.Forms.FlowLayoutPanel(); this.flowPanelRight = new System.Windows.Forms.FlowLayoutPanel();
this.checkHardwareAcceleration = new System.Windows.Forms.CheckBox();
this.labelLocales = new System.Windows.Forms.Label(); this.labelLocales = new System.Windows.Forms.Label();
this.checkSpellCheck = new System.Windows.Forms.CheckBox(); this.checkSpellCheck = new System.Windows.Forms.CheckBox();
this.labelSpellCheckLanguage = new System.Windows.Forms.Label(); this.labelSpellCheckLanguage = new System.Windows.Forms.Label();
this.comboBoxSpellCheckLanguage = new System.Windows.Forms.ComboBox(); this.comboBoxSpellCheckLanguage = new System.Windows.Forms.ComboBox();
this.labelTranslationTarget = new System.Windows.Forms.Label(); this.labelTranslationTarget = new System.Windows.Forms.Label();
this.comboBoxTranslationTarget = new System.Windows.Forms.ComboBox(); this.comboBoxTranslationTarget = new System.Windows.Forms.ComboBox();
this.labelFirstDayOfWeek = new System.Windows.Forms.Label();
this.comboBoxFirstDayOfWeek = new System.Windows.Forms.ComboBox();
this.labelExternalApplications = new System.Windows.Forms.Label();
this.panelCustomBrowser = new System.Windows.Forms.Panel();
this.btnCustomBrowserChange = new System.Windows.Forms.Button();
this.labelVideoPlayerPath = new System.Windows.Forms.Label();
this.panelCustomVideoPlayer = new System.Windows.Forms.Panel();
this.comboBoxCustomVideoPlayer = new System.Windows.Forms.ComboBox();
this.btnCustomVideoPlayerChange = new System.Windows.Forms.Button();
this.panelSeparator = new System.Windows.Forms.Panel(); this.panelSeparator = new System.Windows.Forms.Panel();
((System.ComponentModel.ISupportInitialize)(this.trackBarZoom)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.trackBarZoom)).BeginInit();
this.panelZoom.SuspendLayout(); this.panelZoom.SuspendLayout();
this.flowPanelLeft.SuspendLayout(); this.flowPanelLeft.SuspendLayout();
this.flowPanelRight.SuspendLayout(); this.flowPanelRight.SuspendLayout();
this.panelCustomBrowser.SuspendLayout();
this.panelCustomVideoPlayer.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
// //
// checkExpandLinks // checkExpandLinks
@@ -90,7 +83,7 @@
// //
this.checkUpdateNotifications.AutoSize = true; this.checkUpdateNotifications.AutoSize = true;
this.checkUpdateNotifications.Font = new System.Drawing.Font("Segoe UI", 9F); this.checkUpdateNotifications.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkUpdateNotifications.Location = new System.Drawing.Point(6, 403); this.checkUpdateNotifications.Location = new System.Drawing.Point(6, 409);
this.checkUpdateNotifications.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2); this.checkUpdateNotifications.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2);
this.checkUpdateNotifications.Name = "checkUpdateNotifications"; this.checkUpdateNotifications.Name = "checkUpdateNotifications";
this.checkUpdateNotifications.Size = new System.Drawing.Size(182, 19); this.checkUpdateNotifications.Size = new System.Drawing.Size(182, 19);
@@ -102,7 +95,7 @@
// //
this.btnCheckUpdates.AutoSize = true; this.btnCheckUpdates.AutoSize = true;
this.btnCheckUpdates.Font = new System.Drawing.Font("Segoe UI", 9F); this.btnCheckUpdates.Font = new System.Drawing.Font("Segoe UI", 9F);
this.btnCheckUpdates.Location = new System.Drawing.Point(5, 427); this.btnCheckUpdates.Location = new System.Drawing.Point(5, 433);
this.btnCheckUpdates.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3); this.btnCheckUpdates.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
this.btnCheckUpdates.Name = "btnCheckUpdates"; this.btnCheckUpdates.Name = "btnCheckUpdates";
this.btnCheckUpdates.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0); this.btnCheckUpdates.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
@@ -115,7 +108,7 @@
// //
this.labelZoomValue.BackColor = System.Drawing.Color.Transparent; this.labelZoomValue.BackColor = System.Drawing.Color.Transparent;
this.labelZoomValue.Font = new System.Drawing.Font("Segoe UI", 9F); this.labelZoomValue.Font = new System.Drawing.Font("Segoe UI", 9F);
this.labelZoomValue.Location = new System.Drawing.Point(176, 4); this.labelZoomValue.Location = new System.Drawing.Point(147, 4);
this.labelZoomValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0); this.labelZoomValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelZoomValue.Name = "labelZoomValue"; this.labelZoomValue.Name = "labelZoomValue";
this.labelZoomValue.Size = new System.Drawing.Size(38, 13); this.labelZoomValue.Size = new System.Drawing.Size(38, 13);
@@ -156,7 +149,7 @@
this.trackBarZoom.Maximum = 200; this.trackBarZoom.Maximum = 200;
this.trackBarZoom.Minimum = 50; this.trackBarZoom.Minimum = 50;
this.trackBarZoom.Name = "trackBarZoom"; this.trackBarZoom.Name = "trackBarZoom";
this.trackBarZoom.Size = new System.Drawing.Size(177, 30); this.trackBarZoom.Size = new System.Drawing.Size(148, 30);
this.trackBarZoom.SmallChange = 5; this.trackBarZoom.SmallChange = 5;
this.trackBarZoom.TabIndex = 0; this.trackBarZoom.TabIndex = 0;
this.trackBarZoom.TickFrequency = 25; this.trackBarZoom.TickFrequency = 25;
@@ -166,11 +159,11 @@
// //
this.labelZoom.AutoSize = true; this.labelZoom.AutoSize = true;
this.labelZoom.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold); this.labelZoom.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold);
this.labelZoom.Location = new System.Drawing.Point(3, 299); this.labelZoom.Location = new System.Drawing.Point(3, 179);
this.labelZoom.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0); this.labelZoom.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelZoom.Name = "labelZoom"; this.labelZoom.Name = "labelZoom";
this.labelZoom.Size = new System.Drawing.Size(39, 15); this.labelZoom.Size = new System.Drawing.Size(39, 15);
this.labelZoom.TabIndex = 11; this.labelZoom.TabIndex = 7;
this.labelZoom.Text = "Zoom"; this.labelZoom.Text = "Zoom";
// //
// zoomUpdateTimer // zoomUpdateTimer
@@ -193,11 +186,11 @@
// //
this.panelZoom.Controls.Add(this.trackBarZoom); this.panelZoom.Controls.Add(this.trackBarZoom);
this.panelZoom.Controls.Add(this.labelZoomValue); this.panelZoom.Controls.Add(this.labelZoomValue);
this.panelZoom.Location = new System.Drawing.Point(0, 315); this.panelZoom.Location = new System.Drawing.Point(0, 195);
this.panelZoom.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0); this.panelZoom.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0);
this.panelZoom.Name = "panelZoom"; this.panelZoom.Name = "panelZoom";
this.panelZoom.Size = new System.Drawing.Size(300, 35); this.panelZoom.Size = new System.Drawing.Size(300, 35);
this.panelZoom.TabIndex = 12; this.panelZoom.TabIndex = 8;
// //
// checkAnimatedAvatars // checkAnimatedAvatars
// //
@@ -215,7 +208,7 @@
// //
this.labelUpdates.AutoSize = true; this.labelUpdates.AutoSize = true;
this.labelUpdates.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold); this.labelUpdates.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
this.labelUpdates.Location = new System.Drawing.Point(0, 377); this.labelUpdates.Location = new System.Drawing.Point(0, 383);
this.labelUpdates.Margin = new System.Windows.Forms.Padding(0, 27, 0, 1); this.labelUpdates.Margin = new System.Windows.Forms.Padding(0, 27, 0, 1);
this.labelUpdates.Name = "labelUpdates"; this.labelUpdates.Name = "labelUpdates";
this.labelUpdates.Size = new System.Drawing.Size(69, 19); this.labelUpdates.Size = new System.Drawing.Size(69, 19);
@@ -233,12 +226,12 @@
this.flowPanelLeft.Controls.Add(this.checkKeepLikeFollowDialogsOpen); this.flowPanelLeft.Controls.Add(this.checkKeepLikeFollowDialogsOpen);
this.flowPanelLeft.Controls.Add(this.checkBestImageQuality); this.flowPanelLeft.Controls.Add(this.checkBestImageQuality);
this.flowPanelLeft.Controls.Add(this.checkAnimatedAvatars); this.flowPanelLeft.Controls.Add(this.checkAnimatedAvatars);
this.flowPanelLeft.Controls.Add(this.labelBrowserSettings);
this.flowPanelLeft.Controls.Add(this.checkSmoothScrolling);
this.flowPanelLeft.Controls.Add(this.checkTouchAdjustment);
this.flowPanelLeft.Controls.Add(this.checkHardwareAcceleration);
this.flowPanelLeft.Controls.Add(this.labelZoom); this.flowPanelLeft.Controls.Add(this.labelZoom);
this.flowPanelLeft.Controls.Add(this.panelZoom); this.flowPanelLeft.Controls.Add(this.panelZoom);
this.flowPanelLeft.Controls.Add(this.labelTray);
this.flowPanelLeft.Controls.Add(this.comboBoxTrayType);
this.flowPanelLeft.Controls.Add(this.labelTrayIcon);
this.flowPanelLeft.Controls.Add(this.checkTrayHighlight);
this.flowPanelLeft.Controls.Add(this.labelUpdates); this.flowPanelLeft.Controls.Add(this.labelUpdates);
this.flowPanelLeft.Controls.Add(this.checkUpdateNotifications); this.flowPanelLeft.Controls.Add(this.checkUpdateNotifications);
this.flowPanelLeft.Controls.Add(this.btnCheckUpdates); this.flowPanelLeft.Controls.Add(this.btnCheckUpdates);
@@ -273,26 +266,71 @@
this.checkKeepLikeFollowDialogsOpen.Text = "Keep Like/Follow Dialogs Open"; this.checkKeepLikeFollowDialogsOpen.Text = "Keep Like/Follow Dialogs Open";
this.checkKeepLikeFollowDialogsOpen.UseVisualStyleBackColor = true; this.checkKeepLikeFollowDialogsOpen.UseVisualStyleBackColor = true;
// //
// labelTray
//
this.labelTray.AutoSize = true;
this.labelTray.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
this.labelTray.Location = new System.Drawing.Point(0, 255);
this.labelTray.Margin = new System.Windows.Forms.Padding(0, 25, 0, 1);
this.labelTray.Name = "labelTray";
this.labelTray.Size = new System.Drawing.Size(99, 19);
this.labelTray.TabIndex = 9;
this.labelTray.Text = "SYSTEM TRAY";
//
// comboBoxTrayType
//
this.comboBoxTrayType.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxTrayType.Font = new System.Drawing.Font("Segoe UI", 9F);
this.comboBoxTrayType.FormattingEnabled = true;
this.comboBoxTrayType.Location = new System.Drawing.Point(5, 279);
this.comboBoxTrayType.Margin = new System.Windows.Forms.Padding(5, 4, 3, 3);
this.comboBoxTrayType.Name = "comboBoxTrayType";
this.comboBoxTrayType.Size = new System.Drawing.Size(144, 23);
this.comboBoxTrayType.TabIndex = 10;
//
// labelTrayIcon
//
this.labelTrayIcon.AutoSize = true;
this.labelTrayIcon.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold);
this.labelTrayIcon.Location = new System.Drawing.Point(3, 314);
this.labelTrayIcon.Margin = new System.Windows.Forms.Padding(3, 9, 3, 0);
this.labelTrayIcon.Name = "labelTrayIcon";
this.labelTrayIcon.Size = new System.Drawing.Size(56, 15);
this.labelTrayIcon.TabIndex = 11;
this.labelTrayIcon.Text = "Tray Icon";
//
// checkTrayHighlight
//
this.checkTrayHighlight.AutoSize = true;
this.checkTrayHighlight.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkTrayHighlight.Location = new System.Drawing.Point(6, 335);
this.checkTrayHighlight.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2);
this.checkTrayHighlight.Name = "checkTrayHighlight";
this.checkTrayHighlight.Size = new System.Drawing.Size(114, 19);
this.checkTrayHighlight.TabIndex = 12;
this.checkTrayHighlight.Text = "Enable Highlight";
this.checkTrayHighlight.UseVisualStyleBackColor = true;
//
// labelBrowserSettings // labelBrowserSettings
// //
this.labelBrowserSettings.AutoSize = true; this.labelBrowserSettings.AutoSize = true;
this.labelBrowserSettings.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold); this.labelBrowserSettings.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
this.labelBrowserSettings.Location = new System.Drawing.Point(0, 192); this.labelBrowserSettings.Location = new System.Drawing.Point(0, 0);
this.labelBrowserSettings.Margin = new System.Windows.Forms.Padding(0, 25, 0, 1); this.labelBrowserSettings.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1);
this.labelBrowserSettings.Name = "labelBrowserSettings"; this.labelBrowserSettings.Name = "labelBrowserSettings";
this.labelBrowserSettings.Size = new System.Drawing.Size(143, 19); this.labelBrowserSettings.Size = new System.Drawing.Size(143, 19);
this.labelBrowserSettings.TabIndex = 7; this.labelBrowserSettings.TabIndex = 0;
this.labelBrowserSettings.Text = "BROWSER SETTINGS"; this.labelBrowserSettings.Text = "BROWSER SETTINGS";
// //
// checkSmoothScrolling // checkSmoothScrolling
// //
this.checkSmoothScrolling.AutoSize = true; this.checkSmoothScrolling.AutoSize = true;
this.checkSmoothScrolling.Font = new System.Drawing.Font("Segoe UI", 9F); this.checkSmoothScrolling.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkSmoothScrolling.Location = new System.Drawing.Point(6, 218); this.checkSmoothScrolling.Location = new System.Drawing.Point(6, 26);
this.checkSmoothScrolling.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2); this.checkSmoothScrolling.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2);
this.checkSmoothScrolling.Name = "checkSmoothScrolling"; this.checkSmoothScrolling.Name = "checkSmoothScrolling";
this.checkSmoothScrolling.Size = new System.Drawing.Size(117, 19); this.checkSmoothScrolling.Size = new System.Drawing.Size(117, 19);
this.checkSmoothScrolling.TabIndex = 8; this.checkSmoothScrolling.TabIndex = 1;
this.checkSmoothScrolling.Text = "Smooth Scrolling"; this.checkSmoothScrolling.Text = "Smooth Scrolling";
this.checkSmoothScrolling.UseVisualStyleBackColor = true; this.checkSmoothScrolling.UseVisualStyleBackColor = true;
// //
@@ -300,57 +338,45 @@
// //
this.checkTouchAdjustment.AutoSize = true; this.checkTouchAdjustment.AutoSize = true;
this.checkTouchAdjustment.Font = new System.Drawing.Font("Segoe UI", 9F); this.checkTouchAdjustment.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkTouchAdjustment.Location = new System.Drawing.Point(6, 242); this.checkTouchAdjustment.Location = new System.Drawing.Point(6, 50);
this.checkTouchAdjustment.Margin = new System.Windows.Forms.Padding(6, 3, 3, 2); this.checkTouchAdjustment.Margin = new System.Windows.Forms.Padding(6, 3, 3, 2);
this.checkTouchAdjustment.Name = "checkTouchAdjustment"; this.checkTouchAdjustment.Name = "checkTouchAdjustment";
this.checkTouchAdjustment.Size = new System.Drawing.Size(163, 19); this.checkTouchAdjustment.Size = new System.Drawing.Size(163, 19);
this.checkTouchAdjustment.TabIndex = 9; this.checkTouchAdjustment.TabIndex = 2;
this.checkTouchAdjustment.Text = "Touch Screen Adjustment"; this.checkTouchAdjustment.Text = "Touch Screen Adjustment";
this.checkTouchAdjustment.UseVisualStyleBackColor = true; this.checkTouchAdjustment.UseVisualStyleBackColor = true;
// //
// checkHardwareAcceleration
//
this.checkHardwareAcceleration.AutoSize = true;
this.checkHardwareAcceleration.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkHardwareAcceleration.Location = new System.Drawing.Point(6, 266);
this.checkHardwareAcceleration.Margin = new System.Windows.Forms.Padding(6, 3, 3, 2);
this.checkHardwareAcceleration.Name = "checkHardwareAcceleration";
this.checkHardwareAcceleration.Size = new System.Drawing.Size(146, 19);
this.checkHardwareAcceleration.TabIndex = 10;
this.checkHardwareAcceleration.Text = "Hardware Acceleration";
this.checkHardwareAcceleration.UseVisualStyleBackColor = true;
//
// labelBrowserPath // labelBrowserPath
// //
this.labelBrowserPath.AutoSize = true; this.labelBrowserPath.AutoSize = true;
this.labelBrowserPath.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold); this.labelBrowserPath.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold);
this.labelBrowserPath.Location = new System.Drawing.Point(3, 275); this.labelBrowserPath.Location = new System.Drawing.Point(3, 107);
this.labelBrowserPath.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0); this.labelBrowserPath.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelBrowserPath.Name = "labelBrowserPath"; this.labelBrowserPath.Name = "labelBrowserPath";
this.labelBrowserPath.Size = new System.Drawing.Size(104, 15); this.labelBrowserPath.Size = new System.Drawing.Size(104, 15);
this.labelBrowserPath.TabIndex = 9; this.labelBrowserPath.TabIndex = 4;
this.labelBrowserPath.Text = "Open Links With..."; this.labelBrowserPath.Text = "Open Links With...";
// //
// comboBoxCustomBrowser // comboBoxBrowserPath
// //
this.comboBoxCustomBrowser.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxBrowserPath.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCustomBrowser.Font = new System.Drawing.Font("Segoe UI", 9F); this.comboBoxBrowserPath.Font = new System.Drawing.Font("Segoe UI", 9F);
this.comboBoxCustomBrowser.FormattingEnabled = true; this.comboBoxBrowserPath.FormattingEnabled = true;
this.comboBoxCustomBrowser.Location = new System.Drawing.Point(5, 1); this.comboBoxBrowserPath.Location = new System.Drawing.Point(5, 126);
this.comboBoxCustomBrowser.Margin = new System.Windows.Forms.Padding(5, 1, 3, 0); this.comboBoxBrowserPath.Margin = new System.Windows.Forms.Padding(5, 4, 3, 3);
this.comboBoxCustomBrowser.Name = "comboBoxCustomBrowser"; this.comboBoxBrowserPath.Name = "comboBoxBrowserPath";
this.comboBoxCustomBrowser.Size = new System.Drawing.Size(173, 23); this.comboBoxBrowserPath.Size = new System.Drawing.Size(173, 23);
this.comboBoxCustomBrowser.TabIndex = 0; this.comboBoxBrowserPath.TabIndex = 5;
// //
// labelSearchEngine // labelSearchEngine
// //
this.labelSearchEngine.AutoSize = true; this.labelSearchEngine.AutoSize = true;
this.labelSearchEngine.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold); this.labelSearchEngine.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold);
this.labelSearchEngine.Location = new System.Drawing.Point(3, 389); this.labelSearchEngine.Location = new System.Drawing.Point(3, 164);
this.labelSearchEngine.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0); this.labelSearchEngine.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelSearchEngine.Name = "labelSearchEngine"; this.labelSearchEngine.Name = "labelSearchEngine";
this.labelSearchEngine.Size = new System.Drawing.Size(82, 15); this.labelSearchEngine.Size = new System.Drawing.Size(82, 15);
this.labelSearchEngine.TabIndex = 13; this.labelSearchEngine.TabIndex = 6;
this.labelSearchEngine.Text = "Search Engine"; this.labelSearchEngine.Text = "Search Engine";
// //
// comboBoxSearchEngine // comboBoxSearchEngine
@@ -358,31 +384,30 @@
this.comboBoxSearchEngine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxSearchEngine.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSearchEngine.Font = new System.Drawing.Font("Segoe UI", 9F); this.comboBoxSearchEngine.Font = new System.Drawing.Font("Segoe UI", 9F);
this.comboBoxSearchEngine.FormattingEnabled = true; this.comboBoxSearchEngine.FormattingEnabled = true;
this.comboBoxSearchEngine.Location = new System.Drawing.Point(5, 408); this.comboBoxSearchEngine.Location = new System.Drawing.Point(5, 183);
this.comboBoxSearchEngine.Margin = new System.Windows.Forms.Padding(5, 4, 3, 3); this.comboBoxSearchEngine.Margin = new System.Windows.Forms.Padding(5, 4, 3, 3);
this.comboBoxSearchEngine.Name = "comboBoxSearchEngine"; this.comboBoxSearchEngine.Name = "comboBoxSearchEngine";
this.comboBoxSearchEngine.Size = new System.Drawing.Size(173, 23); this.comboBoxSearchEngine.Size = new System.Drawing.Size(173, 23);
this.comboBoxSearchEngine.TabIndex = 14; this.comboBoxSearchEngine.TabIndex = 7;
// //
// flowPanelRight // flowPanelRight
// //
this.flowPanelRight.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) this.flowPanelRight.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left))); | System.Windows.Forms.AnchorStyles.Left)));
this.flowPanelRight.Controls.Add(this.labelBrowserSettings);
this.flowPanelRight.Controls.Add(this.checkSmoothScrolling);
this.flowPanelRight.Controls.Add(this.checkTouchAdjustment);
this.flowPanelRight.Controls.Add(this.checkHardwareAcceleration);
this.flowPanelRight.Controls.Add(this.labelBrowserPath);
this.flowPanelRight.Controls.Add(this.comboBoxBrowserPath);
this.flowPanelRight.Controls.Add(this.labelSearchEngine);
this.flowPanelRight.Controls.Add(this.comboBoxSearchEngine);
this.flowPanelRight.Controls.Add(this.labelLocales); this.flowPanelRight.Controls.Add(this.labelLocales);
this.flowPanelRight.Controls.Add(this.checkSpellCheck); this.flowPanelRight.Controls.Add(this.checkSpellCheck);
this.flowPanelRight.Controls.Add(this.labelSpellCheckLanguage); this.flowPanelRight.Controls.Add(this.labelSpellCheckLanguage);
this.flowPanelRight.Controls.Add(this.comboBoxSpellCheckLanguage); this.flowPanelRight.Controls.Add(this.comboBoxSpellCheckLanguage);
this.flowPanelRight.Controls.Add(this.labelTranslationTarget); this.flowPanelRight.Controls.Add(this.labelTranslationTarget);
this.flowPanelRight.Controls.Add(this.comboBoxTranslationTarget); this.flowPanelRight.Controls.Add(this.comboBoxTranslationTarget);
this.flowPanelRight.Controls.Add(this.labelFirstDayOfWeek);
this.flowPanelRight.Controls.Add(this.comboBoxFirstDayOfWeek);
this.flowPanelRight.Controls.Add(this.labelExternalApplications);
this.flowPanelRight.Controls.Add(this.labelBrowserPath);
this.flowPanelRight.Controls.Add(this.panelCustomBrowser);
this.flowPanelRight.Controls.Add(this.labelVideoPlayerPath);
this.flowPanelRight.Controls.Add(this.panelCustomVideoPlayer);
this.flowPanelRight.Controls.Add(this.labelSearchEngine);
this.flowPanelRight.Controls.Add(this.comboBoxSearchEngine);
this.flowPanelRight.FlowDirection = System.Windows.Forms.FlowDirection.TopDown; this.flowPanelRight.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.flowPanelRight.Location = new System.Drawing.Point(322, 9); this.flowPanelRight.Location = new System.Drawing.Point(322, 9);
this.flowPanelRight.Name = "flowPanelRight"; this.flowPanelRight.Name = "flowPanelRight";
@@ -390,26 +415,38 @@
this.flowPanelRight.TabIndex = 1; this.flowPanelRight.TabIndex = 1;
this.flowPanelRight.WrapContents = false; this.flowPanelRight.WrapContents = false;
// //
// checkHardwareAcceleration
//
this.checkHardwareAcceleration.AutoSize = true;
this.checkHardwareAcceleration.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkHardwareAcceleration.Location = new System.Drawing.Point(6, 74);
this.checkHardwareAcceleration.Margin = new System.Windows.Forms.Padding(6, 3, 3, 2);
this.checkHardwareAcceleration.Name = "checkHardwareAcceleration";
this.checkHardwareAcceleration.Size = new System.Drawing.Size(146, 19);
this.checkHardwareAcceleration.TabIndex = 3;
this.checkHardwareAcceleration.Text = "Hardware Acceleration";
this.checkHardwareAcceleration.UseVisualStyleBackColor = true;
//
// labelLocales // labelLocales
// //
this.labelLocales.AutoSize = true; this.labelLocales.AutoSize = true;
this.labelLocales.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold); this.labelLocales.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
this.labelLocales.Location = new System.Drawing.Point(0, 0); this.labelLocales.Location = new System.Drawing.Point(0, 236);
this.labelLocales.Margin = new System.Windows.Forms.Padding(0, 0, 0, 1); this.labelLocales.Margin = new System.Windows.Forms.Padding(0, 27, 0, 1);
this.labelLocales.Name = "labelLocales"; this.labelLocales.Name = "labelLocales";
this.labelLocales.Size = new System.Drawing.Size(67, 19); this.labelLocales.Size = new System.Drawing.Size(67, 19);
this.labelLocales.TabIndex = 0; this.labelLocales.TabIndex = 8;
this.labelLocales.Text = "LOCALES"; this.labelLocales.Text = "LOCALES";
// //
// checkSpellCheck // checkSpellCheck
// //
this.checkSpellCheck.AutoSize = true; this.checkSpellCheck.AutoSize = true;
this.checkSpellCheck.Font = new System.Drawing.Font("Segoe UI", 9F); this.checkSpellCheck.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkSpellCheck.Location = new System.Drawing.Point(6, 26); this.checkSpellCheck.Location = new System.Drawing.Point(6, 262);
this.checkSpellCheck.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2); this.checkSpellCheck.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2);
this.checkSpellCheck.Name = "checkSpellCheck"; this.checkSpellCheck.Name = "checkSpellCheck";
this.checkSpellCheck.Size = new System.Drawing.Size(125, 19); this.checkSpellCheck.Size = new System.Drawing.Size(125, 19);
this.checkSpellCheck.TabIndex = 1; this.checkSpellCheck.TabIndex = 9;
this.checkSpellCheck.Text = "Enable Spell Check"; this.checkSpellCheck.Text = "Enable Spell Check";
this.checkSpellCheck.UseVisualStyleBackColor = true; this.checkSpellCheck.UseVisualStyleBackColor = true;
// //
@@ -417,11 +454,11 @@
// //
this.labelSpellCheckLanguage.AutoSize = true; this.labelSpellCheckLanguage.AutoSize = true;
this.labelSpellCheckLanguage.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold); this.labelSpellCheckLanguage.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold);
this.labelSpellCheckLanguage.Location = new System.Drawing.Point(3, 59); this.labelSpellCheckLanguage.Location = new System.Drawing.Point(3, 295);
this.labelSpellCheckLanguage.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0); this.labelSpellCheckLanguage.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelSpellCheckLanguage.Name = "labelSpellCheckLanguage"; this.labelSpellCheckLanguage.Name = "labelSpellCheckLanguage";
this.labelSpellCheckLanguage.Size = new System.Drawing.Size(123, 15); this.labelSpellCheckLanguage.Size = new System.Drawing.Size(123, 15);
this.labelSpellCheckLanguage.TabIndex = 2; this.labelSpellCheckLanguage.TabIndex = 10;
this.labelSpellCheckLanguage.Text = "Spell Check Language"; this.labelSpellCheckLanguage.Text = "Spell Check Language";
// //
// comboBoxSpellCheckLanguage // comboBoxSpellCheckLanguage
@@ -429,21 +466,21 @@
this.comboBoxSpellCheckLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxSpellCheckLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxSpellCheckLanguage.Font = new System.Drawing.Font("Segoe UI", 9F); this.comboBoxSpellCheckLanguage.Font = new System.Drawing.Font("Segoe UI", 9F);
this.comboBoxSpellCheckLanguage.FormattingEnabled = true; this.comboBoxSpellCheckLanguage.FormattingEnabled = true;
this.comboBoxSpellCheckLanguage.Location = new System.Drawing.Point(5, 78); this.comboBoxSpellCheckLanguage.Location = new System.Drawing.Point(5, 314);
this.comboBoxSpellCheckLanguage.Margin = new System.Windows.Forms.Padding(5, 4, 3, 3); this.comboBoxSpellCheckLanguage.Margin = new System.Windows.Forms.Padding(5, 4, 3, 3);
this.comboBoxSpellCheckLanguage.Name = "comboBoxSpellCheckLanguage"; this.comboBoxSpellCheckLanguage.Name = "comboBoxSpellCheckLanguage";
this.comboBoxSpellCheckLanguage.Size = new System.Drawing.Size(290, 23); this.comboBoxSpellCheckLanguage.Size = new System.Drawing.Size(290, 23);
this.comboBoxSpellCheckLanguage.TabIndex = 3; this.comboBoxSpellCheckLanguage.TabIndex = 11;
// //
// labelTranslationTarget // labelTranslationTarget
// //
this.labelTranslationTarget.AutoSize = true; this.labelTranslationTarget.AutoSize = true;
this.labelTranslationTarget.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold); this.labelTranslationTarget.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold);
this.labelTranslationTarget.Location = new System.Drawing.Point(3, 116); this.labelTranslationTarget.Location = new System.Drawing.Point(3, 352);
this.labelTranslationTarget.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0); this.labelTranslationTarget.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelTranslationTarget.Name = "labelTranslationTarget"; this.labelTranslationTarget.Name = "labelTranslationTarget";
this.labelTranslationTarget.Size = new System.Drawing.Size(142, 15); this.labelTranslationTarget.Size = new System.Drawing.Size(142, 15);
this.labelTranslationTarget.TabIndex = 4; this.labelTranslationTarget.TabIndex = 12;
this.labelTranslationTarget.Text = "Bing Translator Language"; this.labelTranslationTarget.Text = "Bing Translator Language";
// //
// comboBoxTranslationTarget // comboBoxTranslationTarget
@@ -451,114 +488,11 @@
this.comboBoxTranslationTarget.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxTranslationTarget.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxTranslationTarget.Font = new System.Drawing.Font("Segoe UI", 9F); this.comboBoxTranslationTarget.Font = new System.Drawing.Font("Segoe UI", 9F);
this.comboBoxTranslationTarget.FormattingEnabled = true; this.comboBoxTranslationTarget.FormattingEnabled = true;
this.comboBoxTranslationTarget.Location = new System.Drawing.Point(5, 135); this.comboBoxTranslationTarget.Location = new System.Drawing.Point(5, 371);
this.comboBoxTranslationTarget.Margin = new System.Windows.Forms.Padding(5, 4, 3, 3); this.comboBoxTranslationTarget.Margin = new System.Windows.Forms.Padding(5, 4, 3, 3);
this.comboBoxTranslationTarget.Name = "comboBoxTranslationTarget"; this.comboBoxTranslationTarget.Name = "comboBoxTranslationTarget";
this.comboBoxTranslationTarget.Size = new System.Drawing.Size(290, 23); this.comboBoxTranslationTarget.Size = new System.Drawing.Size(290, 23);
this.comboBoxTranslationTarget.TabIndex = 5; this.comboBoxTranslationTarget.TabIndex = 13;
//
// labelFirstDayOfWeek
//
this.labelFirstDayOfWeek.AutoSize = true;
this.labelFirstDayOfWeek.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold);
this.labelFirstDayOfWeek.Location = new System.Drawing.Point(3, 173);
this.labelFirstDayOfWeek.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelFirstDayOfWeek.Name = "labelFirstDayOfWeek";
this.labelFirstDayOfWeek.Size = new System.Drawing.Size(125, 15);
this.labelFirstDayOfWeek.TabIndex = 6;
this.labelFirstDayOfWeek.Text = "First Day Of The Week";
//
// comboBoxFirstDayOfWeek
//
this.comboBoxFirstDayOfWeek.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxFirstDayOfWeek.Font = new System.Drawing.Font("Segoe UI", 9F);
this.comboBoxFirstDayOfWeek.FormattingEnabled = true;
this.comboBoxFirstDayOfWeek.Location = new System.Drawing.Point(5, 192);
this.comboBoxFirstDayOfWeek.Margin = new System.Windows.Forms.Padding(5, 4, 3, 3);
this.comboBoxFirstDayOfWeek.Name = "comboBoxFirstDayOfWeek";
this.comboBoxFirstDayOfWeek.Size = new System.Drawing.Size(173, 23);
this.comboBoxFirstDayOfWeek.TabIndex = 7;
//
// labelExternalApplications
//
this.labelExternalApplications.AutoSize = true;
this.labelExternalApplications.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
this.labelExternalApplications.Location = new System.Drawing.Point(0, 243);
this.labelExternalApplications.Margin = new System.Windows.Forms.Padding(0, 25, 0, 1);
this.labelExternalApplications.Name = "labelExternalApplications";
this.labelExternalApplications.Size = new System.Drawing.Size(176, 19);
this.labelExternalApplications.TabIndex = 8;
this.labelExternalApplications.Text = "EXTERNAL APPLICATIONS";
//
// panelCustomBrowser
//
this.panelCustomBrowser.Controls.Add(this.comboBoxCustomBrowser);
this.panelCustomBrowser.Controls.Add(this.btnCustomBrowserChange);
this.panelCustomBrowser.Location = new System.Drawing.Point(0, 293);
this.panelCustomBrowser.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.panelCustomBrowser.Name = "panelCustomBrowser";
this.panelCustomBrowser.Size = new System.Drawing.Size(300, 24);
this.panelCustomBrowser.TabIndex = 10;
//
// btnCustomBrowserChange
//
this.btnCustomBrowserChange.AutoSize = true;
this.btnCustomBrowserChange.Font = new System.Drawing.Font("Segoe UI", 9F);
this.btnCustomBrowserChange.Location = new System.Drawing.Point(186, 0);
this.btnCustomBrowserChange.Margin = new System.Windows.Forms.Padding(5, 0, 3, 0);
this.btnCustomBrowserChange.Name = "btnCustomBrowserChange";
this.btnCustomBrowserChange.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.btnCustomBrowserChange.Size = new System.Drawing.Size(71, 25);
this.btnCustomBrowserChange.TabIndex = 1;
this.btnCustomBrowserChange.Text = "Change...";
this.btnCustomBrowserChange.UseVisualStyleBackColor = true;
this.btnCustomBrowserChange.Visible = false;
//
// labelVideoPlayerPath
//
this.labelVideoPlayerPath.AutoSize = true;
this.labelVideoPlayerPath.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold);
this.labelVideoPlayerPath.Location = new System.Drawing.Point(3, 332);
this.labelVideoPlayerPath.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelVideoPlayerPath.Name = "labelVideoPlayerPath";
this.labelVideoPlayerPath.Size = new System.Drawing.Size(106, 15);
this.labelVideoPlayerPath.TabIndex = 11;
this.labelVideoPlayerPath.Text = "Play Videos With...";
//
// panelCustomVideoPlayer
//
this.panelCustomVideoPlayer.Controls.Add(this.comboBoxCustomVideoPlayer);
this.panelCustomVideoPlayer.Controls.Add(this.btnCustomVideoPlayerChange);
this.panelCustomVideoPlayer.Location = new System.Drawing.Point(0, 350);
this.panelCustomVideoPlayer.Margin = new System.Windows.Forms.Padding(0, 3, 0, 3);
this.panelCustomVideoPlayer.Name = "panelCustomVideoPlayer";
this.panelCustomVideoPlayer.Size = new System.Drawing.Size(300, 24);
this.panelCustomVideoPlayer.TabIndex = 12;
//
// comboBoxCustomVideoPlayer
//
this.comboBoxCustomVideoPlayer.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCustomVideoPlayer.Font = new System.Drawing.Font("Segoe UI", 9F);
this.comboBoxCustomVideoPlayer.FormattingEnabled = true;
this.comboBoxCustomVideoPlayer.Location = new System.Drawing.Point(5, 1);
this.comboBoxCustomVideoPlayer.Margin = new System.Windows.Forms.Padding(5, 1, 3, 0);
this.comboBoxCustomVideoPlayer.Name = "comboBoxCustomVideoPlayer";
this.comboBoxCustomVideoPlayer.Size = new System.Drawing.Size(173, 23);
this.comboBoxCustomVideoPlayer.TabIndex = 0;
//
// btnCustomVideoPlayerChange
//
this.btnCustomVideoPlayerChange.AutoSize = true;
this.btnCustomVideoPlayerChange.Font = new System.Drawing.Font("Segoe UI", 9F);
this.btnCustomVideoPlayerChange.Location = new System.Drawing.Point(186, 0);
this.btnCustomVideoPlayerChange.Margin = new System.Windows.Forms.Padding(5, 0, 3, 0);
this.btnCustomVideoPlayerChange.Name = "btnCustomVideoPlayerChange";
this.btnCustomVideoPlayerChange.Padding = new System.Windows.Forms.Padding(2, 0, 2, 0);
this.btnCustomVideoPlayerChange.Size = new System.Drawing.Size(71, 25);
this.btnCustomVideoPlayerChange.TabIndex = 1;
this.btnCustomVideoPlayerChange.Text = "Change...";
this.btnCustomVideoPlayerChange.UseVisualStyleBackColor = true;
this.btnCustomVideoPlayerChange.Visible = false;
// //
// panelSeparator // panelSeparator
// //
@@ -586,10 +520,6 @@
this.flowPanelLeft.PerformLayout(); this.flowPanelLeft.PerformLayout();
this.flowPanelRight.ResumeLayout(false); this.flowPanelRight.ResumeLayout(false);
this.flowPanelRight.PerformLayout(); this.flowPanelRight.PerformLayout();
this.panelCustomBrowser.ResumeLayout(false);
this.panelCustomBrowser.PerformLayout();
this.panelCustomVideoPlayer.ResumeLayout(false);
this.panelCustomVideoPlayer.PerformLayout();
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -613,7 +543,7 @@
private System.Windows.Forms.FlowLayoutPanel flowPanelLeft; private System.Windows.Forms.FlowLayoutPanel flowPanelLeft;
private System.Windows.Forms.CheckBox checkKeepLikeFollowDialogsOpen; private System.Windows.Forms.CheckBox checkKeepLikeFollowDialogsOpen;
private System.Windows.Forms.Label labelBrowserPath; private System.Windows.Forms.Label labelBrowserPath;
private System.Windows.Forms.ComboBox comboBoxCustomBrowser; private System.Windows.Forms.ComboBox comboBoxBrowserPath;
private System.Windows.Forms.Label labelBrowserSettings; private System.Windows.Forms.Label labelBrowserSettings;
private System.Windows.Forms.CheckBox checkSmoothScrolling; private System.Windows.Forms.CheckBox checkSmoothScrolling;
private System.Windows.Forms.Label labelSearchEngine; private System.Windows.Forms.Label labelSearchEngine;
@@ -621,6 +551,10 @@
private System.Windows.Forms.CheckBox checkTouchAdjustment; private System.Windows.Forms.CheckBox checkTouchAdjustment;
private System.Windows.Forms.FlowLayoutPanel flowPanelRight; private System.Windows.Forms.FlowLayoutPanel flowPanelRight;
private System.Windows.Forms.Panel panelSeparator; private System.Windows.Forms.Panel panelSeparator;
private System.Windows.Forms.Label labelTray;
private System.Windows.Forms.ComboBox comboBoxTrayType;
private System.Windows.Forms.Label labelTrayIcon;
private System.Windows.Forms.CheckBox checkTrayHighlight;
private System.Windows.Forms.Label labelLocales; private System.Windows.Forms.Label labelLocales;
private System.Windows.Forms.CheckBox checkSpellCheck; private System.Windows.Forms.CheckBox checkSpellCheck;
private System.Windows.Forms.Label labelSpellCheckLanguage; private System.Windows.Forms.Label labelSpellCheckLanguage;
@@ -629,14 +563,5 @@
private System.Windows.Forms.ComboBox comboBoxTranslationTarget; private System.Windows.Forms.ComboBox comboBoxTranslationTarget;
private System.Windows.Forms.CheckBox checkHardwareAcceleration; private System.Windows.Forms.CheckBox checkHardwareAcceleration;
private System.Windows.Forms.CheckBox checkFocusDmInput; private System.Windows.Forms.CheckBox checkFocusDmInput;
private System.Windows.Forms.Panel panelCustomBrowser;
private System.Windows.Forms.Button btnCustomBrowserChange;
private System.Windows.Forms.Label labelVideoPlayerPath;
private System.Windows.Forms.Panel panelCustomVideoPlayer;
private System.Windows.Forms.ComboBox comboBoxCustomVideoPlayer;
private System.Windows.Forms.Button btnCustomVideoPlayerChange;
private System.Windows.Forms.Label labelExternalApplications;
private System.Windows.Forms.Label labelFirstDayOfWeek;
private System.Windows.Forms.ComboBox comboBoxFirstDayOfWeek;
} }
} }

View File

@@ -2,14 +2,14 @@
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Browser.Handling.General; using TweetDuck.Core.Controls;
using TweetDuck.Controls; using TweetDuck.Core.Handling.General;
using TweetDuck.Utils; using TweetDuck.Core.Other.Settings.Dialogs;
using TweetLib.Core.Systems.Updates; using TweetDuck.Core.Utils;
using TweetLib.Core.Utils; using TweetDuck.Updates;
namespace TweetDuck.Dialogs.Settings{ namespace TweetDuck.Core.Other.Settings{
sealed partial class TabSettingsGeneral : FormSettings.BaseTab{ sealed partial class TabSettingsGeneral : BaseTabSettings{
private readonly Action reloadColumns; private readonly Action reloadColumns;
private readonly UpdateHandler updates; private readonly UpdateHandler updates;
@@ -18,9 +18,6 @@ namespace TweetDuck.Dialogs.Settings{
private readonly int browserListIndexDefault; private readonly int browserListIndexDefault;
private readonly int browserListIndexCustom; private readonly int browserListIndexCustom;
private readonly int videoPlayerListIndexDefault;
private readonly int videoPlayerListIndexCustom;
private readonly int searchEngineIndexDefault; private readonly int searchEngineIndexDefault;
private readonly int searchEngineIndexCustom; private readonly int searchEngineIndexCustom;
@@ -55,6 +52,21 @@ namespace TweetDuck.Dialogs.Settings{
trackBarZoom.SetValueSafe(Config.ZoomLevel); trackBarZoom.SetValueSafe(Config.ZoomLevel);
labelZoomValue.Text = trackBarZoom.Value+"%"; labelZoomValue.Text = trackBarZoom.Value+"%";
// system tray
toolTip.SetToolTip(comboBoxTrayType, "Changes behavior of the Tray icon.\r\nRight-click the icon for an action menu.");
toolTip.SetToolTip(checkTrayHighlight, "Highlights the tray icon if there are new tweets.\r\nOnly works for columns with popup or audio notifications.\r\nThe icon resets when the main window is restored.");
comboBoxTrayType.Items.Add("Disabled");
comboBoxTrayType.Items.Add("Display Icon Only");
comboBoxTrayType.Items.Add("Minimize to Tray");
comboBoxTrayType.Items.Add("Close to Tray");
comboBoxTrayType.Items.Add("Combined");
comboBoxTrayType.SelectedIndex = Math.Min(Math.Max((int)Config.TrayBehavior, 0), comboBoxTrayType.Items.Count-1);
checkTrayHighlight.Enabled = Config.TrayBehavior.ShouldDisplayIcon();
checkTrayHighlight.Checked = Config.EnableTrayHighlight;
// updates // updates
toolTip.SetToolTip(checkUpdateNotifications, "Checks for updates every hour.\r\nIf an update is dismissed, it will not appear again."); toolTip.SetToolTip(checkUpdateNotifications, "Checks for updates every hour.\r\nIf an update is dismissed, it will not appear again.");
@@ -67,8 +79,7 @@ namespace TweetDuck.Dialogs.Settings{
toolTip.SetToolTip(checkSmoothScrolling, "Toggles smooth mouse wheel scrolling."); toolTip.SetToolTip(checkSmoothScrolling, "Toggles smooth mouse wheel scrolling.");
toolTip.SetToolTip(checkTouchAdjustment, "Toggles Chromium touch screen adjustment.\r\nDisabled by default, because it is very imprecise with TweetDeck."); toolTip.SetToolTip(checkTouchAdjustment, "Toggles Chromium touch screen adjustment.\r\nDisabled by default, because it is very imprecise with TweetDeck.");
toolTip.SetToolTip(checkHardwareAcceleration, "Uses graphics card to improve performance.\r\nDisable if you experience visual glitches, or to save a small amount of RAM."); toolTip.SetToolTip(checkHardwareAcceleration, "Uses graphics card to improve performance.\r\nDisable if you experience visual glitches, or to save a small amount of RAM.");
toolTip.SetToolTip(comboBoxCustomBrowser, "Sets the default browser for opening links."); toolTip.SetToolTip(comboBoxBrowserPath, "Sets the default browser for opening links.");
toolTip.SetToolTip(comboBoxCustomVideoPlayer, "Sets the default application for playing videos.");
toolTip.SetToolTip(comboBoxSearchEngine, "Sets the default website for opening searches."); toolTip.SetToolTip(comboBoxSearchEngine, "Sets the default website for opening searches.");
checkSmoothScrolling.Checked = Config.EnableSmoothScrolling; checkSmoothScrolling.Checked = Config.EnableSmoothScrolling;
@@ -76,17 +87,13 @@ namespace TweetDuck.Dialogs.Settings{
checkHardwareAcceleration.Checked = SysConfig.HardwareAcceleration; checkHardwareAcceleration.Checked = SysConfig.HardwareAcceleration;
foreach(WindowsUtils.Browser browserInfo in WindowsUtils.FindInstalledBrowsers()){ foreach(WindowsUtils.Browser browserInfo in WindowsUtils.FindInstalledBrowsers()){
comboBoxCustomBrowser.Items.Add(browserInfo); comboBoxBrowserPath.Items.Add(browserInfo);
} }
browserListIndexDefault = comboBoxCustomBrowser.Items.Add("(default browser)"); browserListIndexDefault = comboBoxBrowserPath.Items.Add("(default browser)");
browserListIndexCustom = comboBoxCustomBrowser.Items.Add("(custom program...)"); browserListIndexCustom = comboBoxBrowserPath.Items.Add("(custom program...)");
UpdateBrowserPathSelection(); UpdateBrowserPathSelection();
videoPlayerListIndexDefault = comboBoxCustomVideoPlayer.Items.Add("(default TweetDuck player)");
videoPlayerListIndexCustom = comboBoxCustomVideoPlayer.Items.Add("(custom program...)");
UpdateVideoPlayerPathSelection();
comboBoxSearchEngine.Items.Add(new SearchEngine("DuckDuckGo", "https://duckduckgo.com/?q=")); comboBoxSearchEngine.Items.Add(new SearchEngine("DuckDuckGo", "https://duckduckgo.com/?q="));
comboBoxSearchEngine.Items.Add(new SearchEngine("Google", "https://www.google.com/search?q=")); comboBoxSearchEngine.Items.Add(new SearchEngine("Google", "https://www.google.com/search?q="));
comboBoxSearchEngine.Items.Add(new SearchEngine("Bing", "https://www.bing.com/search?q=")); comboBoxSearchEngine.Items.Add(new SearchEngine("Bing", "https://www.bing.com/search?q="));
@@ -100,7 +107,6 @@ namespace TweetDuck.Dialogs.Settings{
toolTip.SetToolTip(checkSpellCheck, "Underlines words that are spelled incorrectly."); toolTip.SetToolTip(checkSpellCheck, "Underlines words that are spelled incorrectly.");
toolTip.SetToolTip(comboBoxSpellCheckLanguage, "Language used for spell check."); toolTip.SetToolTip(comboBoxSpellCheckLanguage, "Language used for spell check.");
toolTip.SetToolTip(comboBoxTranslationTarget, "Language tweets are translated into."); toolTip.SetToolTip(comboBoxTranslationTarget, "Language tweets are translated into.");
toolTip.SetToolTip(comboBoxFirstDayOfWeek, "First day of week used in the date picker.");
checkSpellCheck.Checked = Config.EnableSpellCheck; checkSpellCheck.Checked = Config.EnableSpellCheck;
@@ -119,17 +125,6 @@ namespace TweetDuck.Dialogs.Settings{
} }
comboBoxTranslationTarget.SelectedItem = new LocaleUtils.Item(Config.TranslationTarget); comboBoxTranslationTarget.SelectedItem = new LocaleUtils.Item(Config.TranslationTarget);
var daysOfWeek = comboBoxFirstDayOfWeek.Items;
daysOfWeek.Add("(based on system locale)");
daysOfWeek.Add(new DayOfWeekItem("Monday", DayOfWeek.Monday));
daysOfWeek.Add(new DayOfWeekItem("Tuesday", DayOfWeek.Tuesday));
daysOfWeek.Add(new DayOfWeekItem("Wednesday", DayOfWeek.Wednesday));
daysOfWeek.Add(new DayOfWeekItem("Thursday", DayOfWeek.Thursday));
daysOfWeek.Add(new DayOfWeekItem("Friday", DayOfWeek.Friday));
daysOfWeek.Add(new DayOfWeekItem("Saturday", DayOfWeek.Saturday));
daysOfWeek.Add(new DayOfWeekItem("Sunday", DayOfWeek.Sunday));
comboBoxFirstDayOfWeek.SelectedItem = daysOfWeek.OfType<DayOfWeekItem>().FirstOrDefault(dow => dow.Id == Config.CalendarFirstDay) ?? daysOfWeek[0];
} }
public override void OnReady(){ public override void OnReady(){
@@ -141,22 +136,21 @@ namespace TweetDuck.Dialogs.Settings{
checkAnimatedAvatars.CheckedChanged += checkAnimatedAvatars_CheckedChanged; checkAnimatedAvatars.CheckedChanged += checkAnimatedAvatars_CheckedChanged;
trackBarZoom.ValueChanged += trackBarZoom_ValueChanged; trackBarZoom.ValueChanged += trackBarZoom_ValueChanged;
comboBoxTrayType.SelectedIndexChanged += comboBoxTrayType_SelectedIndexChanged;
checkTrayHighlight.CheckedChanged += checkTrayHighlight_CheckedChanged;
checkUpdateNotifications.CheckedChanged += checkUpdateNotifications_CheckedChanged; checkUpdateNotifications.CheckedChanged += checkUpdateNotifications_CheckedChanged;
btnCheckUpdates.Click += btnCheckUpdates_Click; btnCheckUpdates.Click += btnCheckUpdates_Click;
checkSmoothScrolling.CheckedChanged += checkSmoothScrolling_CheckedChanged; checkSmoothScrolling.CheckedChanged += checkSmoothScrolling_CheckedChanged;
checkTouchAdjustment.CheckedChanged += checkTouchAdjustment_CheckedChanged; checkTouchAdjustment.CheckedChanged += checkTouchAdjustment_CheckedChanged;
checkHardwareAcceleration.CheckedChanged += checkHardwareAcceleration_CheckedChanged; checkHardwareAcceleration.CheckedChanged += checkHardwareAcceleration_CheckedChanged;
comboBoxCustomBrowser.SelectedIndexChanged += comboBoxCustomBrowser_SelectedIndexChanged; comboBoxBrowserPath.SelectedIndexChanged += comboBoxBrowserPath_SelectedIndexChanged;
btnCustomBrowserChange.Click += btnCustomBrowserChange_Click;
comboBoxCustomVideoPlayer.SelectedIndexChanged += comboBoxCustomVideoPlayer_SelectedIndexChanged;
btnCustomVideoPlayerChange.Click += btnCustomVideoPlayerChange_Click;
comboBoxSearchEngine.SelectedIndexChanged += comboBoxSearchEngine_SelectedIndexChanged; comboBoxSearchEngine.SelectedIndexChanged += comboBoxSearchEngine_SelectedIndexChanged;
checkSpellCheck.CheckedChanged += checkSpellCheck_CheckedChanged; checkSpellCheck.CheckedChanged += checkSpellCheck_CheckedChanged;
comboBoxSpellCheckLanguage.SelectedValueChanged += comboBoxSpellCheckLanguage_SelectedValueChanged; comboBoxSpellCheckLanguage.SelectedValueChanged += comboBoxSpellCheckLanguage_SelectedValueChanged;
comboBoxTranslationTarget.SelectedValueChanged += comboBoxTranslationTarget_SelectedValueChanged; comboBoxTranslationTarget.SelectedValueChanged += comboBoxTranslationTarget_SelectedValueChanged;
comboBoxFirstDayOfWeek.SelectedValueChanged += comboBoxFirstDayOfWeek_SelectedValueChanged;
} }
public override void OnClosing(){ public override void OnClosing(){
@@ -203,6 +197,18 @@ namespace TweetDuck.Dialogs.Settings{
zoomUpdateTimer.Stop(); zoomUpdateTimer.Stop();
} }
#endregion
#region System Tray
private void comboBoxTrayType_SelectedIndexChanged(object sender, EventArgs e){
Config.TrayBehavior = (TrayIcon.Behavior)comboBoxTrayType.SelectedIndex;
checkTrayHighlight.Enabled = Config.TrayBehavior.ShouldDisplayIcon();
}
private void checkTrayHighlight_CheckedChanged(object sender, EventArgs e){
Config.EnableTrayHighlight = checkTrayHighlight.Checked;
}
#endregion #endregion
#region Updates #region Updates
@@ -246,95 +252,43 @@ namespace TweetDuck.Dialogs.Settings{
SysConfig.HardwareAcceleration = checkHardwareAcceleration.Checked; SysConfig.HardwareAcceleration = checkHardwareAcceleration.Checked;
} }
private void UpdateBrowserChangeButton(){
btnCustomBrowserChange.Visible = comboBoxCustomBrowser.SelectedIndex == browserListIndexCustom;
}
private void UpdateBrowserPathSelection(){ private void UpdateBrowserPathSelection(){
if (string.IsNullOrEmpty(Config.BrowserPath) || !File.Exists(Config.BrowserPath)){ if (string.IsNullOrEmpty(Config.BrowserPath) || !File.Exists(Config.BrowserPath)){
comboBoxCustomBrowser.SelectedIndex = browserListIndexDefault; comboBoxBrowserPath.SelectedIndex = browserListIndexDefault;
} }
else{ else{
WindowsUtils.Browser browserInfo = comboBoxCustomBrowser.Items.OfType<WindowsUtils.Browser>().FirstOrDefault(browser => browser.Path == Config.BrowserPath); WindowsUtils.Browser browserInfo = comboBoxBrowserPath.Items.OfType<WindowsUtils.Browser>().FirstOrDefault(browser => browser.Path == Config.BrowserPath);
if (browserInfo == null || Config.BrowserPathArgs != null){ if (browserInfo == null){
comboBoxCustomBrowser.SelectedIndex = browserListIndexCustom; comboBoxBrowserPath.SelectedIndex = browserListIndexCustom;
} }
else{ else{
comboBoxCustomBrowser.SelectedItem = browserInfo; comboBoxBrowserPath.SelectedItem = browserInfo;
}
} }
} }
UpdateBrowserChangeButton(); private void comboBoxBrowserPath_SelectedIndexChanged(object sender, EventArgs e){
} if (comboBoxBrowserPath.SelectedIndex == browserListIndexCustom){
using(OpenFileDialog dialog = new OpenFileDialog{
private void comboBoxCustomBrowser_SelectedIndexChanged(object sender, EventArgs e){ AutoUpgradeEnabled = true,
if (comboBoxCustomBrowser.SelectedIndex == browserListIndexCustom){ DereferenceLinks = true,
btnCustomBrowserChange_Click(sender, e); InitialDirectory = Path.GetDirectoryName(Config.BrowserPath), // returns null if argument is null
} Title = "Open Links With...",
else{ Filter = "Executables (*.exe;*.bat;*.cmd)|*.exe;*.bat;*.cmd|All Files (*.*)|*.*"
Config.BrowserPath = (comboBoxCustomBrowser.SelectedItem as WindowsUtils.Browser)?.Path; // default browser item is a string and casts to null
Config.BrowserPathArgs = null;
UpdateBrowserChangeButton();
}
}
private void btnCustomBrowserChange_Click(object sender, EventArgs e){
using(DialogSettingsExternalProgram dialog = new DialogSettingsExternalProgram("External Browser", "Open Links With..."){
Path = Config.BrowserPath,
Args = Config.BrowserPathArgs
}){ }){
if (dialog.ShowDialog() == DialogResult.OK){ if (dialog.ShowDialog() == DialogResult.OK){
Config.BrowserPath = dialog.Path; Config.BrowserPath = dialog.FileName;
Config.BrowserPathArgs = dialog.Args;
} }
} }
comboBoxCustomBrowser.SelectedIndexChanged -= comboBoxCustomBrowser_SelectedIndexChanged; comboBoxBrowserPath.SelectedIndexChanged -= comboBoxBrowserPath_SelectedIndexChanged;
UpdateBrowserPathSelection(); UpdateBrowserPathSelection();
comboBoxCustomBrowser.SelectedIndexChanged += comboBoxCustomBrowser_SelectedIndexChanged; comboBoxBrowserPath.SelectedIndexChanged += comboBoxBrowserPath_SelectedIndexChanged;
}
private void UpdateVideoPlayerChangeButton(){
btnCustomVideoPlayerChange.Visible = comboBoxCustomVideoPlayer.SelectedIndex == videoPlayerListIndexCustom;
}
private void UpdateVideoPlayerPathSelection(){
if (string.IsNullOrEmpty(Config.VideoPlayerPath) || !File.Exists(Config.VideoPlayerPath)){
comboBoxCustomVideoPlayer.SelectedIndex = videoPlayerListIndexDefault;
} }
else{ else{
comboBoxCustomVideoPlayer.SelectedIndex = videoPlayerListIndexCustom; Config.BrowserPath = (comboBoxBrowserPath.SelectedItem as WindowsUtils.Browser)?.Path; // default browser item is a string and casts to null
} }
UpdateVideoPlayerChangeButton();
}
private void comboBoxCustomVideoPlayer_SelectedIndexChanged(object sender, EventArgs e){
if (comboBoxCustomVideoPlayer.SelectedIndex == videoPlayerListIndexCustom){
btnCustomVideoPlayerChange_Click(sender, e);
}
else{
Config.VideoPlayerPath = null;
Config.VideoPlayerPathArgs = null;
UpdateVideoPlayerChangeButton();
}
}
private void btnCustomVideoPlayerChange_Click(object sender, EventArgs e){
using(DialogSettingsExternalProgram dialog = new DialogSettingsExternalProgram("External Video Player", "Play Videos With..."){
Path = Config.VideoPlayerPath,
Args = Config.VideoPlayerPathArgs
}){
if (dialog.ShowDialog() == DialogResult.OK){
Config.VideoPlayerPath = dialog.Path;
Config.VideoPlayerPathArgs = dialog.Args;
}
}
comboBoxCustomVideoPlayer.SelectedIndexChanged -= comboBoxCustomVideoPlayer_SelectedIndexChanged;
UpdateVideoPlayerPathSelection();
comboBoxCustomVideoPlayer.SelectedIndexChanged += comboBoxCustomVideoPlayer_SelectedIndexChanged;
} }
private void comboBoxSearchEngine_SelectedIndexChanged(object sender, EventArgs e){ private void comboBoxSearchEngine_SelectedIndexChanged(object sender, EventArgs e){
@@ -400,24 +354,6 @@ namespace TweetDuck.Dialogs.Settings{
Config.TranslationTarget = (comboBoxTranslationTarget.SelectedItem as LocaleUtils.Item)?.Code ?? "en"; Config.TranslationTarget = (comboBoxTranslationTarget.SelectedItem as LocaleUtils.Item)?.Code ?? "en";
} }
private void comboBoxFirstDayOfWeek_SelectedValueChanged(object sender, EventArgs e){
Config.CalendarFirstDay = (comboBoxFirstDayOfWeek.SelectedItem as DayOfWeekItem)?.Id ?? -1;
}
private sealed class DayOfWeekItem{
private string Name { get; }
public int Id { get; }
public DayOfWeekItem(string name, DayOfWeek dow){
Name = name;
Id = LocaleUtils.GetJQueryDayOfWeek(dow);
}
public override int GetHashCode() => Name.GetHashCode();
public override bool Equals(object obj) => obj is DayOfWeekItem other && Name == other.Name;
public override string ToString() => Name;
}
#endregion #endregion
} }
} }

View File

@@ -1,4 +1,4 @@
namespace TweetDuck.Dialogs.Settings { namespace TweetDuck.Core.Other.Settings {
partial class TabSettingsNotifications { partial class TabSettingsNotifications {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -35,9 +35,9 @@
this.radioLocTL = new System.Windows.Forms.RadioButton(); this.radioLocTL = new System.Windows.Forms.RadioButton();
this.trackBarEdgeDistance = new System.Windows.Forms.TrackBar(); this.trackBarEdgeDistance = new System.Windows.Forms.TrackBar();
this.tableLayoutDurationButtons = new System.Windows.Forms.TableLayoutPanel(); this.tableLayoutDurationButtons = new System.Windows.Forms.TableLayoutPanel();
this.btnDurationMedium = new TweetDuck.Controls.FlatButton(); this.btnDurationMedium = new TweetDuck.Core.Controls.FlatButton();
this.btnDurationLong = new TweetDuck.Controls.FlatButton(); this.btnDurationLong = new TweetDuck.Core.Controls.FlatButton();
this.btnDurationShort = new TweetDuck.Controls.FlatButton(); this.btnDurationShort = new TweetDuck.Core.Controls.FlatButton();
this.labelDurationValue = new System.Windows.Forms.Label(); this.labelDurationValue = new System.Windows.Forms.Label();
this.trackBarDuration = new System.Windows.Forms.TrackBar(); this.trackBarDuration = new System.Windows.Forms.TrackBar();
this.checkSkipOnLinkClick = new System.Windows.Forms.CheckBox(); this.checkSkipOnLinkClick = new System.Windows.Forms.CheckBox();
@@ -65,10 +65,6 @@
this.panelSize = new System.Windows.Forms.Panel(); this.panelSize = new System.Windows.Forms.Panel();
this.durationUpdateTimer = new System.Windows.Forms.Timer(this.components); this.durationUpdateTimer = new System.Windows.Forms.Timer(this.components);
this.flowPanelLeft = new System.Windows.Forms.FlowLayoutPanel(); 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.panelScrollSpeed = new System.Windows.Forms.Panel();
this.flowPanelRight = new System.Windows.Forms.FlowLayoutPanel(); this.flowPanelRight = new System.Windows.Forms.FlowLayoutPanel();
this.panelSeparator = new System.Windows.Forms.Panel(); this.panelSeparator = new System.Windows.Forms.Panel();
@@ -81,8 +77,6 @@
this.panelTimer.SuspendLayout(); this.panelTimer.SuspendLayout();
this.panelSize.SuspendLayout(); this.panelSize.SuspendLayout();
this.flowPanelLeft.SuspendLayout(); this.flowPanelLeft.SuspendLayout();
this.panelOpacity.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.trackBarOpacity)).BeginInit();
this.panelScrollSpeed.SuspendLayout(); this.panelScrollSpeed.SuspendLayout();
this.flowPanelRight.SuspendLayout(); this.flowPanelRight.SuspendLayout();
this.SuspendLayout(); this.SuspendLayout();
@@ -90,7 +84,7 @@
// labelEdgeDistanceValue // labelEdgeDistanceValue
// //
this.labelEdgeDistanceValue.Font = new System.Drawing.Font("Segoe UI", 9F); this.labelEdgeDistanceValue.Font = new System.Drawing.Font("Segoe UI", 9F);
this.labelEdgeDistanceValue.Location = new System.Drawing.Point(175, 4); this.labelEdgeDistanceValue.Location = new System.Drawing.Point(145, 4);
this.labelEdgeDistanceValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0); this.labelEdgeDistanceValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelEdgeDistanceValue.Name = "labelEdgeDistanceValue"; this.labelEdgeDistanceValue.Name = "labelEdgeDistanceValue";
this.labelEdgeDistanceValue.Size = new System.Drawing.Size(40, 15); this.labelEdgeDistanceValue.Size = new System.Drawing.Size(40, 15);
@@ -199,7 +193,7 @@
this.trackBarEdgeDistance.Maximum = 40; this.trackBarEdgeDistance.Maximum = 40;
this.trackBarEdgeDistance.Minimum = 8; this.trackBarEdgeDistance.Minimum = 8;
this.trackBarEdgeDistance.Name = "trackBarEdgeDistance"; this.trackBarEdgeDistance.Name = "trackBarEdgeDistance";
this.trackBarEdgeDistance.Size = new System.Drawing.Size(177, 30); this.trackBarEdgeDistance.Size = new System.Drawing.Size(148, 30);
this.trackBarEdgeDistance.SmallChange = 2; this.trackBarEdgeDistance.SmallChange = 2;
this.trackBarEdgeDistance.TabIndex = 0; this.trackBarEdgeDistance.TabIndex = 0;
this.trackBarEdgeDistance.TickFrequency = 4; this.trackBarEdgeDistance.TickFrequency = 4;
@@ -214,12 +208,12 @@
this.tableLayoutDurationButtons.Controls.Add(this.btnDurationMedium, 0, 0); this.tableLayoutDurationButtons.Controls.Add(this.btnDurationMedium, 0, 0);
this.tableLayoutDurationButtons.Controls.Add(this.btnDurationLong, 1, 0); this.tableLayoutDurationButtons.Controls.Add(this.btnDurationLong, 1, 0);
this.tableLayoutDurationButtons.Controls.Add(this.btnDurationShort, 0, 0); this.tableLayoutDurationButtons.Controls.Add(this.btnDurationShort, 0, 0);
this.tableLayoutDurationButtons.Location = new System.Drawing.Point(3, 401); this.tableLayoutDurationButtons.Location = new System.Drawing.Point(3, 353);
this.tableLayoutDurationButtons.Name = "tableLayoutDurationButtons"; this.tableLayoutDurationButtons.Name = "tableLayoutDurationButtons";
this.tableLayoutDurationButtons.RowCount = 1; this.tableLayoutDurationButtons.RowCount = 1;
this.tableLayoutDurationButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F)); 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.Size = new System.Drawing.Size(180, 27);
this.tableLayoutDurationButtons.TabIndex = 14; this.tableLayoutDurationButtons.TabIndex = 12;
// //
// btnDurationMedium // btnDurationMedium
// //
@@ -273,7 +267,7 @@
// //
this.labelDurationValue.BackColor = System.Drawing.Color.Transparent; this.labelDurationValue.BackColor = System.Drawing.Color.Transparent;
this.labelDurationValue.Font = new System.Drawing.Font("Segoe UI", 9F); this.labelDurationValue.Font = new System.Drawing.Font("Segoe UI", 9F);
this.labelDurationValue.Location = new System.Drawing.Point(177, 4); this.labelDurationValue.Location = new System.Drawing.Point(147, 4);
this.labelDurationValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0); this.labelDurationValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelDurationValue.Name = "labelDurationValue"; this.labelDurationValue.Name = "labelDurationValue";
this.labelDurationValue.Size = new System.Drawing.Size(52, 15); this.labelDurationValue.Size = new System.Drawing.Size(52, 15);
@@ -288,7 +282,7 @@
this.trackBarDuration.Maximum = 60; this.trackBarDuration.Maximum = 60;
this.trackBarDuration.Minimum = 10; this.trackBarDuration.Minimum = 10;
this.trackBarDuration.Name = "trackBarDuration"; this.trackBarDuration.Name = "trackBarDuration";
this.trackBarDuration.Size = new System.Drawing.Size(177, 30); this.trackBarDuration.Size = new System.Drawing.Size(148, 30);
this.trackBarDuration.TabIndex = 0; this.trackBarDuration.TabIndex = 0;
this.trackBarDuration.TickFrequency = 5; this.trackBarDuration.TickFrequency = 5;
this.trackBarDuration.Value = 25; this.trackBarDuration.Value = 25;
@@ -355,11 +349,11 @@
// //
this.checkTimerCountDown.AutoSize = true; this.checkTimerCountDown.AutoSize = true;
this.checkTimerCountDown.Font = new System.Drawing.Font("Segoe UI", 9F); this.checkTimerCountDown.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkTimerCountDown.Location = new System.Drawing.Point(6, 314); this.checkTimerCountDown.Location = new System.Drawing.Point(6, 266);
this.checkTimerCountDown.Margin = new System.Windows.Forms.Padding(6, 3, 3, 2); this.checkTimerCountDown.Margin = new System.Windows.Forms.Padding(6, 3, 3, 2);
this.checkTimerCountDown.Name = "checkTimerCountDown"; this.checkTimerCountDown.Name = "checkTimerCountDown";
this.checkTimerCountDown.Size = new System.Drawing.Size(132, 19); this.checkTimerCountDown.Size = new System.Drawing.Size(132, 19);
this.checkTimerCountDown.TabIndex = 11; this.checkTimerCountDown.TabIndex = 9;
this.checkTimerCountDown.Text = "Timer Counts Down"; this.checkTimerCountDown.Text = "Timer Counts Down";
this.checkTimerCountDown.UseVisualStyleBackColor = true; this.checkTimerCountDown.UseVisualStyleBackColor = true;
// //
@@ -367,11 +361,11 @@
// //
this.checkNotificationTimer.AutoSize = true; this.checkNotificationTimer.AutoSize = true;
this.checkNotificationTimer.Font = new System.Drawing.Font("Segoe UI", 9F); this.checkNotificationTimer.Font = new System.Drawing.Font("Segoe UI", 9F);
this.checkNotificationTimer.Location = new System.Drawing.Point(6, 290); this.checkNotificationTimer.Location = new System.Drawing.Point(6, 242);
this.checkNotificationTimer.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2); this.checkNotificationTimer.Margin = new System.Windows.Forms.Padding(6, 6, 3, 2);
this.checkNotificationTimer.Name = "checkNotificationTimer"; this.checkNotificationTimer.Name = "checkNotificationTimer";
this.checkNotificationTimer.Size = new System.Drawing.Size(164, 19); this.checkNotificationTimer.Size = new System.Drawing.Size(164, 19);
this.checkNotificationTimer.TabIndex = 10; this.checkNotificationTimer.TabIndex = 8;
this.checkNotificationTimer.Text = "Display Notification Timer"; this.checkNotificationTimer.Text = "Display Notification Timer";
this.checkNotificationTimer.UseVisualStyleBackColor = true; this.checkNotificationTimer.UseVisualStyleBackColor = true;
// //
@@ -435,7 +429,7 @@
// labelScrollSpeedValue // labelScrollSpeedValue
// //
this.labelScrollSpeedValue.Font = new System.Drawing.Font("Segoe UI", 9F); this.labelScrollSpeedValue.Font = new System.Drawing.Font("Segoe UI", 9F);
this.labelScrollSpeedValue.Location = new System.Drawing.Point(176, 4); this.labelScrollSpeedValue.Location = new System.Drawing.Point(145, 4);
this.labelScrollSpeedValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0); this.labelScrollSpeedValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
this.labelScrollSpeedValue.Name = "labelScrollSpeedValue"; this.labelScrollSpeedValue.Name = "labelScrollSpeedValue";
this.labelScrollSpeedValue.Size = new System.Drawing.Size(38, 15); this.labelScrollSpeedValue.Size = new System.Drawing.Size(38, 15);
@@ -451,7 +445,7 @@
this.trackBarScrollSpeed.Maximum = 200; this.trackBarScrollSpeed.Maximum = 200;
this.trackBarScrollSpeed.Minimum = 25; this.trackBarScrollSpeed.Minimum = 25;
this.trackBarScrollSpeed.Name = "trackBarScrollSpeed"; this.trackBarScrollSpeed.Name = "trackBarScrollSpeed";
this.trackBarScrollSpeed.Size = new System.Drawing.Size(177, 30); this.trackBarScrollSpeed.Size = new System.Drawing.Size(148, 30);
this.trackBarScrollSpeed.SmallChange = 5; this.trackBarScrollSpeed.SmallChange = 5;
this.trackBarScrollSpeed.TabIndex = 0; this.trackBarScrollSpeed.TabIndex = 0;
this.trackBarScrollSpeed.TickFrequency = 25; this.trackBarScrollSpeed.TickFrequency = 25;
@@ -496,32 +490,32 @@
// //
this.panelTimer.Controls.Add(this.labelDurationValue); this.panelTimer.Controls.Add(this.labelDurationValue);
this.panelTimer.Controls.Add(this.trackBarDuration); this.panelTimer.Controls.Add(this.trackBarDuration);
this.panelTimer.Location = new System.Drawing.Point(0, 363); this.panelTimer.Location = new System.Drawing.Point(0, 315);
this.panelTimer.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0); this.panelTimer.Margin = new System.Windows.Forms.Padding(0, 1, 0, 0);
this.panelTimer.Name = "panelTimer"; this.panelTimer.Name = "panelTimer";
this.panelTimer.Size = new System.Drawing.Size(300, 35); this.panelTimer.Size = new System.Drawing.Size(300, 35);
this.panelTimer.TabIndex = 13; this.panelTimer.TabIndex = 11;
// //
// labelDuration // labelDuration
// //
this.labelDuration.AutoSize = true; this.labelDuration.AutoSize = true;
this.labelDuration.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold); this.labelDuration.Font = new System.Drawing.Font("Segoe UI Semibold", 9F, System.Drawing.FontStyle.Bold);
this.labelDuration.Location = new System.Drawing.Point(3, 347); this.labelDuration.Location = new System.Drawing.Point(3, 299);
this.labelDuration.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0); this.labelDuration.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
this.labelDuration.Name = "labelDuration"; this.labelDuration.Name = "labelDuration";
this.labelDuration.Size = new System.Drawing.Size(54, 15); this.labelDuration.Size = new System.Drawing.Size(54, 15);
this.labelDuration.TabIndex = 12; this.labelDuration.TabIndex = 10;
this.labelDuration.Text = "Duration"; this.labelDuration.Text = "Duration";
// //
// labelTimer // labelTimer
// //
this.labelTimer.AutoSize = true; this.labelTimer.AutoSize = true;
this.labelTimer.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold); this.labelTimer.Font = new System.Drawing.Font("Segoe UI Semibold", 10.5F, System.Drawing.FontStyle.Bold);
this.labelTimer.Location = new System.Drawing.Point(0, 264); this.labelTimer.Location = new System.Drawing.Point(0, 216);
this.labelTimer.Margin = new System.Windows.Forms.Padding(0, 25, 0, 1); this.labelTimer.Margin = new System.Windows.Forms.Padding(0, 40, 0, 1);
this.labelTimer.Name = "labelTimer"; this.labelTimer.Name = "labelTimer";
this.labelTimer.Size = new System.Drawing.Size(50, 19); this.labelTimer.Size = new System.Drawing.Size(50, 19);
this.labelTimer.TabIndex = 9; this.labelTimer.TabIndex = 7;
this.labelTimer.Text = "TIMER"; this.labelTimer.Text = "TIMER";
// //
// labelSize // labelSize
@@ -561,8 +555,6 @@
this.flowPanelLeft.Controls.Add(this.checkNonIntrusive); this.flowPanelLeft.Controls.Add(this.checkNonIntrusive);
this.flowPanelLeft.Controls.Add(this.labelIdlePause); this.flowPanelLeft.Controls.Add(this.labelIdlePause);
this.flowPanelLeft.Controls.Add(this.comboBoxIdlePause); 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.labelTimer);
this.flowPanelLeft.Controls.Add(this.checkNotificationTimer); this.flowPanelLeft.Controls.Add(this.checkNotificationTimer);
this.flowPanelLeft.Controls.Add(this.checkTimerCountDown); this.flowPanelLeft.Controls.Add(this.checkTimerCountDown);
@@ -576,52 +568,6 @@
this.flowPanelLeft.TabIndex = 0; this.flowPanelLeft.TabIndex = 0;
this.flowPanelLeft.WrapContents = false; 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 // panelScrollSpeed
// //
this.panelScrollSpeed.Controls.Add(this.trackBarScrollSpeed); this.panelScrollSpeed.Controls.Add(this.trackBarScrollSpeed);
@@ -684,8 +630,6 @@
this.panelSize.ResumeLayout(false); this.panelSize.ResumeLayout(false);
this.flowPanelLeft.ResumeLayout(false); this.flowPanelLeft.ResumeLayout(false);
this.flowPanelLeft.PerformLayout(); this.flowPanelLeft.PerformLayout();
this.panelOpacity.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.trackBarOpacity)).EndInit();
this.panelScrollSpeed.ResumeLayout(false); this.panelScrollSpeed.ResumeLayout(false);
this.flowPanelRight.ResumeLayout(false); this.flowPanelRight.ResumeLayout(false);
this.flowPanelRight.PerformLayout(); this.flowPanelRight.PerformLayout();
@@ -708,9 +652,9 @@
private System.Windows.Forms.Label labelDurationValue; private System.Windows.Forms.Label labelDurationValue;
private System.Windows.Forms.TrackBar trackBarDuration; private System.Windows.Forms.TrackBar trackBarDuration;
private System.Windows.Forms.TableLayoutPanel tableLayoutDurationButtons; private System.Windows.Forms.TableLayoutPanel tableLayoutDurationButtons;
private TweetDuck.Controls.FlatButton btnDurationMedium; private TweetDuck.Core.Controls.FlatButton btnDurationMedium;
private TweetDuck.Controls.FlatButton btnDurationLong; private TweetDuck.Core.Controls.FlatButton btnDurationLong;
private TweetDuck.Controls.FlatButton btnDurationShort; private TweetDuck.Core.Controls.FlatButton btnDurationShort;
private System.Windows.Forms.CheckBox checkNonIntrusive; private System.Windows.Forms.CheckBox checkNonIntrusive;
private System.Windows.Forms.Label labelIdlePause; private System.Windows.Forms.Label labelIdlePause;
private System.Windows.Forms.ComboBox comboBoxIdlePause; private System.Windows.Forms.ComboBox comboBoxIdlePause;
@@ -738,9 +682,5 @@
private System.Windows.Forms.Panel panelScrollSpeed; private System.Windows.Forms.Panel panelScrollSpeed;
private System.Windows.Forms.FlowLayoutPanel flowPanelRight; private System.Windows.Forms.FlowLayoutPanel flowPanelRight;
private System.Windows.Forms.Panel panelSeparator; 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;
using System.Windows.Forms; using System.Windows.Forms;
using TweetDuck.Browser.Notification.Example; using TweetDuck.Core.Controls;
using TweetDuck.Controls; using TweetDuck.Core.Notification;
using TweetLib.Core.Features.Notifications; using TweetDuck.Core.Notification.Example;
namespace TweetDuck.Dialogs.Settings{ namespace TweetDuck.Core.Other.Settings{
sealed partial class TabSettingsNotifications : FormSettings.BaseTab{ sealed partial class TabSettingsNotifications : BaseTabSettings{
private static readonly int[] IdlePauseSeconds = { 0, 30, 60, 120, 300 }; private static readonly int[] IdlePauseSeconds = { 0, 30, 60, 120, 300 };
private readonly FormNotificationExample notification; private readonly FormNotificationExample notification;
@@ -48,9 +48,6 @@ namespace TweetDuck.Dialogs.Settings{
comboBoxIdlePause.Items.Add("5 minutes"); comboBoxIdlePause.Items.Add("5 minutes");
comboBoxIdlePause.SelectedIndex = Math.Max(0, Array.FindIndex(IdlePauseSeconds, val => val == Config.NotificationIdlePauseSeconds)); comboBoxIdlePause.SelectedIndex = Math.Max(0, Array.FindIndex(IdlePauseSeconds, val => val == Config.NotificationIdlePauseSeconds));
trackBarOpacity.SetValueSafe(Config.NotificationWindowOpacity);
labelOpacityValue.Text = Config.NotificationWindowOpacity + "%";
// timer // timer
toolTip.SetToolTip(checkTimerCountDown, "The notification timer counts down instead of up."); toolTip.SetToolTip(checkTimerCountDown, "The notification timer counts down instead of up.");
@@ -69,18 +66,18 @@ namespace TweetDuck.Dialogs.Settings{
toolTip.SetToolTip(radioLocCustom, "Drag the example notification window to the desired location."); toolTip.SetToolTip(radioLocCustom, "Drag the example notification window to the desired location.");
switch(Config.NotificationPosition){ switch(Config.NotificationPosition){
case DesktopNotification.Position.TopLeft: radioLocTL.Checked = true; break; case TweetNotification.Position.TopLeft: radioLocTL.Checked = true; break;
case DesktopNotification.Position.TopRight: radioLocTR.Checked = true; break; case TweetNotification.Position.TopRight: radioLocTR.Checked = true; break;
case DesktopNotification.Position.BottomLeft: radioLocBL.Checked = true; break; case TweetNotification.Position.BottomLeft: radioLocBL.Checked = true; break;
case DesktopNotification.Position.BottomRight: radioLocBR.Checked = true; break; case TweetNotification.Position.BottomRight: radioLocBR.Checked = true; break;
case DesktopNotification.Position.Custom: radioLocCustom.Checked = true; break; case TweetNotification.Position.Custom: radioLocCustom.Checked = true; break;
} }
comboBoxDisplay.Enabled = trackBarEdgeDistance.Enabled = !radioLocCustom.Checked; comboBoxDisplay.Enabled = trackBarEdgeDistance.Enabled = !radioLocCustom.Checked;
comboBoxDisplay.Items.Add("(Same as TweetDuck)"); comboBoxDisplay.Items.Add("(Same as TweetDuck)");
foreach(Screen screen in Screen.AllScreens){ foreach(Screen screen in Screen.AllScreens){
comboBoxDisplay.Items.Add($"{screen.DeviceName.TrimStart('\\', '.')} ({screen.Bounds.Width}x{screen.Bounds.Height})"); comboBoxDisplay.Items.Add(screen.DeviceName.TrimStart('\\', '.')+" ("+screen.Bounds.Width+"x"+screen.Bounds.Height+")");
} }
comboBoxDisplay.SelectedIndex = Math.Min(comboBoxDisplay.Items.Count-1, Config.NotificationDisplay); comboBoxDisplay.SelectedIndex = Math.Min(comboBoxDisplay.Items.Count-1, Config.NotificationDisplay);
@@ -94,8 +91,8 @@ namespace TweetDuck.Dialogs.Settings{
toolTip.SetToolTip(radioSizeCustom, "Resize the example notification window to the desired size."); toolTip.SetToolTip(radioSizeCustom, "Resize the example notification window to the desired size.");
switch(Config.NotificationSize){ switch(Config.NotificationSize){
case DesktopNotification.Size.Auto: radioSizeAuto.Checked = true; break; case TweetNotification.Size.Auto: radioSizeAuto.Checked = true; break;
case DesktopNotification.Size.Custom: radioSizeCustom.Checked = true; break; case TweetNotification.Size.Custom: radioSizeCustom.Checked = true; break;
} }
trackBarScrollSpeed.SetValueSafe(Config.NotificationScrollSpeed); trackBarScrollSpeed.SetValueSafe(Config.NotificationScrollSpeed);
@@ -108,7 +105,6 @@ namespace TweetDuck.Dialogs.Settings{
checkSkipOnLinkClick.CheckedChanged += checkSkipOnLinkClick_CheckedChanged; checkSkipOnLinkClick.CheckedChanged += checkSkipOnLinkClick_CheckedChanged;
checkNonIntrusive.CheckedChanged += checkNonIntrusive_CheckedChanged; checkNonIntrusive.CheckedChanged += checkNonIntrusive_CheckedChanged;
comboBoxIdlePause.SelectedValueChanged += comboBoxIdlePause_SelectedValueChanged; comboBoxIdlePause.SelectedValueChanged += comboBoxIdlePause_SelectedValueChanged;
trackBarOpacity.ValueChanged += trackBarOpacity_ValueChanged;
checkNotificationTimer.CheckedChanged += checkNotificationTimer_CheckedChanged; checkNotificationTimer.CheckedChanged += checkNotificationTimer_CheckedChanged;
checkTimerCountDown.CheckedChanged += checkTimerCountDown_CheckedChanged; checkTimerCountDown.CheckedChanged += checkTimerCountDown_CheckedChanged;
@@ -180,13 +176,6 @@ namespace TweetDuck.Dialogs.Settings{
Config.NotificationIdlePauseSeconds = IdlePauseSeconds[comboBoxIdlePause.SelectedIndex]; 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 #endregion
#region Timer #region Timer
@@ -230,18 +219,10 @@ namespace TweetDuck.Dialogs.Settings{
#region Location #region Location
private void radioLoc_CheckedChanged(object sender, EventArgs e){ private void radioLoc_CheckedChanged(object sender, EventArgs e){
if (radioLocTL.Checked){ if (radioLocTL.Checked)Config.NotificationPosition = TweetNotification.Position.TopLeft;
Config.NotificationPosition = DesktopNotification.Position.TopLeft; else if (radioLocTR.Checked)Config.NotificationPosition = TweetNotification.Position.TopRight;
} else if (radioLocBL.Checked)Config.NotificationPosition = TweetNotification.Position.BottomLeft;
else if (radioLocTR.Checked){ else if (radioLocBR.Checked)Config.NotificationPosition = TweetNotification.Position.BottomRight;
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; comboBoxDisplay.Enabled = trackBarEdgeDistance.Enabled = true;
notification.ShowExampleNotification(false); notification.ShowExampleNotification(false);
@@ -252,18 +233,18 @@ namespace TweetDuck.Dialogs.Settings{
Config.CustomNotificationPosition = notification.Location; Config.CustomNotificationPosition = notification.Location;
} }
Config.NotificationPosition = DesktopNotification.Position.Custom; Config.NotificationPosition = TweetNotification.Position.Custom;
comboBoxDisplay.Enabled = trackBarEdgeDistance.Enabled = false; comboBoxDisplay.Enabled = trackBarEdgeDistance.Enabled = false;
notification.ShowExampleNotification(false); notification.ShowExampleNotification(false);
if (notification.IsFullyOutsideView() && FormMessage.Question("Notification is Outside View", "The notification seems to be outside of view, would you like to reset its position?", FormMessage.Yes, FormMessage.No)){ if (notification.IsFullyOutsideView() && FormMessage.Question("Notification is Outside View", "The notification seems to be outside of view, would you like to reset its position?", FormMessage.Yes, FormMessage.No)){
Config.NotificationPosition = DesktopNotification.Position.TopRight; Config.NotificationPosition = TweetNotification.Position.TopRight;
notification.MoveToVisibleLocation(); notification.MoveToVisibleLocation();
Config.CustomNotificationPosition = notification.Location; Config.CustomNotificationPosition = notification.Location;
Config.NotificationPosition = DesktopNotification.Position.Custom; Config.NotificationPosition = TweetNotification.Position.Custom;
notification.MoveToVisibleLocation(); notification.MoveToVisibleLocation();
} }
} }
@@ -284,7 +265,7 @@ namespace TweetDuck.Dialogs.Settings{
private void radioSize_CheckedChanged(object sender, EventArgs e){ private void radioSize_CheckedChanged(object sender, EventArgs e){
if (radioSizeAuto.Checked){ if (radioSizeAuto.Checked){
Config.NotificationSize = DesktopNotification.Size.Auto; Config.NotificationSize = TweetNotification.Size.Auto;
} }
notification.ShowExampleNotification(false); notification.ShowExampleNotification(false);
@@ -295,7 +276,7 @@ namespace TweetDuck.Dialogs.Settings{
Config.CustomNotificationSize = notification.BrowserSize; Config.CustomNotificationSize = notification.BrowserSize;
} }
Config.NotificationSize = DesktopNotification.Size.Custom; Config.NotificationSize = TweetNotification.Size.Custom;
notification.ShowExampleNotification(false); notification.ShowExampleNotification(false);
} }

View File

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

View File

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

49
Core/Other/TaskbarIcon.cs Normal file
View File

@@ -0,0 +1,49 @@
using System;
using Microsoft.WindowsAPICodePack.Taskbar;
using TweetDuck.Configuration;
using Res = TweetDuck.Properties.Resources;
namespace TweetDuck.Core.Other{
sealed class TaskbarIcon : IDisposable{
private static UserConfig Config => Program.Config.User;
public bool HasNotifications{
get{
return hasNotifications;
}
set{
if (hasNotifications != value){
hasNotifications = value;
UpdateIcon();
}
}
}
private bool hasNotifications;
public TaskbarIcon(){
Config.MuteToggled += Config_MuteToggled;
}
public void Dispose(){
Config.MuteToggled -= Config_MuteToggled;
}
private void Config_MuteToggled(object sender, EventArgs e){
UpdateIcon();
}
public void UpdateIcon(){
if (hasNotifications){
TaskbarManager.Instance.SetOverlayIcon(Res.overlay_notification, "Unread Notifications");
}
else if (Config.MuteNotifications){
TaskbarManager.Instance.SetOverlayIcon(Res.overlay_muted, "Notifications Muted");
}
else{
TaskbarManager.Instance.SetOverlayIcon(null, string.Empty);
}
}
}
}

View File

@@ -1,10 +1,21 @@
namespace TweetDuck.Browser { namespace TweetDuck.Core.Other {
partial class TrayIcon { partial class TrayIcon {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
/// </summary> /// </summary>
private System.ComponentModel.IContainer components = null; 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 #region Component Designer generated code
/// <summary> /// <summary>

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