mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-09-14 19:32:10 +02:00
Compare commits
253 Commits
Author | SHA1 | Date | |
---|---|---|---|
4afac91bce | |||
6e6312f6d7 | |||
df4c4e443d | |||
ff40474f92 | |||
aca06ee805 | |||
ba8e29a9f8 | |||
583da2bd9f | |||
0ea07016b4 | |||
616421db9a | |||
293ddacd19 | |||
13945ec937 | |||
4ea6f336f8 | |||
58296aa266 | |||
742df9dff3 | |||
011e1f5922 | |||
8f67d69325 | |||
9ac133b605 | |||
538b2d26cd | |||
cc3895c423 | |||
79454bfc3b | |||
734c7572bb | |||
9f93fbb161 | |||
c78c63285e | |||
c8cbf70a28 | |||
2b116d6756 | |||
da611153cf | |||
fd9bf4468a | |||
fa234eb9d6 | |||
dbfebf6a32 | |||
7b91e31485 | |||
e882fc8b5e | |||
5a54195cac | |||
a442adf8d5 | |||
38466878db | |||
7c86e4e743 | |||
41cbfb8d39 | |||
7c394f4b20 | |||
c1a35e1053 | |||
cddce8596f | |||
c75058b1da | |||
1a73fcdb39 | |||
8e0c4f5308 | |||
51e2791cc7 | |||
130159f06c | |||
42d1140b55 | |||
dfd987041a | |||
790d1787fd | |||
2a6a607c7b | |||
b3521d2a18 | |||
dee99caa7d | |||
cf525a3929 | |||
18d658f7e1 | |||
1c42ab77d8 | |||
33d5638bb0 | |||
8ce92df87a | |||
80654449af | |||
eee1622801 | |||
4c54876ecf | |||
1cbcd5c2da | |||
55253e284e | |||
e9795cd697 | |||
be76d9a6dc | |||
d7cdaf2870 | |||
48ed0e01d1 | |||
dca31dedde | |||
ab7356b991 | |||
a46a673cf8 | |||
c8d52539ca | |||
ed9267b6ba | |||
b7c02d1cf8 | |||
fb66beb29f | |||
8c3bf6bbc3 | |||
b943078132 | |||
e727617bf1 | |||
ffaea6dcbe | |||
bf1f72a2a4 | |||
be0df7c5b0 | |||
5ab769e74d | |||
d22ddb1731 | |||
9fed8c022b | |||
a315ed90af | |||
1ebf3c9af2 | |||
0e4c923c23 | |||
63835b9f99 | |||
ff17f7c132 | |||
f4631c9b38 | |||
35931023ae | |||
6d93381760 | |||
f1bdd5f1b2 | |||
1c3e2fbad7 | |||
29a02db07d | |||
f1db1ba708 | |||
c1420bac88 | |||
8e527fbbdf | |||
5ec1bcfe3f | |||
7226461cd0 | |||
6d6f383c92 | |||
e1a6328d09 | |||
6e4153911a | |||
342f74646e | |||
fe5191d3b5 | |||
504cf97c6c | |||
f8c494c9c1 | |||
b90d7f721a | |||
7936af6c9a | |||
52d01e3dd7 | |||
d30d70395a | |||
491a3ae525 | |||
1eae380b08 | |||
f091b2526e | |||
7548e2e202 | |||
d9b9afbf2d | |||
8036659003 | |||
f9fb4668c2 | |||
7047924947 | |||
8f6be3911a | |||
0d95b8eb44 | |||
61d2d124ff | |||
7b218b2544 | |||
87ac7daf76 | |||
6b4817df36 | |||
22d99da2e1 | |||
47b6cf7068 | |||
606c9512f8 | |||
aef9c591e9 | |||
71f67e9191 | |||
636f2b3017 | |||
2de5b5c6e4 | |||
0cbcc8c9f3 | |||
96146e3dc8 | |||
5aaae51be1 | |||
b98625fdbc | |||
09a748e9dc | |||
87b07c6d5b | |||
f39e668f8d | |||
6ea95342a0 | |||
c594bf5757 | |||
cd3b198c6f | |||
b249b5f46e | |||
bbe3b48bcc | |||
3bcd056197 | |||
6387ab41b3 | |||
4df16b7f15 | |||
ed387a2873 | |||
9e225530a6 | |||
7b23686dc6 | |||
4de31453fd | |||
4c59526e39 | |||
9ec1764194 | |||
47afa32902 | |||
2a09487b55 | |||
563c856dd3 | |||
69ea242408 | |||
d6e0e0726f | |||
73d460d40a | |||
1f27d96ac9 | |||
93e9f28d69 | |||
ec2e26752a | |||
fadd95f3e6 | |||
00acc677e6 | |||
1a799881e8 | |||
f75677593a | |||
19e3bd19f0 | |||
85701b0a3c | |||
014cb18dcb | |||
e71e1c853f | |||
ee9d9196f5 | |||
53c8272e01 | |||
7f7b6b1e2a | |||
405777e0f5 | |||
df2b624cb5 | |||
8a48d5c2f9 | |||
c55ee71442 | |||
3f82745f5b | |||
404187a1ae | |||
2b7b3f586b | |||
04959a3493 | |||
97cf4932ae | |||
b0d88a0a37 | |||
67a2e40622 | |||
3a28556c7f | |||
9ecc92b9a5 | |||
ca023be98a | |||
11a1423f76 | |||
79f6df121b | |||
71eade7e86 | |||
5f81d29036 | |||
ec1cb5dc5f | |||
fd969e2d55 | |||
37e33b77ff | |||
f7ed7703b4 | |||
4bb35295ca | |||
1e4f673f9e | |||
7cadb1c403 | |||
37148f5093 | |||
f6bc26789f | |||
b3f5a88525 | |||
1e538d2b28 | |||
7d7bfb7b01 | |||
41d86ba440 | |||
3df474a8a5 | |||
a50d6e8f47 | |||
6081e5b9c1 | |||
66ccea920c | |||
470d63093f | |||
eae0507831 | |||
92af85d3bb | |||
7635af5730 | |||
a838e89695 | |||
b22289a8b9 | |||
45b3ff52c6 | |||
4464991f4c | |||
b0d2f77583 | |||
b211a4405d | |||
8823016d2c | |||
859fdc7ec1 | |||
028d5ed01f | |||
5fd5a2a436 | |||
79a7e7470c | |||
9ecef78aed | |||
65a837a6e1 | |||
6e4db4acea | |||
26fb977d05 | |||
b42cd1c048 | |||
467f7cd12f | |||
66699ce9df | |||
cf7d903932 | |||
a7ab67925c | |||
a474ba4260 | |||
09e5636e86 | |||
2295a875be | |||
82a2455afc | |||
268de676ee | |||
8fe26c07f1 | |||
da3921b1ca | |||
4dd2e787d1 | |||
ce005ae6c2 | |||
1513f46a11 | |||
7543eeb0f4 | |||
873242120c | |||
98f8095a65 | |||
785571a550 | |||
0c4bd4044e | |||
0319543dce | |||
82d70b2d7f | |||
62d18e010a | |||
fc77b85083 | |||
50a8893f4f | |||
9252b3040e | |||
d5141ed020 | |||
7ff9e23283 | |||
89854d527c | |||
6ff0cad2a8 |
108
.gitignore
vendored
108
.gitignore
vendored
@@ -1,6 +1,12 @@
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
||||
# TweetDuck installer builds
|
||||
bld/*
|
||||
!bld/*.iss
|
||||
!bld/*.bat
|
||||
!bld/Resources
|
||||
|
||||
# User-specific files
|
||||
*.suo
|
||||
*.user
|
||||
@@ -19,16 +25,9 @@ x64/
|
||||
x86/
|
||||
[Bb]in/
|
||||
[Oo]bj/
|
||||
bld/*
|
||||
!bld/gen_full.iss
|
||||
!bld/gen_port.iss
|
||||
!bld/gen_upd.iss
|
||||
!bld/Resources
|
||||
|
||||
# Visual Studio 2015 cache/options directory
|
||||
.vs/
|
||||
# Uncomment if you have tasks that create the project's static files in wwwroot
|
||||
#wwwroot/
|
||||
|
||||
# MSTest test Results
|
||||
[Tt]est[Rr]esult*/
|
||||
@@ -38,11 +37,6 @@ bld/*
|
||||
*.VisualState.xml
|
||||
TestResult.xml
|
||||
|
||||
# Build Results of an ATL Project
|
||||
[Dd]ebugPS/
|
||||
[Rr]eleasePS/
|
||||
dlldata.c
|
||||
|
||||
# DNX
|
||||
project.lock.json
|
||||
artifacts/
|
||||
@@ -71,27 +65,12 @@ artifacts/
|
||||
*.svclog
|
||||
*.scc
|
||||
|
||||
# Chutzpah Test files
|
||||
_Chutzpah*
|
||||
|
||||
# Visual C++ cache files
|
||||
ipch/
|
||||
*.aps
|
||||
*.ncb
|
||||
*.opendb
|
||||
*.opensdf
|
||||
*.sdf
|
||||
*.cachefile
|
||||
|
||||
# Visual Studio profiler
|
||||
*.psess
|
||||
*.vsp
|
||||
*.vspx
|
||||
*.sap
|
||||
|
||||
# TFS 2012 Local Workspace
|
||||
$tf/
|
||||
|
||||
# Guidance Automation Toolkit
|
||||
*.gpState
|
||||
|
||||
@@ -118,33 +97,9 @@ nCrunchTemp_*
|
||||
*.mm.*
|
||||
AutoTest.Net/
|
||||
|
||||
# Web workbench (sass)
|
||||
.sass-cache/
|
||||
|
||||
# Installshield output folder
|
||||
[Ee]xpress/
|
||||
|
||||
# DocProject is a documentation generator add-in
|
||||
DocProject/buildhelp/
|
||||
DocProject/Help/*.HxT
|
||||
DocProject/Help/*.HxC
|
||||
DocProject/Help/*.hhc
|
||||
DocProject/Help/*.hhk
|
||||
DocProject/Help/*.hhp
|
||||
DocProject/Help/Html2
|
||||
DocProject/Help/html
|
||||
|
||||
# Click-Once directory
|
||||
publish/
|
||||
|
||||
# Publish Web Output
|
||||
*.[Pp]ublish.xml
|
||||
*.azurePubxml
|
||||
# TODO: Comment the next line if you want to checkin your web deploy settings
|
||||
# but database connection strings (with potential passwords) will be unencrypted
|
||||
*.pubxml
|
||||
*.publishproj
|
||||
|
||||
# NuGet Packages
|
||||
*.nupkg
|
||||
# The packages folder can be ignored because of Package Restore
|
||||
@@ -157,17 +112,6 @@ publish/
|
||||
*.nuget.props
|
||||
*.nuget.targets
|
||||
|
||||
# Microsoft Azure Build Output
|
||||
csx/
|
||||
*.build.csdef
|
||||
|
||||
# Microsoft Azure Emulator
|
||||
ecf/
|
||||
rcf/
|
||||
|
||||
# Microsoft Azure ApplicationInsights config file
|
||||
ApplicationInsights.config
|
||||
|
||||
# Windows Store app package directory
|
||||
AppPackages/
|
||||
BundleArtifacts/
|
||||
@@ -189,9 +133,6 @@ ClientBin/
|
||||
node_modules/
|
||||
orleans.codegen.cs
|
||||
|
||||
# RIA/Silverlight projects
|
||||
Generated_Code/
|
||||
|
||||
# Backup & report files from converting an old project file
|
||||
# to a newer Visual Studio version. Backup files are not needed,
|
||||
# because we have git ;-)
|
||||
@@ -200,40 +141,3 @@ Backup*/
|
||||
UpgradeLog*.XML
|
||||
UpgradeLog*.htm
|
||||
|
||||
# SQL Server files
|
||||
*.mdf
|
||||
*.ldf
|
||||
|
||||
# Business Intelligence projects
|
||||
*.rdl.data
|
||||
*.bim.layout
|
||||
*.bim_*.settings
|
||||
|
||||
# Microsoft Fakes
|
||||
FakesAssemblies/
|
||||
|
||||
# GhostDoc plugin setting file
|
||||
*.GhostDoc.xml
|
||||
|
||||
# Node.js Tools for Visual Studio
|
||||
.ntvs_analysis.dat
|
||||
|
||||
# Visual Studio 6 build log
|
||||
*.plg
|
||||
|
||||
# Visual Studio 6 workspace options file
|
||||
*.opt
|
||||
|
||||
# Visual Studio LightSwitch build output
|
||||
**/*.HTMLClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/GeneratedArtifacts
|
||||
**/*.DesktopClient/ModelManifest.xml
|
||||
**/*.Server/GeneratedArtifacts
|
||||
**/*.Server/ModelManifest.xml
|
||||
_Pvt_Extensions
|
||||
|
||||
# Paket dependency manager
|
||||
.paket/paket.exe
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
34
Configuration/Arguments.cs
Normal file
34
Configuration/Arguments.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using TweetDck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Configuration{
|
||||
static class Arguments{
|
||||
// public args
|
||||
public const string ArgDataFolder = "-datafolder";
|
||||
public const string ArgLocale = "-locale";
|
||||
public const string ArgLogging = "-log";
|
||||
public const string ArgDebugUpdates = "-debugupdates";
|
||||
|
||||
// internal args
|
||||
public const string ArgRestart = "-restart";
|
||||
public const string ArgImportCookies = "-importcookies";
|
||||
|
||||
// class data and methods
|
||||
private static readonly CommandLineArgs Current = CommandLineArgs.FromStringArray('-', Environment.GetCommandLineArgs());
|
||||
|
||||
public static bool HasFlag(string flag){
|
||||
return Current.HasFlag(flag);
|
||||
}
|
||||
|
||||
public static string GetValue(string key, string defaultValue){
|
||||
return Current.GetValue(key, defaultValue);
|
||||
}
|
||||
|
||||
public static CommandLineArgs GetCurrentClean(){
|
||||
CommandLineArgs args = Current.Clone();
|
||||
args.RemoveFlag(ArgRestart);
|
||||
args.RemoveFlag(ArgImportCookies);
|
||||
return args;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,8 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using TweetDck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Configuration{
|
||||
sealed class LockManager{
|
||||
@@ -114,25 +115,45 @@ namespace TweetDck.Configuration{
|
||||
return result;
|
||||
}
|
||||
|
||||
public bool CloseLockingProcess(int timeout){
|
||||
public bool CloseLockingProcess(int closeTimeout, int killTimeout){
|
||||
if (LockingProcess != null){
|
||||
LockingProcess.CloseMainWindow();
|
||||
try{
|
||||
if (LockingProcess.CloseMainWindow()){
|
||||
WindowsUtils.TrySleepUntil(CheckLockingProcessExited, closeTimeout, 250);
|
||||
}
|
||||
|
||||
for(int waited = 0; waited < timeout && !LockingProcess.HasExited; waited += 250){
|
||||
LockingProcess.Refresh();
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
if (!LockingProcess.HasExited){
|
||||
LockingProcess.Kill();
|
||||
WindowsUtils.TrySleepUntil(CheckLockingProcessExited, killTimeout, 250);
|
||||
}
|
||||
|
||||
if (LockingProcess.HasExited){
|
||||
LockingProcess.Dispose();
|
||||
LockingProcess = null;
|
||||
return true;
|
||||
if (LockingProcess.HasExited){
|
||||
LockingProcess.Dispose();
|
||||
LockingProcess = null;
|
||||
return true;
|
||||
}
|
||||
}catch(Exception ex){
|
||||
if (ex is InvalidOperationException || ex is Win32Exception){
|
||||
if (LockingProcess != null){
|
||||
LockingProcess.Refresh();
|
||||
|
||||
bool hasExited = LockingProcess.HasExited;
|
||||
LockingProcess.Dispose();
|
||||
return hasExited;
|
||||
}
|
||||
}
|
||||
else throw;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool CheckLockingProcessExited(){
|
||||
LockingProcess.Refresh();
|
||||
return LockingProcess.HasExited;
|
||||
}
|
||||
|
||||
// Utility functions
|
||||
|
||||
private static void WriteIntToStream(Stream stream, int value){
|
||||
|
@@ -14,21 +14,22 @@ namespace TweetDck.Configuration{
|
||||
sealed class UserConfig{
|
||||
private static readonly IFormatter Formatter = new BinaryFormatter();
|
||||
|
||||
private const int CurrentFileVersion = 5;
|
||||
private const int CurrentFileVersion = 7;
|
||||
|
||||
// START OF CONFIGURATION
|
||||
|
||||
public WindowState BrowserWindow { get; set; }
|
||||
public bool DisplayNotificationColumn { get; set; }
|
||||
public bool DisplayNotificationTimer { get; set; }
|
||||
public bool NotificationTimerCountDown { get; set; }
|
||||
public bool NotificationNonIntrusiveMode { get; set; }
|
||||
|
||||
public TweetNotification.Duration NotificationDuration { get; set; }
|
||||
public TweetNotification.Position NotificationPosition { get; set; }
|
||||
public Point CustomNotificationPosition { get; set; }
|
||||
public int NotificationEdgeDistance { get; set; }
|
||||
public int NotificationDisplay { get; set; }
|
||||
public int NotificationIdlePauseSeconds { get; set; }
|
||||
public int NotificationDurationValue { get; set; }
|
||||
public bool NotificationLegacyLoad { get; set; }
|
||||
|
||||
public bool EnableSpellCheck { get; set; }
|
||||
public bool ExpandLinksOnHover { get; set; }
|
||||
@@ -68,7 +69,7 @@ namespace TweetDck.Configuration{
|
||||
|
||||
public string NotificationSoundPath{
|
||||
get{
|
||||
return !string.IsNullOrEmpty(notificationSoundPath) && File.Exists(notificationSoundPath) ? notificationSoundPath : string.Empty;
|
||||
return string.IsNullOrEmpty(notificationSoundPath) ? string.Empty : notificationSoundPath;
|
||||
}
|
||||
|
||||
set{
|
||||
@@ -113,7 +114,7 @@ namespace TweetDck.Configuration{
|
||||
|
||||
BrowserWindow = new WindowState();
|
||||
DisplayNotificationTimer = true;
|
||||
NotificationDuration = TweetNotification.Duration.Medium;
|
||||
NotificationNonIntrusiveMode = true;
|
||||
NotificationPosition = TweetNotification.Position.TopRight;
|
||||
CustomNotificationPosition = ControlExtensions.InvisibleLocation;
|
||||
NotificationEdgeDistance = 8;
|
||||
@@ -154,14 +155,7 @@ namespace TweetDck.Configuration{
|
||||
|
||||
if (fileVersion == 3){
|
||||
EnableTrayHighlight = true;
|
||||
|
||||
switch(NotificationDuration){
|
||||
case TweetNotification.Duration.Short: NotificationDurationValue = 15; break;
|
||||
case TweetNotification.Duration.Medium: NotificationDurationValue = 25; break;
|
||||
case TweetNotification.Duration.Long: NotificationDurationValue = 35; break;
|
||||
case TweetNotification.Duration.VeryLong: NotificationDurationValue = 45; break;
|
||||
}
|
||||
|
||||
NotificationDurationValue = 25;
|
||||
++fileVersion;
|
||||
}
|
||||
|
||||
@@ -171,6 +165,15 @@ namespace TweetDck.Configuration{
|
||||
++fileVersion;
|
||||
}
|
||||
|
||||
if (fileVersion == 5){
|
||||
++fileVersion;
|
||||
}
|
||||
|
||||
if (fileVersion == 6){
|
||||
NotificationNonIntrusiveMode = true;
|
||||
++fileVersion;
|
||||
}
|
||||
|
||||
// update the version
|
||||
fileVersion = CurrentFileVersion;
|
||||
Save();
|
||||
|
@@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2"/></startup></configuration>
|
@@ -1,8 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
|
||||
<package id="cef.redist.x64" version="3.2785.1486" targetFramework="net452" />
|
||||
<package id="cef.redist.x86" version="3.2785.1486" targetFramework="net452" />
|
||||
<package id="CefSharp.Common" version="53.0.1" targetFramework="net452" />
|
||||
<package id="CefSharp.WinForms" version="53.0.1" targetFramework="net452" />
|
||||
<package id="Microsoft.VC120.CRT.JetBrains" version="12.0.21005.2" targetFramework="net452" />
|
||||
</packages>
|
34
Core/Bridge/PropertyBridge.cs
Normal file
34
Core/Bridge/PropertyBridge.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
|
||||
namespace TweetDck.Core.Bridge{
|
||||
static class PropertyBridge{
|
||||
[Flags]
|
||||
public enum Properties{
|
||||
ExpandLinksOnHover = 1,
|
||||
MuteNotifications = 2,
|
||||
HasCustomNotificationSound = 4,
|
||||
All = ExpandLinksOnHover | MuteNotifications | HasCustomNotificationSound
|
||||
}
|
||||
|
||||
public static string GenerateScript(Properties properties = Properties.All){
|
||||
StringBuilder build = new StringBuilder();
|
||||
build.Append("(function(c){");
|
||||
|
||||
if (properties.HasFlag(Properties.ExpandLinksOnHover)){
|
||||
build.Append("c.expandLinksOnHover=").Append(Program.UserConfig.ExpandLinksOnHover ? "true;" : "false;");
|
||||
}
|
||||
|
||||
if (properties.HasFlag(Properties.MuteNotifications)){
|
||||
build.Append("c.muteNotifications=").Append(Program.UserConfig.MuteNotifications ? "true;" : "false;");
|
||||
}
|
||||
|
||||
if (properties.HasFlag(Properties.HasCustomNotificationSound)){
|
||||
build.Append("c.hasCustomNotificationSound=").Append(Program.UserConfig.NotificationSoundPath.Length > 0 ? "true;" : "false;");
|
||||
}
|
||||
|
||||
build.Append("})(window.$TDX=window.$TDX||{})");
|
||||
return build.ToString();
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,121 +19,69 @@ namespace TweetDck.Core.Bridge{
|
||||
}
|
||||
|
||||
private readonly FormBrowser form;
|
||||
private readonly FormNotification notification;
|
||||
private readonly FormNotificationMain notification;
|
||||
|
||||
public string BrandName{
|
||||
get{
|
||||
return Program.BrandName;
|
||||
}
|
||||
}
|
||||
|
||||
public string VersionTag{
|
||||
get{
|
||||
return Program.VersionTag;
|
||||
}
|
||||
}
|
||||
|
||||
public bool MuteNotifications{
|
||||
get{
|
||||
return Program.UserConfig.MuteNotifications;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasCustomNotificationSound{
|
||||
get{
|
||||
return !string.IsNullOrEmpty(Program.UserConfig.NotificationSoundPath);
|
||||
}
|
||||
}
|
||||
|
||||
public bool ExpandLinksOnHover{
|
||||
get{
|
||||
return Program.UserConfig.ExpandLinksOnHover;
|
||||
}
|
||||
}
|
||||
|
||||
public bool HasCustomBrowserCSS{
|
||||
get{
|
||||
return !string.IsNullOrEmpty(Program.UserConfig.CustomBrowserCSS);
|
||||
}
|
||||
}
|
||||
|
||||
public string CustomBrowserCSS{
|
||||
get{
|
||||
return Program.UserConfig.CustomBrowserCSS;
|
||||
}
|
||||
}
|
||||
|
||||
public TweetDeckBridge(FormBrowser form, FormNotification notification){
|
||||
public TweetDeckBridge(FormBrowser form, FormNotificationMain notification){
|
||||
this.form = form;
|
||||
this.notification = notification;
|
||||
}
|
||||
|
||||
public void LoadFontSizeClass(string fsClass){
|
||||
form.InvokeSafe(() => {
|
||||
form.InvokeAsyncSafe(() => {
|
||||
TweetNotification.SetFontSizeClass(fsClass);
|
||||
});
|
||||
}
|
||||
|
||||
public void LoadNotificationHeadContents(string headContents){
|
||||
form.InvokeSafe(() => {
|
||||
form.InvokeAsyncSafe(() => {
|
||||
TweetNotification.SetHeadTag(headContents);
|
||||
});
|
||||
}
|
||||
|
||||
public void SetLastRightClickedLink(string link){
|
||||
form.InvokeSafe(() => LastRightClickedLink = link);
|
||||
form.InvokeAsyncSafe(() => LastRightClickedLink = link);
|
||||
}
|
||||
|
||||
public void SetLastHighlightedTweet(string link, string quotedLink){
|
||||
form.InvokeSafe(() => {
|
||||
form.InvokeAsyncSafe(() => {
|
||||
LastHighlightedTweet = link;
|
||||
LastHighlightedQuotedTweet = quotedLink;
|
||||
});
|
||||
}
|
||||
|
||||
public void SetNotificationQuotedTweet(string link){
|
||||
notification.InvokeSafe(() => notification.CurrentQuotedTweetUrl = link);
|
||||
notification.InvokeAsyncSafe(() => notification.CurrentQuotedTweetUrl = link);
|
||||
}
|
||||
|
||||
public void OpenSettingsMenu(){
|
||||
form.InvokeSafe(form.OpenSettings);
|
||||
public void OpenContextMenu(){
|
||||
form.InvokeAsyncSafe(form.OpenContextMenu);
|
||||
}
|
||||
|
||||
public void OpenPluginsMenu(){
|
||||
form.InvokeSafe(form.OpenPlugins);
|
||||
}
|
||||
|
||||
public void OnTweetPopup(string tweetHtml, string tweetUrl, int tweetCharacters){
|
||||
notification.InvokeSafe(() => {
|
||||
public void OnTweetPopup(string columnName, string tweetHtml, string tweetUrl, int tweetCharacters){
|
||||
notification.InvokeAsyncSafe(() => {
|
||||
form.OnTweetNotification();
|
||||
notification.ShowNotification(new TweetNotification(tweetHtml, tweetUrl, tweetCharacters));
|
||||
notification.ShowNotification(new TweetNotification(columnName, tweetHtml, tweetUrl, tweetCharacters));
|
||||
});
|
||||
}
|
||||
|
||||
public void OnTweetSound(){
|
||||
form.InvokeSafe(() => {
|
||||
form.InvokeAsyncSafe(() => {
|
||||
form.OnTweetNotification();
|
||||
form.PlayNotificationSound();
|
||||
});
|
||||
}
|
||||
|
||||
public void OnNotificationReady(){
|
||||
if (!Program.UserConfig.NotificationLegacyLoad){
|
||||
notification.InvokeSafe(notification.OnNotificationReady);
|
||||
}
|
||||
}
|
||||
|
||||
public void DisplayTooltip(string text, bool showInNotification){
|
||||
if (showInNotification){
|
||||
notification.InvokeSafe(() => notification.DisplayTooltip(text));
|
||||
notification.InvokeAsyncSafe(() => notification.DisplayTooltip(text));
|
||||
}
|
||||
else{
|
||||
form.InvokeSafe(() => form.DisplayTooltip(text));
|
||||
form.InvokeAsyncSafe(() => form.DisplayTooltip(text));
|
||||
}
|
||||
}
|
||||
|
||||
public void LoadNextNotification(){
|
||||
notification.InvokeSafe(notification.FinishCurrentTweet);
|
||||
notification.InvokeAsyncSafe(notification.FinishCurrentNotification);
|
||||
}
|
||||
|
||||
public void TryPasteImage(){
|
||||
@@ -157,19 +105,15 @@ namespace TweetDck.Core.Bridge{
|
||||
}
|
||||
|
||||
public void ClickUploadImage(int offsetX, int offsetY){
|
||||
form.InvokeSafe(() => {
|
||||
Point prevPos = Cursor.Position;
|
||||
|
||||
Cursor.Position = form.PointToScreen(new Point(offsetX, offsetY));
|
||||
NativeMethods.SimulateMouseClick(NativeMethods.MouseButton.Left);
|
||||
Cursor.Position = prevPos;
|
||||
|
||||
form.OnImagePastedFinish();
|
||||
});
|
||||
form.InvokeAsyncSafe(() => form.TriggerImageUpload(offsetX, offsetY));
|
||||
}
|
||||
|
||||
public void ScreenshotTweet(string html, int width, int height){
|
||||
form.InvokeSafe(() => form.OnTweetScreenshotReady(html, width, height));
|
||||
form.InvokeAsyncSafe(() => form.OnTweetScreenshotReady(html, width, height));
|
||||
}
|
||||
|
||||
public void FixClipboard(){
|
||||
form.InvokeAsyncSafe(WindowsUtils.ClipboardStripHtmlStyles);
|
||||
}
|
||||
|
||||
public void OpenBrowser(string url){
|
||||
|
@@ -16,6 +16,10 @@ namespace TweetDck.Core.Controls{
|
||||
}
|
||||
}
|
||||
|
||||
public static void InvokeAsyncSafe(this Control control, Action func){
|
||||
control.BeginInvoke(func);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
7
Core/FormBrowser.Designer.cs
generated
7
Core/FormBrowser.Designer.cs
generated
@@ -24,18 +24,15 @@
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.trayIcon = new TweetDck.Core.TrayIcon();
|
||||
this.trayIcon = new TweetDck.Core.TrayIcon(this.components);
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// trayIcon
|
||||
//
|
||||
this.trayIcon.Visible = false;
|
||||
//
|
||||
// FormBrowser
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = TweetDck.Core.Utils.BrowserUtils.BackgroundColor;
|
||||
this.ClientSize = new System.Drawing.Size(324, 386);
|
||||
this.Icon = Properties.Resources.icon;
|
||||
this.Location = TweetDck.Core.Controls.ControlExtensions.InvisibleLocation;
|
||||
|
@@ -13,10 +13,12 @@ using TweetDck.Updates;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using TweetDck.Plugins.Events;
|
||||
using System.Media;
|
||||
using TweetDck.Core.Bridge;
|
||||
using TweetDck.Core.Notification;
|
||||
using TweetDck.Core.Notification.Screenshot;
|
||||
using TweetDck.Updates.Events;
|
||||
using System.Diagnostics;
|
||||
using TweetDck.Core.Notification.Sound;
|
||||
|
||||
namespace TweetDck.Core{
|
||||
sealed partial class FormBrowser : Form{
|
||||
@@ -31,7 +33,8 @@ namespace TweetDck.Core{
|
||||
private readonly ChromiumWebBrowser browser;
|
||||
private readonly PluginManager plugins;
|
||||
private readonly UpdateHandler updates;
|
||||
private readonly FormNotification notification;
|
||||
private readonly FormNotificationTweet notification;
|
||||
private readonly ContextMenu contextMenu;
|
||||
|
||||
private FormSettings currentFormSettings;
|
||||
private FormAbout currentFormAbout;
|
||||
@@ -41,7 +44,7 @@ namespace TweetDck.Core{
|
||||
private FormWindowState prevState;
|
||||
|
||||
private TweetScreenshotManager notificationScreenshotManager;
|
||||
private SoundPlayer notificationSound;
|
||||
private ISoundNotificationPlayer soundNotification;
|
||||
|
||||
public FormBrowser(PluginManager pluginManager, UpdaterSettings updaterSettings){
|
||||
InitializeComponent();
|
||||
@@ -52,8 +55,16 @@ namespace TweetDck.Core{
|
||||
this.plugins.Reloaded += plugins_Reloaded;
|
||||
this.plugins.PluginChangedState += plugins_PluginChangedState;
|
||||
|
||||
this.notification = CreateNotificationForm(NotificationFlags.AutoHide | NotificationFlags.TopMost);
|
||||
this.notification.CanMoveWindow = () => false;
|
||||
this.contextMenu = ContextMenuBrowser.CreateMenu(this);
|
||||
|
||||
this.notification = new FormNotificationTweet(this, plugins){
|
||||
#if DEBUG
|
||||
CanMoveWindow = () => (ModifierKeys & Keys.Alt) == Keys.Alt
|
||||
#else
|
||||
CanMoveWindow = () => false
|
||||
#endif
|
||||
};
|
||||
|
||||
this.notification.Show();
|
||||
|
||||
this.browser = new ChromiumWebBrowser("https://tweetdeck.twitter.com/"){
|
||||
@@ -67,22 +78,30 @@ namespace TweetDck.Core{
|
||||
this.browser.ConsoleMessage += BrowserUtils.HandleConsoleMessage;
|
||||
#endif
|
||||
|
||||
this.browser.LoadingStateChanged += Browser_LoadingStateChanged;
|
||||
this.browser.FrameLoadEnd += Browser_FrameLoadEnd;
|
||||
this.browser.RegisterJsObject("$TD", new TweetDeckBridge(this, notification));
|
||||
this.browser.LoadingStateChanged += browser_LoadingStateChanged;
|
||||
this.browser.FrameLoadStart += browser_FrameLoadStart;
|
||||
this.browser.FrameLoadEnd += browser_FrameLoadEnd;
|
||||
this.browser.LoadError += browser_LoadError;
|
||||
this.browser.RegisterAsyncJsObject("$TD", new TweetDeckBridge(this, notification));
|
||||
this.browser.RegisterAsyncJsObject("$TDP", plugins.Bridge);
|
||||
|
||||
|
||||
browser.BrowserSettings.BackgroundColor = (uint)BrowserUtils.BackgroundColor.ToArgb();
|
||||
browser.Dock = DockStyle.None;
|
||||
browser.Location = ControlExtensions.InvisibleLocation;
|
||||
Controls.Add(browser);
|
||||
|
||||
Controls.Add(new MenuStrip{ Visible = false }); // fixes Alt freezing the program in Win 10 Anniversary Update
|
||||
|
||||
Disposed += (sender, args) => {
|
||||
browser.Dispose();
|
||||
contextMenu.Dispose();
|
||||
|
||||
if (notificationScreenshotManager != null){
|
||||
notificationScreenshotManager.Dispose();
|
||||
}
|
||||
|
||||
if (notificationSound != null){
|
||||
notificationSound.Dispose();
|
||||
if (soundNotification != null){
|
||||
soundNotification.Dispose();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -92,13 +111,18 @@ namespace TweetDck.Core{
|
||||
|
||||
UpdateTrayIcon();
|
||||
|
||||
Config.MuteToggled += Config_MuteToggled;
|
||||
|
||||
this.updates = new UpdateHandler(browser, this, updaterSettings);
|
||||
this.updates.UpdateAccepted += updates_UpdateAccepted;
|
||||
this.updates.UpdateDismissed += updates_UpdateDismissed;
|
||||
|
||||
RestoreWindow();
|
||||
}
|
||||
|
||||
private void ShowChildForm(Form form){
|
||||
form.VisibleChanged += (sender, args) => form.MoveToCenter(this);
|
||||
form.Show(this);
|
||||
form.Shown += (sender, args) => form.MoveToCenter(this);
|
||||
}
|
||||
|
||||
public void ForceClose(){
|
||||
@@ -108,10 +132,17 @@ namespace TweetDck.Core{
|
||||
|
||||
// window setup
|
||||
|
||||
private void SetupWindow(){
|
||||
private void RestoreWindow(){
|
||||
Config.BrowserWindow.Restore(this, true);
|
||||
prevState = WindowState;
|
||||
isLoaded = true;
|
||||
}
|
||||
|
||||
private void OnLoaded(){
|
||||
if (!isLoaded){
|
||||
browser.Location = Point.Empty;
|
||||
browser.Dock = DockStyle.Fill;
|
||||
isLoaded = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateTrayIcon(){
|
||||
@@ -120,26 +151,30 @@ namespace TweetDck.Core{
|
||||
|
||||
// active event handlers
|
||||
|
||||
private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){
|
||||
private void browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){
|
||||
if (!e.IsLoading){
|
||||
browser.AddWordToDictionary("tweetdeck");
|
||||
browser.AddWordToDictionary("TweetDeck");
|
||||
browser.AddWordToDictionary("tweetduck");
|
||||
browser.AddWordToDictionary("TweetDuck");
|
||||
browser.AddWordToDictionary("TD");
|
||||
foreach(string word in BrowserUtils.DictionaryWords){
|
||||
browser.AddWordToDictionary(word);
|
||||
}
|
||||
|
||||
Invoke(new Action(SetupWindow));
|
||||
browser.LoadingStateChanged -= Browser_LoadingStateChanged;
|
||||
BeginInvoke(new Action(OnLoaded));
|
||||
browser.LoadingStateChanged -= browser_LoadingStateChanged;
|
||||
}
|
||||
}
|
||||
|
||||
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||
if (e.Frame.IsMain && BrowserUtils.IsTweetDeckWebsite(e.Frame)){
|
||||
ScriptLoader.ExecuteFile(e.Frame, "code.js");
|
||||
private void browser_FrameLoadStart(object sender, FrameLoadStartEventArgs e){
|
||||
if (e.Frame.IsMain && BrowserUtils.IsTwitterWebsite(e.Frame)){
|
||||
ScriptLoader.ExecuteFile(e.Frame, "twitter.js");
|
||||
}
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
ScriptLoader.ExecuteFile(e.Frame, "debug.js");
|
||||
#endif
|
||||
private void browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||
if (e.Frame.IsMain && BrowserUtils.IsTweetDeckWebsite(e.Frame)){
|
||||
e.Frame.ExecuteJavaScriptAsync(BrowserUtils.BackgroundColorFix);
|
||||
|
||||
UpdateProperties();
|
||||
ScriptLoader.ExecuteFile(e.Frame, "code.js");
|
||||
ReinjectCustomCSS(Config.CustomBrowserCSS);
|
||||
|
||||
if (plugins.HasAnyPlugin(PluginEnvironment.Browser)){
|
||||
ScriptLoader.ExecuteFile(e.Frame, PluginManager.PluginBrowserScriptFile);
|
||||
@@ -151,6 +186,20 @@ namespace TweetDck.Core{
|
||||
}
|
||||
}
|
||||
|
||||
private void browser_LoadError(object sender, LoadErrorEventArgs e){
|
||||
if (e.ErrorCode == CefErrorCode.Aborted){
|
||||
return;
|
||||
}
|
||||
|
||||
if (!e.FailedUrl.StartsWith("http://td/")){
|
||||
string errorPage = ScriptLoader.LoadResource("pages/error.html", true);
|
||||
|
||||
if (errorPage != null){
|
||||
browser.LoadHtml(errorPage.Replace("{err}", BrowserUtils.GetErrorName(e.ErrorCode)), "http://td/error");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FormBrowser_Activated(object sender, EventArgs e){
|
||||
if (!isLoaded)return;
|
||||
|
||||
@@ -192,34 +241,32 @@ namespace TweetDck.Core{
|
||||
}
|
||||
}
|
||||
|
||||
private void Config_MuteToggled(object sender, EventArgs e){
|
||||
UpdateProperties(PropertyBridge.Properties.MuteNotifications);
|
||||
}
|
||||
|
||||
private void Config_TrayBehaviorChanged(object sender, EventArgs e){
|
||||
if (!isLoaded)return;
|
||||
|
||||
UpdateTrayIcon();
|
||||
}
|
||||
|
||||
private void trayIcon_ClickRestore(object sender, EventArgs e){
|
||||
if (!isLoaded)return;
|
||||
|
||||
isLoaded = false;
|
||||
Show();
|
||||
SetupWindow();
|
||||
RestoreWindow();
|
||||
Activate();
|
||||
UpdateTrayIcon();
|
||||
}
|
||||
|
||||
private void trayIcon_ClickClose(object sender, EventArgs e){
|
||||
if (!isLoaded)return;
|
||||
|
||||
ForceClose();
|
||||
}
|
||||
|
||||
private void plugins_Reloaded(object sender, PluginLoadEventArgs e){
|
||||
ReloadBrowser();
|
||||
private void plugins_Reloaded(object sender, PluginErrorEventArgs e){
|
||||
browser.GetBrowser().Reload();
|
||||
}
|
||||
|
||||
private void plugins_PluginChangedState(object sender, PluginChangedStateEventArgs e){
|
||||
browser.ExecuteScriptAsync("window.TDPF_setPluginState", e.Plugin, e.IsEnabled ? 1 : 0); // ExecuteScriptAsync cannot handle boolean values as of yet
|
||||
browser.ExecuteScriptAsync("window.TDPF_setPluginState", e.Plugin, e.IsEnabled);
|
||||
Config.Save();
|
||||
}
|
||||
|
||||
private void updates_UpdateAccepted(object sender, UpdateAcceptedEventArgs e){
|
||||
@@ -228,6 +275,7 @@ namespace TweetDck.Core{
|
||||
FormUpdateDownload downloadForm = new FormUpdateDownload(e.UpdateInfo);
|
||||
downloadForm.MoveToCenter(this);
|
||||
downloadForm.ShowDialog();
|
||||
downloadForm.Dispose();
|
||||
|
||||
if (downloadForm.UpdateStatus == FormUpdateDownload.Status.Succeeded){
|
||||
UpdateInstallerPath = downloadForm.InstallerPath;
|
||||
@@ -241,9 +289,35 @@ namespace TweetDck.Core{
|
||||
}
|
||||
}
|
||||
|
||||
private void updates_UpdateDismissed(object sender, UpdateDismissedEventArgs e){
|
||||
Config.DismissedUpdate = e.VersionTag;
|
||||
Config.Save();
|
||||
}
|
||||
|
||||
private void soundNotification_PlaybackError(object sender, PlaybackErrorEventArgs e){
|
||||
e.Ignore = true;
|
||||
|
||||
using(FormMessage form = new FormMessage("Notification Sound Error", "Could not play custom notification sound."+Environment.NewLine+e.Message, MessageBoxIcon.Error)){
|
||||
form.CancelButton = form.AddButton("Ignore");
|
||||
|
||||
Button btnOpenSettings = form.AddButton("Open Settings");
|
||||
btnOpenSettings.Width += 16;
|
||||
btnOpenSettings.Location = new Point(btnOpenSettings.Location.X-16, btnOpenSettings.Location.Y);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnOpenSettings){
|
||||
OpenSettings(FormSettings.TabIndexNotification);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m){
|
||||
if (isLoaded && m.Msg == Program.WindowRestoreMessage){
|
||||
trayIcon_ClickRestore(trayIcon, new EventArgs());
|
||||
using(Process process = Process.GetCurrentProcess()){
|
||||
if (process.Id == m.WParam.ToInt32()){
|
||||
trayIcon_ClickRestore(trayIcon, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -257,8 +331,8 @@ namespace TweetDck.Core{
|
||||
|
||||
// notification helpers
|
||||
|
||||
public FormNotification CreateNotificationForm(NotificationFlags flags){
|
||||
return new FormNotification(this, plugins, flags);
|
||||
public FormNotificationMain CreateNotificationForm(bool enableContextMenu){
|
||||
return new FormNotificationMain(this, plugins, enableContextMenu);
|
||||
}
|
||||
|
||||
public void PauseNotification(){
|
||||
@@ -269,29 +343,52 @@ namespace TweetDck.Core{
|
||||
notification.ResumeNotification();
|
||||
}
|
||||
|
||||
// javascript calls
|
||||
|
||||
public void ReinjectCustomCSS(string css){
|
||||
browser.ExecuteScriptAsync("TDGF_reinjectCustomCSS", css == null ? string.Empty : css.Replace(Environment.NewLine, " "));
|
||||
}
|
||||
|
||||
public void UpdateProperties(PropertyBridge.Properties properties = PropertyBridge.Properties.All){
|
||||
browser.ExecuteScriptAsync(PropertyBridge.GenerateScript(properties));
|
||||
}
|
||||
|
||||
public void ReloadToTweetDeck(){
|
||||
browser.ExecuteScriptAsync("window.location.href = 'https://tweetdeck.twitter.com'");
|
||||
}
|
||||
|
||||
// callback handlers
|
||||
|
||||
public void OpenContextMenu(){
|
||||
contextMenu.Show(this, PointToClient(Cursor.Position));
|
||||
}
|
||||
|
||||
public void OpenSettings(){
|
||||
OpenSettings(0);
|
||||
}
|
||||
|
||||
public void OpenSettings(int tabIndex){
|
||||
if (currentFormSettings != null){
|
||||
currentFormSettings.BringToFront();
|
||||
}
|
||||
else{
|
||||
bool prevEnableUpdateCheck = Config.EnableUpdateCheck;
|
||||
|
||||
currentFormSettings = new FormSettings(this, plugins, updates);
|
||||
currentFormSettings = new FormSettings(this, plugins, updates, tabIndex);
|
||||
|
||||
currentFormSettings.FormClosed += (sender, args) => {
|
||||
currentFormSettings = null;
|
||||
|
||||
if (!prevEnableUpdateCheck && Config.EnableUpdateCheck){
|
||||
Config.DismissedUpdate = string.Empty;
|
||||
Config.Save();
|
||||
updates.DismissUpdate(string.Empty);
|
||||
updates.Check(false);
|
||||
}
|
||||
|
||||
if (!Config.EnableTrayHighlight){
|
||||
trayIcon.HasNotifications = false;
|
||||
}
|
||||
|
||||
UpdateProperties(PropertyBridge.Properties.ExpandLinksOnHover | PropertyBridge.Properties.HasCustomNotificationSound);
|
||||
};
|
||||
|
||||
ShowChildForm(currentFormSettings);
|
||||
@@ -327,19 +424,16 @@ namespace TweetDck.Core{
|
||||
}
|
||||
|
||||
public void PlayNotificationSound(){
|
||||
if (string.IsNullOrEmpty(Config.NotificationSoundPath)){
|
||||
if (Config.NotificationSoundPath.Length == 0){
|
||||
return;
|
||||
}
|
||||
|
||||
if (notificationSound == null){
|
||||
notificationSound = new SoundPlayer();
|
||||
if (soundNotification == null){
|
||||
soundNotification = SoundNotification.New();
|
||||
soundNotification.PlaybackError += soundNotification_PlaybackError;
|
||||
}
|
||||
|
||||
if (notificationSound.SoundLocation != Config.NotificationSoundPath){
|
||||
notificationSound.SoundLocation = Config.NotificationSoundPath;
|
||||
}
|
||||
|
||||
notificationSound.Play();
|
||||
soundNotification.Play(Config.NotificationSoundPath);
|
||||
}
|
||||
|
||||
public void OnTweetScreenshotReady(string html, int width, int height){
|
||||
@@ -365,16 +459,14 @@ namespace TweetDck.Core{
|
||||
browser.ExecuteScriptAsync("TDGF_tryPasteImage()");
|
||||
}
|
||||
|
||||
public void OnImagePastedFinish(){
|
||||
browser.ExecuteScriptAsync("TDGF_tryPasteImageFinish()");
|
||||
public void TriggerImageUpload(int offsetX, int offsetY){
|
||||
IBrowserHost host = browser.GetBrowser().GetHost();
|
||||
host.SendMouseClickEvent(offsetX, offsetY, MouseButtonType.Left, false, 1, CefEventFlags.None);
|
||||
host.SendMouseClickEvent(offsetX, offsetY, MouseButtonType.Left, true, 1, CefEventFlags.None);
|
||||
}
|
||||
|
||||
public void TriggerTweetScreenshot(){
|
||||
browser.ExecuteScriptAsync("TDGF_triggerScreenshot()");
|
||||
}
|
||||
|
||||
public void ReloadBrowser(){
|
||||
browser.ExecuteScriptAsync("window.location.reload()");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,441 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDck.Core.Bridge;
|
||||
using TweetDck.Core.Handling;
|
||||
using TweetDck.Resources;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Notification;
|
||||
|
||||
namespace TweetDck.Core{
|
||||
partial class FormNotification : Form{
|
||||
private const string NotificationScriptFile = "notification.js";
|
||||
|
||||
private static readonly string NotificationScriptIdentifier = ScriptLoader.GetRootIdentifier(NotificationScriptFile);
|
||||
private static readonly string PluginScriptIdentifier = ScriptLoader.GetRootIdentifier(PluginManager.PluginNotificationScriptFile);
|
||||
|
||||
public Func<bool> CanMoveWindow = () => true;
|
||||
|
||||
public bool IsNotificationVisible{
|
||||
get{
|
||||
return Location != ControlExtensions.InvisibleLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public new Point Location{
|
||||
get{
|
||||
return base.Location;
|
||||
}
|
||||
|
||||
set{
|
||||
Visible = (base.Location = value) != ControlExtensions.InvisibleLocation;
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Control owner;
|
||||
private readonly PluginManager plugins;
|
||||
protected readonly NotificationFlags flags;
|
||||
protected readonly ChromiumWebBrowser browser;
|
||||
|
||||
private readonly Queue<TweetNotification> tweetQueue = new Queue<TweetNotification>(4);
|
||||
private int timeLeft, totalTime;
|
||||
|
||||
private readonly NativeMethods.HookProc mouseHookDelegate;
|
||||
private IntPtr mouseHook;
|
||||
|
||||
private bool? prevDisplayTimer;
|
||||
private int? prevFontSize;
|
||||
|
||||
private bool RequiresResize{
|
||||
get{
|
||||
return !prevDisplayTimer.HasValue || !prevFontSize.HasValue || prevDisplayTimer != Program.UserConfig.DisplayNotificationTimer || prevFontSize != TweetNotification.FontSizeLevel;
|
||||
}
|
||||
|
||||
set{
|
||||
if (value){
|
||||
prevDisplayTimer = null;
|
||||
prevFontSize = null;
|
||||
}
|
||||
else{
|
||||
prevDisplayTimer = Program.UserConfig.DisplayNotificationTimer;
|
||||
prevFontSize = TweetNotification.FontSizeLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly string notificationJS;
|
||||
private readonly string pluginJS;
|
||||
|
||||
protected override bool ShowWithoutActivation{
|
||||
get{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool FreezeTimer { get; set; }
|
||||
public bool ContextMenuOpen { get; set; }
|
||||
public string CurrentUrl { get; private set; }
|
||||
public string CurrentQuotedTweetUrl { get; set; }
|
||||
|
||||
public EventHandler Initialized;
|
||||
private bool isInitialized;
|
||||
|
||||
private int pauseCounter;
|
||||
private bool pausedDuringNotification;
|
||||
|
||||
public bool IsPaused{
|
||||
get{
|
||||
return pauseCounter > 0;
|
||||
}
|
||||
}
|
||||
|
||||
private static int BaseClientWidth{
|
||||
get{
|
||||
int level = TweetNotification.FontSizeLevel;
|
||||
return level == 0 ? 284 : (int)Math.Round(284.0*(1.0+0.05*level));
|
||||
}
|
||||
}
|
||||
|
||||
private static int BaseClientHeight{
|
||||
get{
|
||||
int level = TweetNotification.FontSizeLevel;
|
||||
return level == 0 ? 118 : (int)Math.Round(118.0*(1.0+0.075*level));
|
||||
}
|
||||
}
|
||||
|
||||
public FormNotification(FormBrowser owner, PluginManager pluginManager, NotificationFlags flags){
|
||||
InitializeComponent();
|
||||
|
||||
this.owner = owner;
|
||||
this.plugins = pluginManager;
|
||||
this.flags = flags;
|
||||
|
||||
owner.FormClosed += (sender, args) => Close();
|
||||
|
||||
browser = new ChromiumWebBrowser("about:blank"){
|
||||
MenuHandler = new ContextMenuNotification(this, !flags.HasFlag(NotificationFlags.DisableContextMenu)),
|
||||
LifeSpanHandler = new LifeSpanHandler()
|
||||
};
|
||||
|
||||
#if DEBUG
|
||||
browser.ConsoleMessage += BrowserUtils.HandleConsoleMessage;
|
||||
#endif
|
||||
|
||||
browser.IsBrowserInitializedChanged += Browser_IsBrowserInitializedChanged;
|
||||
browser.FrameLoadEnd += Browser_FrameLoadEnd;
|
||||
|
||||
if (!flags.HasFlag(NotificationFlags.DisableScripts)){
|
||||
notificationJS = ScriptLoader.LoadResource(NotificationScriptFile);
|
||||
browser.RegisterJsObject("$TD", new TweetDeckBridge(owner, this));
|
||||
|
||||
if (plugins != null){
|
||||
pluginJS = ScriptLoader.LoadResource(PluginManager.PluginNotificationScriptFile);
|
||||
browser.RegisterAsyncJsObject("$TDP", plugins.Bridge);
|
||||
}
|
||||
}
|
||||
|
||||
panelBrowser.Controls.Add(browser);
|
||||
|
||||
if (flags.HasFlag(NotificationFlags.AutoHide)){
|
||||
Program.UserConfig.MuteToggled += Config_MuteToggled;
|
||||
Disposed += (sender, args) => Program.UserConfig.MuteToggled -= Config_MuteToggled;
|
||||
|
||||
if (Program.UserConfig.MuteNotifications){
|
||||
PauseNotification();
|
||||
}
|
||||
}
|
||||
|
||||
mouseHookDelegate = MouseHookProc;
|
||||
|
||||
Disposed += FormNotification_Disposed;
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m){
|
||||
if (m.Msg == 0x0112 && (m.WParam.ToInt32() & 0xFFF0) == 0xF010 && !CanMoveWindow()){ // WM_SYSCOMMAND, SC_MOVE
|
||||
return;
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
// mouse wheel hook
|
||||
|
||||
private void StartMouseHook(){
|
||||
if (mouseHook == IntPtr.Zero){
|
||||
mouseHook = NativeMethods.SetWindowsHookEx(NativeMethods.WH_MOUSE_LL, mouseHookDelegate, IntPtr.Zero, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void StopMouseHook(){
|
||||
if (mouseHook != IntPtr.Zero){
|
||||
NativeMethods.UnhookWindowsHookEx(mouseHook);
|
||||
mouseHook = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam){
|
||||
if (!ContainsFocus && wParam.ToInt32() == NativeMethods.WH_MOUSEWHEEL && browser.Bounds.Contains(PointToClient(Cursor.Position))){
|
||||
// fuck it, Activate() doesn't work with this
|
||||
Point prevPos = Cursor.Position;
|
||||
Cursor.Position = PointToScreen(new Point(0, -1));
|
||||
NativeMethods.SimulateMouseClick(NativeMethods.MouseButton.Left);
|
||||
Cursor.Position = prevPos;
|
||||
}
|
||||
|
||||
return NativeMethods.CallNextHookEx(mouseHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
// event handlers
|
||||
|
||||
private void timerHideProgress_Tick(object sender, EventArgs e){
|
||||
if (Bounds.Contains(Cursor.Position) || FreezeTimer || ContextMenuOpen)return;
|
||||
|
||||
timeLeft -= timerProgress.Interval;
|
||||
|
||||
int value = (int)Math.Round(1025.0*(totalTime-timeLeft)/totalTime);
|
||||
progressBarTimer.SetValueInstant(Math.Min(1000, Math.Max(0, Program.UserConfig.NotificationTimerCountDown ? 1000-value : value)));
|
||||
|
||||
if (timeLeft <= 0){
|
||||
FinishCurrentTweet();
|
||||
}
|
||||
}
|
||||
|
||||
private void Config_MuteToggled(object sender, EventArgs e){
|
||||
if (Program.UserConfig.MuteNotifications){
|
||||
PauseNotification();
|
||||
}
|
||||
else{
|
||||
ResumeNotification();
|
||||
}
|
||||
}
|
||||
|
||||
private void Browser_IsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs e){
|
||||
if (e.IsBrowserInitialized && Initialized != null){
|
||||
Initialized(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||
if (!e.Frame.IsMain)return;
|
||||
|
||||
if (!isInitialized && !Program.UserConfig.NotificationLegacyLoad){
|
||||
isInitialized = true;
|
||||
|
||||
if (Initialized != null){
|
||||
Initialized(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
else if (notificationJS != null && browser.Address != "about:blank" && !flags.HasFlag(NotificationFlags.DisableScripts)){
|
||||
ScriptLoader.ExecuteScript(e.Frame, notificationJS, NotificationScriptIdentifier);
|
||||
|
||||
if (plugins != null && plugins.HasAnyPlugin(PluginEnvironment.Notification)){
|
||||
ScriptLoader.ExecuteScript(e.Frame, pluginJS, PluginScriptIdentifier);
|
||||
ScriptLoader.ExecuteFile(e.Frame, PluginManager.PluginGlobalScriptFile);
|
||||
plugins.ExecutePlugins(e.Frame, PluginEnvironment.Notification, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void FormNotification_FormClosing(object sender, FormClosingEventArgs e){
|
||||
if (e.CloseReason == CloseReason.UserClosing){
|
||||
HideNotification(false);
|
||||
tweetQueue.Clear();
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void FormNotification_Disposed(object sender, EventArgs e){
|
||||
browser.Dispose();
|
||||
StopMouseHook();
|
||||
}
|
||||
|
||||
// notification methods
|
||||
|
||||
public void ShowNotification(TweetNotification notification){
|
||||
if (IsPaused){
|
||||
tweetQueue.Enqueue(notification);
|
||||
}
|
||||
else{
|
||||
tweetQueue.Enqueue(notification);
|
||||
UpdateTitle();
|
||||
|
||||
if (totalTime == 0){
|
||||
LoadNextNotification();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ShowNotificationForSettings(bool reset){
|
||||
if (reset){
|
||||
LoadTweet(TweetNotification.ExampleTweet);
|
||||
}
|
||||
else{
|
||||
PrepareAndDisplayWindow();
|
||||
}
|
||||
}
|
||||
|
||||
public void HideNotification(bool loadBlank){
|
||||
if (loadBlank || Program.UserConfig.NotificationLegacyLoad){
|
||||
browser.LoadHtml("", "about:blank");
|
||||
}
|
||||
|
||||
Location = ControlExtensions.InvisibleLocation;
|
||||
progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? 1000 : 0;
|
||||
timerProgress.Stop();
|
||||
totalTime = 0;
|
||||
|
||||
StopMouseHook();
|
||||
}
|
||||
|
||||
public void OnNotificationReady(){
|
||||
UpdateTitle();
|
||||
PrepareAndDisplayWindow();
|
||||
timerProgress.Start();
|
||||
}
|
||||
|
||||
public void FinishCurrentTweet(){
|
||||
if (tweetQueue.Count > 0){
|
||||
LoadNextNotification();
|
||||
}
|
||||
else if (flags.HasFlag(NotificationFlags.AutoHide)){
|
||||
HideNotification(true);
|
||||
}
|
||||
else{
|
||||
timerProgress.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void PauseNotification(){
|
||||
if (pauseCounter++ == 0){
|
||||
pausedDuringNotification = IsNotificationVisible;
|
||||
|
||||
if (IsNotificationVisible){
|
||||
Location = ControlExtensions.InvisibleLocation;
|
||||
timerProgress.Stop();
|
||||
StopMouseHook();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void ResumeNotification(){
|
||||
if (pauseCounter > 0 && --pauseCounter == 0){
|
||||
if (pausedDuringNotification){
|
||||
OnNotificationReady();
|
||||
}
|
||||
else if (tweetQueue.Count > 0){
|
||||
LoadNextNotification();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadNextNotification(){
|
||||
LoadTweet(tweetQueue.Dequeue());
|
||||
}
|
||||
|
||||
private void LoadTweet(TweetNotification tweet){
|
||||
CurrentUrl = tweet.Url;
|
||||
CurrentQuotedTweetUrl = string.Empty; // load from JS
|
||||
|
||||
timerProgress.Stop();
|
||||
totalTime = timeLeft = tweet.GetDisplayDuration(Program.UserConfig.NotificationDurationValue);
|
||||
progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? 1000 : 0;
|
||||
|
||||
string bodyClasses = browser.Bounds.Contains(PointToClient(Cursor.Position)) ? "td-hover" : string.Empty;
|
||||
|
||||
browser.LoadHtml(tweet.GenerateHtml(bodyClasses), "http://tweetdeck.twitter.com/?"+DateTime.Now.Ticks);
|
||||
|
||||
if (Program.UserConfig.NotificationLegacyLoad){
|
||||
OnNotificationReady();
|
||||
}
|
||||
}
|
||||
|
||||
private void PrepareAndDisplayWindow(){
|
||||
if (RequiresResize){
|
||||
RequiresResize = false;
|
||||
SetNotificationSize(BaseClientWidth, BaseClientHeight, Program.UserConfig.DisplayNotificationTimer);
|
||||
}
|
||||
|
||||
MoveToVisibleLocation();
|
||||
StartMouseHook();
|
||||
}
|
||||
|
||||
protected void SetNotificationSize(int width, int height, bool displayTimer){
|
||||
if (displayTimer){
|
||||
ClientSize = new Size(width, height+4);
|
||||
progressBarTimer.Visible = true;
|
||||
}
|
||||
else{
|
||||
ClientSize = new Size(width, height);
|
||||
progressBarTimer.Visible = false;
|
||||
}
|
||||
|
||||
panelBrowser.Height = height;
|
||||
}
|
||||
|
||||
protected void MoveToVisibleLocation(){
|
||||
UserConfig config = Program.UserConfig;
|
||||
|
||||
Screen screen = Screen.FromControl(owner);
|
||||
|
||||
if (config.NotificationDisplay > 0 && config.NotificationDisplay <= Screen.AllScreens.Length){
|
||||
screen = Screen.AllScreens[config.NotificationDisplay-1];
|
||||
}
|
||||
|
||||
bool needsReactivating = Location == ControlExtensions.InvisibleLocation;
|
||||
int edgeDist = config.NotificationEdgeDistance;
|
||||
|
||||
switch(config.NotificationPosition){
|
||||
case TweetNotification.Position.TopLeft:
|
||||
Location = new Point(screen.WorkingArea.X+edgeDist, screen.WorkingArea.Y+edgeDist);
|
||||
break;
|
||||
|
||||
case TweetNotification.Position.TopRight:
|
||||
Location = new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+edgeDist);
|
||||
break;
|
||||
|
||||
case TweetNotification.Position.BottomLeft:
|
||||
Location = new Point(screen.WorkingArea.X+edgeDist, screen.WorkingArea.Y+screen.WorkingArea.Height-edgeDist-Height);
|
||||
break;
|
||||
|
||||
case TweetNotification.Position.BottomRight:
|
||||
Location = new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+screen.WorkingArea.Height-edgeDist-Height);
|
||||
break;
|
||||
|
||||
case TweetNotification.Position.Custom:
|
||||
if (!config.IsCustomNotificationPositionSet){
|
||||
config.CustomNotificationPosition = new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+edgeDist);
|
||||
config.Save();
|
||||
}
|
||||
|
||||
Location = config.CustomNotificationPosition;
|
||||
break;
|
||||
}
|
||||
|
||||
if (needsReactivating && flags.HasFlag(NotificationFlags.TopMost)){
|
||||
NativeMethods.SetFormPos(this, NativeMethods.HWND_TOPMOST, NativeMethods.SWP_NOACTIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
protected void UpdateTitle(){
|
||||
Text = tweetQueue.Count > 0 ? Program.BrandName+" ("+tweetQueue.Count+" more left)" : Program.BrandName;
|
||||
}
|
||||
|
||||
public void DisplayTooltip(string text){
|
||||
if (string.IsNullOrEmpty(text)){
|
||||
toolTip.Hide(this);
|
||||
}
|
||||
else{
|
||||
Point position = PointToClient(Cursor.Position);
|
||||
position.Offset(20, 5);
|
||||
toolTip.Show(text, this, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,17 +1,22 @@
|
||||
using CefSharp;
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Bridge;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Handling{
|
||||
abstract class ContextMenuBase : IContextMenuHandler{
|
||||
private static readonly Regex RegexTwitterAccount = new Regex(@"^https?://twitter\.com/([^/]+)/?$", RegexOptions.Compiled);
|
||||
|
||||
private const int MenuOpenLinkUrl = 26500;
|
||||
private const int MenuCopyLinkUrl = 26501;
|
||||
private const int MenuOpenImage = 26502;
|
||||
private const int MenuSaveImage = 26503;
|
||||
private const int MenuCopyImageUrl = 26504;
|
||||
private const int MenuCopyUsername = 26502;
|
||||
private const int MenuOpenImage = 26503;
|
||||
private const int MenuSaveImage = 26504;
|
||||
private const int MenuCopyImageUrl = 26505;
|
||||
|
||||
#if DEBUG
|
||||
private const int MenuOpenDevTools = 26599;
|
||||
@@ -21,10 +26,24 @@ namespace TweetDck.Core.Handling{
|
||||
}
|
||||
#endif
|
||||
|
||||
private readonly Form form;
|
||||
|
||||
protected ContextMenuBase(Form form){
|
||||
this.form = form;
|
||||
}
|
||||
|
||||
public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model){
|
||||
if (parameters.TypeFlags.HasFlag(ContextMenuType.Link) && !parameters.UnfilteredLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal)){
|
||||
model.AddItem((CefMenuCommand)MenuOpenLinkUrl, "Open link in browser");
|
||||
model.AddItem((CefMenuCommand)MenuCopyLinkUrl, "Copy link address");
|
||||
if (RegexTwitterAccount.IsMatch(parameters.UnfilteredLinkUrl)){
|
||||
model.AddItem((CefMenuCommand)MenuOpenLinkUrl, "Open account in browser");
|
||||
model.AddItem((CefMenuCommand)MenuCopyLinkUrl, "Copy account address");
|
||||
model.AddItem((CefMenuCommand)MenuCopyUsername, "Copy account username");
|
||||
}
|
||||
else{
|
||||
model.AddItem((CefMenuCommand)MenuOpenLinkUrl, "Open link in browser");
|
||||
model.AddItem((CefMenuCommand)MenuCopyLinkUrl, "Copy link address");
|
||||
}
|
||||
|
||||
model.AddSeparator();
|
||||
}
|
||||
|
||||
@@ -43,7 +62,7 @@ namespace TweetDck.Core.Handling{
|
||||
break;
|
||||
|
||||
case MenuCopyLinkUrl:
|
||||
Clipboard.SetText(string.IsNullOrEmpty(TweetDeckBridge.LastRightClickedLink) ? parameters.UnfilteredLinkUrl : TweetDeckBridge.LastRightClickedLink, TextDataFormat.UnicodeText);
|
||||
SetClipboardText(string.IsNullOrEmpty(TweetDeckBridge.LastRightClickedLink) ? parameters.UnfilteredLinkUrl : TweetDeckBridge.LastRightClickedLink);
|
||||
break;
|
||||
|
||||
case MenuOpenImage:
|
||||
@@ -74,7 +93,12 @@ namespace TweetDck.Core.Handling{
|
||||
break;
|
||||
|
||||
case MenuCopyImageUrl:
|
||||
Clipboard.SetText(parameters.SourceUrl, TextDataFormat.UnicodeText);
|
||||
SetClipboardText(parameters.SourceUrl);
|
||||
break;
|
||||
|
||||
case MenuCopyUsername:
|
||||
Match match = RegexTwitterAccount.Match(parameters.UnfilteredLinkUrl);
|
||||
SetClipboardText(match.Success ? match.Groups[1].Value : parameters.UnfilteredLinkUrl);
|
||||
break;
|
||||
|
||||
#if DEBUG
|
||||
@@ -93,6 +117,10 @@ namespace TweetDck.Core.Handling{
|
||||
return false;
|
||||
}
|
||||
|
||||
protected void SetClipboardText(string text){
|
||||
form.InvokeAsyncSafe(() => WindowsUtils.SetClipboard(text, TextDataFormat.UnicodeText));
|
||||
}
|
||||
|
||||
protected static void RemoveSeparatorIfLast(IMenuModel model){
|
||||
if (model.Count > 0 && model.GetTypeAt(model.Count-1) == MenuItemType.Separator){
|
||||
model.RemoveAt(model.Count-1);
|
||||
|
@@ -1,5 +1,5 @@
|
||||
using CefSharp;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDck.Core.Bridge;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Utils;
|
||||
@@ -18,12 +18,18 @@ namespace TweetDck.Core.Handling{
|
||||
private const int MenuCopyQuotedTweetUrl = 26613;
|
||||
private const int MenuScreenshotTweet = 26614;
|
||||
|
||||
private const string TitleReloadBrowser = "Reload browser";
|
||||
private const string TitleMuteNotifications = "Mute notifications";
|
||||
private const string TitleSettings = "Settings";
|
||||
private const string TitlePlugins = "Plugins";
|
||||
private const string TitleAboutProgram = "About "+Program.BrandName;
|
||||
|
||||
private readonly FormBrowser form;
|
||||
|
||||
private string lastHighlightedTweet;
|
||||
private string lastHighlightedQuotedTweet;
|
||||
|
||||
public ContextMenuBrowser(FormBrowser form){
|
||||
public ContextMenuBrowser(FormBrowser form) : base(form){
|
||||
this.form = form;
|
||||
}
|
||||
|
||||
@@ -34,6 +40,10 @@ namespace TweetDck.Core.Handling{
|
||||
model.Remove(CefMenuCommand.ViewSource);
|
||||
RemoveSeparatorIfLast(model);
|
||||
|
||||
if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection)){
|
||||
model.AddSeparator();
|
||||
}
|
||||
|
||||
base.OnBeforeContextMenu(browserControl, browser, frame, parameters, model);
|
||||
|
||||
lastHighlightedTweet = TweetDeckBridge.LastHighlightedTweet;
|
||||
@@ -63,20 +73,22 @@ namespace TweetDck.Core.Handling{
|
||||
|
||||
IMenuModel globalMenu = model.Count == 0 ? model : model.AddSubMenu((CefMenuCommand)MenuGlobal, Program.BrandName);
|
||||
|
||||
globalMenu.AddItem(CefMenuCommand.Reload, "Reload browser");
|
||||
globalMenu.AddCheckItem((CefMenuCommand)MenuMute, "Mute notifications");
|
||||
globalMenu.AddItem(CefMenuCommand.Reload, TitleReloadBrowser);
|
||||
globalMenu.AddCheckItem((CefMenuCommand)MenuMute, TitleMuteNotifications);
|
||||
globalMenu.SetChecked((CefMenuCommand)MenuMute, Program.UserConfig.MuteNotifications);
|
||||
globalMenu.AddSeparator();
|
||||
|
||||
globalMenu.AddItem((CefMenuCommand)MenuSettings, "Settings");
|
||||
globalMenu.AddItem((CefMenuCommand)MenuPlugins, "Plugins");
|
||||
globalMenu.AddItem((CefMenuCommand)MenuAbout, "About "+Program.BrandName);
|
||||
globalMenu.AddItem((CefMenuCommand)MenuSettings, TitleSettings);
|
||||
globalMenu.AddItem((CefMenuCommand)MenuPlugins, TitlePlugins);
|
||||
globalMenu.AddItem((CefMenuCommand)MenuAbout, TitleAboutProgram);
|
||||
|
||||
#if DEBUG
|
||||
globalMenu.AddSeparator();
|
||||
AddDebugMenuItems(globalMenu);
|
||||
#endif
|
||||
}
|
||||
|
||||
RemoveSeparatorIfLast(model);
|
||||
}
|
||||
|
||||
public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags){
|
||||
@@ -86,27 +98,23 @@ namespace TweetDck.Core.Handling{
|
||||
|
||||
switch((int)commandId){
|
||||
case (int)CefMenuCommand.Reload:
|
||||
frame.ExecuteJavaScriptAsync("window.location.href = 'https://tweetdeck.twitter.com'");
|
||||
form.InvokeAsyncSafe(form.ReloadToTweetDeck);
|
||||
return true;
|
||||
|
||||
case MenuSettings:
|
||||
form.InvokeSafe(form.OpenSettings);
|
||||
form.InvokeAsyncSafe(form.OpenSettings);
|
||||
return true;
|
||||
|
||||
case MenuAbout:
|
||||
form.InvokeSafe(form.OpenAbout);
|
||||
form.InvokeAsyncSafe(form.OpenAbout);
|
||||
return true;
|
||||
|
||||
case MenuPlugins:
|
||||
form.InvokeSafe(form.OpenPlugins);
|
||||
form.InvokeAsyncSafe(form.OpenPlugins);
|
||||
return true;
|
||||
|
||||
case MenuMute:
|
||||
form.InvokeSafe(() => {
|
||||
Program.UserConfig.MuteNotifications = !Program.UserConfig.MuteNotifications;
|
||||
Program.UserConfig.Save();
|
||||
});
|
||||
|
||||
form.InvokeAsyncSafe(ToggleMuteNotifications);
|
||||
return true;
|
||||
|
||||
case MenuOpenTweetUrl:
|
||||
@@ -114,11 +122,11 @@ namespace TweetDck.Core.Handling{
|
||||
return true;
|
||||
|
||||
case MenuCopyTweetUrl:
|
||||
Clipboard.SetText(lastHighlightedTweet, TextDataFormat.UnicodeText);
|
||||
SetClipboardText(lastHighlightedTweet);
|
||||
return true;
|
||||
|
||||
case MenuScreenshotTweet:
|
||||
form.InvokeSafe(form.TriggerTweetScreenshot);
|
||||
form.InvokeAsyncSafe(form.TriggerTweetScreenshot);
|
||||
return true;
|
||||
|
||||
case MenuOpenQuotedTweetUrl:
|
||||
@@ -126,11 +134,33 @@ namespace TweetDck.Core.Handling{
|
||||
return true;
|
||||
|
||||
case MenuCopyQuotedTweetUrl:
|
||||
Clipboard.SetText(lastHighlightedQuotedTweet, TextDataFormat.UnicodeText);
|
||||
SetClipboardText(lastHighlightedQuotedTweet);
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ContextMenu CreateMenu(FormBrowser form){
|
||||
ContextMenu menu = new ContextMenu();
|
||||
|
||||
menu.MenuItems.Add(TitleReloadBrowser, (sender, args) => form.ReloadToTweetDeck());
|
||||
menu.MenuItems.Add(TitleMuteNotifications, (sender, args) => ToggleMuteNotifications());
|
||||
menu.MenuItems.Add("-");
|
||||
menu.MenuItems.Add(TitleSettings, (sender, args) => form.OpenSettings());
|
||||
menu.MenuItems.Add(TitlePlugins, (sender, args) => form.OpenPlugins());
|
||||
menu.MenuItems.Add(TitleAboutProgram, (sender, args) => form.OpenAbout());
|
||||
|
||||
menu.Popup += (sender, args) => {
|
||||
menu.MenuItems[1].Checked = Program.UserConfig.MuteNotifications;
|
||||
};
|
||||
|
||||
return menu;
|
||||
}
|
||||
|
||||
private static void ToggleMuteNotifications(){
|
||||
Program.UserConfig.MuteNotifications = !Program.UserConfig.MuteNotifications;
|
||||
Program.UserConfig.Save();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using CefSharp;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Notification;
|
||||
|
||||
namespace TweetDck.Core.Handling{
|
||||
class ContextMenuNotification : ContextMenuBase{
|
||||
@@ -9,16 +9,22 @@ namespace TweetDck.Core.Handling{
|
||||
private const int MenuCopyTweetUrl = 26602;
|
||||
private const int MenuCopyQuotedTweetUrl = 26603;
|
||||
|
||||
private readonly FormNotification form;
|
||||
private readonly FormNotificationBase form;
|
||||
private readonly bool enableCustomMenu;
|
||||
|
||||
public ContextMenuNotification(FormNotification form, bool enableCustomMenu){
|
||||
public ContextMenuNotification(FormNotificationBase form, bool enableCustomMenu) : base(form){
|
||||
this.form = form;
|
||||
this.enableCustomMenu = enableCustomMenu;
|
||||
}
|
||||
|
||||
public override void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, IMenuModel model){
|
||||
model.Clear();
|
||||
|
||||
if (parameters.TypeFlags.HasFlag(ContextMenuType.Selection)){
|
||||
model.AddItem(CefMenuCommand.Copy, "Copy");
|
||||
model.AddSeparator();
|
||||
}
|
||||
|
||||
base.OnBeforeContextMenu(browserControl, browser, frame, parameters, model);
|
||||
|
||||
if (enableCustomMenu){
|
||||
@@ -44,7 +50,7 @@ namespace TweetDck.Core.Handling{
|
||||
|
||||
RemoveSeparatorIfLast(model);
|
||||
|
||||
form.InvokeSafe(() => form.ContextMenuOpen = true);
|
||||
form.InvokeAsyncSafe(() => form.ContextMenuOpen = true);
|
||||
}
|
||||
|
||||
public override bool OnContextMenuCommand(IWebBrowser browserControl, IBrowser browser, IFrame frame, IContextMenuParams parameters, CefMenuCommand commandId, CefEventFlags eventFlags){
|
||||
@@ -54,19 +60,19 @@ namespace TweetDck.Core.Handling{
|
||||
|
||||
switch((int)commandId){
|
||||
case MenuSkipTweet:
|
||||
form.InvokeSafe(form.FinishCurrentTweet);
|
||||
form.InvokeAsyncSafe(form.FinishCurrentNotification);
|
||||
return true;
|
||||
|
||||
case MenuFreeze:
|
||||
form.InvokeSafe(() => form.FreezeTimer = !form.FreezeTimer);
|
||||
form.InvokeAsyncSafe(() => form.FreezeTimer = !form.FreezeTimer);
|
||||
return true;
|
||||
|
||||
case MenuCopyTweetUrl:
|
||||
Clipboard.SetText(form.CurrentUrl, TextDataFormat.UnicodeText);
|
||||
SetClipboardText(form.CurrentUrl);
|
||||
return true;
|
||||
|
||||
case MenuCopyQuotedTweetUrl:
|
||||
Clipboard.SetText(form.CurrentQuotedTweetUrl, TextDataFormat.UnicodeText);
|
||||
SetClipboardText(form.CurrentQuotedTweetUrl);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -75,7 +81,7 @@ namespace TweetDck.Core.Handling{
|
||||
|
||||
public override void OnContextMenuDismissed(IWebBrowser browserControl, IBrowser browser, IFrame frame){
|
||||
base.OnContextMenuDismissed(browserControl, browser, frame);
|
||||
form.InvokeSafe(() => form.ContextMenuOpen = false);
|
||||
form.InvokeAsyncSafe(() => form.ContextMenuOpen = false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Other;
|
||||
@@ -7,30 +8,40 @@ using TweetDck.Core.Other;
|
||||
namespace TweetDck.Core.Handling {
|
||||
class JavaScriptDialogHandler : IJsDialogHandler{
|
||||
bool IJsDialogHandler.OnJSDialog(IWebBrowser browserControl, IBrowser browser, string originUrl, CefJsDialogType dialogType, string messageText, string defaultPromptText, IJsDialogCallback callback, ref bool suppressMessage){
|
||||
if (dialogType != CefJsDialogType.Alert && dialogType != CefJsDialogType.Confirm){
|
||||
return false;
|
||||
}
|
||||
|
||||
((ChromiumWebBrowser)browserControl).InvokeSafe(() => {
|
||||
FormMessage form = new FormMessage(Program.BrandName, messageText, MessageBoxIcon.None);
|
||||
Button btnConfirm;
|
||||
TextBox input = null;
|
||||
|
||||
if (dialogType == CefJsDialogType.Alert){
|
||||
btnConfirm = form.AddButton("OK");
|
||||
form.AcceptButton = form.AddButton("OK");
|
||||
}
|
||||
else if (dialogType == CefJsDialogType.Confirm){
|
||||
form.AddButton("No");
|
||||
btnConfirm = form.AddButton("Yes");
|
||||
form.CancelButton = form.AddButton("No", DialogResult.No);
|
||||
form.AcceptButton = form.AddButton("Yes");
|
||||
}
|
||||
else{
|
||||
return;
|
||||
else if (dialogType == CefJsDialogType.Prompt){
|
||||
form.CancelButton = form.AddButton("Cancel", DialogResult.Cancel);
|
||||
form.AcceptButton = form.AddButton("OK");
|
||||
|
||||
input = new TextBox{
|
||||
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
|
||||
Location = new Point(27, form.ActionPanelY-46),
|
||||
Size = new Size(form.ClientSize.Width-54, 20)
|
||||
};
|
||||
|
||||
form.Controls.Add(input);
|
||||
form.ActiveControl = input;
|
||||
form.Height += input.Size.Height+input.Margin.Vertical;
|
||||
}
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnConfirm){
|
||||
callback.Continue(true);
|
||||
bool success = form.ShowDialog() == DialogResult.OK;
|
||||
|
||||
if (input == null){
|
||||
callback.Continue(success);
|
||||
}
|
||||
else{
|
||||
callback.Continue(false);
|
||||
callback.Continue(success, input.Text);
|
||||
input.Dispose();
|
||||
}
|
||||
|
||||
form.Dispose();
|
||||
|
52
Core/Notification/FormNotificationBase.Designer.cs
generated
Normal file
52
Core/Notification/FormNotificationBase.Designer.cs
generated
Normal file
@@ -0,0 +1,52 @@
|
||||
namespace TweetDck.Core.Notification {
|
||||
partial class FormNotificationBase {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// FormNotification
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.ClientSize = new System.Drawing.Size(284, 122);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Location = TweetDck.Core.Controls.ControlExtensions.InvisibleLocation;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FormNotification";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
}
|
||||
}
|
216
Core/Notification/FormNotificationBase.cs
Normal file
216
Core/Notification/FormNotificationBase.cs
Normal file
@@ -0,0 +1,216 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using CefSharp.WinForms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Handling;
|
||||
using TweetDck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Notification{
|
||||
partial class FormNotificationBase : Form{
|
||||
protected Point PrimaryLocation{
|
||||
get{
|
||||
UserConfig config = Program.UserConfig;
|
||||
Screen screen;
|
||||
|
||||
if (config.NotificationDisplay > 0 && config.NotificationDisplay <= Screen.AllScreens.Length){
|
||||
screen = Screen.AllScreens[config.NotificationDisplay-1];
|
||||
}
|
||||
else{
|
||||
screen = Screen.FromControl(owner);
|
||||
}
|
||||
|
||||
int edgeDist = config.NotificationEdgeDistance;
|
||||
|
||||
switch(config.NotificationPosition){
|
||||
case TweetNotification.Position.TopLeft:
|
||||
return new Point(screen.WorkingArea.X+edgeDist, screen.WorkingArea.Y+edgeDist);
|
||||
|
||||
case TweetNotification.Position.TopRight:
|
||||
return new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+edgeDist);
|
||||
|
||||
case TweetNotification.Position.BottomLeft:
|
||||
return new Point(screen.WorkingArea.X+edgeDist, screen.WorkingArea.Y+screen.WorkingArea.Height-edgeDist-Height);
|
||||
|
||||
case TweetNotification.Position.BottomRight:
|
||||
return new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+screen.WorkingArea.Height-edgeDist-Height);
|
||||
|
||||
case TweetNotification.Position.Custom:
|
||||
if (!config.IsCustomNotificationPositionSet){
|
||||
config.CustomNotificationPosition = new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+edgeDist);
|
||||
config.Save();
|
||||
}
|
||||
|
||||
return config.CustomNotificationPosition;
|
||||
}
|
||||
|
||||
return Location;
|
||||
}
|
||||
}
|
||||
|
||||
public bool IsNotificationVisible{
|
||||
get{
|
||||
return Location != ControlExtensions.InvisibleLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public new Point Location{
|
||||
get{
|
||||
return base.Location;
|
||||
}
|
||||
|
||||
set{
|
||||
Visible = (base.Location = value) != ControlExtensions.InvisibleLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public Func<bool> CanMoveWindow = () => true;
|
||||
|
||||
protected readonly Form owner;
|
||||
protected readonly ChromiumWebBrowser browser;
|
||||
|
||||
private string currentColumn;
|
||||
private int pauseCounter;
|
||||
|
||||
public bool IsPaused{
|
||||
get{
|
||||
return pauseCounter > 0;
|
||||
}
|
||||
}
|
||||
|
||||
protected override bool ShowWithoutActivation{
|
||||
get{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public bool FreezeTimer { get; set; }
|
||||
public bool ContextMenuOpen { get; set; }
|
||||
public string CurrentUrl { get; private set; }
|
||||
public string CurrentQuotedTweetUrl { get; set; }
|
||||
|
||||
public event EventHandler Initialized;
|
||||
|
||||
public FormNotificationBase(Form owner, bool enableContextMenu){
|
||||
InitializeComponent();
|
||||
|
||||
this.owner = owner;
|
||||
this.owner.FormClosed += owner_FormClosed;
|
||||
|
||||
this.browser = new ChromiumWebBrowser("about:blank"){
|
||||
MenuHandler = new ContextMenuNotification(this, enableContextMenu),
|
||||
LifeSpanHandler = new LifeSpanHandler()
|
||||
};
|
||||
|
||||
this.browser.Dock = DockStyle.None;
|
||||
this.browser.ClientSize = ClientSize;
|
||||
|
||||
#if DEBUG
|
||||
this.browser.ConsoleMessage += BrowserUtils.HandleConsoleMessage;
|
||||
#endif
|
||||
|
||||
this.browser.IsBrowserInitializedChanged += Browser_IsBrowserInitializedChanged;
|
||||
|
||||
Controls.Add(browser);
|
||||
|
||||
Disposed += (sender, args) => {
|
||||
this.browser.Dispose();
|
||||
this.owner.FormClosed -= owner_FormClosed;
|
||||
};
|
||||
|
||||
// ReSharper disable once VirtualMemberCallInContructor
|
||||
UpdateTitle();
|
||||
}
|
||||
|
||||
protected override void WndProc(ref Message m){
|
||||
if (m.Msg == 0x0112 && (m.WParam.ToInt32() & 0xFFF0) == 0xF010 && !CanMoveWindow()){ // WM_SYSCOMMAND, SC_MOVE
|
||||
return;
|
||||
}
|
||||
|
||||
base.WndProc(ref m);
|
||||
}
|
||||
|
||||
// event handlers
|
||||
|
||||
private void owner_FormClosed(object sender, FormClosedEventArgs e){
|
||||
Close();
|
||||
}
|
||||
|
||||
private void Browser_IsBrowserInitializedChanged(object sender, IsBrowserInitializedChangedEventArgs e){
|
||||
if (e.IsBrowserInitialized && Initialized != null){
|
||||
Initialized(this, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
// notification methods
|
||||
|
||||
public virtual void HideNotification(bool loadBlank){
|
||||
if (loadBlank){
|
||||
browser.LoadHtml("", "about:blank");
|
||||
}
|
||||
|
||||
Location = ControlExtensions.InvisibleLocation;
|
||||
currentColumn = null;
|
||||
}
|
||||
|
||||
public virtual void FinishCurrentNotification(){}
|
||||
|
||||
public virtual void PauseNotification(){
|
||||
if (pauseCounter++ == 0 && IsNotificationVisible){
|
||||
Location = ControlExtensions.InvisibleLocation;
|
||||
}
|
||||
}
|
||||
|
||||
public virtual void ResumeNotification(){
|
||||
if (pauseCounter > 0){
|
||||
--pauseCounter;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual string GetTweetHTML(TweetNotification tweet){
|
||||
string bodyClasses = browser.Bounds.Contains(PointToClient(Cursor.Position)) ? "td-hover" : string.Empty;
|
||||
return tweet.GenerateHtml(bodyClasses);
|
||||
}
|
||||
|
||||
protected virtual void LoadTweet(TweetNotification tweet){
|
||||
CurrentUrl = tweet.Url;
|
||||
CurrentQuotedTweetUrl = string.Empty; // load from JS
|
||||
currentColumn = tweet.Column;
|
||||
browser.LoadHtml(GetTweetHTML(tweet), "http://tweetdeck.twitter.com/?"+DateTime.Now.Ticks);
|
||||
}
|
||||
|
||||
protected virtual void SetNotificationSize(int width, int height){
|
||||
browser.ClientSize = ClientSize = new Size(width, height);
|
||||
}
|
||||
|
||||
protected void MoveToVisibleLocation(){
|
||||
bool needsReactivating = Location == ControlExtensions.InvisibleLocation;
|
||||
Location = PrimaryLocation;
|
||||
|
||||
if (needsReactivating){
|
||||
NativeMethods.SetFormPos(this, NativeMethods.HWND_TOPMOST, NativeMethods.SWP_NOACTIVATE);
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void OnNotificationReady(){
|
||||
MoveToVisibleLocation();
|
||||
}
|
||||
|
||||
protected virtual void UpdateTitle(){
|
||||
Text = string.IsNullOrEmpty(currentColumn) || !Program.UserConfig.DisplayNotificationColumn ? Program.BrandName : Program.BrandName+" - "+currentColumn;
|
||||
}
|
||||
|
||||
public void DisplayTooltip(string text){
|
||||
if (string.IsNullOrEmpty(text)){
|
||||
toolTip.Hide(this);
|
||||
}
|
||||
else{
|
||||
Point position = PointToClient(Cursor.Position);
|
||||
position.Offset(20, 5);
|
||||
toolTip.Show(text, this, position);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,7 +1,5 @@
|
||||
using TweetDck.Core.Controls;
|
||||
|
||||
namespace TweetDck.Core {
|
||||
partial class FormNotification {
|
||||
namespace TweetDck.Core.Notification {
|
||||
partial class FormNotificationMain {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
@@ -26,22 +24,15 @@ namespace TweetDck.Core {
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.panelBrowser = new System.Windows.Forms.Panel();
|
||||
this.timerDisplayDelay = new System.Windows.Forms.Timer(this.components);
|
||||
this.timerProgress = new System.Windows.Forms.Timer(this.components);
|
||||
this.progressBarTimer = new TweetDck.Core.Controls.FlatProgressBar();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// panelBrowser
|
||||
// timerDisplayDelay
|
||||
//
|
||||
this.panelBrowser.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.panelBrowser.BackColor = System.Drawing.Color.White;
|
||||
this.panelBrowser.Location = new System.Drawing.Point(0, 0);
|
||||
this.panelBrowser.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.panelBrowser.Name = "panelBrowser";
|
||||
this.panelBrowser.Size = new System.Drawing.Size(284, 118);
|
||||
this.panelBrowser.TabIndex = 0;
|
||||
this.timerDisplayDelay.Interval = 17;
|
||||
this.timerDisplayDelay.Tick += new System.EventHandler(this.timerDisplayDelay_Tick);
|
||||
//
|
||||
// timerProgress
|
||||
//
|
||||
@@ -68,15 +59,6 @@ namespace TweetDck.Core {
|
||||
this.BackColor = System.Drawing.SystemColors.Control;
|
||||
this.ClientSize = new System.Drawing.Size(284, 122);
|
||||
this.Controls.Add(this.progressBarTimer);
|
||||
this.Controls.Add(this.panelBrowser);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
|
||||
this.Location = TweetDck.Core.Controls.ControlExtensions.InvisibleLocation;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FormNotification";
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormNotification_FormClosing);
|
||||
this.ResumeLayout(false);
|
||||
|
||||
@@ -84,9 +66,8 @@ namespace TweetDck.Core {
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Panel panelBrowser;
|
||||
private System.Windows.Forms.Timer timerDisplayDelay;
|
||||
protected System.Windows.Forms.Timer timerProgress;
|
||||
private Controls.FlatProgressBar progressBarTimer;
|
||||
private System.Windows.Forms.Timer timerProgress;
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
}
|
||||
}
|
251
Core/Notification/FormNotificationMain.cs
Normal file
251
Core/Notification/FormNotificationMain.cs
Normal file
@@ -0,0 +1,251 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using TweetDck.Core.Bridge;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using TweetDck.Resources;
|
||||
|
||||
namespace TweetDck.Core.Notification{
|
||||
partial class FormNotificationMain : FormNotificationBase{
|
||||
private const string NotificationScriptFile = "notification.js";
|
||||
|
||||
private static readonly string NotificationScriptIdentifier = ScriptLoader.GetRootIdentifier(NotificationScriptFile);
|
||||
private static readonly string PluginScriptIdentifier = ScriptLoader.GetRootIdentifier(PluginManager.PluginNotificationScriptFile);
|
||||
|
||||
private static readonly string NotificationJS, PluginJS;
|
||||
|
||||
static FormNotificationMain(){
|
||||
NotificationJS = ScriptLoader.LoadResource(NotificationScriptFile);
|
||||
PluginJS = ScriptLoader.LoadResource(PluginManager.PluginNotificationScriptFile);
|
||||
}
|
||||
|
||||
private static int BaseClientWidth{
|
||||
get{
|
||||
int level = TweetNotification.FontSizeLevel;
|
||||
return level == 0 ? 284 : (int)Math.Round(284.0*(1.0+0.05*level));
|
||||
}
|
||||
}
|
||||
|
||||
private static int BaseClientHeight{
|
||||
get{
|
||||
int level = TweetNotification.FontSizeLevel;
|
||||
return level == 0 ? 118 : (int)Math.Round(118.0*(1.0+0.075*level));
|
||||
}
|
||||
}
|
||||
|
||||
private readonly PluginManager plugins;
|
||||
|
||||
protected int timeLeft, totalTime;
|
||||
protected bool pausedDuringNotification;
|
||||
|
||||
private readonly NativeMethods.HookProc mouseHookDelegate;
|
||||
private IntPtr mouseHook;
|
||||
|
||||
private bool? prevDisplayTimer;
|
||||
private int? prevFontSize;
|
||||
|
||||
private bool RequiresResize{
|
||||
get{
|
||||
return !prevDisplayTimer.HasValue || !prevFontSize.HasValue || prevDisplayTimer != Program.UserConfig.DisplayNotificationTimer || prevFontSize != TweetNotification.FontSizeLevel;
|
||||
}
|
||||
|
||||
set{
|
||||
if (value){
|
||||
prevDisplayTimer = null;
|
||||
prevFontSize = null;
|
||||
}
|
||||
else{
|
||||
prevDisplayTimer = Program.UserConfig.DisplayNotificationTimer;
|
||||
prevFontSize = TweetNotification.FontSizeLevel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public FormNotificationMain(FormBrowser owner, PluginManager pluginManager, bool enableContextMenu) : base(owner, enableContextMenu){
|
||||
InitializeComponent();
|
||||
|
||||
this.plugins = pluginManager;
|
||||
|
||||
browser.RegisterAsyncJsObject("$TD", new TweetDeckBridge(owner, this));
|
||||
browser.RegisterAsyncJsObject("$TDP", plugins.Bridge);
|
||||
|
||||
browser.LoadingStateChanged += Browser_LoadingStateChanged;
|
||||
browser.FrameLoadEnd += Browser_FrameLoadEnd;
|
||||
|
||||
mouseHookDelegate = MouseHookProc;
|
||||
Disposed += (sender, args) => StopMouseHook();
|
||||
}
|
||||
|
||||
// mouse wheel hook
|
||||
|
||||
private void StartMouseHook(){
|
||||
if (mouseHook == IntPtr.Zero){
|
||||
mouseHook = NativeMethods.SetWindowsHookEx(NativeMethods.WM_MOUSE_LL, mouseHookDelegate, IntPtr.Zero, 0);
|
||||
}
|
||||
}
|
||||
|
||||
private void StopMouseHook(){
|
||||
if (mouseHook != IntPtr.Zero){
|
||||
NativeMethods.UnhookWindowsHookEx(mouseHook);
|
||||
mouseHook = IntPtr.Zero;
|
||||
}
|
||||
}
|
||||
|
||||
private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam){
|
||||
if (wParam.ToInt32() == NativeMethods.WM_MOUSEWHEEL && browser.Bounds.Contains(PointToClient(Cursor.Position)) && !ContainsFocus && !owner.ContainsFocus){
|
||||
browser.SendMouseWheelEvent(0, 0, 0, NativeMethods.GetHookWheelDelta(lParam), CefEventFlags.None);
|
||||
}
|
||||
|
||||
return NativeMethods.CallNextHookEx(mouseHook, nCode, wParam, lParam);
|
||||
}
|
||||
|
||||
// event handlers
|
||||
|
||||
private void FormNotification_FormClosing(object sender, FormClosingEventArgs e){
|
||||
if (e.CloseReason == CloseReason.UserClosing){
|
||||
HideNotification(false);
|
||||
e.Cancel = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void Browser_LoadingStateChanged(object sender, LoadingStateChangedEventArgs e){
|
||||
if (!e.IsLoading && browser.Address != "about:blank"){
|
||||
this.InvokeSafe(() => {
|
||||
Visible = true; // ensures repaint before moving the window to a visible location
|
||||
timerDisplayDelay.Start();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void Browser_FrameLoadEnd(object sender, FrameLoadEndEventArgs e){
|
||||
if (e.Frame.IsMain && NotificationJS != null && browser.Address != "about:blank"){
|
||||
e.Frame.ExecuteJavaScriptAsync(PropertyBridge.GenerateScript(PropertyBridge.Properties.ExpandLinksOnHover));
|
||||
ScriptLoader.ExecuteScript(e.Frame, NotificationJS, NotificationScriptIdentifier);
|
||||
|
||||
if (plugins.HasAnyPlugin(PluginEnvironment.Notification)){
|
||||
ScriptLoader.ExecuteScript(e.Frame, PluginJS, PluginScriptIdentifier);
|
||||
ScriptLoader.ExecuteFile(e.Frame, PluginManager.PluginGlobalScriptFile);
|
||||
plugins.ExecutePlugins(e.Frame, PluginEnvironment.Notification, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void timerDisplayDelay_Tick(object sender, EventArgs e){
|
||||
OnNotificationReady();
|
||||
timerDisplayDelay.Stop();
|
||||
}
|
||||
|
||||
private void timerHideProgress_Tick(object sender, EventArgs e){
|
||||
if (Bounds.Contains(Cursor.Position) || FreezeTimer || ContextMenuOpen)return;
|
||||
|
||||
timeLeft -= timerProgress.Interval;
|
||||
|
||||
int value = (int)Math.Round(1025.0*(totalTime-timeLeft)/totalTime);
|
||||
progressBarTimer.SetValueInstant(Math.Min(1000, Math.Max(0, Program.UserConfig.NotificationTimerCountDown ? 1000-value : value)));
|
||||
|
||||
if (timeLeft <= 0){
|
||||
FinishCurrentNotification();
|
||||
}
|
||||
}
|
||||
|
||||
// notification methods
|
||||
|
||||
public virtual void ShowNotification(TweetNotification notification){
|
||||
LoadTweet(notification);
|
||||
}
|
||||
|
||||
public void ShowNotificationForSettings(bool reset){
|
||||
if (reset){
|
||||
LoadTweet(TweetNotification.ExampleTweet);
|
||||
}
|
||||
else{
|
||||
PrepareAndDisplayWindow();
|
||||
}
|
||||
|
||||
UpdateTitle();
|
||||
}
|
||||
|
||||
public override void HideNotification(bool loadBlank){
|
||||
base.HideNotification(loadBlank);
|
||||
|
||||
progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? 1000 : 0;
|
||||
timerProgress.Stop();
|
||||
totalTime = 0;
|
||||
|
||||
StopMouseHook();
|
||||
}
|
||||
|
||||
public override void FinishCurrentNotification(){
|
||||
timerProgress.Stop();
|
||||
}
|
||||
|
||||
public override void PauseNotification(){
|
||||
if (!IsPaused){
|
||||
pausedDuringNotification = IsNotificationVisible;
|
||||
timerProgress.Stop();
|
||||
StopMouseHook();
|
||||
}
|
||||
|
||||
base.PauseNotification();
|
||||
}
|
||||
|
||||
public override void ResumeNotification(){
|
||||
bool wasPaused = IsPaused;
|
||||
base.ResumeNotification();
|
||||
|
||||
if (wasPaused && !IsPaused && pausedDuringNotification){
|
||||
OnNotificationReady();
|
||||
}
|
||||
}
|
||||
|
||||
protected override string GetTweetHTML(TweetNotification tweet){
|
||||
string html = base.GetTweetHTML(tweet);
|
||||
|
||||
foreach(InjectedHTML injection in plugins.Bridge.NotificationInjections){
|
||||
html = injection.Inject(html);
|
||||
}
|
||||
|
||||
return html;
|
||||
}
|
||||
|
||||
protected override void LoadTweet(TweetNotification tweet){
|
||||
timerProgress.Stop();
|
||||
totalTime = timeLeft = tweet.GetDisplayDuration(Program.UserConfig.NotificationDurationValue);
|
||||
progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? 1000 : 0;
|
||||
|
||||
base.LoadTweet(tweet);
|
||||
}
|
||||
|
||||
protected override void SetNotificationSize(int width, int height){
|
||||
if (Program.UserConfig.DisplayNotificationTimer){
|
||||
ClientSize = new Size(width, height+4);
|
||||
progressBarTimer.Visible = true;
|
||||
}
|
||||
else{
|
||||
ClientSize = new Size(width, height);
|
||||
progressBarTimer.Visible = false;
|
||||
}
|
||||
|
||||
browser.ClientSize = new Size(width, height);
|
||||
}
|
||||
|
||||
private void PrepareAndDisplayWindow(){
|
||||
if (RequiresResize){
|
||||
RequiresResize = false;
|
||||
SetNotificationSize(BaseClientWidth, BaseClientHeight);
|
||||
}
|
||||
|
||||
MoveToVisibleLocation();
|
||||
StartMouseHook();
|
||||
}
|
||||
|
||||
protected override void OnNotificationReady(){
|
||||
PrepareAndDisplayWindow();
|
||||
timerProgress.Start();
|
||||
}
|
||||
}
|
||||
}
|
59
Core/Notification/FormNotificationTweet.Designer.cs
generated
Normal file
59
Core/Notification/FormNotificationTweet.Designer.cs
generated
Normal file
@@ -0,0 +1,59 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace TweetDck.Core.Notification {
|
||||
partial class FormNotificationTweet {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.timerCursorCheck = new System.Windows.Forms.Timer(this.components);
|
||||
this.timerIdlePauseCheck = new System.Windows.Forms.Timer(this.components);
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// timerCursorCheck
|
||||
//
|
||||
this.timerCursorCheck.Interval = 200;
|
||||
this.timerCursorCheck.Tick += new System.EventHandler(this.timerCursorCheck_Tick);
|
||||
//
|
||||
// timerIdlePauseCheck
|
||||
//
|
||||
this.timerIdlePauseCheck.Interval = 750;
|
||||
this.timerIdlePauseCheck.Tick += new System.EventHandler(this.timerIdlePauseCheck_Tick);
|
||||
//
|
||||
// FormNotificationTweet
|
||||
//
|
||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormNotificationTweet_FormClosing);
|
||||
this.ResumeLayout(true);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Timer timerCursorCheck;
|
||||
private System.Windows.Forms.Timer timerIdlePauseCheck;
|
||||
}
|
||||
}
|
132
Core/Notification/FormNotificationTweet.cs
Normal file
132
Core/Notification/FormNotificationTweet.cs
Normal file
@@ -0,0 +1,132 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using TweetDck.Plugins;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Notification{
|
||||
sealed partial class FormNotificationTweet : FormNotificationMain{
|
||||
private const int NonIntrusiveIdleLimit = 30;
|
||||
|
||||
private bool IsCursorOverNotificationArea{
|
||||
get{
|
||||
return new Rectangle(PrimaryLocation, Size).Contains(Cursor.Position);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Queue<TweetNotification> tweetQueue = new Queue<TweetNotification>(4);
|
||||
|
||||
public FormNotificationTweet(FormBrowser owner, PluginManager pluginManager) : base(owner, pluginManager, true){
|
||||
InitializeComponent();
|
||||
|
||||
Program.UserConfig.MuteToggled += Config_MuteToggled;
|
||||
Disposed += (sender, args) => Program.UserConfig.MuteToggled -= Config_MuteToggled;
|
||||
|
||||
if (Program.UserConfig.MuteNotifications){
|
||||
PauseNotification();
|
||||
}
|
||||
}
|
||||
|
||||
private void FormNotificationTweet_FormClosing(object sender, FormClosingEventArgs e){
|
||||
if (e.CloseReason == CloseReason.UserClosing){
|
||||
tweetQueue.Clear(); // already canceled
|
||||
}
|
||||
}
|
||||
|
||||
// event handlers
|
||||
|
||||
private void Config_MuteToggled(object sender, EventArgs e){
|
||||
if (Program.UserConfig.MuteNotifications){
|
||||
PauseNotification();
|
||||
}
|
||||
else{
|
||||
ResumeNotification();
|
||||
}
|
||||
}
|
||||
|
||||
private void timerCursorCheck_Tick(object sender, EventArgs e){
|
||||
if (!IsCursorOverNotificationArea){
|
||||
ResumeNotification();
|
||||
timerCursorCheck.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
private void timerIdlePauseCheck_Tick(object sender, EventArgs e){
|
||||
if (NativeMethods.GetIdleSeconds() < Program.UserConfig.NotificationIdlePauseSeconds){
|
||||
ResumeNotification();
|
||||
timerIdlePauseCheck.Stop();
|
||||
}
|
||||
}
|
||||
|
||||
// notification methods
|
||||
|
||||
public override void ShowNotification(TweetNotification notification){
|
||||
if (IsPaused){
|
||||
tweetQueue.Enqueue(notification);
|
||||
}
|
||||
else{
|
||||
tweetQueue.Enqueue(notification);
|
||||
UpdateTitle();
|
||||
|
||||
if (totalTime == 0){
|
||||
LoadNextNotification();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void FinishCurrentNotification(){
|
||||
if (tweetQueue.Count > 0){
|
||||
LoadNextNotification();
|
||||
}
|
||||
else{
|
||||
HideNotification(true);
|
||||
}
|
||||
}
|
||||
|
||||
public override void ResumeNotification(){
|
||||
bool wasPaused = IsPaused;
|
||||
base.ResumeNotification();
|
||||
|
||||
if (wasPaused && !IsPaused && !pausedDuringNotification && tweetQueue.Count > 0){
|
||||
LoadNextNotification();
|
||||
}
|
||||
}
|
||||
|
||||
private void LoadNextNotification(){
|
||||
if (!IsNotificationVisible){
|
||||
if (Program.UserConfig.NotificationNonIntrusiveMode && IsCursorOverNotificationArea && NativeMethods.GetIdleSeconds() < NonIntrusiveIdleLimit){
|
||||
if (!timerCursorCheck.Enabled){
|
||||
PauseNotification();
|
||||
timerCursorCheck.Start();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
else if (Program.UserConfig.NotificationIdlePauseSeconds > 0 && NativeMethods.GetIdleSeconds() >= Program.UserConfig.NotificationIdlePauseSeconds){
|
||||
if (!timerIdlePauseCheck.Enabled){
|
||||
PauseNotification();
|
||||
timerIdlePauseCheck.Start();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
LoadTweet(tweetQueue.Dequeue());
|
||||
}
|
||||
|
||||
protected override void UpdateTitle(){
|
||||
base.UpdateTitle();
|
||||
|
||||
if (tweetQueue.Count > 0){
|
||||
Text = Text+" ("+tweetQueue.Count+" more left)";
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnNotificationReady(){
|
||||
UpdateTitle();
|
||||
base.OnNotificationReady();
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,12 +0,0 @@
|
||||
using System;
|
||||
|
||||
namespace TweetDck.Core.Notification{
|
||||
[Flags]
|
||||
public enum NotificationFlags{
|
||||
None = 0,
|
||||
AutoHide = 1,
|
||||
DisableScripts = 2,
|
||||
DisableContextMenu = 4,
|
||||
TopMost = 8
|
||||
}
|
||||
}
|
@@ -4,40 +4,44 @@ using CefSharp;
|
||||
using TweetDck.Core.Bridge;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Resources;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Imaging;
|
||||
using TweetDck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Notification.Screenshot{
|
||||
sealed class FormNotificationScreenshotable : FormNotification{
|
||||
public FormNotificationScreenshotable(FormBrowser owner, NotificationFlags flags) : base(owner, null, flags){
|
||||
UpdateTitle();
|
||||
}
|
||||
|
||||
public void PrepareNotificationForScreenshot(Action callback){
|
||||
sealed class FormNotificationScreenshotable : FormNotificationBase{
|
||||
public FormNotificationScreenshotable(Action callback, Form owner) : base(owner, false){
|
||||
browser.RegisterAsyncJsObject("$TD_NotificationScreenshot", new CallbackBridge(this, callback));
|
||||
|
||||
browser.FrameLoadEnd += (sender, args) => {
|
||||
if (args.Frame.IsMain && browser.Address != "about:blank"){
|
||||
ScriptLoader.ExecuteScript(args.Frame, "window.setTimeout(() => $TD_NotificationScreenshot.trigger(), 25)", "gen:screenshot");
|
||||
ScriptLoader.ExecuteScript(args.Frame, "window.setTimeout($TD_NotificationScreenshot.trigger, 67)", "gen:screenshot");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public void LoadNotificationForScreenshot(TweetNotification tweet, int width, int height){
|
||||
browser.LoadHtml(tweet.GenerateHtml(enableCustomCSS: false), "http://tweetdeck.twitter.com/?"+DateTime.Now.Ticks);
|
||||
|
||||
Location = ControlExtensions.InvisibleLocation;
|
||||
SetNotificationSize(width, height, false);
|
||||
SetNotificationSize(width, height);
|
||||
}
|
||||
|
||||
public void TakeScreenshotAndHide(){
|
||||
MoveToVisibleLocation();
|
||||
Activate();
|
||||
SendKeys.SendWait("%{PRTSC}");
|
||||
Reset();
|
||||
}
|
||||
public void TakeScreenshot(){
|
||||
IntPtr context = NativeMethods.GetDC(this.Handle);
|
||||
|
||||
public void Reset(){
|
||||
Location = ControlExtensions.InvisibleLocation;
|
||||
browser.LoadHtml("", "about:blank");
|
||||
if (context == IntPtr.Zero){
|
||||
MessageBox.Show("Could not retrieve a graphics context handle for the notification window to take the screenshot.", "Screenshot Failed", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
else{
|
||||
using(Bitmap bmp = new Bitmap(ClientSize.Width, ClientSize.Height, PixelFormat.Format32bppRgb)){
|
||||
try{
|
||||
NativeMethods.RenderSourceIntoBitmap(context, bmp);
|
||||
}finally{
|
||||
NativeMethods.ReleaseDC(this.Handle, context);
|
||||
}
|
||||
|
||||
Clipboard.SetImage(bmp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,30 +1,50 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
// Uncomment to keep screenshot windows visible for debugging
|
||||
// #define NO_HIDE_SCREENSHOTS
|
||||
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Notification.Screenshot{
|
||||
sealed class TweetScreenshotManager : IDisposable{
|
||||
private readonly FormBrowser browser;
|
||||
private readonly FormNotificationScreenshotable screenshot;
|
||||
private readonly Form owner;
|
||||
private readonly Timer timeout;
|
||||
private readonly Timer disposer;
|
||||
|
||||
private FormNotificationScreenshotable screenshot;
|
||||
|
||||
public TweetScreenshotManager(FormBrowser browser){
|
||||
this.browser = browser;
|
||||
public TweetScreenshotManager(Form owner){
|
||||
this.owner = owner;
|
||||
|
||||
this.screenshot = new FormNotificationScreenshotable(browser, NotificationFlags.DisableScripts | NotificationFlags.DisableContextMenu | NotificationFlags.TopMost){
|
||||
CanMoveWindow = () => false
|
||||
};
|
||||
this.timeout = new Timer{ Interval = 5000 };
|
||||
this.timeout.Tick += timeout_Tick;
|
||||
|
||||
this.screenshot.PrepareNotificationForScreenshot(Callback);
|
||||
this.disposer = new Timer{ Interval = 1 };
|
||||
this.disposer.Tick += disposer_Tick;
|
||||
}
|
||||
|
||||
this.timeout = WindowsUtils.CreateSingleTickTimer(10000);
|
||||
this.timeout.Tick += (sender, args) => screenshot.Reset();
|
||||
private void timeout_Tick(object sender, EventArgs e){
|
||||
timeout.Stop();
|
||||
screenshot.Location = ControlExtensions.InvisibleLocation;
|
||||
disposer.Start();
|
||||
}
|
||||
|
||||
private void disposer_Tick(object sender, EventArgs e){
|
||||
disposer.Stop();
|
||||
screenshot.Dispose();
|
||||
screenshot = null;
|
||||
}
|
||||
|
||||
public void Trigger(string html, int width, int height){
|
||||
screenshot.LoadNotificationForScreenshot(new TweetNotification(html, string.Empty, 0), width, height);
|
||||
if (screenshot != null){
|
||||
return;
|
||||
}
|
||||
|
||||
screenshot = new FormNotificationScreenshotable(Callback, owner){
|
||||
CanMoveWindow = () => false
|
||||
};
|
||||
|
||||
screenshot.LoadNotificationForScreenshot(new TweetNotification(string.Empty, html, string.Empty, 0), width, height);
|
||||
screenshot.Show();
|
||||
timeout.Start();
|
||||
}
|
||||
@@ -35,15 +55,23 @@ namespace TweetDck.Core.Notification.Screenshot{
|
||||
}
|
||||
|
||||
timeout.Stop();
|
||||
screenshot.TakeScreenshot();
|
||||
|
||||
browser.PauseNotification();
|
||||
screenshot.TakeScreenshotAndHide();
|
||||
browser.ResumeNotification();
|
||||
#if !(DEBUG && NO_HIDE_SCREENSHOTS)
|
||||
screenshot.Location = ControlExtensions.InvisibleLocation;
|
||||
disposer.Start();
|
||||
#else
|
||||
screenshot.FormClosed += (sender, args) => disposer.Start();
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Dispose(){
|
||||
timeout.Dispose();
|
||||
screenshot.Dispose();
|
||||
disposer.Dispose();
|
||||
|
||||
if (screenshot != null){
|
||||
screenshot.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
Core/Notification/Sound/ISoundNotificationPlayer.cs
Normal file
12
Core/Notification/Sound/ISoundNotificationPlayer.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using System;
|
||||
|
||||
namespace TweetDck.Core.Notification.Sound{
|
||||
interface ISoundNotificationPlayer : IDisposable{
|
||||
string SupportedFormats { get; }
|
||||
|
||||
event EventHandler<PlaybackErrorEventArgs> PlaybackError;
|
||||
|
||||
void Play(string file);
|
||||
void Stop();
|
||||
}
|
||||
}
|
13
Core/Notification/Sound/PlaybackErrorEventArgs.cs
Normal file
13
Core/Notification/Sound/PlaybackErrorEventArgs.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using System;
|
||||
|
||||
namespace TweetDck.Core.Notification.Sound{
|
||||
sealed class PlaybackErrorEventArgs : EventArgs{
|
||||
public string Message { get; private set; }
|
||||
public bool Ignore { get; set; }
|
||||
|
||||
public PlaybackErrorEventArgs(string message){
|
||||
this.Message = message;
|
||||
this.Ignore = false;
|
||||
}
|
||||
}
|
||||
}
|
57
Core/Notification/Sound/SoundPlayerImplFallback.cs
Normal file
57
Core/Notification/Sound/SoundPlayerImplFallback.cs
Normal file
@@ -0,0 +1,57 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Media;
|
||||
|
||||
namespace TweetDck.Core.Notification.Sound{
|
||||
sealed class SoundPlayerImplFallback : ISoundNotificationPlayer{
|
||||
string ISoundNotificationPlayer.SupportedFormats{
|
||||
get{
|
||||
return "*.wav";
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<PlaybackErrorEventArgs> PlaybackError;
|
||||
|
||||
private readonly SoundPlayer player;
|
||||
private bool ignorePlaybackError;
|
||||
|
||||
public SoundPlayerImplFallback(){
|
||||
player = new SoundPlayer{
|
||||
LoadTimeout = 5000
|
||||
};
|
||||
}
|
||||
|
||||
void ISoundNotificationPlayer.Play(string file){
|
||||
if (player.SoundLocation != file){
|
||||
player.SoundLocation = file;
|
||||
ignorePlaybackError = false;
|
||||
}
|
||||
|
||||
try{
|
||||
player.Play();
|
||||
}catch(FileNotFoundException e){
|
||||
OnNotificationSoundError("File not found: "+e.FileName);
|
||||
}catch(InvalidOperationException){
|
||||
OnNotificationSoundError("File format was not recognized.");
|
||||
}catch(TimeoutException){
|
||||
OnNotificationSoundError("File took too long to load.");
|
||||
}
|
||||
}
|
||||
|
||||
void ISoundNotificationPlayer.Stop(){
|
||||
player.Stop();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose(){
|
||||
player.Dispose();
|
||||
}
|
||||
|
||||
private void OnNotificationSoundError(string message){
|
||||
if (!ignorePlaybackError && PlaybackError != null){
|
||||
PlaybackErrorEventArgs args = new PlaybackErrorEventArgs(message);
|
||||
PlaybackError(this, args);
|
||||
ignorePlaybackError = args.Ignore;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
109
Core/Notification/Sound/SoundPlayerImplWMP.cs
Normal file
109
Core/Notification/Sound/SoundPlayerImplWMP.cs
Normal file
@@ -0,0 +1,109 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using TweetDck.Core.Utils;
|
||||
using WMPLib;
|
||||
|
||||
namespace TweetDck.Core.Notification.Sound{
|
||||
sealed class SoundPlayerImplWMP : ISoundNotificationPlayer{
|
||||
string ISoundNotificationPlayer.SupportedFormats{
|
||||
get{
|
||||
return "*.wav;*.mp3;*.mp2;*.m4a;*.mid;*.midi;*.rmi;*.wma;*.aif;*.aifc;*.aiff;*.snd;*.au";
|
||||
}
|
||||
}
|
||||
|
||||
public event EventHandler<PlaybackErrorEventArgs> PlaybackError;
|
||||
|
||||
private readonly WindowsMediaPlayer player;
|
||||
private bool wasTryingToPlay;
|
||||
private bool ignorePlaybackError;
|
||||
|
||||
// changing the player volume also affects the value in the Windows mixer
|
||||
// however, the initial value is always 50 or some other stupid shit
|
||||
// so we have to tell the player to set its volume to whatever the mixer is set to
|
||||
// using the most code required for the least functionality with a sorry excuse for an API
|
||||
// thanks, Microsoft
|
||||
|
||||
public SoundPlayerImplWMP(){
|
||||
player = new WindowsMediaPlayer();
|
||||
player.settings.autoStart = false;
|
||||
player.settings.enableErrorDialogs = false;
|
||||
player.settings.invokeURLs = false;
|
||||
player.settings.volume = (int)Math.Floor(100.0*NativeCoreAudio.GetMixerVolumeForCurrentProcess());
|
||||
player.MediaChange += player_MediaChange;
|
||||
player.MediaError += player_MediaError;
|
||||
}
|
||||
|
||||
void ISoundNotificationPlayer.Play(string file){
|
||||
wasTryingToPlay = true;
|
||||
|
||||
if (player.URL != file){
|
||||
player.close();
|
||||
player.URL = file;
|
||||
ignorePlaybackError = false;
|
||||
}
|
||||
else{
|
||||
player.controls.stop();
|
||||
}
|
||||
|
||||
player.controls.play();
|
||||
}
|
||||
|
||||
void ISoundNotificationPlayer.Stop(){
|
||||
player.controls.stop();
|
||||
}
|
||||
|
||||
void IDisposable.Dispose(){
|
||||
player.close();
|
||||
Marshal.ReleaseComObject(player);
|
||||
}
|
||||
|
||||
private void player_MediaChange(object item){
|
||||
IWMPMedia2 media = item as IWMPMedia2;
|
||||
|
||||
if (media == null){
|
||||
OnNotificationSoundError("Unknown error.");
|
||||
return;
|
||||
}
|
||||
// ReSharper disable once CompareOfFloatsByEqualityOperator
|
||||
else if (media.Error == null && media.duration == 0.0){
|
||||
OnNotificationSoundError("File does not contain an audio track.");
|
||||
}
|
||||
else if (media.Error != null){
|
||||
OnNotificationSoundError(media.Error);
|
||||
}
|
||||
|
||||
Marshal.ReleaseComObject(media);
|
||||
}
|
||||
|
||||
private void player_MediaError(object pMediaObject){
|
||||
IWMPMedia2 media = pMediaObject as IWMPMedia2;
|
||||
|
||||
if (media == null){
|
||||
OnNotificationSoundError("Unknown error.");
|
||||
return;
|
||||
}
|
||||
else if (media.Error != null){
|
||||
OnNotificationSoundError(media.Error);
|
||||
}
|
||||
|
||||
Marshal.ReleaseComObject(media);
|
||||
}
|
||||
|
||||
private void OnNotificationSoundError(IWMPErrorItem error){
|
||||
OnNotificationSoundError(error.errorCode == -1072885353 ? "Invalid media file." : error.errorDescription);
|
||||
Marshal.ReleaseComObject(error);
|
||||
}
|
||||
|
||||
private void OnNotificationSoundError(string message){
|
||||
if (wasTryingToPlay){
|
||||
wasTryingToPlay = false;
|
||||
|
||||
if (!ignorePlaybackError && PlaybackError != null){
|
||||
PlaybackErrorEventArgs args = new PlaybackErrorEventArgs(message);
|
||||
PlaybackError(this, args);
|
||||
ignorePlaybackError = args.Ignore;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
28
Core/Notification/SoundNotification.cs
Normal file
28
Core/Notification/SoundNotification.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using System.Runtime.InteropServices;
|
||||
using TweetDck.Core.Notification.Sound;
|
||||
|
||||
namespace TweetDck.Core.Notification{
|
||||
static class SoundNotification{
|
||||
private static bool? IsWMPAvailable;
|
||||
|
||||
public static ISoundNotificationPlayer New(){
|
||||
if (IsWMPAvailable.HasValue){
|
||||
if (IsWMPAvailable.Value){
|
||||
return new SoundPlayerImplWMP();
|
||||
}
|
||||
else{
|
||||
return new SoundPlayerImplFallback();
|
||||
}
|
||||
}
|
||||
|
||||
try{
|
||||
SoundPlayerImplWMP implWMP = new SoundPlayerImplWMP();
|
||||
IsWMPAvailable = true;
|
||||
return implWMP;
|
||||
}catch(COMException){
|
||||
IsWMPAvailable = false;
|
||||
return new SoundPlayerImplFallback();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Text;
|
||||
using TweetDck.Resources;
|
||||
|
||||
namespace TweetDck.Core.Notification{
|
||||
sealed class TweetNotification{
|
||||
@@ -8,9 +9,7 @@ namespace TweetDck.Core.Notification{
|
||||
|
||||
private const string DefaultFontSizeClass = "medium";
|
||||
private const string DefaultHeadTag = @"<meta charset='utf-8'><meta http-equiv='X-UA-Compatible' content='chrome=1'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/font.5ef884f9f9.css'><link rel='stylesheet' href='https://ton.twimg.com/tweetdeck-web/web/css/app-dark.5631e0dd42.css'>";
|
||||
|
||||
private const string FixedCSS = @"a[data-full-url]{word-break:break-all}.txt-base-smallest .badge-verified:before{height:13px!important}";
|
||||
private const string CustomCSS = @".scroll-styled-v::-webkit-scrollbar{width:8px}.scroll-styled-v::-webkit-scrollbar-thumb{border-radius:0}#td-skip{opacity:0;cursor:pointer;transition:opacity 0.15s ease}.td-hover #td-skip{opacity:0.75}#td-skip:hover{opacity:1}";
|
||||
private const string CustomCSS = @"body:before{content:none}body{overflow-y:auto}.scroll-styled-v::-webkit-scrollbar{width:7px}.scroll-styled-v::-webkit-scrollbar-thumb{border-radius:0}.scroll-styled-v::-webkit-scrollbar-track{border-left:0}#td-skip{opacity:0;cursor:pointer;transition:opacity 0.15s ease}.td-hover #td-skip{opacity:0.75}#td-skip:hover{opacity:1}";
|
||||
|
||||
public static int FontSizeLevel{
|
||||
get{
|
||||
@@ -24,26 +23,19 @@ namespace TweetDck.Core.Notification{
|
||||
}
|
||||
}
|
||||
|
||||
private static string ExampleTweetHTML;
|
||||
|
||||
public static TweetNotification ExampleTweet{
|
||||
get{
|
||||
StringBuilder build = new StringBuilder();
|
||||
build.Append(@"<article><div class='js-stream-item-content item-box js-show-detail'><div class='js-tweet tweet'>");
|
||||
build.Append(@"<header class='tweet-header'>");
|
||||
build.Append(@"<time class='tweet-timestamp js-timestamp pull-right txt-mute'><a target='_blank' rel='url' href='https://twitter.com/chylexmc' class='txt-small'>0s</a></time>");
|
||||
build.Append(@"<a target='_blank' rel='user' href='https://twitter.com/chylexmc' class='account-link link-complex block'>");
|
||||
build.Append(@"<div class='obj-left item-img tweet-img'><img width='48' height='48' alt='chylexmc's avatar' src='https://pbs.twimg.com/profile_images/765161905312980992/AhDP9iY-_normal.jpg' class='tweet-avatar avatar pull-right'></div>");
|
||||
build.Append(@"<div class='nbfc'><span class='account-inline txt-ellipsis'><b class='fullname link-complex-target'>chylex</b> <span class='username txt-mute'>@chylexmc</span></span></div>");
|
||||
build.Append(@"</a>");
|
||||
build.Append(@"</header>");
|
||||
build.Append(@"<div class='tweet-body'><p class='js-tweet-text tweet-text with-linebreaks'>This is an example tweet, which lets you test the location and duration of popup notifications.</p></div>");
|
||||
|
||||
#if DEBUG
|
||||
build.Append(@"<div style='margin-top:64px'>Scrollbar test padding...</div>");
|
||||
#endif
|
||||
if (ExampleTweetHTML == null){
|
||||
ExampleTweetHTML = ScriptLoader.LoadResource("pages/example.html", true);
|
||||
|
||||
build.Append(@"</div></div></article>");
|
||||
#if DEBUG
|
||||
ExampleTweetHTML = ExampleTweetHTML.Replace("</p>", @"</p><div style='margin-top:64px'>Scrollbar test padding...</div>");
|
||||
#endif
|
||||
}
|
||||
|
||||
return new TweetNotification(build.ToString(), "", 95, true);
|
||||
return new TweetNotification("Home", ExampleTweetHTML, "", 95, true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,8 +51,10 @@ namespace TweetDck.Core.Notification{
|
||||
TopLeft, TopRight, BottomLeft, BottomRight, Custom
|
||||
}
|
||||
|
||||
public enum Duration{
|
||||
Short, Medium, Long, VeryLong
|
||||
public string Column{
|
||||
get{
|
||||
return column;
|
||||
}
|
||||
}
|
||||
|
||||
public string Url{
|
||||
@@ -69,14 +63,16 @@ namespace TweetDck.Core.Notification{
|
||||
}
|
||||
}
|
||||
|
||||
private readonly string column;
|
||||
private readonly string html;
|
||||
private readonly string url;
|
||||
private readonly int characters;
|
||||
private readonly bool isExample;
|
||||
|
||||
public TweetNotification(string html, string url, int characters) : this(html, url, characters, false){}
|
||||
public TweetNotification(string column, string html, string url, int characters) : this(column, html, url, characters, false){}
|
||||
|
||||
private TweetNotification(string html, string url, int characters, bool isExample){
|
||||
private TweetNotification(string column, string html, string url, int characters, bool isExample){
|
||||
this.column = column;
|
||||
this.html = html;
|
||||
this.url = url;
|
||||
this.characters = characters;
|
||||
@@ -94,26 +90,23 @@ namespace TweetDck.Core.Notification{
|
||||
build.Append("<head>").Append(HeadTag ?? DefaultHeadTag);
|
||||
|
||||
if (enableCustomCSS){
|
||||
build.Append("<style type='text/css'>").Append(FixedCSS).Append(CustomCSS).Append("</style>");
|
||||
build.Append("<style type='text/css'>").Append(CustomCSS).Append("</style>");
|
||||
|
||||
if (!string.IsNullOrEmpty(Program.UserConfig.CustomNotificationCSS)){
|
||||
build.Append("<style type='text/css'>").Append(Program.UserConfig.CustomNotificationCSS).Append("</style>");
|
||||
}
|
||||
}
|
||||
else{
|
||||
build.Append("<style type='text/css'>").Append(FixedCSS).Append("</style>");
|
||||
}
|
||||
|
||||
build.Append("</head>");
|
||||
build.Append("<body class='hearty");
|
||||
build.Append("<body class='hearty scroll-styled-v");
|
||||
|
||||
if (!string.IsNullOrEmpty(bodyClasses)){
|
||||
build.Append(' ').Append(bodyClasses);
|
||||
}
|
||||
|
||||
build.Append('\'').Append(isExample ? " td-example-notification" : "").Append("><div class='app-columns-container'><div class='column scroll-styled-v' style='width:100%;overflow-y:auto'>");
|
||||
build.Append('\'').Append(isExample ? " td-example-notification" : "").Append("><div class='column' style='width:100%;height:auto;overflow:initial;'>");
|
||||
build.Append(html);
|
||||
build.Append("</div></div></body>");
|
||||
build.Append("</div></body>");
|
||||
build.Append("</html>");
|
||||
return build.ToString();
|
||||
}
|
||||
|
13
Core/Other/FormAbout.Designer.cs
generated
13
Core/Other/FormAbout.Designer.cs
generated
@@ -57,7 +57,7 @@ namespace TweetDck.Core.Other {
|
||||
this.labelDescription.Location = new System.Drawing.Point(114, 12);
|
||||
this.labelDescription.Name = "labelDescription";
|
||||
this.labelDescription.Size = new System.Drawing.Size(232, 109);
|
||||
this.labelDescription.TabIndex = 1;
|
||||
this.labelDescription.TabIndex = 0;
|
||||
//
|
||||
// labelTips
|
||||
//
|
||||
@@ -68,7 +68,8 @@ namespace TweetDck.Core.Other {
|
||||
this.labelTips.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.labelTips.Name = "labelTips";
|
||||
this.labelTips.Size = new System.Drawing.Size(99, 16);
|
||||
this.labelTips.TabIndex = 3;
|
||||
this.labelTips.TabIndex = 1;
|
||||
this.labelTips.TabStop = true;
|
||||
this.labelTips.Text = "Tips && Tricks";
|
||||
this.labelTips.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
this.labelTips.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnLinkClicked);
|
||||
@@ -83,7 +84,8 @@ namespace TweetDck.Core.Other {
|
||||
this.labelWebsite.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.labelWebsite.Name = "labelWebsite";
|
||||
this.labelWebsite.Size = new System.Drawing.Size(117, 16);
|
||||
this.labelWebsite.TabIndex = 2;
|
||||
this.labelWebsite.TabIndex = 0;
|
||||
this.labelWebsite.TabStop = true;
|
||||
this.labelWebsite.Text = "Official Website";
|
||||
this.labelWebsite.TextAlign = System.Drawing.ContentAlignment.MiddleLeft;
|
||||
this.labelWebsite.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnLinkClicked);
|
||||
@@ -104,7 +106,7 @@ namespace TweetDck.Core.Other {
|
||||
this.tablePanelLinks.RowCount = 1;
|
||||
this.tablePanelLinks.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tablePanelLinks.Size = new System.Drawing.Size(334, 16);
|
||||
this.tablePanelLinks.TabIndex = 4;
|
||||
this.tablePanelLinks.TabIndex = 1;
|
||||
//
|
||||
// labelIssues
|
||||
//
|
||||
@@ -115,7 +117,8 @@ namespace TweetDck.Core.Other {
|
||||
this.labelIssues.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.labelIssues.Name = "labelIssues";
|
||||
this.labelIssues.Size = new System.Drawing.Size(118, 16);
|
||||
this.labelIssues.TabIndex = 4;
|
||||
this.labelIssues.TabIndex = 2;
|
||||
this.labelIssues.TabStop = true;
|
||||
this.labelIssues.Text = "Report an Issue";
|
||||
this.labelIssues.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
|
||||
this.labelIssues.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.OnLinkClicked);
|
||||
|
@@ -19,7 +19,7 @@ namespace TweetDck.Core.Other{
|
||||
}
|
||||
|
||||
private void OnLinkClicked(object sender, LinkLabelLinkClickedEventArgs e){
|
||||
BrowserUtils.OpenExternalBrowser(e.Link.LinkData as string);
|
||||
BrowserUtils.OpenExternalBrowserUnsafe(e.Link.LinkData as string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
3
Core/Other/FormMessage.Designer.cs
generated
3
Core/Other/FormMessage.Designer.cs
generated
@@ -33,7 +33,7 @@
|
||||
this.panelActions.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.panelActions.Location = new System.Drawing.Point(0, 84);
|
||||
this.panelActions.Name = "panelActions";
|
||||
this.panelActions.Size = new System.Drawing.Size(233, 49);
|
||||
this.panelActions.Size = new System.Drawing.Size(98, 49);
|
||||
this.panelActions.TabIndex = 0;
|
||||
//
|
||||
// labelMessage
|
||||
@@ -66,6 +66,7 @@
|
||||
this.Name = "FormMessage";
|
||||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.SizeChanged += new System.EventHandler(this.FormMessage_SizeChanged);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
|
@@ -6,6 +6,22 @@ namespace TweetDck.Core.Other{
|
||||
sealed partial class FormMessage : Form{
|
||||
public Button ClickedButton { get; private set; }
|
||||
|
||||
public int ActionPanelY{
|
||||
get{
|
||||
return panelActions.Location.Y;
|
||||
}
|
||||
}
|
||||
|
||||
private int ClientWidth{
|
||||
get{
|
||||
return ClientSize.Width;
|
||||
}
|
||||
|
||||
set{
|
||||
ClientSize = new Size(value, ClientSize.Height);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly Icon icon;
|
||||
private readonly bool isReady;
|
||||
|
||||
@@ -19,7 +35,7 @@ namespace TweetDck.Core.Other{
|
||||
|
||||
this.prevLabelWidth = labelMessage.Width;
|
||||
this.prevLabelHeight = labelMessage.Height;
|
||||
this.minFormWidth = 18;
|
||||
this.minFormWidth = 40;
|
||||
|
||||
switch(messageIcon){
|
||||
case MessageBoxIcon.Information:
|
||||
@@ -40,7 +56,7 @@ namespace TweetDck.Core.Other{
|
||||
|
||||
default:
|
||||
icon = null;
|
||||
labelMessage.Location = new Point(labelMessage.Location.X-37, labelMessage.Location.Y);
|
||||
labelMessage.Location = new Point(labelMessage.Location.X-38, labelMessage.Location.Y);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -50,11 +66,15 @@ namespace TweetDck.Core.Other{
|
||||
this.labelMessage.Text = text;
|
||||
}
|
||||
|
||||
public Button AddButton(string title){
|
||||
private void FormMessage_SizeChanged(object sender, EventArgs e){
|
||||
RecalculateButtonLocation();
|
||||
}
|
||||
|
||||
public Button AddButton(string title, DialogResult result = DialogResult.OK){
|
||||
Button button = new Button{
|
||||
Anchor = AnchorStyles.Bottom | AnchorStyles.Right,
|
||||
Anchor = AnchorStyles.Bottom,
|
||||
Font = SystemFonts.MessageBoxFont,
|
||||
Location = new Point(Width-112-buttonCount*96, 12),
|
||||
Location = new Point(0, 12),
|
||||
Size = new Size(88, 26),
|
||||
TabIndex = buttonCount,
|
||||
Text = title,
|
||||
@@ -63,16 +83,17 @@ namespace TweetDck.Core.Other{
|
||||
|
||||
button.Click += (sender, args) => {
|
||||
ClickedButton = (Button)sender;
|
||||
DialogResult = DialogResult.OK;
|
||||
DialogResult = result;
|
||||
Close();
|
||||
};
|
||||
|
||||
panelActions.Controls.Add(button);
|
||||
++buttonCount;
|
||||
|
||||
minFormWidth += 96;
|
||||
Width = Math.Max(realFormWidth, minFormWidth);
|
||||
ClientWidth = Math.Max(realFormWidth, minFormWidth);
|
||||
RecalculateButtonLocation();
|
||||
|
||||
++buttonCount;
|
||||
return button;
|
||||
}
|
||||
|
||||
@@ -80,7 +101,14 @@ namespace TweetDck.Core.Other{
|
||||
panelActions.Controls.Add(control);
|
||||
|
||||
minFormWidth += control.Width+control.Margin.Horizontal;
|
||||
Width = Math.Max(realFormWidth, minFormWidth);
|
||||
ClientWidth = Math.Max(realFormWidth, minFormWidth);
|
||||
}
|
||||
|
||||
private void RecalculateButtonLocation(){
|
||||
for(int index = 0; index < buttonCount; index++){
|
||||
Control control = panelActions.Controls[index];
|
||||
control.Location = new Point(ClientWidth-97-index*96, control.Location.Y);
|
||||
}
|
||||
}
|
||||
|
||||
private void labelMessage_SizeChanged(object sender, EventArgs e){
|
||||
@@ -99,8 +127,8 @@ namespace TweetDck.Core.Other{
|
||||
prevLabelHeight -= 8;
|
||||
}
|
||||
|
||||
realFormWidth = Width-(icon == null ? 32+35+(labelMessage.Margin.Left-labelMessage.Margin.Right) : 0)+labelMessage.Margin.Right+labelMessage.Width-prevLabelWidth;
|
||||
Width = Math.Max(realFormWidth, minFormWidth);
|
||||
realFormWidth = ClientWidth-(icon == null ? 50 : 0)+labelMessage.Width-prevLabelWidth;
|
||||
ClientWidth = Math.Max(realFormWidth, minFormWidth);
|
||||
Height += labelMessage.Height-prevLabelHeight;
|
||||
|
||||
prevLabelWidth = labelMessage.Width;
|
||||
|
2
Core/Other/FormPlugins.Designer.cs
generated
2
Core/Other/FormPlugins.Designer.cs
generated
@@ -76,7 +76,7 @@
|
||||
this.tabPanelPlugins.Location = new System.Drawing.Point(12, 12);
|
||||
this.tabPanelPlugins.Name = "tabPanelPlugins";
|
||||
this.tabPanelPlugins.Size = new System.Drawing.Size(680, 421);
|
||||
this.tabPanelPlugins.TabIndex = 4;
|
||||
this.tabPanelPlugins.TabIndex = 0;
|
||||
//
|
||||
// FormPlugins
|
||||
//
|
||||
|
@@ -36,17 +36,19 @@ namespace TweetDck.Core.Other{
|
||||
this.tabBtnOfficial = tabPanelPlugins.AddButton("", () => SelectGroup(PluginGroup.Official));
|
||||
this.tabBtnCustom = tabPanelPlugins.AddButton("", () => SelectGroup(PluginGroup.Custom));
|
||||
|
||||
this.tabPanelPlugins.SelectTab(tabBtnOfficial);
|
||||
this.pluginManager_Reloaded(pluginManager, null);
|
||||
|
||||
Shown += (sender, args) => {
|
||||
Program.UserConfig.PluginsWindow.Restore(this, false);
|
||||
this.tabPanelPlugins.SelectTab(tabBtnOfficial);
|
||||
};
|
||||
|
||||
FormClosed += (sender, args) => {
|
||||
Program.UserConfig.PluginsWindow.Save(this);
|
||||
Program.UserConfig.Save();
|
||||
};
|
||||
|
||||
Disposed += (sender, args) => this.pluginManager.Reloaded -= pluginManager_Reloaded;
|
||||
}
|
||||
|
||||
private void SelectGroup(PluginGroup group){
|
||||
@@ -76,11 +78,11 @@ namespace TweetDck.Core.Other{
|
||||
}
|
||||
}
|
||||
|
||||
flowLayoutPlugins_Resize(flowLayoutPlugins, new EventArgs());
|
||||
flowLayoutPlugins.ResumeLayout(true);
|
||||
flowLayoutPlugins_Resize(flowLayoutPlugins, new EventArgs());
|
||||
}
|
||||
|
||||
private void pluginManager_Reloaded(object sender, PluginLoadEventArgs e){
|
||||
private void pluginManager_Reloaded(object sender, PluginErrorEventArgs e){
|
||||
tabBtnOfficial.Text = "Official: "+pluginManager.CountPluginByGroup(PluginGroup.Official);
|
||||
tabBtnCustom.Text = "Custom: "+pluginManager.CountPluginByGroup(PluginGroup.Custom);
|
||||
}
|
||||
|
@@ -2,17 +2,18 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Notification;
|
||||
using TweetDck.Core.Other.Settings;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Updates;
|
||||
|
||||
namespace TweetDck.Core.Other{
|
||||
sealed partial class FormSettings : Form{
|
||||
public const int TabIndexNotification = 1;
|
||||
|
||||
private readonly FormBrowser browser;
|
||||
private readonly Dictionary<Type, BaseTabSettings> tabs = new Dictionary<Type, BaseTabSettings>(4);
|
||||
|
||||
public FormSettings(FormBrowser browser, PluginManager plugins, UpdateHandler updates){
|
||||
public FormSettings(FormBrowser browser, PluginManager plugins, UpdateHandler updates, int startTabIndex = 0){
|
||||
InitializeComponent();
|
||||
|
||||
Text = Program.BrandName+" Settings";
|
||||
@@ -21,15 +22,12 @@ namespace TweetDck.Core.Other{
|
||||
this.browser.PauseNotification();
|
||||
|
||||
this.tabPanel.SetupTabPanel(100);
|
||||
this.tabPanel.AddButton("General", SelectTab<TabSettingsGeneral>);
|
||||
this.tabPanel.AddButton("Notifications", () => SelectTab(() => new TabSettingsNotifications(browser.CreateNotificationForm(NotificationFlags.DisableContextMenu))));
|
||||
this.tabPanel.AddButton("Updates", () => SelectTab(() => new TabSettingsUpdates(updates)));
|
||||
this.tabPanel.AddButton("Advanced", () => SelectTab(() => new TabSettingsAdvanced(browser.ReloadBrowser, plugins)));
|
||||
this.tabPanel.SelectTab(tabPanel.Buttons.First());
|
||||
}
|
||||
this.tabPanel.AddButton("General", () => SelectTab(() => new TabSettingsGeneral(updates)));
|
||||
this.tabPanel.AddButton("Notifications", () => SelectTab(() => new TabSettingsNotifications(browser.CreateNotificationForm(false))));
|
||||
this.tabPanel.AddButton("Sounds", () => SelectTab(() => new TabSettingsSounds()));
|
||||
this.tabPanel.AddButton("Advanced", () => SelectTab(() => new TabSettingsAdvanced(browser.ReinjectCustomCSS, plugins)));
|
||||
|
||||
private void SelectTab<T>() where T : BaseTabSettings, new(){
|
||||
SelectTab(() => new T());
|
||||
this.tabPanel.SelectTab(tabPanel.Buttons.ElementAt(startTabIndex));
|
||||
}
|
||||
|
||||
private void SelectTab<T>(Func<T> constructor) where T : BaseTabSettings{
|
||||
@@ -40,7 +38,7 @@ namespace TweetDck.Core.Other{
|
||||
}
|
||||
else{
|
||||
control = tabs[typeof(T)] = constructor();
|
||||
control.Ready = true;
|
||||
control.OnReady();
|
||||
tabPanel.ReplaceContent(control);
|
||||
}
|
||||
}
|
||||
|
@@ -9,12 +9,11 @@ namespace TweetDck.Core.Other.Settings{
|
||||
}
|
||||
}
|
||||
|
||||
public bool Ready { get; set; }
|
||||
|
||||
public BaseTabSettings(){
|
||||
Padding = new Padding(6);
|
||||
}
|
||||
|
||||
public virtual void OnReady(){}
|
||||
public virtual void OnClosing(){}
|
||||
|
||||
protected static void PromptRestart(){
|
||||
|
@@ -23,6 +23,7 @@
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.textBoxBrowserCSS = new System.Windows.Forms.TextBox();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.btnApply = new System.Windows.Forms.Button();
|
||||
@@ -32,6 +33,7 @@
|
||||
this.textBoxNotificationCSS = new System.Windows.Forms.TextBox();
|
||||
this.labelWarning = new System.Windows.Forms.Label();
|
||||
this.btnOpenWiki = new System.Windows.Forms.Button();
|
||||
this.timerTestBrowser = new System.Windows.Forms.Timer(this.components);
|
||||
((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
|
||||
this.splitContainer.Panel1.SuspendLayout();
|
||||
this.splitContainer.Panel2.SuspendLayout();
|
||||
@@ -50,8 +52,9 @@
|
||||
this.textBoxBrowserCSS.Name = "textBoxBrowserCSS";
|
||||
this.textBoxBrowserCSS.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBoxBrowserCSS.Size = new System.Drawing.Size(373, 253);
|
||||
this.textBoxBrowserCSS.TabIndex = 0;
|
||||
this.textBoxBrowserCSS.TabIndex = 1;
|
||||
this.textBoxBrowserCSS.WordWrap = false;
|
||||
this.textBoxBrowserCSS.KeyUp += new System.Windows.Forms.KeyEventHandler(this.textBoxBrowserCSS_KeyUp);
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
@@ -60,7 +63,7 @@
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnCancel.Size = new System.Drawing.Size(56, 23);
|
||||
this.btnCancel.TabIndex = 1;
|
||||
this.btnCancel.TabIndex = 2;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
@@ -72,7 +75,7 @@
|
||||
this.btnApply.Name = "btnApply";
|
||||
this.btnApply.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnApply.Size = new System.Drawing.Size(56, 23);
|
||||
this.btnApply.TabIndex = 2;
|
||||
this.btnApply.TabIndex = 1;
|
||||
this.btnApply.Text = "Apply";
|
||||
this.btnApply.UseVisualStyleBackColor = true;
|
||||
this.btnApply.Click += new System.EventHandler(this.btnApply_Click);
|
||||
@@ -99,7 +102,7 @@
|
||||
this.splitContainer.Size = new System.Drawing.Size(760, 269);
|
||||
this.splitContainer.SplitterDistance = 373;
|
||||
this.splitContainer.SplitterWidth = 5;
|
||||
this.splitContainer.TabIndex = 5;
|
||||
this.splitContainer.TabIndex = 0;
|
||||
//
|
||||
// labelBrowser
|
||||
//
|
||||
@@ -108,7 +111,7 @@
|
||||
this.labelBrowser.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
|
||||
this.labelBrowser.Name = "labelBrowser";
|
||||
this.labelBrowser.Size = new System.Drawing.Size(45, 13);
|
||||
this.labelBrowser.TabIndex = 1;
|
||||
this.labelBrowser.TabIndex = 0;
|
||||
this.labelBrowser.Text = "Browser";
|
||||
//
|
||||
// labelNotification
|
||||
@@ -118,7 +121,7 @@
|
||||
this.labelNotification.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
|
||||
this.labelNotification.Name = "labelNotification";
|
||||
this.labelNotification.Size = new System.Drawing.Size(60, 13);
|
||||
this.labelNotification.TabIndex = 2;
|
||||
this.labelNotification.TabIndex = 0;
|
||||
this.labelNotification.Text = "Notification";
|
||||
//
|
||||
// textBoxNotificationCSS
|
||||
@@ -132,7 +135,7 @@
|
||||
this.textBoxNotificationCSS.Multiline = true;
|
||||
this.textBoxNotificationCSS.Name = "textBoxNotificationCSS";
|
||||
this.textBoxNotificationCSS.ScrollBars = System.Windows.Forms.ScrollBars.Both;
|
||||
this.textBoxNotificationCSS.Size = new System.Drawing.Size(376, 253);
|
||||
this.textBoxNotificationCSS.Size = new System.Drawing.Size(372, 253);
|
||||
this.textBoxNotificationCSS.TabIndex = 1;
|
||||
this.textBoxNotificationCSS.WordWrap = false;
|
||||
//
|
||||
@@ -143,7 +146,7 @@
|
||||
this.labelWarning.Location = new System.Drawing.Point(91, 292);
|
||||
this.labelWarning.Name = "labelWarning";
|
||||
this.labelWarning.Size = new System.Drawing.Size(341, 13);
|
||||
this.labelWarning.TabIndex = 6;
|
||||
this.labelWarning.TabIndex = 3;
|
||||
this.labelWarning.Text = "The code is not validated, please make sure there are no syntax errors.";
|
||||
//
|
||||
// btnOpenWiki
|
||||
@@ -154,11 +157,16 @@
|
||||
this.btnOpenWiki.Name = "btnOpenWiki";
|
||||
this.btnOpenWiki.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnOpenWiki.Size = new System.Drawing.Size(73, 23);
|
||||
this.btnOpenWiki.TabIndex = 7;
|
||||
this.btnOpenWiki.TabIndex = 4;
|
||||
this.btnOpenWiki.Text = "Open Wiki";
|
||||
this.btnOpenWiki.UseVisualStyleBackColor = true;
|
||||
this.btnOpenWiki.Click += new System.EventHandler(this.btnOpenWiki_Click);
|
||||
//
|
||||
// timerTestBrowser
|
||||
//
|
||||
this.timerTestBrowser.Interval = 500;
|
||||
this.timerTestBrowser.Tick += new System.EventHandler(this.timerTestBrowser_Tick);
|
||||
//
|
||||
// DialogSettingsCSS
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
@@ -195,5 +203,6 @@
|
||||
private System.Windows.Forms.Label labelNotification;
|
||||
private System.Windows.Forms.Label labelWarning;
|
||||
private System.Windows.Forms.Button btnOpenWiki;
|
||||
private System.Windows.Forms.Timer timerTestBrowser;
|
||||
}
|
||||
}
|
@@ -17,10 +17,14 @@ namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
}
|
||||
}
|
||||
|
||||
public DialogSettingsCSS(){
|
||||
private readonly Action<string> reinjectBrowserCSS;
|
||||
|
||||
public DialogSettingsCSS(Action<string> reinjectBrowserCSS){
|
||||
InitializeComponent();
|
||||
|
||||
Text = Program.BrandName+" Settings - CSS";
|
||||
|
||||
this.reinjectBrowserCSS = reinjectBrowserCSS;
|
||||
|
||||
textBoxBrowserCSS.EnableMultilineShortcuts();
|
||||
textBoxBrowserCSS.Text = Program.UserConfig.CustomBrowserCSS ?? "";
|
||||
@@ -29,8 +33,18 @@ namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
textBoxNotificationCSS.Text = Program.UserConfig.CustomNotificationCSS ?? "";
|
||||
}
|
||||
|
||||
private void textBoxBrowserCSS_KeyUp(object sender, KeyEventArgs e){
|
||||
timerTestBrowser.Stop();
|
||||
timerTestBrowser.Start();
|
||||
}
|
||||
|
||||
private void timerTestBrowser_Tick(object sender, EventArgs e){
|
||||
reinjectBrowserCSS(textBoxBrowserCSS.Text);
|
||||
timerTestBrowser.Stop();
|
||||
}
|
||||
|
||||
private void btnOpenWiki_Click(object sender, EventArgs e){
|
||||
BrowserUtils.OpenExternalBrowser("https://github.com/chylex/TweetDuck/wiki");
|
||||
BrowserUtils.OpenExternalBrowserUnsafe("https://github.com/chylex/TweetDuck/wiki");
|
||||
}
|
||||
|
||||
private void btnApply_Click(object sender, EventArgs e){
|
||||
|
@@ -40,7 +40,7 @@
|
||||
this.textBoxArgs.Multiline = true;
|
||||
this.textBoxArgs.Name = "textBoxArgs";
|
||||
this.textBoxArgs.Size = new System.Drawing.Size(460, 193);
|
||||
this.textBoxArgs.TabIndex = 0;
|
||||
this.textBoxArgs.TabIndex = 1;
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
@@ -49,7 +49,7 @@
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnCancel.Size = new System.Drawing.Size(56, 23);
|
||||
this.btnCancel.TabIndex = 1;
|
||||
this.btnCancel.TabIndex = 3;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
@@ -74,7 +74,7 @@
|
||||
this.btnHelp.Name = "btnHelp";
|
||||
this.btnHelp.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnHelp.Size = new System.Drawing.Size(124, 23);
|
||||
this.btnHelp.TabIndex = 3;
|
||||
this.btnHelp.TabIndex = 4;
|
||||
this.btnHelp.Text = "List of Chromium Args";
|
||||
this.btnHelp.UseVisualStyleBackColor = true;
|
||||
this.btnHelp.Click += new System.EventHandler(this.btnHelp_Click);
|
||||
@@ -86,7 +86,7 @@
|
||||
this.labelWarning.Margin = new System.Windows.Forms.Padding(3, 0, 3, 3);
|
||||
this.labelWarning.Name = "labelWarning";
|
||||
this.labelWarning.Size = new System.Drawing.Size(423, 13);
|
||||
this.labelWarning.TabIndex = 4;
|
||||
this.labelWarning.TabIndex = 0;
|
||||
this.labelWarning.Text = "Warning: Some arguments may cause the program to stop working, edit at your own r" +
|
||||
"isk.";
|
||||
//
|
||||
|
@@ -22,7 +22,7 @@ namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
}
|
||||
|
||||
private void btnHelp_Click(object sender, EventArgs e){
|
||||
BrowserUtils.OpenExternalBrowser("http://peter.sh/experiments/chromium-command-line-switches/");
|
||||
BrowserUtils.OpenExternalBrowserUnsafe("http://peter.sh/experiments/chromium-command-line-switches/");
|
||||
}
|
||||
|
||||
private void btnApply_Click(object sender, EventArgs e){
|
||||
|
@@ -40,7 +40,7 @@
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnCancel.Size = new System.Drawing.Size(56, 23);
|
||||
this.btnCancel.TabIndex = 0;
|
||||
this.btnCancel.TabIndex = 4;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
@@ -49,11 +49,13 @@
|
||||
//
|
||||
this.btnApply.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnApply.AutoSize = true;
|
||||
this.btnApply.Location = new System.Drawing.Point(117, 97);
|
||||
this.btnApply.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.btnApply.Location = new System.Drawing.Point(144, 97);
|
||||
this.btnApply.Name = "btnApply";
|
||||
this.btnApply.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnApply.Size = new System.Drawing.Size(53, 23);
|
||||
this.btnApply.TabIndex = 1;
|
||||
this.btnApply.Size = new System.Drawing.Size(26, 23);
|
||||
this.btnApply.TabIndex = 3;
|
||||
this.btnApply.Text = " ";
|
||||
this.btnApply.UseVisualStyleBackColor = true;
|
||||
this.btnApply.Click += new System.EventHandler(this.btnApply_Click);
|
||||
//
|
||||
@@ -63,7 +65,7 @@
|
||||
this.cbConfig.Location = new System.Drawing.Point(13, 13);
|
||||
this.cbConfig.Name = "cbConfig";
|
||||
this.cbConfig.Size = new System.Drawing.Size(106, 17);
|
||||
this.cbConfig.TabIndex = 2;
|
||||
this.cbConfig.TabIndex = 0;
|
||||
this.cbConfig.Text = "Program Settings";
|
||||
this.toolTip.SetToolTip(this.cbConfig, "Interface, notification, and update settings.\r\nIncludes a list of disabled plugin" +
|
||||
"s.");
|
||||
@@ -76,7 +78,7 @@
|
||||
this.cbSession.Location = new System.Drawing.Point(13, 37);
|
||||
this.cbSession.Name = "cbSession";
|
||||
this.cbSession.Size = new System.Drawing.Size(92, 17);
|
||||
this.cbSession.TabIndex = 3;
|
||||
this.cbSession.TabIndex = 1;
|
||||
this.cbSession.Text = "Login Session";
|
||||
this.toolTip.SetToolTip(this.cbSession, "A token that allows logging into the\r\ncurrent TweetDeck account.");
|
||||
this.cbSession.UseVisualStyleBackColor = true;
|
||||
@@ -88,7 +90,7 @@
|
||||
this.cbPluginData.Location = new System.Drawing.Point(13, 61);
|
||||
this.cbPluginData.Name = "cbPluginData";
|
||||
this.cbPluginData.Size = new System.Drawing.Size(81, 17);
|
||||
this.cbPluginData.TabIndex = 4;
|
||||
this.cbPluginData.TabIndex = 2;
|
||||
this.cbPluginData.Text = "Plugin Data";
|
||||
this.toolTip.SetToolTip(this.cbPluginData, "Data files generated by plugins.\r\nDoes not include the plugins themselves.");
|
||||
this.cbPluginData.UseVisualStyleBackColor = true;
|
||||
@@ -104,6 +106,9 @@
|
||||
this.Controls.Add(this.cbConfig);
|
||||
this.Controls.Add(this.btnApply);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.MinimumSize = new System.Drawing.Size(200, 170);
|
||||
this.Name = "DialogSettingsExport";
|
||||
this.ShowIcon = false;
|
||||
|
@@ -18,30 +18,28 @@ namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
}
|
||||
|
||||
set{
|
||||
selectedFlags = value;
|
||||
btnApply.Enabled = selectedFlags != ExportFileFlags.None;
|
||||
|
||||
cbConfig.Checked = selectedFlags.HasFlag(ExportFileFlags.Config);
|
||||
cbSession.Checked = selectedFlags.HasFlag(ExportFileFlags.Session);
|
||||
cbPluginData.Checked = selectedFlags.HasFlag(ExportFileFlags.PluginData);
|
||||
// this will call events and SetFlag, which also updates the UI
|
||||
cbConfig.Checked = value.HasFlag(ExportFileFlags.Config);
|
||||
cbSession.Checked = value.HasFlag(ExportFileFlags.Session);
|
||||
cbPluginData.Checked = value.HasFlag(ExportFileFlags.PluginData);
|
||||
}
|
||||
}
|
||||
|
||||
private readonly bool isExporting;
|
||||
private ExportFileFlags selectedFlags = ExportFileFlags.None;
|
||||
|
||||
private DialogSettingsExport(ExportFileFlags importFlags){
|
||||
InitializeComponent();
|
||||
|
||||
bool isExporting = importFlags == ExportFileFlags.None;
|
||||
this.isExporting = importFlags == ExportFileFlags.None;
|
||||
|
||||
if (isExporting){
|
||||
Text = "Export Profile";
|
||||
btnApply.Text = "Export";
|
||||
btnApply.Text = "Export Profile";
|
||||
Flags = ExportFileFlags.All & ~ExportFileFlags.Session;
|
||||
}
|
||||
else{
|
||||
Text = "Import Profile";
|
||||
btnApply.Text = "Import";
|
||||
Flags = importFlags;
|
||||
|
||||
cbConfig.Enabled = cbConfig.Checked;
|
||||
@@ -53,6 +51,10 @@ namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
private void SetFlag(ExportFileFlags flag, bool enable){
|
||||
selectedFlags = enable ? selectedFlags | flag : selectedFlags & ~flag;
|
||||
btnApply.Enabled = selectedFlags != ExportFileFlags.None;
|
||||
|
||||
if (!isExporting){
|
||||
btnApply.Text = selectedFlags.HasFlag(ExportFileFlags.Session) ? "Import && Restart" : "Import Profile";
|
||||
}
|
||||
}
|
||||
|
||||
private void cbConfig_CheckedChanged(object sender, EventArgs e){
|
||||
|
161
Core/Other/Settings/Dialogs/DialogSettingsRestart.Designer.cs
generated
Normal file
161
Core/Other/Settings/Dialogs/DialogSettingsRestart.Designer.cs
generated
Normal file
@@ -0,0 +1,161 @@
|
||||
namespace TweetDck.Core.Other.Settings.Dialogs {
|
||||
partial class DialogSettingsRestart {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows Form Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.btnCancel = new System.Windows.Forms.Button();
|
||||
this.btnRestart = new System.Windows.Forms.Button();
|
||||
this.cbLogging = new System.Windows.Forms.CheckBox();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.cbDebugUpdates = new System.Windows.Forms.CheckBox();
|
||||
this.labelLocale = new System.Windows.Forms.Label();
|
||||
this.comboLocale = new System.Windows.Forms.ComboBox();
|
||||
this.labelDataFolder = new System.Windows.Forms.Label();
|
||||
this.tbDataFolder = new System.Windows.Forms.TextBox();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnCancel
|
||||
//
|
||||
this.btnCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnCancel.AutoSize = true;
|
||||
this.btnCancel.Location = new System.Drawing.Point(160, 171);
|
||||
this.btnCancel.Name = "btnCancel";
|
||||
this.btnCancel.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnCancel.Size = new System.Drawing.Size(56, 23);
|
||||
this.btnCancel.TabIndex = 7;
|
||||
this.btnCancel.Text = "Cancel";
|
||||
this.btnCancel.UseVisualStyleBackColor = true;
|
||||
this.btnCancel.Click += new System.EventHandler(this.btnCancel_Click);
|
||||
//
|
||||
// btnRestart
|
||||
//
|
||||
this.btnRestart.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.btnRestart.AutoSize = true;
|
||||
this.btnRestart.Location = new System.Drawing.Point(97, 171);
|
||||
this.btnRestart.Name = "btnRestart";
|
||||
this.btnRestart.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnRestart.Size = new System.Drawing.Size(57, 23);
|
||||
this.btnRestart.TabIndex = 6;
|
||||
this.btnRestart.Text = "Restart";
|
||||
this.btnRestart.UseVisualStyleBackColor = true;
|
||||
this.btnRestart.Click += new System.EventHandler(this.btnRestart_Click);
|
||||
//
|
||||
// cbLogging
|
||||
//
|
||||
this.cbLogging.AutoSize = true;
|
||||
this.cbLogging.Location = new System.Drawing.Point(12, 12);
|
||||
this.cbLogging.Name = "cbLogging";
|
||||
this.cbLogging.Size = new System.Drawing.Size(64, 17);
|
||||
this.cbLogging.TabIndex = 0;
|
||||
this.cbLogging.Text = "Logging";
|
||||
this.toolTip.SetToolTip(this.cbLogging, "Logging JavaScript output into a\r\ndebug.txt file in the data folder.");
|
||||
this.cbLogging.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// cbDebugUpdates
|
||||
//
|
||||
this.cbDebugUpdates.AutoSize = true;
|
||||
this.cbDebugUpdates.Location = new System.Drawing.Point(12, 35);
|
||||
this.cbDebugUpdates.Name = "cbDebugUpdates";
|
||||
this.cbDebugUpdates.Size = new System.Drawing.Size(127, 17);
|
||||
this.cbDebugUpdates.TabIndex = 1;
|
||||
this.cbDebugUpdates.Text = "Pre-Release Updates";
|
||||
this.toolTip.SetToolTip(this.cbDebugUpdates, "Allows updating to pre-releases.");
|
||||
this.cbDebugUpdates.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelLocale
|
||||
//
|
||||
this.labelLocale.AutoSize = true;
|
||||
this.labelLocale.Location = new System.Drawing.Point(12, 67);
|
||||
this.labelLocale.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelLocale.Name = "labelLocale";
|
||||
this.labelLocale.Size = new System.Drawing.Size(39, 13);
|
||||
this.labelLocale.TabIndex = 2;
|
||||
this.labelLocale.Text = "Locale";
|
||||
//
|
||||
// comboLocale
|
||||
//
|
||||
this.comboLocale.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.comboLocale.FormattingEnabled = true;
|
||||
this.comboLocale.Location = new System.Drawing.Point(15, 83);
|
||||
this.comboLocale.Name = "comboLocale";
|
||||
this.comboLocale.Size = new System.Drawing.Size(201, 21);
|
||||
this.comboLocale.TabIndex = 3;
|
||||
//
|
||||
// labelDataFolder
|
||||
//
|
||||
this.labelDataFolder.AutoSize = true;
|
||||
this.labelDataFolder.Location = new System.Drawing.Point(12, 119);
|
||||
this.labelDataFolder.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelDataFolder.Name = "labelDataFolder";
|
||||
this.labelDataFolder.Size = new System.Drawing.Size(62, 13);
|
||||
this.labelDataFolder.TabIndex = 4;
|
||||
this.labelDataFolder.Text = "Data Folder";
|
||||
//
|
||||
// tbDataFolder
|
||||
//
|
||||
this.tbDataFolder.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.tbDataFolder.Location = new System.Drawing.Point(15, 135);
|
||||
this.tbDataFolder.Name = "tbDataFolder";
|
||||
this.tbDataFolder.Size = new System.Drawing.Size(201, 20);
|
||||
this.tbDataFolder.TabIndex = 5;
|
||||
//
|
||||
// DialogSettingsRestart
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(228, 206);
|
||||
this.Controls.Add(this.tbDataFolder);
|
||||
this.Controls.Add(this.labelDataFolder);
|
||||
this.Controls.Add(this.comboLocale);
|
||||
this.Controls.Add(this.labelLocale);
|
||||
this.Controls.Add(this.cbDebugUpdates);
|
||||
this.Controls.Add(this.cbLogging);
|
||||
this.Controls.Add(this.btnRestart);
|
||||
this.Controls.Add(this.btnCancel);
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "DialogSettingsRestart";
|
||||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnCancel;
|
||||
private System.Windows.Forms.Button btnRestart;
|
||||
private System.Windows.Forms.CheckBox cbLogging;
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
private System.Windows.Forms.CheckBox cbDebugUpdates;
|
||||
private System.Windows.Forms.Label labelLocale;
|
||||
private System.Windows.Forms.ComboBox comboLocale;
|
||||
private System.Windows.Forms.Label labelDataFolder;
|
||||
private System.Windows.Forms.TextBox tbDataFolder;
|
||||
}
|
||||
}
|
62
Core/Other/Settings/Dialogs/DialogSettingsRestart.cs
Normal file
62
Core/Other/Settings/Dialogs/DialogSettingsRestart.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings.Dialogs{
|
||||
sealed partial class DialogSettingsRestart : Form{
|
||||
private const string DefaultLocale = "en-US";
|
||||
|
||||
public CommandLineArgs Args { get; private set; }
|
||||
|
||||
public DialogSettingsRestart(CommandLineArgs currentArgs){
|
||||
InitializeComponent();
|
||||
|
||||
try{
|
||||
object[] locales = Directory.EnumerateFiles(Path.Combine(Program.ProgramPath, "locales"), "*.pak", SearchOption.TopDirectoryOnly).Select(Path.GetFileNameWithoutExtension).ToArray<object>();
|
||||
comboLocale.Items.AddRange(locales);
|
||||
}catch{
|
||||
comboLocale.Items.Add(DefaultLocale);
|
||||
}
|
||||
|
||||
cbLogging.Checked = currentArgs.HasFlag(Arguments.ArgLogging);
|
||||
cbDebugUpdates.Checked = currentArgs.HasFlag(Arguments.ArgDebugUpdates);
|
||||
comboLocale.SelectedItem = currentArgs.GetValue(Arguments.ArgLocale, DefaultLocale);
|
||||
tbDataFolder.Text = currentArgs.GetValue(Arguments.ArgDataFolder, string.Empty);
|
||||
|
||||
Text = Program.BrandName+" Arguments";
|
||||
}
|
||||
|
||||
private void btnRestart_Click(object sender, EventArgs e){
|
||||
Args = new CommandLineArgs();
|
||||
|
||||
if (cbLogging.Checked){
|
||||
Args.AddFlag(Arguments.ArgLogging);
|
||||
}
|
||||
|
||||
if (cbDebugUpdates.Checked){
|
||||
Args.AddFlag(Arguments.ArgDebugUpdates);
|
||||
}
|
||||
|
||||
string locale = comboLocale.SelectedItem as string;
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(locale) && locale != DefaultLocale){
|
||||
Args.SetValue(Arguments.ArgLocale, locale);
|
||||
}
|
||||
|
||||
if (!string.IsNullOrWhiteSpace(tbDataFolder.Text)){
|
||||
Args.SetValue(Arguments.ArgDataFolder, tbDataFolder.Text);
|
||||
}
|
||||
|
||||
DialogResult = DialogResult.OK;
|
||||
Close();
|
||||
}
|
||||
|
||||
private void btnCancel_Click(object sender, EventArgs e){
|
||||
DialogResult = DialogResult.Cancel;
|
||||
Close();
|
||||
}
|
||||
}
|
||||
}
|
@@ -121,8 +121,11 @@ namespace TweetDck.Core.Other.Settings.Export{
|
||||
|
||||
public void WriteToFile(string path, bool createDirectory){
|
||||
if (createDirectory){
|
||||
// ReSharper disable once AssignNullToNotNullAttribute
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(path));
|
||||
string dir = Path.GetDirectoryName(path);
|
||||
|
||||
if (!string.IsNullOrEmpty(dir)){
|
||||
Directory.CreateDirectory(dir);
|
||||
}
|
||||
}
|
||||
|
||||
File.WriteAllBytes(path, contents);
|
||||
|
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDck.Plugins;
|
||||
using TweetDck.Plugins.Enums;
|
||||
|
||||
@@ -98,7 +99,6 @@ namespace TweetDck.Core.Other.Settings.Export{
|
||||
case "config":
|
||||
if (flags.HasFlag(ExportFileFlags.Config)){
|
||||
entry.WriteToFile(Program.ConfigFilePath);
|
||||
Program.ReloadConfig();
|
||||
}
|
||||
|
||||
break;
|
||||
@@ -117,7 +117,7 @@ namespace TweetDck.Core.Other.Settings.Export{
|
||||
break;
|
||||
|
||||
case "cookies":
|
||||
if (flags.HasFlag(ExportFileFlags.Session) && MessageBox.Show("Do you want to import the login session? This will restart "+Program.BrandName+".", "Importing "+Program.BrandName+" Profile", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes){
|
||||
if (flags.HasFlag(ExportFileFlags.Session)){
|
||||
entry.WriteToFile(Path.Combine(Program.StoragePath, TempCookiesPath));
|
||||
IsRestarting = true;
|
||||
}
|
||||
@@ -132,10 +132,10 @@ namespace TweetDck.Core.Other.Settings.Export{
|
||||
}
|
||||
|
||||
if (IsRestarting){
|
||||
Program.Restart(new string[]{ "-importcookies" });
|
||||
Program.Restart(new string[]{ Arguments.ArgImportCookies });
|
||||
}
|
||||
else{
|
||||
plugins.Reload();
|
||||
Program.ReloadConfig();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
64
Core/Other/Settings/TabSettingsAdvanced.Designer.cs
generated
64
Core/Other/Settings/TabSettingsAdvanced.Designer.cs
generated
@@ -29,7 +29,7 @@
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.btnEditCefArgs = new System.Windows.Forms.Button();
|
||||
this.btnEditCSS = new System.Windows.Forms.Button();
|
||||
this.btnRestartLog = new System.Windows.Forms.Button();
|
||||
this.btnRestartArgs = new System.Windows.Forms.Button();
|
||||
this.btnRestart = new System.Windows.Forms.Button();
|
||||
this.btnOpenAppFolder = new System.Windows.Forms.Button();
|
||||
this.btnOpenDataFolder = new System.Windows.Forms.Button();
|
||||
@@ -49,94 +49,85 @@
|
||||
this.btnClearCache.Location = new System.Drawing.Point(6, 44);
|
||||
this.btnClearCache.Name = "btnClearCache";
|
||||
this.btnClearCache.Size = new System.Drawing.Size(171, 23);
|
||||
this.btnClearCache.TabIndex = 14;
|
||||
this.btnClearCache.TabIndex = 1;
|
||||
this.btnClearCache.Text = "Clear Cache (calculating)";
|
||||
this.toolTip.SetToolTip(this.btnClearCache, "Clearing cache will free up space taken by downloaded images and other resources." +
|
||||
"");
|
||||
this.btnClearCache.UseVisualStyleBackColor = true;
|
||||
this.btnClearCache.Click += new System.EventHandler(this.btnClearCache_Click);
|
||||
//
|
||||
// checkHardwareAcceleration
|
||||
//
|
||||
this.checkHardwareAcceleration.AutoSize = true;
|
||||
this.checkHardwareAcceleration.Location = new System.Drawing.Point(6, 21);
|
||||
this.checkHardwareAcceleration.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
|
||||
this.checkHardwareAcceleration.Location = new System.Drawing.Point(9, 21);
|
||||
this.checkHardwareAcceleration.Margin = new System.Windows.Forms.Padding(6, 5, 3, 3);
|
||||
this.checkHardwareAcceleration.Name = "checkHardwareAcceleration";
|
||||
this.checkHardwareAcceleration.Size = new System.Drawing.Size(134, 17);
|
||||
this.checkHardwareAcceleration.TabIndex = 12;
|
||||
this.checkHardwareAcceleration.TabIndex = 0;
|
||||
this.checkHardwareAcceleration.Text = "Hardware Acceleration";
|
||||
this.toolTip.SetToolTip(this.checkHardwareAcceleration, "Uses your graphics card to improve performance.\r\nDisable if you experience issues" +
|
||||
" with rendering.");
|
||||
this.checkHardwareAcceleration.UseVisualStyleBackColor = true;
|
||||
this.checkHardwareAcceleration.CheckedChanged += new System.EventHandler(this.checkHardwareAcceleration_CheckedChanged);
|
||||
//
|
||||
// btnEditCefArgs
|
||||
//
|
||||
this.btnEditCefArgs.Location = new System.Drawing.Point(6, 19);
|
||||
this.btnEditCefArgs.Name = "btnEditCefArgs";
|
||||
this.btnEditCefArgs.Size = new System.Drawing.Size(171, 23);
|
||||
this.btnEditCefArgs.TabIndex = 15;
|
||||
this.btnEditCefArgs.TabIndex = 0;
|
||||
this.btnEditCefArgs.Text = "Edit CEF Arguments";
|
||||
this.toolTip.SetToolTip(this.btnEditCefArgs, "Set custom command line arguments for Chromium Embedded Framework.");
|
||||
this.btnEditCefArgs.UseVisualStyleBackColor = true;
|
||||
this.btnEditCefArgs.Click += new System.EventHandler(this.btnEditCefArgs_Click);
|
||||
//
|
||||
// btnEditCSS
|
||||
//
|
||||
this.btnEditCSS.Location = new System.Drawing.Point(6, 48);
|
||||
this.btnEditCSS.Name = "btnEditCSS";
|
||||
this.btnEditCSS.Size = new System.Drawing.Size(171, 23);
|
||||
this.btnEditCSS.TabIndex = 16;
|
||||
this.btnEditCSS.TabIndex = 1;
|
||||
this.btnEditCSS.Text = "Edit CSS";
|
||||
this.toolTip.SetToolTip(this.btnEditCSS, "Set custom CSS for browser and notification windows.");
|
||||
this.btnEditCSS.UseVisualStyleBackColor = true;
|
||||
this.btnEditCSS.Click += new System.EventHandler(this.btnEditCSS_Click);
|
||||
//
|
||||
// btnRestartLog
|
||||
// btnRestartArgs
|
||||
//
|
||||
this.btnRestartLog.Location = new System.Drawing.Point(6, 106);
|
||||
this.btnRestartLog.Name = "btnRestartLog";
|
||||
this.btnRestartLog.Size = new System.Drawing.Size(171, 23);
|
||||
this.btnRestartLog.TabIndex = 18;
|
||||
this.btnRestartLog.Text = "Restart with Logging";
|
||||
this.toolTip.SetToolTip(this.btnRestartLog, "Restarts the program and enables logging\r\ninto a debug.txt file in the data folde" +
|
||||
"r.");
|
||||
this.btnRestartLog.UseVisualStyleBackColor = true;
|
||||
this.btnRestartLog.Click += new System.EventHandler(this.btnRestartLog_Click);
|
||||
this.btnRestartArgs.Location = new System.Drawing.Point(6, 106);
|
||||
this.btnRestartArgs.Name = "btnRestartArgs";
|
||||
this.btnRestartArgs.Size = new System.Drawing.Size(171, 23);
|
||||
this.btnRestartArgs.TabIndex = 3;
|
||||
this.btnRestartArgs.Text = "Restart with Arguments";
|
||||
this.toolTip.SetToolTip(this.btnRestartArgs, "Restarts the program with customizable\r\ncommand line arguments.");
|
||||
this.btnRestartArgs.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnRestart
|
||||
//
|
||||
this.btnRestart.Location = new System.Drawing.Point(6, 77);
|
||||
this.btnRestart.Name = "btnRestart";
|
||||
this.btnRestart.Size = new System.Drawing.Size(171, 23);
|
||||
this.btnRestart.TabIndex = 17;
|
||||
this.btnRestart.TabIndex = 2;
|
||||
this.btnRestart.Text = "Restart the Program";
|
||||
this.toolTip.SetToolTip(this.btnRestart, "Restarts the program using the same command\r\nline arguments that were used at lau" +
|
||||
"nch.");
|
||||
this.btnRestart.UseVisualStyleBackColor = true;
|
||||
this.btnRestart.Click += new System.EventHandler(this.btnRestart_Click);
|
||||
//
|
||||
// btnOpenAppFolder
|
||||
//
|
||||
this.btnOpenAppFolder.Location = new System.Drawing.Point(6, 19);
|
||||
this.btnOpenAppFolder.Name = "btnOpenAppFolder";
|
||||
this.btnOpenAppFolder.Size = new System.Drawing.Size(171, 23);
|
||||
this.btnOpenAppFolder.TabIndex = 16;
|
||||
this.btnOpenAppFolder.TabIndex = 0;
|
||||
this.btnOpenAppFolder.Text = "Open Program Folder";
|
||||
this.toolTip.SetToolTip(this.btnOpenAppFolder, "Opens the folder where the app is located.");
|
||||
this.btnOpenAppFolder.UseVisualStyleBackColor = true;
|
||||
this.btnOpenAppFolder.Click += new System.EventHandler(this.btnOpenAppFolder_Click);
|
||||
//
|
||||
// btnOpenDataFolder
|
||||
//
|
||||
this.btnOpenDataFolder.Location = new System.Drawing.Point(6, 48);
|
||||
this.btnOpenDataFolder.Name = "btnOpenDataFolder";
|
||||
this.btnOpenDataFolder.Size = new System.Drawing.Size(171, 23);
|
||||
this.btnOpenDataFolder.TabIndex = 19;
|
||||
this.btnOpenDataFolder.TabIndex = 1;
|
||||
this.btnOpenDataFolder.Text = "Open Data Folder";
|
||||
this.toolTip.SetToolTip(this.btnOpenDataFolder, "Opens the folder where your profile data is located.");
|
||||
this.btnOpenDataFolder.UseVisualStyleBackColor = true;
|
||||
this.btnOpenDataFolder.Click += new System.EventHandler(this.btnOpenDataFolder_Click);
|
||||
//
|
||||
// btnReset
|
||||
//
|
||||
@@ -146,10 +137,9 @@
|
||||
this.btnReset.Name = "btnReset";
|
||||
this.btnReset.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnReset.Size = new System.Drawing.Size(102, 23);
|
||||
this.btnReset.TabIndex = 17;
|
||||
this.btnReset.TabIndex = 5;
|
||||
this.btnReset.Text = "Restore Defaults";
|
||||
this.btnReset.UseVisualStyleBackColor = true;
|
||||
this.btnReset.Click += new System.EventHandler(this.btnReset_Click);
|
||||
//
|
||||
// btnImport
|
||||
//
|
||||
@@ -159,10 +149,9 @@
|
||||
this.btnImport.Name = "btnImport";
|
||||
this.btnImport.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnImport.Size = new System.Drawing.Size(84, 23);
|
||||
this.btnImport.TabIndex = 16;
|
||||
this.btnImport.TabIndex = 4;
|
||||
this.btnImport.Text = "Import Profile";
|
||||
this.btnImport.UseVisualStyleBackColor = true;
|
||||
this.btnImport.Click += new System.EventHandler(this.btnImport_Click);
|
||||
//
|
||||
// btnExport
|
||||
//
|
||||
@@ -173,10 +162,9 @@
|
||||
this.btnExport.Name = "btnExport";
|
||||
this.btnExport.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnExport.Size = new System.Drawing.Size(85, 23);
|
||||
this.btnExport.TabIndex = 15;
|
||||
this.btnExport.TabIndex = 3;
|
||||
this.btnExport.Text = "Export Profile";
|
||||
this.btnExport.UseVisualStyleBackColor = true;
|
||||
this.btnExport.Click += new System.EventHandler(this.btnExport_Click);
|
||||
//
|
||||
// groupPerformance
|
||||
//
|
||||
@@ -185,7 +173,7 @@
|
||||
this.groupPerformance.Location = new System.Drawing.Point(9, 9);
|
||||
this.groupPerformance.Name = "groupPerformance";
|
||||
this.groupPerformance.Size = new System.Drawing.Size(183, 74);
|
||||
this.groupPerformance.TabIndex = 18;
|
||||
this.groupPerformance.TabIndex = 0;
|
||||
this.groupPerformance.TabStop = false;
|
||||
this.groupPerformance.Text = "Performance";
|
||||
//
|
||||
@@ -196,7 +184,7 @@
|
||||
this.groupConfiguration.Location = new System.Drawing.Point(9, 89);
|
||||
this.groupConfiguration.Name = "groupConfiguration";
|
||||
this.groupConfiguration.Size = new System.Drawing.Size(183, 77);
|
||||
this.groupConfiguration.TabIndex = 19;
|
||||
this.groupConfiguration.TabIndex = 1;
|
||||
this.groupConfiguration.TabStop = false;
|
||||
this.groupConfiguration.Text = "Configuration";
|
||||
//
|
||||
@@ -204,12 +192,12 @@
|
||||
//
|
||||
this.groupApp.Controls.Add(this.btnOpenDataFolder);
|
||||
this.groupApp.Controls.Add(this.btnOpenAppFolder);
|
||||
this.groupApp.Controls.Add(this.btnRestartLog);
|
||||
this.groupApp.Controls.Add(this.btnRestartArgs);
|
||||
this.groupApp.Controls.Add(this.btnRestart);
|
||||
this.groupApp.Location = new System.Drawing.Point(198, 9);
|
||||
this.groupApp.Name = "groupApp";
|
||||
this.groupApp.Size = new System.Drawing.Size(183, 135);
|
||||
this.groupApp.TabIndex = 20;
|
||||
this.groupApp.TabIndex = 2;
|
||||
this.groupApp.TabStop = false;
|
||||
this.groupApp.Text = "App";
|
||||
//
|
||||
@@ -247,7 +235,7 @@
|
||||
private System.Windows.Forms.Button btnEditCefArgs;
|
||||
private System.Windows.Forms.Button btnEditCSS;
|
||||
private System.Windows.Forms.GroupBox groupApp;
|
||||
private System.Windows.Forms.Button btnRestartLog;
|
||||
private System.Windows.Forms.Button btnRestartArgs;
|
||||
private System.Windows.Forms.Button btnRestart;
|
||||
private System.Windows.Forms.Button btnOpenAppFolder;
|
||||
private System.Windows.Forms.Button btnOpenDataFolder;
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Configuration;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Other.Settings.Dialogs;
|
||||
using TweetDck.Core.Other.Settings.Export;
|
||||
@@ -9,13 +10,13 @@ using TweetDck.Plugins;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings{
|
||||
partial class TabSettingsAdvanced : BaseTabSettings{
|
||||
private readonly Action browserReloadAction;
|
||||
private readonly Action<string> reinjectBrowserCSS;
|
||||
private readonly PluginManager plugins;
|
||||
|
||||
public TabSettingsAdvanced(Action browserReloadAction, PluginManager plugins){
|
||||
public TabSettingsAdvanced(Action<string> reinjectBrowserCSS, PluginManager plugins){
|
||||
InitializeComponent();
|
||||
|
||||
this.browserReloadAction = browserReloadAction;
|
||||
this.reinjectBrowserCSS = reinjectBrowserCSS;
|
||||
this.plugins = plugins;
|
||||
|
||||
checkHardwareAcceleration.Checked = HardwareAcceleration.IsEnabled;
|
||||
@@ -30,9 +31,24 @@ namespace TweetDck.Core.Other.Settings{
|
||||
}));
|
||||
}
|
||||
|
||||
private void btnClearCache_Click(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
public override void OnReady(){
|
||||
btnClearCache.Click += btnClearCache_Click;
|
||||
checkHardwareAcceleration.CheckedChanged += checkHardwareAcceleration_CheckedChanged;
|
||||
|
||||
btnEditCefArgs.Click += btnEditCefArgs_Click;
|
||||
btnEditCSS.Click += btnEditCSS_Click;
|
||||
|
||||
btnExport.Click += btnExport_Click;
|
||||
btnImport.Click += btnImport_Click;
|
||||
btnReset.Click += btnReset_Click;
|
||||
|
||||
btnOpenAppFolder.Click += btnOpenAppFolder_Click;
|
||||
btnOpenDataFolder.Click += btnOpenDataFolder_Click;
|
||||
btnRestart.Click += btnRestart_Click;
|
||||
btnRestartArgs.Click += btnRestartArgs_Click;
|
||||
}
|
||||
|
||||
private void btnClearCache_Click(object sender, EventArgs e){
|
||||
btnClearCache.Enabled = false;
|
||||
BrowserCache.SetClearOnExit();
|
||||
|
||||
@@ -40,8 +56,6 @@ namespace TweetDck.Core.Other.Settings{
|
||||
}
|
||||
|
||||
private void checkHardwareAcceleration_CheckedChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
bool succeeded = false;
|
||||
|
||||
if (checkHardwareAcceleration.Checked){
|
||||
@@ -80,17 +94,13 @@ namespace TweetDck.Core.Other.Settings{
|
||||
}
|
||||
|
||||
private void btnEditCSS_Click(object sender, EventArgs e){
|
||||
using(DialogSettingsCSS form = new DialogSettingsCSS()){
|
||||
using(DialogSettingsCSS form = new DialogSettingsCSS(reinjectBrowserCSS)){
|
||||
if (form.ShowDialog(ParentForm) == DialogResult.OK){
|
||||
bool hasChangedBrowser = form.BrowserCSS != Config.CustomBrowserCSS;
|
||||
|
||||
Config.CustomBrowserCSS = form.BrowserCSS;
|
||||
Config.CustomNotificationCSS = form.NotificationCSS;
|
||||
|
||||
if (hasChangedBrowser && MessageBox.Show("The browser CSS has changed, do you want to reload it?", "Browser CSS Changed", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2) == DialogResult.Yes){
|
||||
browserReloadAction();
|
||||
}
|
||||
}
|
||||
|
||||
reinjectBrowserCSS(Config.CustomBrowserCSS); // reinject on cancel too, because the CSS is updated while typing
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,8 +198,12 @@ namespace TweetDck.Core.Other.Settings{
|
||||
Program.Restart();
|
||||
}
|
||||
|
||||
private void btnRestartLog_Click(object sender, EventArgs e){
|
||||
Program.Restart(new string[]{ "-log" });
|
||||
private void btnRestartArgs_Click(object sender, EventArgs e){
|
||||
using(DialogSettingsRestart dialog = new DialogSettingsRestart(Arguments.GetCurrentClean())){
|
||||
if (dialog.ShowDialog() == DialogResult.OK){
|
||||
Program.RestartWithArgs(dialog.Args);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
71
Core/Other/Settings/TabSettingsGeneral.Designer.cs
generated
71
Core/Other/Settings/TabSettingsGeneral.Designer.cs
generated
@@ -29,26 +29,29 @@
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.checkTrayHighlight = new System.Windows.Forms.CheckBox();
|
||||
this.checkSpellCheck = new System.Windows.Forms.CheckBox();
|
||||
this.checkUpdateNotifications = new System.Windows.Forms.CheckBox();
|
||||
this.btnCheckUpdates = new System.Windows.Forms.Button();
|
||||
this.groupTray = new System.Windows.Forms.GroupBox();
|
||||
this.labelTrayIcon = new System.Windows.Forms.Label();
|
||||
this.groupInterface = new System.Windows.Forms.GroupBox();
|
||||
this.groupUpdates = new System.Windows.Forms.GroupBox();
|
||||
this.groupTray.SuspendLayout();
|
||||
this.groupInterface.SuspendLayout();
|
||||
this.groupUpdates.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// checkExpandLinks
|
||||
//
|
||||
this.checkExpandLinks.AutoSize = true;
|
||||
this.checkExpandLinks.Location = new System.Drawing.Point(9, 21);
|
||||
this.checkExpandLinks.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
|
||||
this.checkExpandLinks.Margin = new System.Windows.Forms.Padding(6, 5, 3, 3);
|
||||
this.checkExpandLinks.Name = "checkExpandLinks";
|
||||
this.checkExpandLinks.Size = new System.Drawing.Size(166, 17);
|
||||
this.checkExpandLinks.TabIndex = 14;
|
||||
this.checkExpandLinks.TabIndex = 0;
|
||||
this.checkExpandLinks.Text = "Expand Links When Hovered";
|
||||
this.toolTip.SetToolTip(this.checkExpandLinks, "Expands links inside the tweets. If disabled,\r\nthe full links show up in a toolti" +
|
||||
"p instead.");
|
||||
this.checkExpandLinks.UseVisualStyleBackColor = true;
|
||||
this.checkExpandLinks.CheckedChanged += new System.EventHandler(this.checkExpandLinks_CheckedChanged);
|
||||
//
|
||||
// comboBoxTrayType
|
||||
//
|
||||
@@ -57,45 +60,66 @@
|
||||
this.comboBoxTrayType.Location = new System.Drawing.Point(6, 19);
|
||||
this.comboBoxTrayType.Name = "comboBoxTrayType";
|
||||
this.comboBoxTrayType.Size = new System.Drawing.Size(171, 21);
|
||||
this.comboBoxTrayType.TabIndex = 13;
|
||||
this.comboBoxTrayType.TabIndex = 0;
|
||||
this.toolTip.SetToolTip(this.comboBoxTrayType, "Changes behavior of the Tray icon.\r\nRight-click the icon for an action menu.");
|
||||
this.comboBoxTrayType.SelectedIndexChanged += new System.EventHandler(this.comboBoxTrayType_SelectedIndexChanged);
|
||||
//
|
||||
// checkTrayHighlight
|
||||
//
|
||||
this.checkTrayHighlight.AutoSize = true;
|
||||
this.checkTrayHighlight.Location = new System.Drawing.Point(9, 70);
|
||||
this.checkTrayHighlight.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
|
||||
this.checkTrayHighlight.Margin = new System.Windows.Forms.Padding(6, 5, 3, 3);
|
||||
this.checkTrayHighlight.Name = "checkTrayHighlight";
|
||||
this.checkTrayHighlight.Size = new System.Drawing.Size(103, 17);
|
||||
this.checkTrayHighlight.TabIndex = 15;
|
||||
this.checkTrayHighlight.TabIndex = 2;
|
||||
this.checkTrayHighlight.Text = "Enable Highlight";
|
||||
this.toolTip.SetToolTip(this.checkTrayHighlight, "Highlights the tray icon if there are new tweets.\r\nOnly works for columns with po" +
|
||||
"pup or audio notifications.\r\nThe icon resets when the main window is restored.");
|
||||
this.checkTrayHighlight.UseVisualStyleBackColor = true;
|
||||
this.checkTrayHighlight.CheckedChanged += new System.EventHandler(this.checkTrayHighlight_CheckedChanged);
|
||||
//
|
||||
// checkSpellCheck
|
||||
//
|
||||
this.checkSpellCheck.AutoSize = true;
|
||||
this.checkSpellCheck.Location = new System.Drawing.Point(9, 44);
|
||||
this.checkSpellCheck.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
|
||||
this.checkSpellCheck.Name = "checkSpellCheck";
|
||||
this.checkSpellCheck.Size = new System.Drawing.Size(119, 17);
|
||||
this.checkSpellCheck.TabIndex = 15;
|
||||
this.checkSpellCheck.TabIndex = 1;
|
||||
this.checkSpellCheck.Text = "Enable Spell Check";
|
||||
this.toolTip.SetToolTip(this.checkSpellCheck, "Underlines words that are spelled incorrectly.");
|
||||
this.checkSpellCheck.UseVisualStyleBackColor = true;
|
||||
this.checkSpellCheck.CheckedChanged += new System.EventHandler(this.checkSpellCheck_CheckedChanged);
|
||||
//
|
||||
// checkUpdateNotifications
|
||||
//
|
||||
this.checkUpdateNotifications.AutoSize = true;
|
||||
this.checkUpdateNotifications.Location = new System.Drawing.Point(9, 21);
|
||||
this.checkUpdateNotifications.Margin = new System.Windows.Forms.Padding(6, 5, 3, 3);
|
||||
this.checkUpdateNotifications.Name = "checkUpdateNotifications";
|
||||
this.checkUpdateNotifications.Size = new System.Drawing.Size(165, 17);
|
||||
this.checkUpdateNotifications.TabIndex = 0;
|
||||
this.checkUpdateNotifications.Text = "Check Updates Automatically";
|
||||
this.toolTip.SetToolTip(this.checkUpdateNotifications, "Checks for updates every hour.\r\nIf an update is dismissed, it will not appear aga" +
|
||||
"in.");
|
||||
this.checkUpdateNotifications.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnCheckUpdates
|
||||
//
|
||||
this.btnCheckUpdates.Location = new System.Drawing.Point(6, 44);
|
||||
this.btnCheckUpdates.Name = "btnCheckUpdates";
|
||||
this.btnCheckUpdates.Size = new System.Drawing.Size(171, 23);
|
||||
this.btnCheckUpdates.TabIndex = 1;
|
||||
this.btnCheckUpdates.Text = "Check Updates Now";
|
||||
this.toolTip.SetToolTip(this.btnCheckUpdates, "Forces an update check, even for updates that had been dismissed.");
|
||||
this.btnCheckUpdates.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// groupTray
|
||||
//
|
||||
this.groupTray.Controls.Add(this.checkTrayHighlight);
|
||||
this.groupTray.Controls.Add(this.labelTrayIcon);
|
||||
this.groupTray.Controls.Add(this.comboBoxTrayType);
|
||||
this.groupTray.Location = new System.Drawing.Point(9, 86);
|
||||
this.groupTray.Location = new System.Drawing.Point(9, 82);
|
||||
this.groupTray.Name = "groupTray";
|
||||
this.groupTray.Size = new System.Drawing.Size(183, 93);
|
||||
this.groupTray.TabIndex = 15;
|
||||
this.groupTray.TabIndex = 1;
|
||||
this.groupTray.TabStop = false;
|
||||
this.groupTray.Text = "System Tray";
|
||||
//
|
||||
@@ -106,7 +130,7 @@
|
||||
this.labelTrayIcon.Margin = new System.Windows.Forms.Padding(3, 9, 3, 0);
|
||||
this.labelTrayIcon.Name = "labelTrayIcon";
|
||||
this.labelTrayIcon.Size = new System.Drawing.Size(52, 13);
|
||||
this.labelTrayIcon.TabIndex = 14;
|
||||
this.labelTrayIcon.TabIndex = 1;
|
||||
this.labelTrayIcon.Text = "Tray Icon";
|
||||
//
|
||||
// groupInterface
|
||||
@@ -115,15 +139,27 @@
|
||||
this.groupInterface.Controls.Add(this.checkExpandLinks);
|
||||
this.groupInterface.Location = new System.Drawing.Point(9, 9);
|
||||
this.groupInterface.Name = "groupInterface";
|
||||
this.groupInterface.Size = new System.Drawing.Size(183, 71);
|
||||
this.groupInterface.TabIndex = 16;
|
||||
this.groupInterface.Size = new System.Drawing.Size(183, 67);
|
||||
this.groupInterface.TabIndex = 0;
|
||||
this.groupInterface.TabStop = false;
|
||||
this.groupInterface.Text = "User Interface";
|
||||
//
|
||||
// groupUpdates
|
||||
//
|
||||
this.groupUpdates.Controls.Add(this.checkUpdateNotifications);
|
||||
this.groupUpdates.Controls.Add(this.btnCheckUpdates);
|
||||
this.groupUpdates.Location = new System.Drawing.Point(198, 9);
|
||||
this.groupUpdates.Name = "groupUpdates";
|
||||
this.groupUpdates.Size = new System.Drawing.Size(183, 75);
|
||||
this.groupUpdates.TabIndex = 2;
|
||||
this.groupUpdates.TabStop = false;
|
||||
this.groupUpdates.Text = "Updates";
|
||||
//
|
||||
// TabSettingsGeneral
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.groupUpdates);
|
||||
this.Controls.Add(this.groupInterface);
|
||||
this.Controls.Add(this.groupTray);
|
||||
this.Name = "TabSettingsGeneral";
|
||||
@@ -132,6 +168,8 @@
|
||||
this.groupTray.PerformLayout();
|
||||
this.groupInterface.ResumeLayout(false);
|
||||
this.groupInterface.PerformLayout();
|
||||
this.groupUpdates.ResumeLayout(false);
|
||||
this.groupUpdates.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@@ -146,5 +184,8 @@
|
||||
private System.Windows.Forms.Label labelTrayIcon;
|
||||
private System.Windows.Forms.CheckBox checkTrayHighlight;
|
||||
private System.Windows.Forms.CheckBox checkSpellCheck;
|
||||
private System.Windows.Forms.GroupBox groupUpdates;
|
||||
private System.Windows.Forms.CheckBox checkUpdateNotifications;
|
||||
private System.Windows.Forms.Button btnCheckUpdates;
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,19 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Updates;
|
||||
using TweetDck.Updates.Events;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings{
|
||||
partial class TabSettingsGeneral : BaseTabSettings{
|
||||
public TabSettingsGeneral(){
|
||||
private readonly UpdateHandler updates;
|
||||
private int updateCheckEventId = -1;
|
||||
|
||||
public TabSettingsGeneral(UpdateHandler updates){
|
||||
InitializeComponent();
|
||||
|
||||
this.updates = updates;
|
||||
this.updates.CheckFinished += updates_CheckFinished;
|
||||
Disposed += (sender, args) => this.updates.CheckFinished -= updates_CheckFinished;
|
||||
|
||||
comboBoxTrayType.Items.Add("Disabled");
|
||||
comboBoxTrayType.Items.Add("Display Icon Only");
|
||||
@@ -15,31 +25,62 @@ namespace TweetDck.Core.Other.Settings{
|
||||
checkExpandLinks.Checked = Config.ExpandLinksOnHover;
|
||||
checkSpellCheck.Checked = Config.EnableSpellCheck;
|
||||
checkTrayHighlight.Checked = Config.EnableTrayHighlight;
|
||||
|
||||
checkUpdateNotifications.Checked = Config.EnableUpdateCheck;
|
||||
}
|
||||
|
||||
public override void OnReady(){
|
||||
checkExpandLinks.CheckedChanged += checkExpandLinks_CheckedChanged;
|
||||
checkSpellCheck.CheckedChanged += checkSpellCheck_CheckedChanged;
|
||||
|
||||
comboBoxTrayType.SelectedIndexChanged += comboBoxTrayType_SelectedIndexChanged;
|
||||
checkTrayHighlight.CheckedChanged += checkTrayHighlight_CheckedChanged;
|
||||
|
||||
checkUpdateNotifications.CheckedChanged += checkUpdateNotifications_CheckedChanged;
|
||||
btnCheckUpdates.Click += btnCheckUpdates_Click;
|
||||
}
|
||||
|
||||
private void checkExpandLinks_CheckedChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
Config.ExpandLinksOnHover = checkExpandLinks.Checked;
|
||||
}
|
||||
|
||||
private void checkSpellCheck_CheckedChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
Config.EnableSpellCheck = checkSpellCheck.Checked;
|
||||
PromptRestart();
|
||||
}
|
||||
|
||||
private void comboBoxTrayType_SelectedIndexChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
Config.TrayBehavior = (TrayIcon.Behavior)comboBoxTrayType.SelectedIndex;
|
||||
}
|
||||
|
||||
private void checkTrayHighlight_CheckedChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
Config.EnableTrayHighlight = checkTrayHighlight.Checked;
|
||||
}
|
||||
|
||||
private void checkUpdateNotifications_CheckedChanged(object sender, EventArgs e){
|
||||
Config.EnableUpdateCheck = checkUpdateNotifications.Checked;
|
||||
}
|
||||
|
||||
private void btnCheckUpdates_Click(object sender, EventArgs e){
|
||||
updateCheckEventId = updates.Check(true);
|
||||
|
||||
if (updateCheckEventId == -1){
|
||||
MessageBox.Show("Sorry, your system is no longer supported.", "Unsupported System", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
else{
|
||||
btnCheckUpdates.Enabled = false;
|
||||
updates.DismissUpdate(string.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
private void updates_CheckFinished(object sender, UpdateCheckEventArgs e){
|
||||
if (e.EventId == updateCheckEventId){
|
||||
btnCheckUpdates.Enabled = true;
|
||||
|
||||
if (!e.UpdateAvailable){
|
||||
MessageBox.Show("Your version of "+Program.BrandName+" is up to date.", "No Updates Available", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
209
Core/Other/Settings/TabSettingsNotifications.Designer.cs
generated
209
Core/Other/Settings/TabSettingsNotifications.Designer.cs
generated
@@ -43,21 +43,19 @@
|
||||
this.labelDurationValue = new System.Windows.Forms.Label();
|
||||
this.trackBarDuration = new System.Windows.Forms.TrackBar();
|
||||
this.groupUserInterface = new System.Windows.Forms.GroupBox();
|
||||
this.checkColumnName = new System.Windows.Forms.CheckBox();
|
||||
this.labelIdlePause = new System.Windows.Forms.Label();
|
||||
this.comboBoxIdlePause = new System.Windows.Forms.ComboBox();
|
||||
this.checkNonIntrusive = new System.Windows.Forms.CheckBox();
|
||||
this.checkTimerCountDown = new System.Windows.Forms.CheckBox();
|
||||
this.checkLegacyLoad = new System.Windows.Forms.CheckBox();
|
||||
this.checkNotificationTimer = new System.Windows.Forms.CheckBox();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.groupCustomSound = new System.Windows.Forms.GroupBox();
|
||||
this.tbCustomSound = new System.Windows.Forms.TextBox();
|
||||
this.btnBrowseSound = new System.Windows.Forms.Button();
|
||||
this.btnResetSound = new System.Windows.Forms.Button();
|
||||
this.groupNotificationLocation.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarEdgeDistance)).BeginInit();
|
||||
this.groupNotificationDuration.SuspendLayout();
|
||||
this.tableLayoutDurationButtons.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarDuration)).BeginInit();
|
||||
this.groupUserInterface.SuspendLayout();
|
||||
this.groupCustomSound.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupNotificationLocation
|
||||
@@ -75,7 +73,7 @@
|
||||
this.groupNotificationLocation.Location = new System.Drawing.Point(198, 9);
|
||||
this.groupNotificationLocation.Name = "groupNotificationLocation";
|
||||
this.groupNotificationLocation.Size = new System.Drawing.Size(183, 264);
|
||||
this.groupNotificationLocation.TabIndex = 1;
|
||||
this.groupNotificationLocation.TabIndex = 2;
|
||||
this.groupNotificationLocation.TabStop = false;
|
||||
this.groupNotificationLocation.Text = "Location";
|
||||
//
|
||||
@@ -86,18 +84,18 @@
|
||||
this.labelEdgeDistanceValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
|
||||
this.labelEdgeDistanceValue.Name = "labelEdgeDistanceValue";
|
||||
this.labelEdgeDistanceValue.Size = new System.Drawing.Size(34, 13);
|
||||
this.labelEdgeDistanceValue.TabIndex = 11;
|
||||
this.labelEdgeDistanceValue.TabIndex = 9;
|
||||
this.labelEdgeDistanceValue.Text = "0 px";
|
||||
this.labelEdgeDistanceValue.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
//
|
||||
// labelDisplay
|
||||
//
|
||||
this.labelDisplay.AutoSize = true;
|
||||
this.labelDisplay.Location = new System.Drawing.Point(3, 148);
|
||||
this.labelDisplay.Location = new System.Drawing.Point(5, 144);
|
||||
this.labelDisplay.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelDisplay.Name = "labelDisplay";
|
||||
this.labelDisplay.Size = new System.Drawing.Size(41, 13);
|
||||
this.labelDisplay.TabIndex = 8;
|
||||
this.labelDisplay.TabIndex = 5;
|
||||
this.labelDisplay.Text = "Display";
|
||||
//
|
||||
// comboBoxDisplay
|
||||
@@ -106,26 +104,26 @@
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.comboBoxDisplay.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxDisplay.FormattingEnabled = true;
|
||||
this.comboBoxDisplay.Location = new System.Drawing.Point(6, 164);
|
||||
this.comboBoxDisplay.Location = new System.Drawing.Point(8, 160);
|
||||
this.comboBoxDisplay.Name = "comboBoxDisplay";
|
||||
this.comboBoxDisplay.Size = new System.Drawing.Size(171, 21);
|
||||
this.comboBoxDisplay.TabIndex = 7;
|
||||
this.comboBoxDisplay.SelectedValueChanged += new System.EventHandler(this.comboBoxDisplay_SelectedValueChanged);
|
||||
this.comboBoxDisplay.TabIndex = 6;
|
||||
//
|
||||
// labelEdgeDistance
|
||||
//
|
||||
this.labelEdgeDistance.AutoSize = true;
|
||||
this.labelEdgeDistance.Location = new System.Drawing.Point(3, 197);
|
||||
this.labelEdgeDistance.Location = new System.Drawing.Point(5, 193);
|
||||
this.labelEdgeDistance.Margin = new System.Windows.Forms.Padding(3, 9, 3, 0);
|
||||
this.labelEdgeDistance.Name = "labelEdgeDistance";
|
||||
this.labelEdgeDistance.Size = new System.Drawing.Size(103, 13);
|
||||
this.labelEdgeDistance.TabIndex = 6;
|
||||
this.labelEdgeDistance.TabIndex = 7;
|
||||
this.labelEdgeDistance.Text = "Distance From Edge";
|
||||
//
|
||||
// radioLocCustom
|
||||
//
|
||||
this.radioLocCustom.AutoSize = true;
|
||||
this.radioLocCustom.Location = new System.Drawing.Point(7, 116);
|
||||
this.radioLocCustom.Location = new System.Drawing.Point(8, 112);
|
||||
this.radioLocCustom.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.radioLocCustom.Name = "radioLocCustom";
|
||||
this.radioLocCustom.Size = new System.Drawing.Size(60, 17);
|
||||
this.radioLocCustom.TabIndex = 4;
|
||||
@@ -133,81 +131,79 @@
|
||||
this.radioLocCustom.Text = "Custom";
|
||||
this.toolTip.SetToolTip(this.radioLocCustom, "Drag the notification window to the desired location.");
|
||||
this.radioLocCustom.UseVisualStyleBackColor = true;
|
||||
this.radioLocCustom.CheckedChanged += new System.EventHandler(this.radioLoc_CheckedChanged);
|
||||
//
|
||||
// radioLocBR
|
||||
//
|
||||
this.radioLocBR.AutoSize = true;
|
||||
this.radioLocBR.Location = new System.Drawing.Point(7, 92);
|
||||
this.radioLocBR.Location = new System.Drawing.Point(8, 89);
|
||||
this.radioLocBR.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.radioLocBR.Name = "radioLocBR";
|
||||
this.radioLocBR.Size = new System.Drawing.Size(86, 17);
|
||||
this.radioLocBR.TabIndex = 3;
|
||||
this.radioLocBR.TabStop = true;
|
||||
this.radioLocBR.Text = "Bottom Right";
|
||||
this.radioLocBR.UseVisualStyleBackColor = true;
|
||||
this.radioLocBR.CheckedChanged += new System.EventHandler(this.radioLoc_CheckedChanged);
|
||||
//
|
||||
// radioLocBL
|
||||
//
|
||||
this.radioLocBL.AutoSize = true;
|
||||
this.radioLocBL.Location = new System.Drawing.Point(7, 68);
|
||||
this.radioLocBL.Location = new System.Drawing.Point(8, 66);
|
||||
this.radioLocBL.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.radioLocBL.Name = "radioLocBL";
|
||||
this.radioLocBL.Size = new System.Drawing.Size(79, 17);
|
||||
this.radioLocBL.TabIndex = 2;
|
||||
this.radioLocBL.TabStop = true;
|
||||
this.radioLocBL.Text = "Bottom Left";
|
||||
this.radioLocBL.UseVisualStyleBackColor = true;
|
||||
this.radioLocBL.CheckedChanged += new System.EventHandler(this.radioLoc_CheckedChanged);
|
||||
//
|
||||
// radioLocTR
|
||||
//
|
||||
this.radioLocTR.AutoSize = true;
|
||||
this.radioLocTR.Location = new System.Drawing.Point(7, 44);
|
||||
this.radioLocTR.Location = new System.Drawing.Point(8, 43);
|
||||
this.radioLocTR.Margin = new System.Windows.Forms.Padding(5, 3, 3, 3);
|
||||
this.radioLocTR.Name = "radioLocTR";
|
||||
this.radioLocTR.Size = new System.Drawing.Size(72, 17);
|
||||
this.radioLocTR.TabIndex = 1;
|
||||
this.radioLocTR.TabStop = true;
|
||||
this.radioLocTR.Text = "Top Right";
|
||||
this.radioLocTR.UseVisualStyleBackColor = true;
|
||||
this.radioLocTR.CheckedChanged += new System.EventHandler(this.radioLoc_CheckedChanged);
|
||||
//
|
||||
// radioLocTL
|
||||
//
|
||||
this.radioLocTL.AutoSize = true;
|
||||
this.radioLocTL.Location = new System.Drawing.Point(7, 20);
|
||||
this.radioLocTL.Location = new System.Drawing.Point(8, 20);
|
||||
this.radioLocTL.Margin = new System.Windows.Forms.Padding(5, 4, 3, 3);
|
||||
this.radioLocTL.Name = "radioLocTL";
|
||||
this.radioLocTL.Size = new System.Drawing.Size(65, 17);
|
||||
this.radioLocTL.TabIndex = 0;
|
||||
this.radioLocTL.TabStop = true;
|
||||
this.radioLocTL.Text = "Top Left";
|
||||
this.radioLocTL.UseVisualStyleBackColor = true;
|
||||
this.radioLocTL.CheckedChanged += new System.EventHandler(this.radioLoc_CheckedChanged);
|
||||
//
|
||||
// trackBarEdgeDistance
|
||||
//
|
||||
this.trackBarEdgeDistance.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.trackBarEdgeDistance.LargeChange = 8;
|
||||
this.trackBarEdgeDistance.Location = new System.Drawing.Point(6, 213);
|
||||
this.trackBarEdgeDistance.Location = new System.Drawing.Point(8, 209);
|
||||
this.trackBarEdgeDistance.Maximum = 40;
|
||||
this.trackBarEdgeDistance.Minimum = 8;
|
||||
this.trackBarEdgeDistance.Name = "trackBarEdgeDistance";
|
||||
this.trackBarEdgeDistance.Size = new System.Drawing.Size(141, 45);
|
||||
this.trackBarEdgeDistance.SmallChange = 2;
|
||||
this.trackBarEdgeDistance.TabIndex = 5;
|
||||
this.trackBarEdgeDistance.TabIndex = 8;
|
||||
this.trackBarEdgeDistance.TickFrequency = 4;
|
||||
this.trackBarEdgeDistance.Value = 8;
|
||||
this.trackBarEdgeDistance.ValueChanged += new System.EventHandler(this.trackBarEdgeDistance_ValueChanged);
|
||||
//
|
||||
// groupNotificationDuration
|
||||
//
|
||||
this.groupNotificationDuration.Controls.Add(this.tableLayoutDurationButtons);
|
||||
this.groupNotificationDuration.Controls.Add(this.labelDurationValue);
|
||||
this.groupNotificationDuration.Controls.Add(this.trackBarDuration);
|
||||
this.groupNotificationDuration.Location = new System.Drawing.Point(9, 106);
|
||||
this.groupNotificationDuration.Location = new System.Drawing.Point(9, 184);
|
||||
this.groupNotificationDuration.Name = "groupNotificationDuration";
|
||||
this.groupNotificationDuration.Size = new System.Drawing.Size(183, 89);
|
||||
this.groupNotificationDuration.TabIndex = 9;
|
||||
this.groupNotificationDuration.TabIndex = 1;
|
||||
this.groupNotificationDuration.TabStop = false;
|
||||
this.groupNotificationDuration.Text = "Duration";
|
||||
//
|
||||
@@ -227,7 +223,7 @@
|
||||
this.tableLayoutDurationButtons.RowCount = 1;
|
||||
this.tableLayoutDurationButtons.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 100F));
|
||||
this.tableLayoutDurationButtons.Size = new System.Drawing.Size(171, 27);
|
||||
this.tableLayoutDurationButtons.TabIndex = 5;
|
||||
this.tableLayoutDurationButtons.TabIndex = 2;
|
||||
//
|
||||
// btnDurationMedium
|
||||
//
|
||||
@@ -240,10 +236,9 @@
|
||||
this.btnDurationMedium.Margin = new System.Windows.Forms.Padding(1);
|
||||
this.btnDurationMedium.Name = "btnDurationMedium";
|
||||
this.btnDurationMedium.Size = new System.Drawing.Size(59, 25);
|
||||
this.btnDurationMedium.TabIndex = 2;
|
||||
this.btnDurationMedium.TabIndex = 1;
|
||||
this.btnDurationMedium.Text = "Medium";
|
||||
this.btnDurationMedium.UseVisualStyleBackColor = true;
|
||||
this.btnDurationMedium.Click += new System.EventHandler(this.btnDurationMedium_Click);
|
||||
//
|
||||
// btnDurationLong
|
||||
//
|
||||
@@ -256,10 +251,9 @@
|
||||
this.btnDurationLong.Margin = new System.Windows.Forms.Padding(1);
|
||||
this.btnDurationLong.Name = "btnDurationLong";
|
||||
this.btnDurationLong.Size = new System.Drawing.Size(54, 25);
|
||||
this.btnDurationLong.TabIndex = 1;
|
||||
this.btnDurationLong.TabIndex = 2;
|
||||
this.btnDurationLong.Text = "Long";
|
||||
this.btnDurationLong.UseVisualStyleBackColor = true;
|
||||
this.btnDurationLong.Click += new System.EventHandler(this.btnDurationLong_Click);
|
||||
//
|
||||
// btnDurationShort
|
||||
//
|
||||
@@ -275,7 +269,6 @@
|
||||
this.btnDurationShort.TabIndex = 0;
|
||||
this.btnDurationShort.Text = "Short";
|
||||
this.btnDurationShort.UseVisualStyleBackColor = true;
|
||||
this.btnDurationShort.Click += new System.EventHandler(this.btnDurationShort_Click);
|
||||
//
|
||||
// labelDurationValue
|
||||
//
|
||||
@@ -285,7 +278,7 @@
|
||||
this.labelDurationValue.Margin = new System.Windows.Forms.Padding(0, 0, 3, 0);
|
||||
this.labelDurationValue.Name = "labelDurationValue";
|
||||
this.labelDurationValue.Size = new System.Drawing.Size(48, 13);
|
||||
this.labelDurationValue.TabIndex = 13;
|
||||
this.labelDurationValue.TabIndex = 1;
|
||||
this.labelDurationValue.Text = "0 ms/c";
|
||||
this.labelDurationValue.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
this.toolTip.SetToolTip(this.labelDurationValue, "Milliseconds per character.");
|
||||
@@ -299,109 +292,102 @@
|
||||
this.trackBarDuration.Minimum = 10;
|
||||
this.trackBarDuration.Name = "trackBarDuration";
|
||||
this.trackBarDuration.Size = new System.Drawing.Size(128, 45);
|
||||
this.trackBarDuration.TabIndex = 12;
|
||||
this.trackBarDuration.TabIndex = 0;
|
||||
this.trackBarDuration.TickFrequency = 5;
|
||||
this.trackBarDuration.Value = 25;
|
||||
this.trackBarDuration.ValueChanged += new System.EventHandler(this.trackBarDuration_ValueChanged);
|
||||
//
|
||||
// groupUserInterface
|
||||
//
|
||||
this.groupUserInterface.Controls.Add(this.checkColumnName);
|
||||
this.groupUserInterface.Controls.Add(this.labelIdlePause);
|
||||
this.groupUserInterface.Controls.Add(this.comboBoxIdlePause);
|
||||
this.groupUserInterface.Controls.Add(this.checkNonIntrusive);
|
||||
this.groupUserInterface.Controls.Add(this.checkTimerCountDown);
|
||||
this.groupUserInterface.Controls.Add(this.checkLegacyLoad);
|
||||
this.groupUserInterface.Controls.Add(this.checkNotificationTimer);
|
||||
this.groupUserInterface.Location = new System.Drawing.Point(9, 9);
|
||||
this.groupUserInterface.Name = "groupUserInterface";
|
||||
this.groupUserInterface.Size = new System.Drawing.Size(183, 91);
|
||||
this.groupUserInterface.TabIndex = 10;
|
||||
this.groupUserInterface.Size = new System.Drawing.Size(183, 169);
|
||||
this.groupUserInterface.TabIndex = 0;
|
||||
this.groupUserInterface.TabStop = false;
|
||||
this.groupUserInterface.Text = "General";
|
||||
//
|
||||
// checkColumnName
|
||||
//
|
||||
this.checkColumnName.AutoSize = true;
|
||||
this.checkColumnName.Location = new System.Drawing.Point(9, 21);
|
||||
this.checkColumnName.Margin = new System.Windows.Forms.Padding(6, 5, 3, 3);
|
||||
this.checkColumnName.Name = "checkColumnName";
|
||||
this.checkColumnName.Size = new System.Drawing.Size(129, 17);
|
||||
this.checkColumnName.TabIndex = 5;
|
||||
this.checkColumnName.Text = "Display Column Name";
|
||||
this.toolTip.SetToolTip(this.checkColumnName, "Shows column name each notification originated\r\nfrom in the notification window t" +
|
||||
"itle.");
|
||||
this.checkColumnName.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// labelIdlePause
|
||||
//
|
||||
this.labelIdlePause.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.labelIdlePause.AutoSize = true;
|
||||
this.labelIdlePause.Location = new System.Drawing.Point(3, 123);
|
||||
this.labelIdlePause.Margin = new System.Windows.Forms.Padding(3, 12, 3, 0);
|
||||
this.labelIdlePause.Name = "labelIdlePause";
|
||||
this.labelIdlePause.Size = new System.Drawing.Size(89, 13);
|
||||
this.labelIdlePause.TabIndex = 3;
|
||||
this.labelIdlePause.Text = "Pause When Idle";
|
||||
//
|
||||
// comboBoxIdlePause
|
||||
//
|
||||
this.comboBoxIdlePause.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.comboBoxIdlePause.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxIdlePause.FormattingEnabled = true;
|
||||
this.comboBoxIdlePause.Location = new System.Drawing.Point(6, 139);
|
||||
this.comboBoxIdlePause.Name = "comboBoxIdlePause";
|
||||
this.comboBoxIdlePause.Size = new System.Drawing.Size(171, 21);
|
||||
this.comboBoxIdlePause.TabIndex = 4;
|
||||
this.toolTip.SetToolTip(this.comboBoxIdlePause, "Pauses new notifications after going idle for a set amount of time.");
|
||||
//
|
||||
// checkNonIntrusive
|
||||
//
|
||||
this.checkNonIntrusive.AutoSize = true;
|
||||
this.checkNonIntrusive.Location = new System.Drawing.Point(9, 90);
|
||||
this.checkNonIntrusive.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
|
||||
this.checkNonIntrusive.Name = "checkNonIntrusive";
|
||||
this.checkNonIntrusive.Size = new System.Drawing.Size(128, 17);
|
||||
this.checkNonIntrusive.TabIndex = 2;
|
||||
this.checkNonIntrusive.Text = "Non-Intrusive Popups";
|
||||
this.toolTip.SetToolTip(this.checkNonIntrusive, "When not idle and the cursor is within the notification window area,\r\nit will be " +
|
||||
"delayed until the cursor moves away to prevent accidental clicks.");
|
||||
this.checkNonIntrusive.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkTimerCountDown
|
||||
//
|
||||
this.checkTimerCountDown.AutoSize = true;
|
||||
this.checkTimerCountDown.Location = new System.Drawing.Point(6, 44);
|
||||
this.checkTimerCountDown.Location = new System.Drawing.Point(9, 67);
|
||||
this.checkTimerCountDown.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
|
||||
this.checkTimerCountDown.Name = "checkTimerCountDown";
|
||||
this.checkTimerCountDown.Size = new System.Drawing.Size(119, 17);
|
||||
this.checkTimerCountDown.TabIndex = 6;
|
||||
this.checkTimerCountDown.TabIndex = 1;
|
||||
this.checkTimerCountDown.Text = "Timer Counts Down";
|
||||
this.toolTip.SetToolTip(this.checkTimerCountDown, "The notification timer counts down instead of up.");
|
||||
this.checkTimerCountDown.UseVisualStyleBackColor = true;
|
||||
this.checkTimerCountDown.CheckedChanged += new System.EventHandler(this.checkTimerCountDown_CheckedChanged);
|
||||
//
|
||||
// checkLegacyLoad
|
||||
//
|
||||
this.checkLegacyLoad.AutoSize = true;
|
||||
this.checkLegacyLoad.Location = new System.Drawing.Point(6, 67);
|
||||
this.checkLegacyLoad.Name = "checkLegacyLoad";
|
||||
this.checkLegacyLoad.Size = new System.Drawing.Size(139, 17);
|
||||
this.checkLegacyLoad.TabIndex = 5;
|
||||
this.checkLegacyLoad.Text = "Legacy Loading System";
|
||||
this.toolTip.SetToolTip(this.checkLegacyLoad, "Try enabling if notifications do not display.\r\nMight cause delays and visual arti" +
|
||||
"facts.");
|
||||
this.checkLegacyLoad.UseVisualStyleBackColor = true;
|
||||
this.checkLegacyLoad.CheckedChanged += new System.EventHandler(this.checkLegacyLoad_CheckedChanged);
|
||||
//
|
||||
// checkNotificationTimer
|
||||
//
|
||||
this.checkNotificationTimer.AutoSize = true;
|
||||
this.checkNotificationTimer.Location = new System.Drawing.Point(6, 21);
|
||||
this.checkNotificationTimer.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
|
||||
this.checkNotificationTimer.Location = new System.Drawing.Point(9, 44);
|
||||
this.checkNotificationTimer.Margin = new System.Windows.Forms.Padding(6, 3, 3, 3);
|
||||
this.checkNotificationTimer.Name = "checkNotificationTimer";
|
||||
this.checkNotificationTimer.Size = new System.Drawing.Size(145, 17);
|
||||
this.checkNotificationTimer.TabIndex = 4;
|
||||
this.checkNotificationTimer.TabIndex = 0;
|
||||
this.checkNotificationTimer.Text = "Display Notification Timer";
|
||||
this.toolTip.SetToolTip(this.checkNotificationTimer, "Shows how much time is left before the current notification disappears.");
|
||||
this.checkNotificationTimer.UseVisualStyleBackColor = true;
|
||||
this.checkNotificationTimer.CheckedChanged += new System.EventHandler(this.checkNotificationTimer_CheckedChanged);
|
||||
//
|
||||
// groupCustomSound
|
||||
//
|
||||
this.groupCustomSound.Controls.Add(this.btnResetSound);
|
||||
this.groupCustomSound.Controls.Add(this.btnBrowseSound);
|
||||
this.groupCustomSound.Controls.Add(this.tbCustomSound);
|
||||
this.groupCustomSound.Location = new System.Drawing.Point(9, 201);
|
||||
this.groupCustomSound.Name = "groupCustomSound";
|
||||
this.groupCustomSound.Size = new System.Drawing.Size(183, 72);
|
||||
this.groupCustomSound.TabIndex = 11;
|
||||
this.groupCustomSound.TabStop = false;
|
||||
this.groupCustomSound.Text = "Custom Sound";
|
||||
//
|
||||
// tbCustomSound
|
||||
//
|
||||
this.tbCustomSound.Location = new System.Drawing.Point(6, 19);
|
||||
this.tbCustomSound.Name = "tbCustomSound";
|
||||
this.tbCustomSound.Size = new System.Drawing.Size(170, 20);
|
||||
this.tbCustomSound.TabIndex = 0;
|
||||
//
|
||||
// btnBrowseSound
|
||||
//
|
||||
this.btnBrowseSound.AutoSize = true;
|
||||
this.btnBrowseSound.Location = new System.Drawing.Point(53, 43);
|
||||
this.btnBrowseSound.Name = "btnBrowseSound";
|
||||
this.btnBrowseSound.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnBrowseSound.Size = new System.Drawing.Size(67, 23);
|
||||
this.btnBrowseSound.TabIndex = 1;
|
||||
this.btnBrowseSound.Text = "Browse...";
|
||||
this.btnBrowseSound.UseVisualStyleBackColor = true;
|
||||
this.btnBrowseSound.Click += new System.EventHandler(this.btnBrowseSound_Click);
|
||||
//
|
||||
// btnResetSound
|
||||
//
|
||||
this.btnResetSound.AutoSize = true;
|
||||
this.btnResetSound.Location = new System.Drawing.Point(126, 43);
|
||||
this.btnResetSound.Name = "btnResetSound";
|
||||
this.btnResetSound.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnResetSound.Size = new System.Drawing.Size(51, 23);
|
||||
this.btnResetSound.TabIndex = 2;
|
||||
this.btnResetSound.Text = "Reset";
|
||||
this.btnResetSound.UseVisualStyleBackColor = true;
|
||||
this.btnResetSound.Click += new System.EventHandler(this.btnResetSound_Click);
|
||||
//
|
||||
// TabSettingsNotifications
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.groupCustomSound);
|
||||
this.Controls.Add(this.groupUserInterface);
|
||||
this.Controls.Add(this.groupNotificationDuration);
|
||||
this.Controls.Add(this.groupNotificationLocation);
|
||||
@@ -417,8 +403,6 @@
|
||||
((System.ComponentModel.ISupportInitialize)(this.trackBarDuration)).EndInit();
|
||||
this.groupUserInterface.ResumeLayout(false);
|
||||
this.groupUserInterface.PerformLayout();
|
||||
this.groupCustomSound.ResumeLayout(false);
|
||||
this.groupCustomSound.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
@@ -440,7 +424,6 @@
|
||||
private System.Windows.Forms.CheckBox checkNotificationTimer;
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
private System.Windows.Forms.Label labelEdgeDistanceValue;
|
||||
private System.Windows.Forms.CheckBox checkLegacyLoad;
|
||||
private System.Windows.Forms.CheckBox checkTimerCountDown;
|
||||
private System.Windows.Forms.Label labelDurationValue;
|
||||
private System.Windows.Forms.TrackBar trackBarDuration;
|
||||
@@ -448,9 +431,9 @@
|
||||
private TweetDck.Core.Controls.FlatButton btnDurationMedium;
|
||||
private TweetDck.Core.Controls.FlatButton btnDurationLong;
|
||||
private TweetDck.Core.Controls.FlatButton btnDurationShort;
|
||||
private System.Windows.Forms.GroupBox groupCustomSound;
|
||||
private System.Windows.Forms.Button btnResetSound;
|
||||
private System.Windows.Forms.Button btnBrowseSound;
|
||||
private System.Windows.Forms.TextBox tbCustomSound;
|
||||
private System.Windows.Forms.CheckBox checkNonIntrusive;
|
||||
private System.Windows.Forms.Label labelIdlePause;
|
||||
private System.Windows.Forms.ComboBox comboBoxIdlePause;
|
||||
private System.Windows.Forms.CheckBox checkColumnName;
|
||||
}
|
||||
}
|
||||
|
@@ -1,17 +1,16 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Globalization;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Controls;
|
||||
using TweetDck.Core.Notification;
|
||||
using TweetDck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings{
|
||||
partial class TabSettingsNotifications : BaseTabSettings{
|
||||
private readonly FormNotification notification;
|
||||
private readonly Point initCursorPosition;
|
||||
private static readonly int[] IdlePauseSeconds = { 0, 30, 60, 120, 300 };
|
||||
|
||||
public TabSettingsNotifications(FormNotification notification){
|
||||
private readonly FormNotificationMain notification;
|
||||
|
||||
public TabSettingsNotifications(FormNotificationMain notification){
|
||||
InitializeComponent();
|
||||
|
||||
this.notification = notification;
|
||||
@@ -24,13 +23,11 @@ namespace TweetDck.Core.Other.Settings{
|
||||
};
|
||||
|
||||
this.notification.Initialized += (sender, args) => {
|
||||
this.InvokeSafe(() => this.notification.ShowNotificationForSettings(true));
|
||||
this.InvokeAsyncSafe(() => this.notification.ShowNotificationForSettings(true));
|
||||
};
|
||||
|
||||
this.notification.Activated += notification_Activated;
|
||||
this.notification.Show(this);
|
||||
|
||||
initCursorPosition = Cursor.Position;
|
||||
this.notification.Show();
|
||||
|
||||
switch(Config.NotificationPosition){
|
||||
case TweetNotification.Position.TopLeft: radioLocTL.Checked = true; break;
|
||||
@@ -43,6 +40,13 @@ namespace TweetDck.Core.Other.Settings{
|
||||
trackBarDuration.SetValueSafe(Config.NotificationDurationValue);
|
||||
labelDurationValue.Text = Config.NotificationDurationValue+" ms/c";
|
||||
|
||||
comboBoxIdlePause.Items.Add("Disabled");
|
||||
comboBoxIdlePause.Items.Add("30 seconds");
|
||||
comboBoxIdlePause.Items.Add("1 minute");
|
||||
comboBoxIdlePause.Items.Add("2 minutes");
|
||||
comboBoxIdlePause.Items.Add("5 minutes");
|
||||
comboBoxIdlePause.SelectedIndex = Math.Max(0, Array.FindIndex(IdlePauseSeconds, val => val == Config.NotificationIdlePauseSeconds));
|
||||
|
||||
comboBoxDisplay.Items.Add("(Same As "+Program.BrandName+")");
|
||||
|
||||
foreach(Screen screen in Screen.AllScreens){
|
||||
@@ -50,22 +54,40 @@ namespace TweetDck.Core.Other.Settings{
|
||||
}
|
||||
|
||||
comboBoxDisplay.SelectedIndex = Math.Min(comboBoxDisplay.Items.Count-1, Config.NotificationDisplay);
|
||||
|
||||
|
||||
checkColumnName.Checked = Config.DisplayNotificationColumn;
|
||||
checkNotificationTimer.Checked = Config.DisplayNotificationTimer;
|
||||
checkTimerCountDown.Enabled = checkNotificationTimer.Checked;
|
||||
checkTimerCountDown.Checked = Config.NotificationTimerCountDown;
|
||||
checkLegacyLoad.Checked = Config.NotificationLegacyLoad;
|
||||
checkNonIntrusive.Checked = Config.NotificationNonIntrusiveMode;
|
||||
|
||||
trackBarEdgeDistance.SetValueSafe(Config.NotificationEdgeDistance);
|
||||
labelEdgeDistanceValue.Text = trackBarEdgeDistance.Value.ToString(CultureInfo.InvariantCulture)+" px";
|
||||
|
||||
tbCustomSound.Text = Config.NotificationSoundPath ?? string.Empty;
|
||||
|
||||
Disposed += (sender, args) => this.notification.Dispose();
|
||||
}
|
||||
|
||||
public override void OnClosing(){
|
||||
Config.NotificationSoundPath = tbCustomSound.Text;
|
||||
public override void OnReady(){
|
||||
radioLocTL.CheckedChanged += radioLoc_CheckedChanged;
|
||||
radioLocTR.CheckedChanged += radioLoc_CheckedChanged;
|
||||
radioLocBL.CheckedChanged += radioLoc_CheckedChanged;
|
||||
radioLocBR.CheckedChanged += radioLoc_CheckedChanged;
|
||||
radioLocCustom.CheckedChanged += radioLoc_CheckedChanged;
|
||||
|
||||
trackBarDuration.ValueChanged += trackBarDuration_ValueChanged;
|
||||
btnDurationShort.Click += btnDurationShort_Click;
|
||||
btnDurationMedium.Click += btnDurationMedium_Click;
|
||||
btnDurationLong.Click += btnDurationLong_Click;
|
||||
|
||||
checkColumnName.CheckedChanged += checkColumnName_CheckedChanged;
|
||||
checkNotificationTimer.CheckedChanged += checkNotificationTimer_CheckedChanged;
|
||||
checkTimerCountDown.CheckedChanged += checkTimerCountDown_CheckedChanged;
|
||||
checkNonIntrusive.CheckedChanged += checkNonIntrusive_CheckedChanged;
|
||||
|
||||
comboBoxIdlePause.SelectedValueChanged += comboBoxIdlePause_SelectedValueChanged;
|
||||
|
||||
comboBoxDisplay.SelectedValueChanged += comboBoxDisplay_SelectedValueChanged;
|
||||
trackBarEdgeDistance.ValueChanged += trackBarEdgeDistance_ValueChanged;
|
||||
}
|
||||
|
||||
private void TabSettingsNotifications_ParentChanged(object sender, EventArgs e){
|
||||
@@ -78,23 +100,11 @@ namespace TweetDck.Core.Other.Settings{
|
||||
}
|
||||
|
||||
private void notification_Activated(object sender, EventArgs e){
|
||||
if (Cursor.Position == initCursorPosition){
|
||||
Timer delay = WindowsUtils.CreateSingleTickTimer(1);
|
||||
|
||||
delay.Tick += (sender2, args2) => { // here you can see a disgusting hack to force the freshly opened notification window out of focus
|
||||
NativeMethods.SimulateMouseClick(NativeMethods.MouseButton.Left); // because for some reason, the stupid thing keeps stealing it
|
||||
delay.Dispose(); // even after using ShowWithoutActivation, the CreateParams bullshit, and about a million different combinations
|
||||
}; // of trying to force the original form back into focus in various events, so you will have to fucking deal with it, alright
|
||||
|
||||
delay.Start();
|
||||
}
|
||||
|
||||
notification.Hide();
|
||||
notification.Activated -= notification_Activated;
|
||||
}
|
||||
|
||||
private void radioLoc_CheckedChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
if (radioLocTL.Checked)Config.NotificationPosition = TweetNotification.Position.TopLeft;
|
||||
else if (radioLocTR.Checked)Config.NotificationPosition = TweetNotification.Position.TopRight;
|
||||
else if (radioLocBL.Checked)Config.NotificationPosition = TweetNotification.Position.BottomLeft;
|
||||
@@ -112,8 +122,6 @@ namespace TweetDck.Core.Other.Settings{
|
||||
}
|
||||
|
||||
private void trackBarDuration_ValueChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
Config.NotificationDurationValue = trackBarDuration.Value;
|
||||
labelDurationValue.Text = Config.NotificationDurationValue+" ms/c";
|
||||
|
||||
@@ -121,74 +129,50 @@ namespace TweetDck.Core.Other.Settings{
|
||||
}
|
||||
|
||||
private void btnDurationShort_Click(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
trackBarDuration.Value = 15;
|
||||
}
|
||||
|
||||
private void btnDurationMedium_Click(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
trackBarDuration.Value = 25;
|
||||
}
|
||||
|
||||
private void btnDurationLong_Click(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
trackBarDuration.Value = 35;
|
||||
}
|
||||
|
||||
private void checkNotificationTimer_CheckedChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
private void checkColumnName_CheckedChanged(object sender, EventArgs e){
|
||||
Config.DisplayNotificationColumn = checkColumnName.Checked;
|
||||
notification.ShowNotificationForSettings(false);
|
||||
}
|
||||
|
||||
private void checkNotificationTimer_CheckedChanged(object sender, EventArgs e){
|
||||
Config.DisplayNotificationTimer = checkNotificationTimer.Checked;
|
||||
checkTimerCountDown.Enabled = checkNotificationTimer.Checked;
|
||||
notification.ShowNotificationForSettings(true);
|
||||
}
|
||||
|
||||
private void checkTimerCountDown_CheckedChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
Config.NotificationTimerCountDown = checkTimerCountDown.Checked;
|
||||
notification.ShowNotificationForSettings(true);
|
||||
}
|
||||
|
||||
private void checkLegacyLoad_CheckedChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
private void checkNonIntrusive_CheckedChanged(object sender, EventArgs e){
|
||||
Config.NotificationNonIntrusiveMode = checkNonIntrusive.Checked;
|
||||
}
|
||||
|
||||
Config.NotificationLegacyLoad = checkLegacyLoad.Checked;
|
||||
private void comboBoxIdlePause_SelectedValueChanged(object sender, EventArgs e){
|
||||
Config.NotificationIdlePauseSeconds = IdlePauseSeconds[comboBoxIdlePause.SelectedIndex];
|
||||
}
|
||||
|
||||
private void comboBoxDisplay_SelectedValueChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
Config.NotificationDisplay = comboBoxDisplay.SelectedIndex;
|
||||
notification.ShowNotificationForSettings(false);
|
||||
}
|
||||
|
||||
private void trackBarEdgeDistance_ValueChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
labelEdgeDistanceValue.Text = trackBarEdgeDistance.Value.ToString(CultureInfo.InvariantCulture)+" px";
|
||||
Config.NotificationEdgeDistance = trackBarEdgeDistance.Value;
|
||||
notification.ShowNotificationForSettings(false);
|
||||
}
|
||||
|
||||
private void btnBrowseSound_Click(object sender, EventArgs e){
|
||||
using(OpenFileDialog dialog = new OpenFileDialog{
|
||||
AutoUpgradeEnabled = true,
|
||||
DereferenceLinks = true,
|
||||
Title = "Custom Notification Sound",
|
||||
Filter = "Wave file (*.wav)|*.wav"
|
||||
}){
|
||||
if (dialog.ShowDialog() == DialogResult.OK){
|
||||
tbCustomSound.Text = dialog.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnResetSound_Click(object sender, EventArgs e){
|
||||
tbCustomSound.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
111
Core/Other/Settings/TabSettingsSounds.Designer.cs
generated
Normal file
111
Core/Other/Settings/TabSettingsSounds.Designer.cs
generated
Normal file
@@ -0,0 +1,111 @@
|
||||
namespace TweetDck.Core.Other.Settings {
|
||||
partial class TabSettingsSounds {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.groupCustomSound = new System.Windows.Forms.GroupBox();
|
||||
this.btnPlaySound = new System.Windows.Forms.Button();
|
||||
this.btnResetSound = new System.Windows.Forms.Button();
|
||||
this.btnBrowseSound = new System.Windows.Forms.Button();
|
||||
this.tbCustomSound = new System.Windows.Forms.TextBox();
|
||||
this.groupCustomSound.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// groupCustomSound
|
||||
//
|
||||
this.groupCustomSound.Controls.Add(this.btnPlaySound);
|
||||
this.groupCustomSound.Controls.Add(this.btnResetSound);
|
||||
this.groupCustomSound.Controls.Add(this.btnBrowseSound);
|
||||
this.groupCustomSound.Controls.Add(this.tbCustomSound);
|
||||
this.groupCustomSound.Location = new System.Drawing.Point(9, 9);
|
||||
this.groupCustomSound.Name = "groupCustomSound";
|
||||
this.groupCustomSound.Size = new System.Drawing.Size(372, 75);
|
||||
this.groupCustomSound.TabIndex = 0;
|
||||
this.groupCustomSound.TabStop = false;
|
||||
this.groupCustomSound.Text = "Custom Sound Notification";
|
||||
//
|
||||
// btnPlaySound
|
||||
//
|
||||
this.btnPlaySound.AutoSize = true;
|
||||
this.btnPlaySound.Location = new System.Drawing.Point(250, 45);
|
||||
this.btnPlaySound.Name = "btnPlaySound";
|
||||
this.btnPlaySound.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnPlaySound.Size = new System.Drawing.Size(43, 23);
|
||||
this.btnPlaySound.TabIndex = 2;
|
||||
this.btnPlaySound.Text = "Play";
|
||||
this.btnPlaySound.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnResetSound
|
||||
//
|
||||
this.btnResetSound.AutoSize = true;
|
||||
this.btnResetSound.Location = new System.Drawing.Point(6, 45);
|
||||
this.btnResetSound.Name = "btnResetSound";
|
||||
this.btnResetSound.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnResetSound.Size = new System.Drawing.Size(51, 23);
|
||||
this.btnResetSound.TabIndex = 3;
|
||||
this.btnResetSound.Text = "Reset";
|
||||
this.btnResetSound.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// btnBrowseSound
|
||||
//
|
||||
this.btnBrowseSound.AutoSize = true;
|
||||
this.btnBrowseSound.Location = new System.Drawing.Point(299, 45);
|
||||
this.btnBrowseSound.Name = "btnBrowseSound";
|
||||
this.btnBrowseSound.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
|
||||
this.btnBrowseSound.Size = new System.Drawing.Size(67, 23);
|
||||
this.btnBrowseSound.TabIndex = 1;
|
||||
this.btnBrowseSound.Text = "Browse...";
|
||||
this.btnBrowseSound.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// tbCustomSound
|
||||
//
|
||||
this.tbCustomSound.Location = new System.Drawing.Point(6, 19);
|
||||
this.tbCustomSound.Name = "tbCustomSound";
|
||||
this.tbCustomSound.Size = new System.Drawing.Size(360, 20);
|
||||
this.tbCustomSound.TabIndex = 0;
|
||||
//
|
||||
// TabSettingsSounds
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.groupCustomSound);
|
||||
this.Name = "TabSettingsSounds";
|
||||
this.Size = new System.Drawing.Size(478, 282);
|
||||
this.groupCustomSound.ResumeLayout(false);
|
||||
this.groupCustomSound.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
private System.Windows.Forms.GroupBox groupCustomSound;
|
||||
private System.Windows.Forms.Button btnResetSound;
|
||||
private System.Windows.Forms.Button btnBrowseSound;
|
||||
private System.Windows.Forms.TextBox tbCustomSound;
|
||||
private System.Windows.Forms.Button btnPlaySound;
|
||||
}
|
||||
}
|
67
Core/Other/Settings/TabSettingsSounds.cs
Normal file
67
Core/Other/Settings/TabSettingsSounds.cs
Normal file
@@ -0,0 +1,67 @@
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Core.Notification;
|
||||
using TweetDck.Core.Notification.Sound;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings{
|
||||
partial class TabSettingsSounds : BaseTabSettings{
|
||||
private readonly ISoundNotificationPlayer soundNotification;
|
||||
|
||||
public TabSettingsSounds(){
|
||||
InitializeComponent();
|
||||
|
||||
soundNotification = SoundNotification.New();
|
||||
soundNotification.PlaybackError += sound_PlaybackError;
|
||||
|
||||
tbCustomSound.Text = Config.NotificationSoundPath;
|
||||
tbCustomSound_TextChanged(tbCustomSound, new EventArgs());
|
||||
|
||||
Disposed += (sender, args) => soundNotification.Dispose();
|
||||
}
|
||||
|
||||
public override void OnReady(){
|
||||
tbCustomSound.TextChanged += tbCustomSound_TextChanged;
|
||||
btnPlaySound.Click += btnPlaySound_Click;
|
||||
btnBrowseSound.Click += btnBrowseSound_Click;
|
||||
btnResetSound.Click += btnResetSound_Click;
|
||||
}
|
||||
|
||||
public override void OnClosing(){
|
||||
Config.NotificationSoundPath = tbCustomSound.Text;
|
||||
}
|
||||
|
||||
private void tbCustomSound_TextChanged(object sender, EventArgs e){
|
||||
bool isEmpty = string.IsNullOrEmpty(tbCustomSound.Text);
|
||||
tbCustomSound.ForeColor = isEmpty || File.Exists(tbCustomSound.Text) ? SystemColors.WindowText : Color.Maroon;
|
||||
btnPlaySound.Enabled = !isEmpty;
|
||||
btnResetSound.Enabled = !isEmpty;
|
||||
}
|
||||
|
||||
private void btnPlaySound_Click(object sender, EventArgs e){
|
||||
soundNotification.Play(tbCustomSound.Text);
|
||||
}
|
||||
|
||||
private void sound_PlaybackError(object sender, PlaybackErrorEventArgs e){
|
||||
MessageBox.Show("Could not play custom notification sound."+Environment.NewLine+e.Message, "Notification Sound Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
private void btnBrowseSound_Click(object sender, EventArgs e){
|
||||
using(OpenFileDialog dialog = new OpenFileDialog{
|
||||
AutoUpgradeEnabled = true,
|
||||
DereferenceLinks = true,
|
||||
Title = "Custom Notification Sound",
|
||||
Filter = "Sound file ("+soundNotification.SupportedFormats+")|"+soundNotification.SupportedFormats+"|All files (*.*)|*.*"
|
||||
}){
|
||||
if (dialog.ShowDialog() == DialogResult.OK){
|
||||
tbCustomSound.Text = dialog.FileName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void btnResetSound_Click(object sender, EventArgs e){
|
||||
tbCustomSound.Text = string.Empty;
|
||||
}
|
||||
}
|
||||
}
|
90
Core/Other/Settings/TabSettingsUpdates.Designer.cs
generated
90
Core/Other/Settings/TabSettingsUpdates.Designer.cs
generated
@@ -1,90 +0,0 @@
|
||||
namespace TweetDck.Core.Other.Settings {
|
||||
partial class TabSettingsUpdates {
|
||||
/// <summary>
|
||||
/// Required designer variable.
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// Clean up any resources being used.
|
||||
/// </summary>
|
||||
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
|
||||
protected override void Dispose(bool disposing) {
|
||||
if (disposing && (components != null)) {
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Component Designer generated code
|
||||
|
||||
/// <summary>
|
||||
/// Required method for Designer support - do not modify
|
||||
/// the contents of this method with the code editor.
|
||||
/// </summary>
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.btnCheckUpdates = new System.Windows.Forms.Button();
|
||||
this.checkUpdateNotifications = new System.Windows.Forms.CheckBox();
|
||||
this.toolTip = new System.Windows.Forms.ToolTip(this.components);
|
||||
this.groupGeneral = new System.Windows.Forms.GroupBox();
|
||||
this.groupGeneral.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// btnCheckUpdates
|
||||
//
|
||||
this.btnCheckUpdates.Location = new System.Drawing.Point(6, 44);
|
||||
this.btnCheckUpdates.Name = "btnCheckUpdates";
|
||||
this.btnCheckUpdates.Size = new System.Drawing.Size(171, 23);
|
||||
this.btnCheckUpdates.TabIndex = 15;
|
||||
this.btnCheckUpdates.Text = "Check Updates Now";
|
||||
this.toolTip.SetToolTip(this.btnCheckUpdates, "Forces an update check, even for updates that had been dismissed.");
|
||||
this.btnCheckUpdates.UseVisualStyleBackColor = true;
|
||||
this.btnCheckUpdates.Click += new System.EventHandler(this.btnCheckUpdates_Click);
|
||||
//
|
||||
// checkUpdateNotifications
|
||||
//
|
||||
this.checkUpdateNotifications.AutoSize = true;
|
||||
this.checkUpdateNotifications.Location = new System.Drawing.Point(6, 21);
|
||||
this.checkUpdateNotifications.Margin = new System.Windows.Forms.Padding(3, 5, 3, 3);
|
||||
this.checkUpdateNotifications.Name = "checkUpdateNotifications";
|
||||
this.checkUpdateNotifications.Size = new System.Drawing.Size(165, 17);
|
||||
this.checkUpdateNotifications.TabIndex = 14;
|
||||
this.checkUpdateNotifications.Text = "Check Updates Automatically";
|
||||
this.toolTip.SetToolTip(this.checkUpdateNotifications, "Checks for updates every hour.\r\nIf an update is dismissed, it will not appear aga" +
|
||||
"in.");
|
||||
this.checkUpdateNotifications.UseVisualStyleBackColor = true;
|
||||
this.checkUpdateNotifications.CheckedChanged += new System.EventHandler(this.checkUpdateNotifications_CheckedChanged);
|
||||
//
|
||||
// groupGeneral
|
||||
//
|
||||
this.groupGeneral.Controls.Add(this.checkUpdateNotifications);
|
||||
this.groupGeneral.Controls.Add(this.btnCheckUpdates);
|
||||
this.groupGeneral.Location = new System.Drawing.Point(9, 9);
|
||||
this.groupGeneral.Name = "groupGeneral";
|
||||
this.groupGeneral.Size = new System.Drawing.Size(183, 75);
|
||||
this.groupGeneral.TabIndex = 16;
|
||||
this.groupGeneral.TabStop = false;
|
||||
this.groupGeneral.Text = "General";
|
||||
//
|
||||
// TabSettingsUpdates
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.groupGeneral);
|
||||
this.Name = "TabSettingsUpdates";
|
||||
this.Size = new System.Drawing.Size(478, 282);
|
||||
this.groupGeneral.ResumeLayout(false);
|
||||
this.groupGeneral.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.Button btnCheckUpdates;
|
||||
private System.Windows.Forms.CheckBox checkUpdateNotifications;
|
||||
private System.Windows.Forms.ToolTip toolTip;
|
||||
private System.Windows.Forms.GroupBox groupGeneral;
|
||||
}
|
||||
}
|
@@ -1,48 +0,0 @@
|
||||
using System;
|
||||
using System.Windows.Forms;
|
||||
using TweetDck.Updates;
|
||||
|
||||
namespace TweetDck.Core.Other.Settings{
|
||||
partial class TabSettingsUpdates : BaseTabSettings{
|
||||
private readonly UpdateHandler updates;
|
||||
private int updateCheckEventId = -1;
|
||||
|
||||
public TabSettingsUpdates(UpdateHandler updates){
|
||||
InitializeComponent();
|
||||
|
||||
this.updates = updates;
|
||||
|
||||
this.updates.CheckFinished += updates_CheckFinished;
|
||||
Disposed += (sender, args) => this.updates.CheckFinished -= updates_CheckFinished;
|
||||
|
||||
checkUpdateNotifications.Checked = Config.EnableUpdateCheck;
|
||||
}
|
||||
|
||||
private void checkUpdateNotifications_CheckedChanged(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
Config.EnableUpdateCheck = checkUpdateNotifications.Checked;
|
||||
}
|
||||
|
||||
private void btnCheckUpdates_Click(object sender, EventArgs e){
|
||||
if (!Ready)return;
|
||||
|
||||
Config.DismissedUpdate = string.Empty;
|
||||
Config.Save();
|
||||
|
||||
updateCheckEventId = updates.Check(true);
|
||||
|
||||
btnCheckUpdates.Enabled = false;
|
||||
}
|
||||
|
||||
private void updates_CheckFinished(object sender, UpdateCheckEventArgs e){
|
||||
if (e.EventId == updateCheckEventId){
|
||||
btnCheckUpdates.Enabled = true;
|
||||
|
||||
if (!e.UpdateAvailable){
|
||||
MessageBox.Show("Your version of "+Program.BrandName+" is up to date.", "No Updates Available", MessageBoxButtons.OK, MessageBoxIcon.Information);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
48
Core/TrayIcon.Designer.cs
generated
48
Core/TrayIcon.Designer.cs
generated
@@ -25,65 +25,17 @@
|
||||
private void InitializeComponent() {
|
||||
this.components = new System.ComponentModel.Container();
|
||||
this.notifyIcon = new System.Windows.Forms.NotifyIcon(this.components);
|
||||
this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components);
|
||||
this.restoreToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.muteNotificationsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.closeToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.contextMenu.SuspendLayout();
|
||||
//
|
||||
// notifyIcon
|
||||
//
|
||||
this.notifyIcon.ContextMenuStrip = this.contextMenu;
|
||||
this.notifyIcon.Icon = global::TweetDck.Properties.Resources.icon_tray;
|
||||
this.notifyIcon.MouseClick += new System.Windows.Forms.MouseEventHandler(this.trayIcon_MouseClick);
|
||||
//
|
||||
// contextMenu
|
||||
//
|
||||
this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
|
||||
this.restoreToolStripMenuItem,
|
||||
this.muteNotificationsToolStripMenuItem,
|
||||
this.closeToolStripMenuItem});
|
||||
this.contextMenu.Name = "contextMenuTray";
|
||||
this.contextMenu.ShowCheckMargin = true;
|
||||
this.contextMenu.ShowImageMargin = false;
|
||||
this.contextMenu.ShowItemToolTips = false;
|
||||
this.contextMenu.Size = new System.Drawing.Size(174, 92);
|
||||
this.contextMenu.Opening += new System.ComponentModel.CancelEventHandler(this.contextMenuTray_Opening);
|
||||
this.contextMenu.Opened += new System.EventHandler(this.contextMenuTray_Opened);
|
||||
//
|
||||
// restoreToolStripMenuItem
|
||||
//
|
||||
this.restoreToolStripMenuItem.Name = "restoreToolStripMenuItem";
|
||||
this.restoreToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
|
||||
this.restoreToolStripMenuItem.Text = "Restore";
|
||||
this.restoreToolStripMenuItem.Click += new System.EventHandler(this.restoreToolStripMenuItem_Click);
|
||||
//
|
||||
// muteNotificationsToolStripMenuItem
|
||||
//
|
||||
this.muteNotificationsToolStripMenuItem.CheckOnClick = true;
|
||||
this.muteNotificationsToolStripMenuItem.Name = "muteNotificationsToolStripMenuItem";
|
||||
this.muteNotificationsToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
|
||||
this.muteNotificationsToolStripMenuItem.Text = "Mute Notifications";
|
||||
this.muteNotificationsToolStripMenuItem.CheckedChanged += new System.EventHandler(this.muteNotificationsToolStripMenuItem_CheckedChanged);
|
||||
//
|
||||
// closeToolStripMenuItem
|
||||
//
|
||||
this.closeToolStripMenuItem.Name = "closeToolStripMenuItem";
|
||||
this.closeToolStripMenuItem.Size = new System.Drawing.Size(173, 22);
|
||||
this.closeToolStripMenuItem.Text = "Close";
|
||||
this.closeToolStripMenuItem.Click += new System.EventHandler(this.closeToolStripMenuItem_Click);
|
||||
//
|
||||
// TrayIcon
|
||||
//
|
||||
this.contextMenu.ResumeLayout(false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.NotifyIcon notifyIcon;
|
||||
private System.Windows.Forms.ContextMenuStrip contextMenu;
|
||||
private System.Windows.Forms.ToolStripMenuItem restoreToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem closeToolStripMenuItem;
|
||||
private System.Windows.Forms.ToolStripMenuItem muteNotificationsToolStripMenuItem;
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,12 @@ namespace TweetDck.Core{
|
||||
}
|
||||
|
||||
set{
|
||||
if (value){
|
||||
notifyIcon.Icon = Properties.Resources.icon_tray;
|
||||
}
|
||||
|
||||
notifyIcon.Visible = value;
|
||||
hasNotifications = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -27,49 +32,57 @@ namespace TweetDck.Core{
|
||||
}
|
||||
|
||||
set{
|
||||
if (hasNotifications != value){
|
||||
if (hasNotifications != value && Visible){
|
||||
notifyIcon.Icon = value ? Properties.Resources.icon_tray_new : Properties.Resources.icon_tray;
|
||||
hasNotifications = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private readonly ContextMenu contextMenu;
|
||||
private bool hasNotifications;
|
||||
|
||||
public TrayIcon(){
|
||||
InitializeComponent();
|
||||
notifyIcon.Text = Program.BrandName;
|
||||
|
||||
this.contextMenu = new ContextMenu();
|
||||
this.contextMenu.MenuItems.Add("Restore", menuItemRestore_Click);
|
||||
this.contextMenu.MenuItems.Add("Mute notifications", menuItemMuteNotifications_Click);
|
||||
this.contextMenu.MenuItems.Add("Close", menuItemClose_Click);
|
||||
this.contextMenu.Popup += contextMenu_Popup;
|
||||
|
||||
this.notifyIcon.ContextMenu = contextMenu;
|
||||
this.notifyIcon.Text = Program.BrandName;
|
||||
}
|
||||
|
||||
public TrayIcon(IContainer container) : this(){
|
||||
container.Add(this);
|
||||
}
|
||||
|
||||
// event handlers
|
||||
|
||||
private void trayIcon_MouseClick(object sender, MouseEventArgs e){
|
||||
if (e.Button == MouseButtons.Left){
|
||||
restoreToolStripMenuItem_Click(sender, e);
|
||||
menuItemRestore_Click(sender, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void contextMenuTray_Opening(object sender, CancelEventArgs e){
|
||||
muteNotificationsToolStripMenuItem.CheckedChanged -= muteNotificationsToolStripMenuItem_CheckedChanged;
|
||||
muteNotificationsToolStripMenuItem.Checked = Program.UserConfig.MuteNotifications;
|
||||
private void contextMenu_Popup(object sender, EventArgs e){
|
||||
contextMenu.MenuItems[1].Checked = Program.UserConfig.MuteNotifications;
|
||||
}
|
||||
|
||||
private void contextMenuTray_Opened(object sender, EventArgs e){
|
||||
muteNotificationsToolStripMenuItem.CheckedChanged += muteNotificationsToolStripMenuItem_CheckedChanged;
|
||||
}
|
||||
|
||||
private void restoreToolStripMenuItem_Click(object sender, EventArgs e){
|
||||
private void menuItemRestore_Click(object sender, EventArgs e){
|
||||
if (ClickRestore != null){
|
||||
ClickRestore(this, e);
|
||||
}
|
||||
}
|
||||
|
||||
private void muteNotificationsToolStripMenuItem_CheckedChanged(object sender, EventArgs e){
|
||||
Program.UserConfig.MuteNotifications = muteNotificationsToolStripMenuItem.Checked;
|
||||
private void menuItemMuteNotifications_Click(object sender, EventArgs e){
|
||||
Program.UserConfig.MuteNotifications = !contextMenu.MenuItems[1].Checked;
|
||||
Program.UserConfig.Save();
|
||||
}
|
||||
|
||||
private void closeToolStripMenuItem_Click(object sender, EventArgs e){
|
||||
private void menuItemClose_Click(object sender, EventArgs e){
|
||||
if (ClickClose != null){
|
||||
ClickClose(this, e);
|
||||
}
|
||||
|
@@ -31,21 +31,6 @@ namespace TweetDck.Core.Utils{
|
||||
task.Start();
|
||||
}
|
||||
|
||||
public static void ClearOldCacheFiles(){
|
||||
if (!Directory.Exists(CacheFolder)){
|
||||
foreach(string file in Directory.EnumerateFiles(Program.StoragePath).Where(path => {
|
||||
string file = Path.GetFileName(path);
|
||||
return file != null && (file.StartsWith("data_", StringComparison.Ordinal) || file.StartsWith("f_", StringComparison.Ordinal));
|
||||
}).Concat(new[]{ Path.Combine(Program.StoragePath, "index") })){
|
||||
try{
|
||||
File.Delete(file);
|
||||
}catch{
|
||||
// welp, too bad
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void SetClearOnExit(){
|
||||
ClearOnExit = true;
|
||||
}
|
||||
|
@@ -5,6 +5,8 @@ using System.IO;
|
||||
using System.Net;
|
||||
using System.Windows.Forms;
|
||||
using CefSharp;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Drawing;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
static class BrowserUtils{
|
||||
@@ -27,7 +29,36 @@ namespace TweetDck.Core.Utils{
|
||||
}
|
||||
}
|
||||
|
||||
public static void OpenExternalBrowser(string url){ // TODO implement mailto
|
||||
public static readonly Color BackgroundColor = Color.FromArgb(28, 99, 153);
|
||||
public const string BackgroundColorFix = "let e=document.createElement('style');document.head.appendChild(e);e.innerHTML='body::before{background:#1c6399!important}'";
|
||||
|
||||
public static readonly string[] DictionaryWords = {
|
||||
"tweetdeck", "TweetDeck", "tweetduck", "TweetDuck", "TD"
|
||||
};
|
||||
|
||||
public static bool IsValidUrl(string url){
|
||||
Uri uri;
|
||||
|
||||
if (Uri.TryCreate(url, UriKind.Absolute, out uri)){
|
||||
string scheme = uri.Scheme;
|
||||
return scheme == Uri.UriSchemeHttp || scheme == Uri.UriSchemeHttps || scheme == Uri.UriSchemeFtp || scheme == Uri.UriSchemeMailto;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void OpenExternalBrowser(string url){
|
||||
if (string.IsNullOrWhiteSpace(url))return;
|
||||
|
||||
if (IsValidUrl(url)){
|
||||
OpenExternalBrowserUnsafe(url);
|
||||
}
|
||||
else{
|
||||
MessageBox.Show("A potentially malicious URL was blocked from opening:"+Environment.NewLine+url, "Blocked URL", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
public static void OpenExternalBrowserUnsafe(string url){
|
||||
using(Process.Start(url)){}
|
||||
}
|
||||
|
||||
@@ -36,6 +67,14 @@ namespace TweetDck.Core.Utils{
|
||||
return string.IsNullOrEmpty(file) ? null : file;
|
||||
}
|
||||
|
||||
public static string ConvertPascalCaseToScreamingSnakeCase(string str){
|
||||
return Regex.Replace(str, @"(\p{Ll})(\P{Ll})|(\P{Ll})(\P{Ll}\p{Ll})", "$1$3_$2$4").ToUpperInvariant();
|
||||
}
|
||||
|
||||
public static string GetErrorName(CefErrorCode code){
|
||||
return ConvertPascalCaseToScreamingSnakeCase(Enum.GetName(typeof(CefErrorCode), code) ?? string.Empty);
|
||||
}
|
||||
|
||||
public static void DownloadFileAsync(string url, string target, Action<Exception> onFailure){
|
||||
WebClient client = new WebClient{ Proxy = null };
|
||||
client.Headers[HttpRequestHeader.UserAgent] = HeaderUserAgent;
|
||||
@@ -53,6 +92,10 @@ namespace TweetDck.Core.Utils{
|
||||
return frame.Url.Contains("//tweetdeck.twitter.com/");
|
||||
}
|
||||
|
||||
public static bool IsTwitterWebsite(IFrame frame){
|
||||
return frame.Url.Contains("//twitter.com/");
|
||||
}
|
||||
|
||||
#if DEBUG
|
||||
public static void HandleConsoleMessage(object sender, ConsoleMessageEventArgs e){
|
||||
Debug.WriteLine("[Console] {0} ({1}:{2})", e.Message, e.Source, e.Line);
|
||||
|
@@ -105,7 +105,7 @@ namespace TweetDck.Core.Utils{
|
||||
build.Append(kvp.Key).Append(" \"").Append(kvp.Value).Append("\" ");
|
||||
}
|
||||
|
||||
return build.Remove(build.Length-1, 1).ToString();
|
||||
return build.Length == 0 ? string.Empty : build.Remove(build.Length-1, 1).ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
37
Core/Utils/InjectedHTML.cs
Normal file
37
Core/Utils/InjectedHTML.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
class InjectedHTML{
|
||||
public enum Position{
|
||||
Before, After
|
||||
}
|
||||
|
||||
private readonly Position position;
|
||||
private readonly string search;
|
||||
private readonly string html;
|
||||
|
||||
public InjectedHTML(Position position, string search, string html){
|
||||
this.position = position;
|
||||
this.search = search;
|
||||
this.html = html;
|
||||
}
|
||||
|
||||
public string Inject(string targetHTML){
|
||||
int index = targetHTML.IndexOf(search, StringComparison.Ordinal);
|
||||
|
||||
if (index == -1){
|
||||
return targetHTML;
|
||||
}
|
||||
|
||||
int cutIndex;
|
||||
|
||||
switch(position){
|
||||
case Position.Before: cutIndex = index; break;
|
||||
case Position.After: cutIndex = index+search.Length; break;
|
||||
default: return targetHTML;
|
||||
}
|
||||
|
||||
return targetHTML.Insert(cutIndex, html);
|
||||
}
|
||||
}
|
||||
}
|
129
Core/Utils/NativeCoreAudio.cs
Normal file
129
Core/Utils/NativeCoreAudio.cs
Normal file
@@ -0,0 +1,129 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
static class NativeCoreAudio{
|
||||
private const int EDATAFLOW_RENDER = 0;
|
||||
private const int EROLE_MULTIMEDIA = 1;
|
||||
|
||||
[ComImport]
|
||||
[Guid("BCDE0395-E52F-467C-8E3D-C4579291692E")]
|
||||
private class MMDeviceEnumerator{}
|
||||
|
||||
[Guid("A95664D2-9614-4F35-A746-DE8DB63617E6")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IMMDeviceEnumerator{
|
||||
int Unimpl_EnumAudioEndpoints();
|
||||
IMMDevice GetDefaultAudioEndpoint(int dataFlow, int role);
|
||||
}
|
||||
|
||||
[Guid("D666063F-1587-4E43-81F1-B948E807363F")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IMMDevice{
|
||||
[return:MarshalAs(UnmanagedType.IUnknown)]
|
||||
object Activate(ref Guid id, int clsCtx, IntPtr activationParams);
|
||||
}
|
||||
|
||||
[Guid("77AA99A0-1BD6-484F-8BC7-2C654C9A9B6F")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IAudioSessionManager2{
|
||||
int Unimpl_FindWillToLive();
|
||||
int Unimpl_HelloDarknessMyOldFriend();
|
||||
IAudioSessionEnumerator GetSessionEnumerator();
|
||||
}
|
||||
|
||||
[Guid("E2F5BB11-0570-40CA-ACDD-3AA01277DEE8")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IAudioSessionEnumerator{
|
||||
int GetCount();
|
||||
IAudioSessionControl GetSession(int sessionIndex);
|
||||
}
|
||||
|
||||
[Guid("F4B1A599-7266-4319-A8CA-E70ACB11E8CD")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IAudioSessionControl{}
|
||||
|
||||
[Guid("BFB7FF88-7239-4FC9-8FA2-07C950BE9C6D")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface IAudioSessionControl2{
|
||||
int Unimpl_GetState();
|
||||
int Unimpl_GetDisplayName();
|
||||
int Unimpl_SetDisplayName();
|
||||
int Unimpl_GetIconPath();
|
||||
int Unimpl_SetIconPath();
|
||||
int Unimpl_GetGroupingParam();
|
||||
int Unimpl_SetGroupingParam();
|
||||
int Unimpl_RegisterAudioSessionNotification();
|
||||
int Unimpl_UnregisterAudioSessionNotification();
|
||||
|
||||
[return:MarshalAs(UnmanagedType.LPWStr)]
|
||||
string GetSessionIdentifier();
|
||||
}
|
||||
|
||||
[Guid("87CE5498-68D6-44E5-9215-6DA47EF883D8")]
|
||||
[InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
|
||||
private interface ISimpleAudioVolume{
|
||||
void SetMasterVolume(float level, ref Guid eventContext);
|
||||
float GetMasterVolume();
|
||||
}
|
||||
|
||||
[SuppressMessage("ReSharper", "SuspiciousTypeConversion.Global")]
|
||||
private static ISimpleAudioVolume GetVolumeObject(string name){
|
||||
IMMDeviceEnumerator devices = (IMMDeviceEnumerator)new MMDeviceEnumerator();
|
||||
IMMDevice device = devices.GetDefaultAudioEndpoint(EDATAFLOW_RENDER, EROLE_MULTIMEDIA);
|
||||
|
||||
Guid sessionManagerGUID = typeof(IAudioSessionManager2).GUID;
|
||||
IAudioSessionManager2 manager = (IAudioSessionManager2)device.Activate(ref sessionManagerGUID, 0, IntPtr.Zero);
|
||||
IAudioSessionEnumerator sessions = manager.GetSessionEnumerator();
|
||||
|
||||
ISimpleAudioVolume volumeObj = null;
|
||||
|
||||
for(int index = sessions.GetCount()-1; index >= 0; index--){
|
||||
IAudioSessionControl2 ctl = sessions.GetSession(index) as IAudioSessionControl2;
|
||||
|
||||
if (ctl != null){
|
||||
string identifier = ctl.GetSessionIdentifier();
|
||||
|
||||
if (identifier != null && identifier.Contains(name)){
|
||||
volumeObj = ctl as ISimpleAudioVolume;
|
||||
break;
|
||||
}
|
||||
|
||||
Marshal.ReleaseComObject(ctl);
|
||||
}
|
||||
}
|
||||
|
||||
Marshal.ReleaseComObject(devices);
|
||||
Marshal.ReleaseComObject(device);
|
||||
Marshal.ReleaseComObject(manager);
|
||||
Marshal.ReleaseComObject(sessions);
|
||||
return volumeObj;
|
||||
}
|
||||
|
||||
public static double GetMixerVolume(string appPath){
|
||||
ISimpleAudioVolume obj = GetVolumeObject(appPath);
|
||||
float level = 1F;
|
||||
|
||||
if (obj != null){
|
||||
level = obj.GetMasterVolume();
|
||||
Marshal.ReleaseComObject(obj);
|
||||
}
|
||||
|
||||
return Math.Round(level, 2);
|
||||
}
|
||||
|
||||
public static double GetMixerVolumeForCurrentProcess(){
|
||||
string path;
|
||||
|
||||
using(Process process = Process.GetCurrentProcess()){
|
||||
path = process.MainModule.FileName;
|
||||
path = path.Substring(Path.GetPathRoot(path).Length);
|
||||
}
|
||||
|
||||
return GetMixerVolume(path);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,36 +1,64 @@
|
||||
using System;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Drawing;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
[SuppressMessage("ReSharper", "FieldCanBeMadeReadOnly.Local")]
|
||||
[SuppressMessage("ReSharper", "MemberCanBePrivate.Local")]
|
||||
static class NativeMethods{
|
||||
public static readonly IntPtr HWND_BROADCAST = new IntPtr(0xFFFF);
|
||||
|
||||
public const int HWND_TOPMOST = -1;
|
||||
public const uint SWP_NOACTIVATE = 0x0010;
|
||||
|
||||
public const int MOUSEEVENTF_LEFTDOWN = 0x02;
|
||||
public const int MOUSEEVENTF_LEFTUP = 0x04;
|
||||
public const int MOUSEEVENTF_RIGHTDOWN = 0x08;
|
||||
public const int MOUSEEVENTF_RIGHTUP = 0x10;
|
||||
|
||||
public const int SB_HORZ = 0;
|
||||
public const int BCM_SETSHIELD = 0x160C;
|
||||
|
||||
public const int WH_MOUSE_LL = 14;
|
||||
public const int WH_MOUSEWHEEL = 0x020A;
|
||||
public const int WM_MOUSE_LL = 14;
|
||||
public const int WM_MOUSEWHEEL = 0x020A;
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct LASTINPUTINFO{
|
||||
public static readonly uint Size = (uint)Marshal.SizeOf(typeof(LASTINPUTINFO));
|
||||
|
||||
public enum MouseButton{
|
||||
Left, Right
|
||||
public uint cbSize;
|
||||
public uint dwTime;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct POINT{
|
||||
public int X;
|
||||
public int Y;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct MSLLHOOKSTRUCT{
|
||||
public POINT pt;
|
||||
public int mouseData;
|
||||
public int flags;
|
||||
public int time;
|
||||
public UIntPtr dwExtraInfo;
|
||||
}
|
||||
|
||||
public delegate IntPtr HookProc(int nCode, IntPtr wParam, IntPtr lParam);
|
||||
|
||||
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
|
||||
public static extern bool SetWindowPos(int hWnd, int hWndOrder, int x, int y, int width, int height, uint flags);
|
||||
private static extern bool SetWindowPos(int hWnd, int hWndOrder, int x, int y, int width, int height, uint flags);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern void mouse_event(int dwFlags, int dx, int dy, int cButtons, int dwExtraInfo);
|
||||
private static extern bool GetLastInputInfo(ref LASTINPUTINFO info);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr GetDC(IntPtr hWnd);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern bool ReleaseDC(IntPtr hWnd, IntPtr hDC);
|
||||
|
||||
[DllImport("gdi32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool BitBlt(IntPtr hdc, int nXDest, int nYDest, int nWidth, int nHeight, IntPtr hdcSrc, int nXSrc, int nYSrc, uint dwRop);
|
||||
|
||||
[DllImport("user32.dll")]
|
||||
public static extern IntPtr SendMessage(IntPtr hWnd, uint msg, int wParam, IntPtr lParam);
|
||||
@@ -55,25 +83,38 @@ namespace TweetDck.Core.Utils{
|
||||
SetWindowPos(form.Handle.ToInt32(), hWndOrder, form.Left, form.Top, form.Width, form.Height, flags);
|
||||
}
|
||||
|
||||
public static void SimulateMouseClick(MouseButton button){
|
||||
int flagHold, flagRelease;
|
||||
public static int GetHookWheelDelta(IntPtr ptr){
|
||||
return Marshal.PtrToStructure<MSLLHOOKSTRUCT>(ptr).mouseData >> 16;
|
||||
}
|
||||
|
||||
switch(button){
|
||||
case MouseButton.Left:
|
||||
flagHold = SystemInformation.MouseButtonsSwapped ? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_LEFTDOWN;
|
||||
flagRelease = SystemInformation.MouseButtonsSwapped ? MOUSEEVENTF_RIGHTUP : MOUSEEVENTF_LEFTUP;
|
||||
break;
|
||||
public static int GetIdleSeconds(){
|
||||
LASTINPUTINFO info = new LASTINPUTINFO();
|
||||
info.cbSize = LASTINPUTINFO.Size;
|
||||
|
||||
case MouseButton.Right:
|
||||
flagHold = SystemInformation.MouseButtonsSwapped ? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN;
|
||||
flagRelease = SystemInformation.MouseButtonsSwapped ? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP;
|
||||
break;
|
||||
|
||||
default: return;
|
||||
if (!GetLastInputInfo(ref info)){
|
||||
return 0;
|
||||
}
|
||||
|
||||
mouse_event(flagHold, Cursor.Position.X, Cursor.Position.Y, 0, 0);
|
||||
mouse_event(flagRelease, Cursor.Position.X, Cursor.Position.Y, 0, 0);
|
||||
uint ticks;
|
||||
|
||||
unchecked{
|
||||
ticks = (uint)Environment.TickCount;
|
||||
}
|
||||
|
||||
int seconds = (int)Math.Floor(TimeSpan.FromMilliseconds(ticks-info.dwTime).TotalSeconds);
|
||||
return Math.Max(0, seconds); // ignore rollover after several weeks of uptime
|
||||
}
|
||||
|
||||
public static void RenderSourceIntoBitmap(IntPtr source, Bitmap target){
|
||||
using(Graphics graphics = Graphics.FromImage(target)){
|
||||
IntPtr graphicsHandle = graphics.GetHdc();
|
||||
|
||||
try{
|
||||
BitBlt(graphicsHandle, 0, 0, target.Width, target.Height, source, 0, 0, 0x00CC0020);
|
||||
}finally{
|
||||
graphics.ReleaseHdc(graphicsHandle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
110
Core/Utils/TwoKeyDictionary.cs
Normal file
110
Core/Utils/TwoKeyDictionary.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
class TwoKeyDictionary<K1, K2, V>{
|
||||
private readonly Dictionary<K1, Dictionary<K2, V>> dict;
|
||||
private readonly int innerCapacity;
|
||||
|
||||
public TwoKeyDictionary() : this(16, 16){}
|
||||
|
||||
public TwoKeyDictionary(int outerCapacity, int innerCapacity){
|
||||
this.dict = new Dictionary<K1, Dictionary<K2, V>>(outerCapacity);
|
||||
this.innerCapacity = innerCapacity;
|
||||
}
|
||||
|
||||
// Properties
|
||||
|
||||
public V this[K1 outerKey, K2 innerKey]{
|
||||
get{ // throws on missing key
|
||||
return dict[outerKey][innerKey];
|
||||
}
|
||||
|
||||
set{
|
||||
Dictionary<K2, V> innerDict;
|
||||
|
||||
if (!dict.TryGetValue(outerKey, out innerDict)){
|
||||
dict.Add(outerKey, innerDict = new Dictionary<K2, V>(innerCapacity));
|
||||
}
|
||||
|
||||
innerDict[innerKey] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public IEnumerable<V> InnerValues{
|
||||
get{
|
||||
foreach(Dictionary<K2, V> innerDict in dict.Values){
|
||||
foreach(V value in innerDict.Values){
|
||||
yield return value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Members
|
||||
|
||||
public void Add(K1 outerKey, K2 innerKey, V value){ // throws on duplicate
|
||||
Dictionary<K2, V> innerDict;
|
||||
|
||||
if (!dict.TryGetValue(outerKey, out innerDict)){
|
||||
dict.Add(outerKey, innerDict = new Dictionary<K2, V>(innerCapacity));
|
||||
}
|
||||
|
||||
innerDict.Add(innerKey, value);
|
||||
}
|
||||
|
||||
public void Clear(){
|
||||
this.dict.Clear();
|
||||
}
|
||||
|
||||
public void Clear(K1 outerKey){ // throws on missing key, but keeps the key unlike Remove(K1)
|
||||
dict[outerKey].Clear();
|
||||
}
|
||||
|
||||
public bool Contains(K1 outerKey){
|
||||
return dict.ContainsKey(outerKey);
|
||||
}
|
||||
|
||||
public bool Contains(K1 outerKey, K2 innerKey){
|
||||
Dictionary<K2, V> innerDict;
|
||||
return dict.TryGetValue(outerKey, out innerDict) && innerDict.ContainsKey(innerKey);
|
||||
}
|
||||
|
||||
public int Count(){
|
||||
return dict.Values.Sum(d => d.Count);
|
||||
}
|
||||
|
||||
public int Count(K1 outerKey){ // throws on missing key
|
||||
return dict[outerKey].Count;
|
||||
}
|
||||
|
||||
public bool Remove(K1 outerKey){
|
||||
return dict.Remove(outerKey);
|
||||
}
|
||||
|
||||
public bool Remove(K1 outerKey, K2 innerKey){
|
||||
Dictionary<K2, V> innerDict;
|
||||
|
||||
if (dict.TryGetValue(outerKey, out innerDict) && innerDict.Remove(innerKey)){
|
||||
if (innerDict.Count == 0){
|
||||
dict.Remove(outerKey);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
public bool TryGetValue(K1 outerKey, K2 innerKey, out V value){
|
||||
Dictionary<K2, V> innerDict;
|
||||
|
||||
if (dict.TryGetValue(outerKey, out innerDict)){
|
||||
return innerDict.TryGetValue(innerKey, out value);
|
||||
}
|
||||
else{
|
||||
value = default(V);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,5 +1,9 @@
|
||||
using System.Diagnostics;
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace TweetDck.Core.Utils{
|
||||
@@ -31,13 +35,58 @@ namespace TweetDck.Core.Utils{
|
||||
return Process.Start(processInfo);
|
||||
}
|
||||
|
||||
public static Timer CreateSingleTickTimer(int timeout){
|
||||
Timer timer = new Timer{
|
||||
Interval = timeout
|
||||
};
|
||||
public static bool TrySleepUntil(Func<bool> test, int timeoutMillis, int timeStepMillis){
|
||||
for(int waited = 0; waited < timeoutMillis; waited += timeStepMillis){
|
||||
if (test()){
|
||||
return true;
|
||||
}
|
||||
|
||||
timer.Tick += (sender, args) => timer.Stop();
|
||||
return timer;
|
||||
Thread.Sleep(timeStepMillis);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void ClipboardStripHtmlStyles(){
|
||||
if (!Clipboard.ContainsText(TextDataFormat.Html)){
|
||||
return;
|
||||
}
|
||||
|
||||
string originalText = Clipboard.GetText(TextDataFormat.UnicodeText);
|
||||
string originalHtml = Clipboard.GetText(TextDataFormat.Html);
|
||||
|
||||
string updatedHtml = ClipboardRegexes.RegexStripHtmlStyles.Replace(originalHtml, string.Empty);
|
||||
|
||||
int removed = originalHtml.Length-updatedHtml.Length;
|
||||
updatedHtml = ClipboardRegexes.RegexOffsetClipboardHtml.Replace(updatedHtml, match => (int.Parse(match.Value)-removed).ToString().PadLeft(match.Value.Length, '0'));
|
||||
|
||||
DataObject obj = new DataObject();
|
||||
obj.SetText(originalText, TextDataFormat.UnicodeText);
|
||||
obj.SetText(updatedHtml, TextDataFormat.Html);
|
||||
SetClipboardData(obj);
|
||||
}
|
||||
|
||||
public static void SetClipboard(string text, TextDataFormat format){
|
||||
if (string.IsNullOrEmpty(text)){
|
||||
return;
|
||||
}
|
||||
|
||||
DataObject obj = new DataObject();
|
||||
obj.SetText(text, format);
|
||||
SetClipboardData(obj);
|
||||
}
|
||||
|
||||
private static void SetClipboardData(DataObject obj){
|
||||
try{
|
||||
Clipboard.SetDataObject(obj);
|
||||
}catch(ExternalException e){
|
||||
Program.Reporter.HandleException("Clipboard Error", Program.BrandName+" could not access the clipboard as it is currently used by another process.", true, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static class ClipboardRegexes{ // delays construction of regular expressions until needed
|
||||
public static readonly Regex RegexStripHtmlStyles = new Regex(@"\s?(?:style|class)="".*?""");
|
||||
public static readonly Regex RegexOffsetClipboardHtml = new Regex(@"(?<=EndHTML:|EndFragment:)(\d+)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
21
Plugins/Controls/PluginControl.Designer.cs
generated
21
Plugins/Controls/PluginControl.Designer.cs
generated
@@ -42,7 +42,7 @@
|
||||
this.btnToggleState.Location = new System.Drawing.Point(459, 80);
|
||||
this.btnToggleState.Name = "btnToggleState";
|
||||
this.btnToggleState.Size = new System.Drawing.Size(65, 23);
|
||||
this.btnToggleState.TabIndex = 0;
|
||||
this.btnToggleState.TabIndex = 5;
|
||||
this.btnToggleState.Text = "Disable";
|
||||
this.btnToggleState.UseVisualStyleBackColor = true;
|
||||
this.btnToggleState.Click += new System.EventHandler(this.btnToggleState_Click);
|
||||
@@ -54,8 +54,9 @@
|
||||
this.labelName.Location = new System.Drawing.Point(7, 7);
|
||||
this.labelName.Name = "labelName";
|
||||
this.labelName.Size = new System.Drawing.Size(61, 24);
|
||||
this.labelName.TabIndex = 1;
|
||||
this.labelName.TabIndex = 0;
|
||||
this.labelName.Text = "Name";
|
||||
this.labelName.UseMnemonic = false;
|
||||
//
|
||||
// panelDescription
|
||||
//
|
||||
@@ -79,8 +80,9 @@
|
||||
this.labelDescription.Margin = new System.Windows.Forms.Padding(0);
|
||||
this.labelDescription.Name = "labelDescription";
|
||||
this.labelDescription.Size = new System.Drawing.Size(13, 39);
|
||||
this.labelDescription.TabIndex = 3;
|
||||
this.labelDescription.TabIndex = 0;
|
||||
this.labelDescription.Text = "a\r\nb\r\nc";
|
||||
this.labelDescription.UseMnemonic = false;
|
||||
//
|
||||
// labelAuthor
|
||||
//
|
||||
@@ -89,8 +91,9 @@
|
||||
this.labelAuthor.Margin = new System.Windows.Forms.Padding(3, 0, 32, 0);
|
||||
this.labelAuthor.Name = "labelAuthor";
|
||||
this.labelAuthor.Size = new System.Drawing.Size(38, 13);
|
||||
this.labelAuthor.TabIndex = 3;
|
||||
this.labelAuthor.TabIndex = 0;
|
||||
this.labelAuthor.Text = "Author";
|
||||
this.labelAuthor.UseMnemonic = false;
|
||||
//
|
||||
// flowLayoutInfo
|
||||
//
|
||||
@@ -101,7 +104,7 @@
|
||||
this.flowLayoutInfo.Location = new System.Drawing.Point(11, 85);
|
||||
this.flowLayoutInfo.Name = "flowLayoutInfo";
|
||||
this.flowLayoutInfo.Size = new System.Drawing.Size(368, 18);
|
||||
this.flowLayoutInfo.TabIndex = 4;
|
||||
this.flowLayoutInfo.TabIndex = 3;
|
||||
this.flowLayoutInfo.WrapContents = false;
|
||||
//
|
||||
// labelWebsite
|
||||
@@ -113,8 +116,9 @@
|
||||
this.labelWebsite.Location = new System.Drawing.Point(76, 0);
|
||||
this.labelWebsite.Name = "labelWebsite";
|
||||
this.labelWebsite.Size = new System.Drawing.Size(46, 13);
|
||||
this.labelWebsite.TabIndex = 5;
|
||||
this.labelWebsite.TabIndex = 1;
|
||||
this.labelWebsite.Text = "Website";
|
||||
this.labelWebsite.UseMnemonic = false;
|
||||
this.labelWebsite.Click += new System.EventHandler(this.labelWebsite_Click);
|
||||
//
|
||||
// labelVersion
|
||||
@@ -125,9 +129,10 @@
|
||||
this.labelVersion.Margin = new System.Windows.Forms.Padding(3, 9, 3, 0);
|
||||
this.labelVersion.Name = "labelVersion";
|
||||
this.labelVersion.Size = new System.Drawing.Size(513, 13);
|
||||
this.labelVersion.TabIndex = 5;
|
||||
this.labelVersion.TabIndex = 1;
|
||||
this.labelVersion.Text = "Version";
|
||||
this.labelVersion.TextAlign = System.Drawing.ContentAlignment.TopRight;
|
||||
this.labelVersion.UseMnemonic = false;
|
||||
//
|
||||
// btnOpenConfig
|
||||
//
|
||||
@@ -135,7 +140,7 @@
|
||||
this.btnOpenConfig.Location = new System.Drawing.Point(385, 80);
|
||||
this.btnOpenConfig.Name = "btnOpenConfig";
|
||||
this.btnOpenConfig.Size = new System.Drawing.Size(68, 23);
|
||||
this.btnOpenConfig.TabIndex = 6;
|
||||
this.btnOpenConfig.TabIndex = 4;
|
||||
this.btnOpenConfig.Text = "Configure";
|
||||
this.btnOpenConfig.UseVisualStyleBackColor = true;
|
||||
this.btnOpenConfig.Click += new System.EventHandler(this.btnOpenConfig_Click);
|
||||
|
@@ -1,3 +0,0 @@
|
||||
namespace TweetDck.Plugins.Controls{
|
||||
partial class PluginListFlowLayout{}
|
||||
}
|
@@ -2,7 +2,7 @@
|
||||
using TweetDck.Core.Utils;
|
||||
|
||||
namespace TweetDck.Plugins.Controls{
|
||||
sealed partial class PluginListFlowLayout : FlowLayoutPanel{
|
||||
sealed class PluginListFlowLayout : FlowLayoutPanel{
|
||||
public PluginListFlowLayout(){
|
||||
FlowDirection = FlowDirection.TopDown;
|
||||
WrapContents = false;
|
||||
|
@@ -2,16 +2,16 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace TweetDck.Plugins.Events{
|
||||
class PluginLoadEventArgs : EventArgs{
|
||||
public bool Success{
|
||||
class PluginErrorEventArgs : EventArgs{
|
||||
public bool HasErrors{
|
||||
get{
|
||||
return Errors.Count == 0;
|
||||
return Errors.Count > 0;
|
||||
}
|
||||
}
|
||||
|
||||
public IList<string> Errors;
|
||||
|
||||
public PluginLoadEventArgs(IList<string> errors){
|
||||
public PluginErrorEventArgs(IList<string> errors){
|
||||
this.Errors = errors;
|
||||
}
|
||||
}
|
@@ -2,23 +2,49 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using TweetDck.Core.Utils;
|
||||
using TweetDck.Plugins.Enums;
|
||||
using TweetDck.Plugins.Events;
|
||||
|
||||
namespace TweetDck.Plugins{
|
||||
class PluginBridge{
|
||||
private static string SanitizeCacheKey(string key){
|
||||
return key.Replace('\\', '/').Trim();
|
||||
}
|
||||
|
||||
private readonly PluginManager manager;
|
||||
private readonly Dictionary<string, string> fileCache = new Dictionary<string, string>(2);
|
||||
private readonly TwoKeyDictionary<int, string, string> fileCache = new TwoKeyDictionary<int, string, string>(4, 2);
|
||||
private readonly TwoKeyDictionary<int, string, InjectedHTML> notificationInjections = new TwoKeyDictionary<int,string,InjectedHTML>(4, 1);
|
||||
|
||||
public IEnumerable<InjectedHTML> NotificationInjections{
|
||||
get{
|
||||
return notificationInjections.InnerValues;
|
||||
}
|
||||
}
|
||||
|
||||
public PluginBridge(PluginManager manager){
|
||||
this.manager = manager;
|
||||
this.manager.Reloaded += manager_Reloaded;
|
||||
this.manager.PluginChangedState += manager_PluginChangedState;
|
||||
}
|
||||
|
||||
private void manager_Reloaded(object sender, PluginLoadEventArgs e){
|
||||
// Event handlers
|
||||
|
||||
private void manager_Reloaded(object sender, PluginErrorEventArgs e){
|
||||
fileCache.Clear();
|
||||
}
|
||||
|
||||
private void manager_PluginChangedState(object sender, PluginChangedStateEventArgs e){
|
||||
if (!e.IsEnabled){
|
||||
int token = manager.GetTokenFromPlugin(e.Plugin);
|
||||
|
||||
fileCache.Remove(token);
|
||||
notificationInjections.Remove(token);
|
||||
}
|
||||
}
|
||||
|
||||
// Utility methods
|
||||
|
||||
private string GetFullPathOrThrow(int token, PluginFolder folder, string path){
|
||||
Plugin plugin = manager.GetPluginFromToken(token);
|
||||
string fullPath = plugin == null ? string.Empty : plugin.GetFullPathIfSafe(folder, path);
|
||||
@@ -35,15 +61,17 @@ namespace TweetDck.Plugins{
|
||||
}
|
||||
}
|
||||
|
||||
private string ReadFileUnsafe(string fullPath, bool readCached){
|
||||
private string ReadFileUnsafe(int token, string cacheKey, string fullPath, bool readCached){
|
||||
cacheKey = SanitizeCacheKey(cacheKey);
|
||||
|
||||
string cachedContents;
|
||||
|
||||
if (readCached && fileCache.TryGetValue(fullPath, out cachedContents)){
|
||||
if (readCached && fileCache.TryGetValue(token, cacheKey, out cachedContents)){
|
||||
return cachedContents;
|
||||
}
|
||||
|
||||
try{
|
||||
return fileCache[fullPath] = File.ReadAllText(fullPath, Encoding.UTF8);
|
||||
return fileCache[token, cacheKey] = File.ReadAllText(fullPath, Encoding.UTF8);
|
||||
}catch(FileNotFoundException){
|
||||
throw new Exception("File not found.");
|
||||
}catch(DirectoryNotFoundException){
|
||||
@@ -60,17 +88,17 @@ namespace TweetDck.Plugins{
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(fullPath));
|
||||
|
||||
File.WriteAllText(fullPath, contents, Encoding.UTF8);
|
||||
fileCache[fullPath] = contents;
|
||||
fileCache[token, SanitizeCacheKey(path)] = contents;
|
||||
}
|
||||
|
||||
public string ReadFile(int token, string path, bool cache){
|
||||
return ReadFileUnsafe(GetFullPathOrThrow(token, PluginFolder.Data, path), cache);
|
||||
return ReadFileUnsafe(token, path, GetFullPathOrThrow(token, PluginFolder.Data, path), cache);
|
||||
}
|
||||
|
||||
public void DeleteFile(int token, string path){
|
||||
string fullPath = GetFullPathOrThrow(token, PluginFolder.Data, path);
|
||||
|
||||
fileCache.Remove(fullPath);
|
||||
fileCache.Remove(token, SanitizeCacheKey(path));
|
||||
File.Delete(fullPath);
|
||||
}
|
||||
|
||||
@@ -79,11 +107,19 @@ namespace TweetDck.Plugins{
|
||||
}
|
||||
|
||||
public string ReadFileRoot(int token, string path){
|
||||
return ReadFileUnsafe(GetFullPathOrThrow(token, PluginFolder.Root, path), true);
|
||||
return ReadFileUnsafe(token, "root*"+path, GetFullPathOrThrow(token, PluginFolder.Root, path), true);
|
||||
}
|
||||
|
||||
public bool CheckFileExistsRoot(int token, string path){
|
||||
return File.Exists(GetFullPathOrThrow(token, PluginFolder.Root, path));
|
||||
}
|
||||
|
||||
public void InjectIntoNotificationsBefore(int token, string key, string search, string html){
|
||||
notificationInjections[token, key] = new InjectedHTML(InjectedHTML.Position.Before, search, html);
|
||||
}
|
||||
|
||||
public void InjectIntoNotificationsAfter(int token, string key, string search, string html){
|
||||
notificationInjections[token, key] = new InjectedHTML(InjectedHTML.Position.After, search, html);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,11 +8,13 @@ using TweetDck.Plugins.Events;
|
||||
using TweetDck.Resources;
|
||||
|
||||
namespace TweetDck.Plugins{
|
||||
class PluginManager{
|
||||
sealed class PluginManager{
|
||||
public const string PluginBrowserScriptFile = "plugins.browser.js";
|
||||
public const string PluginNotificationScriptFile = "plugins.notification.js";
|
||||
public const string PluginGlobalScriptFile = "plugins.js";
|
||||
|
||||
private const int InvalidToken = 0;
|
||||
|
||||
public string PathOfficialPlugins { get { return Path.Combine(rootPath, "official"); } }
|
||||
public string PathCustomPlugins { get { return Path.Combine(rootPath, "user"); } }
|
||||
|
||||
@@ -20,7 +22,8 @@ namespace TweetDck.Plugins{
|
||||
public PluginConfig Config { get; private set; }
|
||||
public PluginBridge Bridge { get; private set; }
|
||||
|
||||
public event EventHandler<PluginLoadEventArgs> Reloaded;
|
||||
public event EventHandler<PluginErrorEventArgs> Reloaded;
|
||||
public event EventHandler<PluginErrorEventArgs> Executed;
|
||||
public event EventHandler<PluginChangedStateEventArgs> PluginChangedState;
|
||||
|
||||
private readonly string rootPath;
|
||||
@@ -34,11 +37,13 @@ namespace TweetDck.Plugins{
|
||||
this.rootPath = path;
|
||||
this.SetConfig(config);
|
||||
this.Bridge = new PluginBridge(this);
|
||||
|
||||
Program.UserConfigReplaced += Program_UserConfigReplaced;
|
||||
}
|
||||
|
||||
public void SetConfig(PluginConfig config){
|
||||
this.Config = config;
|
||||
this.Config.InternalPluginChangedState += Config_InternalPluginChangedState;
|
||||
private void Program_UserConfigReplaced(object sender, EventArgs e){
|
||||
SetConfig(Program.UserConfig.Plugins);
|
||||
Reload();
|
||||
}
|
||||
|
||||
private void Config_InternalPluginChangedState(object sender, PluginChangedStateEventArgs e){
|
||||
@@ -47,6 +52,15 @@ namespace TweetDck.Plugins{
|
||||
}
|
||||
}
|
||||
|
||||
private void SetConfig(PluginConfig config){
|
||||
if (this.Config != null){
|
||||
this.Config.InternalPluginChangedState -= Config_InternalPluginChangedState;
|
||||
}
|
||||
|
||||
this.Config = config;
|
||||
this.Config.InternalPluginChangedState += Config_InternalPluginChangedState;
|
||||
}
|
||||
|
||||
public bool IsPluginInstalled(string identifier){
|
||||
return plugins.Any(plugin => plugin.Identifier.Equals(identifier));
|
||||
}
|
||||
@@ -63,6 +77,16 @@ namespace TweetDck.Plugins{
|
||||
return plugins.Any(plugin => plugin.Environments.HasFlag(environment));
|
||||
}
|
||||
|
||||
public int GetTokenFromPlugin(Plugin plugin){
|
||||
foreach(KeyValuePair<int, Plugin> kvp in tokens){
|
||||
if (kvp.Value.Equals(plugin)){
|
||||
return kvp.Key;
|
||||
}
|
||||
}
|
||||
|
||||
return InvalidToken;
|
||||
}
|
||||
|
||||
public Plugin GetPluginFromToken(int token){
|
||||
Plugin plugin;
|
||||
return tokens.TryGetValue(token, out plugin) ? plugin : null;
|
||||
@@ -83,7 +107,7 @@ namespace TweetDck.Plugins{
|
||||
}
|
||||
|
||||
if (Reloaded != null){
|
||||
Reloaded(this, new PluginLoadEventArgs(loadErrors));
|
||||
Reloaded(this, new PluginErrorEventArgs(loadErrors));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -92,6 +116,8 @@ namespace TweetDck.Plugins{
|
||||
ScriptLoader.ExecuteScript(frame, PluginScriptGenerator.GenerateConfig(Config), "gen:pluginconfig");
|
||||
}
|
||||
|
||||
List<string> failedPlugins = new List<string>(1);
|
||||
|
||||
foreach(Plugin plugin in Plugins){
|
||||
string path = plugin.GetScriptPath(environment);
|
||||
if (string.IsNullOrEmpty(path) || !plugin.CanRun || (!includeDisabled && !Config.IsEnabled(plugin)))continue;
|
||||
@@ -100,15 +126,15 @@ namespace TweetDck.Plugins{
|
||||
|
||||
try{
|
||||
script = File.ReadAllText(path);
|
||||
}catch{
|
||||
// TODO
|
||||
}catch(Exception e){
|
||||
failedPlugins.Add(plugin.Identifier+" ("+Path.GetFileName(path)+"): "+e.Message);
|
||||
continue;
|
||||
}
|
||||
|
||||
int token;
|
||||
|
||||
if (tokens.ContainsValue(plugin)){
|
||||
token = tokens.First(kvp => kvp.Value.Equals(plugin)).Key;
|
||||
token = GetTokenFromPlugin(plugin);
|
||||
}
|
||||
else{
|
||||
token = GenerateToken();
|
||||
@@ -117,6 +143,10 @@ namespace TweetDck.Plugins{
|
||||
|
||||
ScriptLoader.ExecuteScript(frame, PluginScriptGenerator.GeneratePlugin(plugin.Identifier, script, token, environment), "plugin:"+plugin);
|
||||
}
|
||||
|
||||
if (Executed != null){
|
||||
Executed(this, new PluginErrorEventArgs(failedPlugins));
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<Plugin> LoadPluginsFrom(string path, PluginGroup group){
|
||||
@@ -141,7 +171,7 @@ namespace TweetDck.Plugins{
|
||||
for(int attempt = 0; attempt < 1000; attempt++){
|
||||
int token = rand.Next();
|
||||
|
||||
if (!tokens.ContainsKey(token)){
|
||||
if (!tokens.ContainsKey(token) && token != InvalidToken){
|
||||
return token;
|
||||
}
|
||||
}
|
||||
|
119
Program.cs
119
Program.cs
@@ -15,19 +15,16 @@ using TweetDck.Core.Handling;
|
||||
using TweetDck.Core.Other;
|
||||
using TweetDck.Updates;
|
||||
|
||||
[assembly: CLSCompliant(true)]
|
||||
namespace TweetDck{
|
||||
static class Program{
|
||||
public const string BrandName = "TweetDuck";
|
||||
public const string Website = "https://tweetduck.chylex.com";
|
||||
|
||||
public const string VersionTag = "1.5.1";
|
||||
public const string VersionFull = "1.5.1.0";
|
||||
public const string VersionTag = "1.7.1";
|
||||
public const string VersionFull = "1.7.1.0";
|
||||
|
||||
public static readonly Version Version = new Version(VersionTag);
|
||||
|
||||
public static readonly bool IsPortable = File.Exists("makeportable");
|
||||
private static readonly CommandLineArgs Args = CommandLineArgs.FromStringArray('-', Environment.GetCommandLineArgs());
|
||||
|
||||
public static readonly string ProgramPath = AppDomain.CurrentDomain.BaseDirectory;
|
||||
public static readonly string StoragePath = IsPortable ? Path.Combine(ProgramPath, "portable", "storage") : GetDataStoragePath();
|
||||
@@ -35,7 +32,8 @@ namespace TweetDck{
|
||||
|
||||
public static readonly string PluginDataPath = Path.Combine(StoragePath, "TD_Plugins");
|
||||
public static readonly string ConfigFilePath = Path.Combine(StoragePath, "TD_UserConfig.cfg");
|
||||
private static readonly string LogFilePath = Path.Combine(StoragePath, "TD_Log.txt");
|
||||
private static readonly string ErrorLogFilePath = Path.Combine(StoragePath, "TD_Log.txt");
|
||||
private static readonly string ConsoleLogFilePath = Path.Combine(StoragePath, "TD_Console.txt");
|
||||
|
||||
public static readonly string ScriptPath = Path.Combine(ProgramPath, "scripts");
|
||||
public static readonly string PluginPath = Path.Combine(ProgramPath, "plugins");
|
||||
@@ -48,6 +46,8 @@ namespace TweetDck{
|
||||
public static UserConfig UserConfig { get; private set; }
|
||||
public static Reporter Reporter { get; private set; }
|
||||
|
||||
public static event EventHandler UserConfigReplaced;
|
||||
|
||||
[STAThread]
|
||||
private static void Main(){
|
||||
Application.EnableVisualStyles();
|
||||
@@ -60,10 +60,10 @@ namespace TweetDck{
|
||||
return;
|
||||
}
|
||||
|
||||
Reporter = new Reporter(LogFilePath);
|
||||
Reporter = new Reporter(ErrorLogFilePath);
|
||||
Reporter.SetupUnhandledExceptionHandler(BrandName+" Has Failed :(");
|
||||
|
||||
if (Args.HasFlag("-restart")){
|
||||
if (Arguments.HasFlag(Arguments.ArgRestart)){
|
||||
for(int attempt = 0; attempt < 21; attempt++){
|
||||
LockManager.Result lockResult = LockManager.Lock();
|
||||
|
||||
@@ -76,34 +76,37 @@ namespace TweetDck{
|
||||
}
|
||||
else if (attempt == 20){
|
||||
using(FormMessage form = new FormMessage(BrandName+" Cannot Restart", BrandName+" is taking too long to close.", MessageBoxIcon.Warning)){
|
||||
form.AddButton("Exit");
|
||||
Button btnRetry = form.AddButton("Retry");
|
||||
form.CancelButton = form.AddButton("Exit");
|
||||
form.ActiveControl = form.AddButton("Retry", DialogResult.Retry);
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK){
|
||||
if (form.ClickedButton == btnRetry){
|
||||
attempt /= 2;
|
||||
continue;
|
||||
}
|
||||
if (form.ShowDialog() == DialogResult.Retry){
|
||||
attempt /= 2;
|
||||
continue;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
else{
|
||||
Thread.Sleep(500);
|
||||
}
|
||||
else Thread.Sleep(500);
|
||||
}
|
||||
}
|
||||
else{
|
||||
LockManager.Result lockResult = LockManager.Lock();
|
||||
|
||||
if (lockResult == LockManager.Result.HasProcess){
|
||||
if (LockManager.LockingProcess.MainWindowHandle == IntPtr.Zero && LockManager.LockingProcess.Responding){ // restore if the original process is in tray
|
||||
NativeMethods.SendMessage(NativeMethods.HWND_BROADCAST, WindowRestoreMessage, 0, IntPtr.Zero);
|
||||
return;
|
||||
if (LockManager.LockingProcess.MainWindowHandle == IntPtr.Zero){ // restore if the original process is in tray
|
||||
NativeMethods.SendMessage(NativeMethods.HWND_BROADCAST, WindowRestoreMessage, LockManager.LockingProcess.Id, IntPtr.Zero);
|
||||
|
||||
if (WindowsUtils.TrySleepUntil(() => {
|
||||
LockManager.LockingProcess.Refresh();
|
||||
return LockManager.LockingProcess.HasExited || (LockManager.LockingProcess.MainWindowHandle != IntPtr.Zero && LockManager.LockingProcess.Responding);
|
||||
}, 2000, 250)){
|
||||
return; // should trigger on first attempt if succeeded, but wait just in case
|
||||
}
|
||||
}
|
||||
else if (MessageBox.Show("Another instance of "+BrandName+" is already running.\r\nDo you want to close it?", BrandName+" is Already Running", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2) == DialogResult.Yes){
|
||||
if (!LockManager.CloseLockingProcess(30000)){
|
||||
|
||||
if (MessageBox.Show("Another instance of "+BrandName+" is already running.\r\nDo you want to close it?", BrandName+" is Already Running", MessageBoxButtons.YesNo, MessageBoxIcon.Error, MessageBoxDefaultButton.Button2) == DialogResult.Yes){
|
||||
if (!LockManager.CloseLockingProcess(10000, 5000)){
|
||||
MessageBox.Show("Could not close the other process.", BrandName+" Has Failed :(", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
return;
|
||||
}
|
||||
@@ -120,21 +123,21 @@ namespace TweetDck{
|
||||
|
||||
ReloadConfig();
|
||||
|
||||
if (Args.HasFlag("-importcookies")){
|
||||
if (Arguments.HasFlag(Arguments.ArgImportCookies)){
|
||||
ExportManager.ImportCookies();
|
||||
}
|
||||
|
||||
BrowserCache.ClearOldCacheFiles();
|
||||
|
||||
CefSharpSettings.WcfEnabled = false;
|
||||
|
||||
CefSettings settings = new CefSettings{
|
||||
AcceptLanguageList = BrowserUtils.HeaderAcceptLanguage,
|
||||
UserAgent = BrowserUtils.HeaderUserAgent,
|
||||
Locale = Args.GetValue("-locale", "en"),
|
||||
Locale = Arguments.GetValue(Arguments.ArgLocale, string.Empty),
|
||||
CachePath = StoragePath,
|
||||
LogFile = Path.Combine(StoragePath, "TD_Console.txt"),
|
||||
LogFile = ConsoleLogFilePath,
|
||||
#if !DEBUG
|
||||
BrowserSubprocessPath = BrandName+".Browser.exe",
|
||||
LogSeverity = Args.HasFlag("-log") ? LogSeverity.Info : LogSeverity.Disable
|
||||
LogSeverity = Arguments.HasFlag(Arguments.ArgLogging) ? LogSeverity.Info : LogSeverity.Disable
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -144,6 +147,10 @@ namespace TweetDck{
|
||||
settings.CefCommandLineArgs["disable-gpu"] = "1";
|
||||
settings.CefCommandLineArgs["disable-gpu-vsync"] = "1";
|
||||
}
|
||||
|
||||
settings.CefCommandLineArgs["disable-extensions"] = "1";
|
||||
settings.CefCommandLineArgs["disable-plugins-discovery"] = "1";
|
||||
settings.CefCommandLineArgs["enable-system-flash"] = "0";
|
||||
|
||||
Cef.Initialize(settings, false, new BrowserProcessHandler());
|
||||
|
||||
@@ -151,11 +158,12 @@ namespace TweetDck{
|
||||
|
||||
PluginManager plugins = new PluginManager(PluginPath, UserConfig.Plugins);
|
||||
plugins.Reloaded += plugins_Reloaded;
|
||||
plugins.PluginChangedState += (sender, args) => UserConfig.Save();
|
||||
plugins.Executed += plugins_Executed;
|
||||
plugins.Reload();
|
||||
|
||||
FormBrowser mainForm = new FormBrowser(plugins, new UpdaterSettings{
|
||||
AllowPreReleases = Args.HasFlag("-debugupdates")
|
||||
AllowPreReleases = Arguments.HasFlag(Arguments.ArgDebugUpdates),
|
||||
DismissedUpdate = UserConfig.DismissedUpdate
|
||||
});
|
||||
|
||||
Application.Run(mainForm);
|
||||
@@ -163,24 +171,31 @@ namespace TweetDck{
|
||||
if (mainForm.UpdateInstallerPath != null){
|
||||
ExitCleanup();
|
||||
|
||||
string updaterArgs = "/SP- /SILENT /CLOSEAPPLICATIONS /UPDATEPATH=\""+ProgramPath+"\" /RUNARGS=\""+GetArgsClean().ToString().Replace("\"", "^\"")+"\""+(IsPortable ? " /PORTABLE=1" : "");
|
||||
// ProgramPath has a trailing backslash
|
||||
string updaterArgs = "/SP- /SILENT /CLOSEAPPLICATIONS /UPDATEPATH=\""+ProgramPath+"\" /RUNARGS=\""+Arguments.GetCurrentClean().ToString().Replace("\"", "^\"")+"\""+(IsPortable ? " /PORTABLE=1" : "");
|
||||
bool runElevated = !IsPortable || !WindowsUtils.CheckFolderWritePermission(ProgramPath);
|
||||
|
||||
WindowsUtils.StartProcess(mainForm.UpdateInstallerPath, updaterArgs, runElevated); // ProgramPath has a trailing backslash
|
||||
WindowsUtils.StartProcess(mainForm.UpdateInstallerPath, updaterArgs, runElevated);
|
||||
Application.Exit();
|
||||
}
|
||||
}
|
||||
|
||||
private static void plugins_Reloaded(object sender, PluginLoadEventArgs e){
|
||||
if (!e.Success){
|
||||
MessageBox.Show("The following plugins will not be available until the issues are resolved:\n"+string.Join("\n", e.Errors), "Error Loading Plugins", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
private static void plugins_Reloaded(object sender, PluginErrorEventArgs e){
|
||||
if (e.HasErrors){
|
||||
string doubleNL = Environment.NewLine+Environment.NewLine;
|
||||
MessageBox.Show("The following plugins will not be available until the issues are resolved:"+doubleNL+string.Join(doubleNL, e.Errors), "Error Loading Plugins", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
((PluginManager)sender).SetConfig(UserConfig.Plugins);
|
||||
private static void plugins_Executed(object sender, PluginErrorEventArgs e){
|
||||
if (e.HasErrors){
|
||||
string doubleNL = Environment.NewLine+Environment.NewLine;
|
||||
MessageBox.Show("Failed to execute the following plugins:"+doubleNL+string.Join(doubleNL, e.Errors), "Error Executing Plugins", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
}
|
||||
|
||||
private static string GetDataStoragePath(){
|
||||
string custom = Args.GetValue("-datafolder", null);
|
||||
string custom = Arguments.GetValue(Arguments.ArgDataFolder, null);
|
||||
|
||||
if (custom != null && (custom.Contains(Path.DirectorySeparatorChar) || custom.Contains(Path.AltDirectorySeparatorChar))){
|
||||
if (Path.GetInvalidPathChars().Any(custom.Contains)){
|
||||
@@ -199,6 +214,10 @@ namespace TweetDck{
|
||||
|
||||
public static void ReloadConfig(){
|
||||
UserConfig = UserConfig.Load(ConfigFilePath);
|
||||
|
||||
if (UserConfigReplaced != null){
|
||||
UserConfigReplaced(UserConfig, new EventArgs());
|
||||
}
|
||||
}
|
||||
|
||||
public static void ResetConfig(){
|
||||
@@ -213,27 +232,21 @@ namespace TweetDck{
|
||||
ReloadConfig();
|
||||
}
|
||||
|
||||
private static CommandLineArgs GetArgsClean(){
|
||||
CommandLineArgs args = Args.Clone();
|
||||
args.RemoveFlag("-importcookies");
|
||||
return args;
|
||||
}
|
||||
|
||||
public static void Restart(){
|
||||
Restart(new string[0]);
|
||||
}
|
||||
|
||||
public static void Restart(string[] extraArgs){
|
||||
FormBrowser browserForm = Application.OpenForms.OfType<FormBrowser>().FirstOrDefault();
|
||||
|
||||
if (browserForm == null){
|
||||
return;
|
||||
}
|
||||
|
||||
CommandLineArgs args = GetArgsClean();
|
||||
args.AddFlag("-restart");
|
||||
|
||||
CommandLineArgs args = Arguments.GetCurrentClean();
|
||||
CommandLineArgs.ReadStringArray('-', extraArgs, args);
|
||||
RestartWithArgs(args);
|
||||
}
|
||||
|
||||
public static void RestartWithArgs(CommandLineArgs args){
|
||||
FormBrowser browserForm = Application.OpenForms.OfType<FormBrowser>().FirstOrDefault();
|
||||
if (browserForm == null)return;
|
||||
|
||||
args.AddFlag(Arguments.ArgRestart);
|
||||
|
||||
browserForm.ForceClose();
|
||||
ExitCleanup();
|
||||
|
@@ -1,4 +1,5 @@
|
||||
using System.Reflection;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Resources;
|
||||
using TweetDck;
|
||||
@@ -36,4 +37,10 @@ using TweetDck;
|
||||
[assembly: AssemblyVersion(Program.VersionFull)]
|
||||
[assembly: AssemblyFileVersion(Program.VersionFull)]
|
||||
|
||||
[assembly: NeutralResourcesLanguageAttribute("en")]
|
||||
[assembly: NeutralResourcesLanguageAttribute("en")]
|
||||
|
||||
[assembly: CLSCompliant(false)]
|
||||
|
||||
#if DEBUG
|
||||
[assembly: System.Runtime.CompilerServices.InternalsVisibleTo("UnitTests")]
|
||||
#endif
|
||||
|
@@ -1,11 +1,11 @@
|
||||
# Build Instructions
|
||||
|
||||
The program was build using Visual Studio 2013. After opening the solution, make sure you have **CefSharp.WinForms** and **Microsoft.VC120.CRT.JetBrains** included - if not, download them using NuGet. For **CefSharp**, you will need version 53 or newer currently available as a pre-release.
|
||||
The program was build using Visual Studio 2013. After opening the solution, make sure you have **CefSharp.WinForms** and **Microsoft.VC120.CRT.JetBrains** included - if not, download them using NuGet.
|
||||
```
|
||||
PM> Install-Package CefSharp.WinForms -Version 53.0.1
|
||||
PM> Install-Package CefSharp.WinForms -Version 57.0.0-pre01
|
||||
PM> Install-Package Microsoft.VC120.CRT.JetBrains
|
||||
```
|
||||
|
||||
After building, run **_postbuild.bat** which deletes unnecessary files that CefSharp adds after post-build events >_>
|
||||
After building, run either `_postbuild.bat` if you want to package the files yourself, or `bld/RUN BUILD.bat` to generate installer files using Inno Setup (make sure the Inno Setup binaries are on your PATH).
|
||||
|
||||
Built files are then available in **bin/x86** and/or **bin/x64**.
|
||||
Built files are then available in **bin/x86**, installer files are generated in **bld/Output**. If you decide to release a custom version publicly, please make it clear that it is not the original TweetDuck.
|
||||
|
22
Reporter.cs
22
Reporter.cs
@@ -48,14 +48,18 @@ namespace TweetDck{
|
||||
|
||||
FormMessage form = new FormMessage(caption, message+"\r\nError: "+e.Message, canIgnore ? MessageBoxIcon.Warning : MessageBoxIcon.Error);
|
||||
|
||||
form.AddButton("Exit");
|
||||
Button btnIgnore = form.AddButton("Ignore");
|
||||
Button btnExit = form.AddButton("Exit");
|
||||
Button btnIgnore = form.AddButton("Ignore", DialogResult.Ignore);
|
||||
|
||||
btnIgnore.Enabled = canIgnore;
|
||||
form.ActiveControl = canIgnore ? btnIgnore : btnExit;
|
||||
form.CancelButton = btnIgnore;
|
||||
|
||||
Button btnOpenLog = new Button{
|
||||
Anchor = AnchorStyles.Bottom | AnchorStyles.Left,
|
||||
Enabled = loggedSuccessfully,
|
||||
Font = SystemFonts.MessageBoxFont,
|
||||
Location = new Point(12, 12),
|
||||
Location = new Point(6, 12),
|
||||
Margin = new Padding(0, 0, 48, 0),
|
||||
Size = new Size(88, 26),
|
||||
Text = "Show Error Log",
|
||||
@@ -68,14 +72,8 @@ namespace TweetDck{
|
||||
|
||||
form.AddActionControl(btnOpenLog);
|
||||
|
||||
if (!canIgnore){
|
||||
btnIgnore.Enabled = false;
|
||||
}
|
||||
|
||||
if (form.ShowDialog() == DialogResult.OK){
|
||||
if (form.ClickedButton == btnIgnore){
|
||||
return;
|
||||
}
|
||||
if (form.ShowDialog() == DialogResult.Ignore){
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
@@ -90,7 +88,7 @@ namespace TweetDck{
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
|
||||
FormMessage form = new FormMessage(caption, message, MessageBoxIcon.Error);
|
||||
form.AddButton("Exit");
|
||||
form.ActiveControl = form.AddButton("Exit");
|
||||
form.ShowDialog();
|
||||
|
||||
try{
|
||||
|
15
Resources/Plugins/.debug/.meta
Normal file
15
Resources/Plugins/.debug/.meta
Normal file
@@ -0,0 +1,15 @@
|
||||
[name]
|
||||
Debug plugin
|
||||
|
||||
[description]
|
||||
- Enables debug functionality and tests
|
||||
- Only included in debug configuration
|
||||
|
||||
[author]
|
||||
chylex
|
||||
|
||||
[version]
|
||||
1.1
|
||||
|
||||
[website]
|
||||
https://tweetduck.chylex.com
|
55
Resources/Plugins/.debug/browser.js
Normal file
55
Resources/Plugins/.debug/browser.js
Normal file
@@ -0,0 +1,55 @@
|
||||
enabled(){
|
||||
this.isDebugging = false;
|
||||
|
||||
this.onKeyDown = (e) => {
|
||||
// ==========================
|
||||
// F4 key - toggle debug mode
|
||||
// ==========================
|
||||
|
||||
if (e.keyCode === 115){
|
||||
this.isDebugging = !this.isDebugging;
|
||||
$(".app-title").first().css("background-color", this.isDebugging ? "#5A6B75" : "#292F33");
|
||||
}
|
||||
|
||||
// Debug mode handling
|
||||
|
||||
else if (this.isDebugging){
|
||||
e.preventDefault();
|
||||
|
||||
// ===================================
|
||||
// N key - simulate popup notification
|
||||
// S key - simulate sound notification
|
||||
// ===================================
|
||||
|
||||
if (e.keyCode === 78 || e.keyCode === 83){
|
||||
var col = TD.controller.columnManager.getAllOrdered()[0];
|
||||
|
||||
var prevPopup = col.model.getHasNotification();
|
||||
var prevSound = col.model.getHasSound();
|
||||
|
||||
col.model.setHasNotification(e.keyCode === 78);
|
||||
col.model.setHasSound(e.keyCode === 83);
|
||||
|
||||
$.publish("/notifications/new",[{
|
||||
column: col,
|
||||
items: [
|
||||
col.updateArray[Math.floor(Math.random()*col.updateArray.length)]
|
||||
]
|
||||
}]);
|
||||
|
||||
setTimeout(function(){
|
||||
col.model.setHasNotification(prevPopup);
|
||||
col.model.setHasSound(prevSound);
|
||||
}, 1);
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ready(){
|
||||
$(document).on("keydown", this.onKeyDown);
|
||||
}
|
||||
|
||||
disabled(){
|
||||
$(document).off("keydown", this.onKeyDown);
|
||||
}
|
@@ -1,18 +0,0 @@
|
||||
[name]
|
||||
Revert TweetDeck design changes
|
||||
|
||||
[description]
|
||||
- Moves action menu to the right and hides it by default
|
||||
- Reverts interactive texts around tweets (such as 'Details' or 'Conversation')
|
||||
|
||||
[author]
|
||||
chylex
|
||||
|
||||
[version]
|
||||
1.1
|
||||
|
||||
[website]
|
||||
https://tweetduck.chylex.com
|
||||
|
||||
[requires]
|
||||
1.4.1
|
@@ -1,34 +0,0 @@
|
||||
enabled(){
|
||||
// add a stylesheet to change tweet actions
|
||||
this.css = window.TDPF_createCustomStyle(this);
|
||||
this.css.insert(".tweet-actions { float: right !important; width: auto !important; }");
|
||||
this.css.insert(".tweet-action { opacity: 0; }");
|
||||
this.css.insert(".is-favorite .tweet-action, .is-retweet .tweet-action { opacity: 0.5; visibility: visible !important; }");
|
||||
this.css.insert(".tweet:hover .tweet-action, .is-favorite .tweet-action[rel='favorite'], .is-retweet .tweet-action[rel='retweet'] { opacity: 1; visibility: visible !important; }");
|
||||
this.css.insert(".tweet-actions > li:nth-child(4) { margin-right: 2px !important; }");
|
||||
|
||||
// revert small links around the tweet
|
||||
this.prevFooterMustache = TD.mustaches["status/tweet_single_footer.mustache"];
|
||||
|
||||
var footerLayout = TD.mustaches["status/tweet_single_footer.mustache"];
|
||||
footerLayout = footerLayout.replace('txt-mute txt-size--12', 'txt-mute txt-small');
|
||||
footerLayout = footerLayout.replace('{{#inReplyToID}}', '{{^inReplyToID}} <a class="pull-left margin-txs txt-mute txt-small is-vishidden-narrow" href="#" rel="viewDetails">{{_i}}Details{{/i}}</a> <a class="pull-left margin-txs txt-mute txt-small is-vishidden is-visshown-narrow" href="#" rel="viewDetails">{{_i}}Open{{/i}}</a> {{/inReplyToID}} {{#inReplyToID}}');
|
||||
footerLayout = footerLayout.replace('<span class="link-complex-target"> {{_i}}View Conversation{{/i}}', '<i class="icon icon-conversation icon-small-context"></i> <span class="link-complex-target"> <span class="is-vishidden-wide is-vishidden-narrow">{{_i}}View{{/i}}</span> <span class="is-vishidden is-visshown-wide">{{_i}}Conversation{{/i}}</span>');
|
||||
TD.mustaches["status/tweet_single_footer.mustache"] = footerLayout;
|
||||
|
||||
// fix layout for right-aligned actions menu
|
||||
this.uiShowActionsMenuEvent = function(){
|
||||
$(".js-dropdown.pos-r").toggleClass("pos-r pos-l");
|
||||
};
|
||||
}
|
||||
|
||||
ready(){
|
||||
$(document).on("uiShowActionsMenu", this.uiShowActionsMenuEvent);
|
||||
}
|
||||
|
||||
disabled(){
|
||||
this.css.remove();
|
||||
|
||||
$(document).off("uiShowActionsMenu", this.uiShowActionsMenuEvent);
|
||||
TD.mustaches["status/tweet_single_footer.mustache"] = this.prevFooterMustache;
|
||||
}
|
17
Resources/Plugins/edit-design/.meta
Normal file
17
Resources/Plugins/edit-design/.meta
Normal file
@@ -0,0 +1,17 @@
|
||||
[name]
|
||||
Edit layout & design
|
||||
|
||||
[description]
|
||||
- Adds new layout and design configuration, which can be accessed via Settings - Edit layout & design
|
||||
|
||||
[author]
|
||||
chylex
|
||||
|
||||
[version]
|
||||
1.0
|
||||
|
||||
[website]
|
||||
https://tweetduck.chylex.com
|
||||
|
||||
[requires]
|
||||
1.7
|
358
Resources/Plugins/edit-design/browser.js
Normal file
358
Resources/Plugins/edit-design/browser.js
Normal file
@@ -0,0 +1,358 @@
|
||||
constructor(){
|
||||
super({
|
||||
requiresPageReload: true
|
||||
})
|
||||
}
|
||||
|
||||
enabled(){
|
||||
// elements & data
|
||||
this.css = null;
|
||||
this.htmlModal = null;
|
||||
this.config = null;
|
||||
|
||||
this.defaultConfig = {
|
||||
columnWidth: "310px",
|
||||
fontSize: "12px",
|
||||
hideTweetActions: true,
|
||||
moveTweetActionsToRight: true,
|
||||
revertReplies: false,
|
||||
roundedScrollBars: false,
|
||||
smallComposeTextSize: false,
|
||||
optimizeAnimations: true,
|
||||
avatarRadius: 10
|
||||
};
|
||||
|
||||
// modal dialog loading
|
||||
$TDP.readFileRoot(this.$token, "modal.html").then(contents => {
|
||||
this.htmlModal = contents;
|
||||
}).catch(err => {
|
||||
$TD.alert("error", "Problem loading data for the design edit plugin: "+err.message);
|
||||
});
|
||||
|
||||
// configuration
|
||||
const configFile = "config.json";
|
||||
this.tmpConfig = null;
|
||||
|
||||
var loadConfigObject = obj => {
|
||||
this.tmpConfig = obj || {};
|
||||
|
||||
if (TD.ready){
|
||||
this.onAppReady();
|
||||
}
|
||||
|
||||
this.injectDeciderReplyHook(this.tmpConfig.revertReplies);
|
||||
};
|
||||
|
||||
this.onAppReady = () => {
|
||||
if (this.tmpConfig !== null){
|
||||
this.config = $.extend(this.defaultConfig, this.tmpConfig);
|
||||
this.tmpConfig = null;
|
||||
this.reinjectAll();
|
||||
}
|
||||
};
|
||||
|
||||
$TDP.checkFileExists(this.$token, configFile).then(exists => {
|
||||
if (!exists){
|
||||
loadConfigObject(null);
|
||||
}
|
||||
else{
|
||||
$TDP.readFile(this.$token, configFile, true).then(contents => {
|
||||
try{
|
||||
loadConfigObject(JSON.parse(contents));
|
||||
}catch(err){
|
||||
loadConfigObject(null);
|
||||
}
|
||||
}).catch(err => {
|
||||
loadConfigObject(null);
|
||||
$TD.alert("error", "Problem loading configuration for the design edit plugin: "+err.message);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
this.saveConfig = () => {
|
||||
$TDP.writeFile(this.$token, configFile, JSON.stringify(this.config)).catch(err => {
|
||||
$TD.alert("error", "Problem saving configuration for the design edit plugin: "+err.message);
|
||||
});
|
||||
};
|
||||
|
||||
// settings click event
|
||||
this.onSettingsMenuClickedEvent = () => {
|
||||
if (this.htmlModal === null || this.config === null){
|
||||
return;
|
||||
}
|
||||
|
||||
setTimeout(() => {
|
||||
let menu = $(".js-dropdown-content").children("ul").first();
|
||||
if (menu.length === 0)return;
|
||||
|
||||
let itemTD = menu.children("[data-std]").first();
|
||||
if (itemTD.length === 0)return;
|
||||
|
||||
if (!itemTD.prev().hasClass("drp-h-divider")){
|
||||
itemTD.before('<li class="drp-h-divider"></li>');
|
||||
}
|
||||
|
||||
let itemEditDesign = $('<li class="is-selectable"><a href="#" data-action>Edit layout & design</a></li>');
|
||||
itemTD.after(itemEditDesign);
|
||||
|
||||
itemEditDesign.on("click", "a", function(){
|
||||
new customDesignModal();
|
||||
});
|
||||
|
||||
itemEditDesign.hover(function(){
|
||||
$(this).addClass("is-selected");
|
||||
}, function(){
|
||||
$(this).removeClass("is-selected");
|
||||
});
|
||||
}, 1);
|
||||
};
|
||||
|
||||
// modal dialog setup
|
||||
var me = this;
|
||||
|
||||
var updateKey = function(key, value){
|
||||
me.config[key] = value;
|
||||
|
||||
setTimeout(function(){
|
||||
me.saveConfig();
|
||||
me.reinjectAll();
|
||||
}, 1); // delays the slight lag caused by saving and reinjection
|
||||
};
|
||||
|
||||
var customDesignModal = TD.components.BaseModal.extend(function(){
|
||||
let modal = $("#td-design-plugin-modal");
|
||||
this.setAndShowContainer(modal, false);
|
||||
|
||||
// RELOAD
|
||||
this.reloadPage = false;
|
||||
modal.find("[data-td-reload]").click(() => this.reloadPage = true);
|
||||
|
||||
// UI EVENTS
|
||||
let getTextForCustom = function(key){
|
||||
return "Custom ("+me.config[key]+")";
|
||||
};
|
||||
|
||||
modal.find("[data-td-key]").each(function(){
|
||||
let item = $(this);
|
||||
let tag = item.prop("tagName");
|
||||
let key = item.attr("data-td-key");
|
||||
|
||||
// INPUTS
|
||||
if (tag === "INPUT"){
|
||||
let type = item.attr("type");
|
||||
|
||||
if (type === "checkbox"){
|
||||
item.prop("checked", me.config[key]);
|
||||
|
||||
item.change(function(){
|
||||
updateKey(key, item.prop("checked"));
|
||||
});
|
||||
}
|
||||
}
|
||||
// SELECTS
|
||||
else if (tag === "SELECT"){
|
||||
if (!item.val(me.config[key]).val()){
|
||||
let custom = item.find("option[value='custom']");
|
||||
|
||||
if (custom.length === 1){
|
||||
item.val("custom");
|
||||
custom.text(getTextForCustom(key));
|
||||
}
|
||||
}
|
||||
|
||||
item.change(function(){ // TODO change doesn't fire when Custom is already selected
|
||||
let val = item.val();
|
||||
|
||||
if (val === "custom"){
|
||||
val = prompt("Enter custom value:");
|
||||
|
||||
if (val){
|
||||
updateKey(key, val);
|
||||
item.find("option[value='custom']").text(getTextForCustom(key));
|
||||
}
|
||||
}
|
||||
else{
|
||||
updateKey(key, item.val());
|
||||
}
|
||||
});
|
||||
}
|
||||
// CUSTOM ELEMENTS
|
||||
else{
|
||||
let value = item.attr("data-td-value");
|
||||
|
||||
if (value == me.config[key]){
|
||||
item.addClass("selected");
|
||||
}
|
||||
|
||||
item.click(function(){
|
||||
modal.find("[data-td-key='"+key+"']").removeClass("selected");
|
||||
item.addClass("selected");
|
||||
updateKey(key, value);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
// THEMES
|
||||
modal.find("[data-td-theme='"+TD.settings.getTheme()+"']").prop("checked", true);
|
||||
|
||||
modal.find("[data-td-theme]").change(function(){
|
||||
setTimeout(function(){
|
||||
TD.settings.setTheme($(this).attr("data-td-theme"));
|
||||
$(document).trigger("uiToggleTheme");
|
||||
}, 1);
|
||||
});
|
||||
}).methods({
|
||||
_render: () => $(this.htmlModal),
|
||||
destroy: function(){
|
||||
if (this.reloadPage){
|
||||
location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
$("#td-design-plugin-modal").hide();
|
||||
this.supr();
|
||||
}
|
||||
});
|
||||
|
||||
// decider injections
|
||||
this.injectDeciderReplyHook = enable => {
|
||||
let prevFunc = TD.decider.updateFromBackend;
|
||||
|
||||
TD.decider.updateFromBackend = function(data){
|
||||
data["simplified_replies"] = !enable;
|
||||
return prevFunc.apply(this, arguments);
|
||||
};
|
||||
|
||||
TD.decider.updateForGuestId();
|
||||
this.$pluginSettings.requiresPageReload = enable;
|
||||
};
|
||||
|
||||
// css and layout injection
|
||||
this.resetDesign = () => {
|
||||
if (this.css){
|
||||
this.css.remove();
|
||||
}
|
||||
|
||||
this.css = window.TDPF_createCustomStyle(this);
|
||||
};
|
||||
|
||||
this.reinjectAll = () => {
|
||||
this.resetDesign();
|
||||
|
||||
this.css.insert("#general_settings .cf { display: none !important }");
|
||||
this.css.insert("#general_settings .divider-bar::after { display: inline-block; padding-top: 10px; line-height: 17px; content: 'Use the new | Edit layout & design | option in the Settings to modify TweetDeck theme, column width, font size, and other features.' }");
|
||||
|
||||
this.css.insert(".txt-base-smallest:not(.icon), .txt-base-largest:not(.icon) { font-size: "+this.config.fontSize+" !important }");
|
||||
this.css.insert(".avatar { border-radius: "+this.config.avatarRadius+"% !important }");
|
||||
|
||||
if (this.config.hideTweetActions){
|
||||
this.css.insert(".tweet-action { opacity: 0; }");
|
||||
this.css.insert(".is-favorite .tweet-action, .is-retweet .tweet-action { opacity: 0.5; visibility: visible !important }");
|
||||
this.css.insert(".tweet:hover .tweet-action, .is-favorite .tweet-action[rel='favorite'], .is-retweet .tweet-action[rel='retweet'] { opacity: 1; visibility: visible !important }");
|
||||
}
|
||||
|
||||
if (this.config.moveTweetActionsToRight){
|
||||
this.css.insert(".tweet-actions { float: right !important; width: auto !important }");
|
||||
this.css.insert(".tweet-actions > li:nth-child(4) { margin-right: 2px !important }");
|
||||
}
|
||||
|
||||
if (this.config.smallComposeTextSize){
|
||||
this.css.insert(".compose-text { font-size: 12px !important; height: 120px !important }");
|
||||
}
|
||||
|
||||
if (!this.config.roundedScrollBars){
|
||||
this.css.insert(".scroll-styled-v:not(.antiscroll-inner)::-webkit-scrollbar { width: 8px }");
|
||||
this.css.insert(".scroll-styled-h:not(.antiscroll-inner)::-webkit-scrollbar { height: 8px }");
|
||||
this.css.insert(".scroll-styled-v::-webkit-scrollbar-thumb { border-radius: 0 }");
|
||||
this.css.insert(".scroll-styled-h::-webkit-scrollbar-thumb { border-radius: 0 }");
|
||||
this.css.insert(".antiscroll-scrollbar { border-radius: 0 }");
|
||||
this.css.insert(".antiscroll-scrollbar-vertical { margin-top: 0 }");
|
||||
this.css.insert(".antiscroll-scrollbar-horizontal { margin-left: 0 }");
|
||||
}
|
||||
|
||||
if (this.config.optimizeAnimations){
|
||||
this.css.insert(".app-content { will-change: transform }");
|
||||
this.css.insert(".column-holder { will-change: transform }");
|
||||
}
|
||||
|
||||
if (this.config.columnWidth[0] === '/'){
|
||||
let cols = this.config.columnWidth.slice(1);
|
||||
|
||||
this.css.insert(".column { width: calc((100vw - 205px) / "+cols+" - 8px) !important }");
|
||||
this.css.insert(".is-condensed .column { width: calc((100vw - 55px) / "+cols+" - 8px) !important }");
|
||||
}
|
||||
else{
|
||||
this.css.insert(".column { width: "+this.config.columnWidth+" !important }");
|
||||
}
|
||||
|
||||
switch(this.config.columnWidth){
|
||||
case "/6":
|
||||
TD.settings.setColumnWidth("narrow");
|
||||
break;
|
||||
|
||||
case "310px":
|
||||
case "/5":
|
||||
TD.settings.setColumnWidth("medium");
|
||||
break;
|
||||
|
||||
default:
|
||||
TD.settings.setColumnWidth(parseInt(this.config.columnWidth, 10) < 310 ? "narrow" : "wide"); // NaN will give "wide"
|
||||
break;
|
||||
}
|
||||
|
||||
switch(this.config.fontSize){
|
||||
case "13px": TD.settings.setFontSize("small"); break;
|
||||
case "14px": TD.settings.setFontSize("medium"); break;
|
||||
case "15px": TD.settings.setFontSize("large"); break;
|
||||
default: TD.settings.setFontSize(parseInt(this.config.fontSize, 10) >= 16 ? "largest" : "smallest"); break;
|
||||
}
|
||||
|
||||
$TDP.injectIntoNotificationsBefore(this.$token, "css", "</head>", [
|
||||
"<style type='text/css'>",
|
||||
".txt-base-smallest:not(.icon), .txt-base-largest:not(.icon) { font-size: "+this.config.fontSize+" !important }",
|
||||
".avatar { border-radius: "+this.config.avatarRadius+"% !important }",
|
||||
"</style>"
|
||||
].join(""));
|
||||
};
|
||||
|
||||
this.uiShowActionsMenuEvent = () => {
|
||||
if (this.config.moveTweetActionsToRight){
|
||||
$(".js-dropdown.pos-r").toggleClass("pos-r pos-l");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ready(){
|
||||
// configuration
|
||||
switch(TD.settings.getColumnWidth()){
|
||||
case "wide": this.defaultConfig.columnWidth = "350px"; break;
|
||||
case "narrow": this.defaultConfig.columnWidth = "270px"; break;
|
||||
}
|
||||
|
||||
switch(TD.settings.getFontSize()){
|
||||
case "small": this.defaultConfig.fontSize = "13px"; break;
|
||||
case "medium": this.defaultConfig.fontSize = "14px"; break;
|
||||
case "large": this.defaultConfig.fontSize = "15px"; break;
|
||||
case "largest": this.defaultConfig.fontSize = "16px"; break;
|
||||
}
|
||||
|
||||
this.onAppReady();
|
||||
|
||||
// layout events
|
||||
$(document).on("uiShowActionsMenu", this.uiShowActionsMenuEvent);
|
||||
|
||||
// modal
|
||||
$("[data-action='settings-menu']").on("click", this.onSettingsMenuClickedEvent);
|
||||
$(".js-app").append('<div id="td-design-plugin-modal" class="js-modal settings-modal ovl scroll-v scroll-styled-v"></div>');
|
||||
}
|
||||
|
||||
disabled(){
|
||||
if (this.css){
|
||||
this.css.remove();
|
||||
}
|
||||
|
||||
$(document).off("uiShowActionsMenu", this.uiShowActionsMenuEvent);
|
||||
|
||||
$("[data-action='settings-menu']").off("click", this.onSettingsMenuClickedEvent);
|
||||
$("#td-design-plugin-modal").remove();
|
||||
}
|
235
Resources/Plugins/edit-design/modal.html
Normal file
235
Resources/Plugins/edit-design/modal.html
Normal file
@@ -0,0 +1,235 @@
|
||||
<div class="td-modal-panel js-modal-panel mdl s-tall-fixed is-inverted-dark">
|
||||
<header class="js-mdl-header mdl-header js-drag-handle">
|
||||
<h3 class="mdl-header-title js-header-title">TweetDuck - Layout & Design</h3>
|
||||
<a href="#" class="mdl-dismiss js-dismiss link-normal-dark">
|
||||
<i class="icon icon-close"></i>
|
||||
</a>
|
||||
</header>
|
||||
<div class="mdl-inner">
|
||||
<div class="td-modal-content mdl-content js-mdl-content horizontal-flow-container">
|
||||
<div class="td-modal-inner-cols">
|
||||
<div class="l-column mdl-column">
|
||||
|
||||
<!-- THEME -->
|
||||
|
||||
<label class="txt-uppercase touch-larger-label">
|
||||
<b>Theme</b>
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input data-td-theme="dark" class="js-theme-radio touch-larger-label" name="theme" type="radio">
|
||||
Dark
|
||||
</label>
|
||||
<label class="radio">
|
||||
<input data-td-theme="light" class="js-theme-radio touch-larger-label" name="theme" type="radio">
|
||||
Light
|
||||
</label>
|
||||
|
||||
<!-- COLUMN SIZE -->
|
||||
|
||||
<label class="txt-uppercase touch-larger-label">
|
||||
<b>Columns</b>
|
||||
</label>
|
||||
<select data-td-key="columnWidth">
|
||||
<option disabled></option>
|
||||
<optgroup label="Fixed width">
|
||||
<option value="270px">Narrow (270px)</option>
|
||||
<option value="310px">Medium (310px)</option>
|
||||
<option value="350px">Wide (350px)</option>
|
||||
<option value="400px">Extreme (400px)</option>
|
||||
<option value="custom">Custom</option>
|
||||
</optgroup>
|
||||
<option disabled></option>
|
||||
<optgroup label="Dynamic width">
|
||||
<option value="/3">3 columns on screen</option>
|
||||
<option value="/4">4 columns on screen</option>
|
||||
<option value="/5">5 columns on screen</option>
|
||||
<option value="/6">6 columns on screen</option>
|
||||
</optgroup>
|
||||
<option disabled></option>
|
||||
</select>
|
||||
|
||||
<!-- FONT SIZE -->
|
||||
|
||||
<label class="txt-uppercase touch-larger-label">
|
||||
<b>Font size</b>
|
||||
</label>
|
||||
<select data-td-key="fontSize">
|
||||
<option value="12px">Tiny (12px)</option>
|
||||
<option value="13px">Small (13px)</option>
|
||||
<option value="14px">Medium (14px)</option>
|
||||
<option value="15px">Large (15px)</option>
|
||||
<option value="16px">Largest (16px)</option>
|
||||
<option value="custom">Custom</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="l-column mdl-column">
|
||||
|
||||
<!-- LAYOUT -->
|
||||
|
||||
<label class="txt-uppercase touch-larger-label">
|
||||
<b>Layout</b>
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input data-td-key="hideTweetActions" class="js-theme-checkbox touch-larger-label" type="checkbox">
|
||||
Hide tweet actions
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input data-td-key="moveTweetActionsToRight" class="js-theme-checkbox touch-larger-label" type="checkbox">
|
||||
Tweet actions on the right side
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input data-td-key="revertReplies" data-td-reload class="js-theme-checkbox touch-larger-label" type="checkbox">
|
||||
Revert reply style (reloads page)
|
||||
</label>
|
||||
|
||||
<!-- DESIGN -->
|
||||
|
||||
<label class="txt-uppercase touch-larger-label">
|
||||
<b>Design</b>
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input data-td-key="roundedScrollBars" class="js-theme-checkbox touch-larger-label" type="checkbox">
|
||||
Rounded scroll bars
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input data-td-key="smallComposeTextSize" class="js-theme-checkbox touch-larger-label" type="checkbox">
|
||||
Small compose tweet font size
|
||||
</label>
|
||||
|
||||
<!-- ADVANCED -->
|
||||
|
||||
<label class="txt-uppercase touch-larger-label">
|
||||
<b>Advanced</b>
|
||||
</label>
|
||||
<label class="checkbox">
|
||||
<input data-td-key="optimizeAnimations" class="js-theme-checkbox touch-larger-label" type="checkbox">
|
||||
Optimize animations (uses more memory for smoother animations)
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="l-column mdl-column">
|
||||
|
||||
<!-- AVATAR SHAPE -->
|
||||
|
||||
<label class="txt-uppercase touch-larger-label">
|
||||
<b>Avatar shape</b>
|
||||
</label>
|
||||
<div class="td-avatar-shape-container">
|
||||
<div class="td-avatar-shape-item-outer" data-td-key="avatarRadius" data-td-value="2">
|
||||
<div class="td-avatar-shape" style="border-radius:2%"></div>
|
||||
<label>Square</label>
|
||||
</div>
|
||||
<div class="td-avatar-shape-item-outer" data-td-key="avatarRadius" data-td-value="10">
|
||||
<div class="td-avatar-shape" style="border-radius:10%"></div>
|
||||
<label>Default</label>
|
||||
</div>
|
||||
<div class="td-avatar-shape-item-outer" data-td-key="avatarRadius" data-td-value="30">
|
||||
<div class="td-avatar-shape" style="border-radius:30%"></div>
|
||||
<label>Round</label>
|
||||
</div>
|
||||
<div class="td-avatar-shape-item-outer" data-td-key="avatarRadius" data-td-value="50">
|
||||
<div class="td-avatar-shape" style="border-radius:50%"></div>
|
||||
<label>Circle</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- END -->
|
||||
</div>
|
||||
<footer class="padding-vxl txt-center">
|
||||
<button class="js-dismiss btn btn-positive pull-right">
|
||||
<i class="icon icon-check icon-small padding-rs"></i>
|
||||
<span class="label">Done</span>
|
||||
</button>
|
||||
</footer>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
/* Containers */
|
||||
|
||||
.td-modal-panel {
|
||||
width: 693px;
|
||||
height: 374px;
|
||||
}
|
||||
|
||||
.td-modal-inner-cols {
|
||||
padding: 0 6px;
|
||||
}
|
||||
|
||||
.td-modal-inner-cols .l-column {
|
||||
padding: 15px 9px;
|
||||
box-sizing: border-box;
|
||||
font-size: 0; /* fix custom font size breaking the modal layout */
|
||||
}
|
||||
|
||||
.td-modal-inner-cols .l-column:nth-child(2) {
|
||||
width: 250px;
|
||||
}
|
||||
|
||||
.td-modal-inner-full {
|
||||
padding: 15px;
|
||||
}
|
||||
|
||||
.td-modal-inner-full .txt-center {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
/* Elements */
|
||||
|
||||
.td-modal-content label {
|
||||
margin-top: 18px;
|
||||
}
|
||||
|
||||
.td-modal-content label:first-child {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.td-modal-content label.radio {
|
||||
display: inline-block;
|
||||
margin: 0 16px 5px 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.td-modal-content label.checkbox {
|
||||
margin: 0 0 5px 4px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* Avatar shape */
|
||||
|
||||
.td-avatar-shape-container {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.td-avatar-shape-item-outer {
|
||||
display: inline-block;
|
||||
margin: 0 4px 10px;
|
||||
padding: 16px 14px 8px;
|
||||
box-sizing: border-box;
|
||||
box-shadow: 0 0 4px rgba(0, 0, 0, 0.1);
|
||||
border: 2px solid #F5F8FA;
|
||||
background-color: #F5F8FA;
|
||||
}
|
||||
|
||||
.td-avatar-shape-item-outer:hover {
|
||||
border-color: #888;
|
||||
}
|
||||
|
||||
.td-avatar-shape-item-outer.selected {
|
||||
border-color: #666;
|
||||
}
|
||||
|
||||
.td-avatar-shape-item-outer label {
|
||||
margin: 10px 0 0;
|
||||
}
|
||||
|
||||
.td-avatar-shape {
|
||||
width: 48px;
|
||||
height: 48px;
|
||||
background-color: #71BAF2;
|
||||
}
|
||||
</style>
|
18
Resources/Plugins/emoji-keyboard/.meta
Normal file
18
Resources/Plugins/emoji-keyboard/.meta
Normal file
@@ -0,0 +1,18 @@
|
||||
[name]
|
||||
Emoji keyboard
|
||||
|
||||
[description]
|
||||
- Adds an emoji keyboard when writing tweets
|
||||
- Emoji list provided by http://unicode.org/emoji/charts/emoji-ordering.html
|
||||
|
||||
[author]
|
||||
chylex
|
||||
|
||||
[version]
|
||||
1.0
|
||||
|
||||
[website]
|
||||
https://tweetduck.chylex.com
|
||||
|
||||
[requires]
|
||||
1.5.3
|
298
Resources/Plugins/emoji-keyboard/browser.js
Normal file
298
Resources/Plugins/emoji-keyboard/browser.js
Normal file
@@ -0,0 +1,298 @@
|
||||
enabled(){
|
||||
this.selectedSkinTone = "";
|
||||
|
||||
this.skinToneList = [
|
||||
"", "1F3FB", "1F3FC", "1F3FD", "1F3FE", "1F3FF"
|
||||
];
|
||||
|
||||
this.skinToneNonDefaultList = [
|
||||
"1F3FB", "1F3FC", "1F3FD", "1F3FE", "1F3FF"
|
||||
];
|
||||
|
||||
this.skinToneData = [
|
||||
[ "", "#FFDD67" ],
|
||||
[ "1F3FB", "#FFE1BD" ],
|
||||
[ "1F3FC", "#FED0AC" ],
|
||||
[ "1F3FD", "#D6A57C" ],
|
||||
[ "1F3FE", "#B47D56" ],
|
||||
[ "1F3FF", "#8A6859" ],
|
||||
];
|
||||
|
||||
this.emojiHTML1 = ""; // no skin tones, prepended
|
||||
this.emojiHTML2 = {}; // contains emojis with skin tones
|
||||
this.emojiHTML3 = ""; // no skin tones, appended
|
||||
|
||||
var me = this;
|
||||
|
||||
// styles
|
||||
|
||||
this.css = window.TDPF_createCustomStyle(this);
|
||||
this.css.insert(".emoji-keyboard { position: absolute; width: 15.35em; background-color: white; border-radius: 2px 2px 3px 3px; font-size: 24px; z-index: 9999 }");
|
||||
this.css.insert(".emoji-keyboard-list { height: 10.14em; padding: 0.1em; box-sizing: border-box; overflow-y: auto }");
|
||||
this.css.insert(".emoji-keyboard-list .separator { height: 26px }");
|
||||
this.css.insert(".emoji-keyboard-list .emoji { padding: 0.1em !important; cursor: pointer }");
|
||||
this.css.insert(".emoji-keyboard-skintones { height: 1.3em; text-align: center; background-color: #292f33; border-radius: 0 0 2px 2px }");
|
||||
this.css.insert(".emoji-keyboard-skintones div { width: 0.8em; height: 0.8em; margin: 0.25em 0.1em; border-radius: 50%; display: inline-block; box-sizing: border-box; cursor: pointer }");
|
||||
this.css.insert(".emoji-keyboard-skintones .sel { border: 2px solid rgba(0, 0, 0, 0.35); box-shadow: 0 0 2px 0 rgba(255, 255, 255, 0.65), 0 0 1px 0 rgba(255, 255, 255, 0.4) inset }");
|
||||
this.css.insert(".emoji-keyboard-skintones :hover { border: 2px solid rgba(0, 0, 0, 0.25); box-shadow: 0 0 1px 0 rgba(255, 255, 255, 0.65), 0 0 1px 0 rgba(255, 255, 255, 0.25) inset }");
|
||||
|
||||
// layout
|
||||
|
||||
var buttonHTML = '<button class="needsclick btn btn-on-blue txt-left padding-v--9 emoji-keyboard-popup-btn"><i class="icon icon-heart"></i></button>';
|
||||
|
||||
this.prevComposeMustache = TD.mustaches["compose/docked_compose.mustache"];
|
||||
TD.mustaches["compose/docked_compose.mustache"] = TD.mustaches["compose/docked_compose.mustache"].replace('<div class="cf margin-t--12 margin-b--30">', '<div class="cf margin-t--12 margin-b--30">'+buttonHTML);
|
||||
|
||||
var dockedComposePanel = $(".js-docked-compose");
|
||||
|
||||
if (dockedComposePanel.length){
|
||||
dockedComposePanel.find(".cf.margin-t--12.margin-b--30").first().append(buttonHTML);
|
||||
}
|
||||
|
||||
// keyboard generation
|
||||
|
||||
this.currentKeyboard = null;
|
||||
|
||||
var hideKeyboard = () => {
|
||||
$(this.currentKeyboard).remove();
|
||||
this.currentKeyboard = null;
|
||||
|
||||
$(".emoji-keyboard-popup-btn").removeClass("is-selected");
|
||||
$(".js-compose-text").first().focus();
|
||||
};
|
||||
|
||||
var generateEmojiHTML = skinTone => {
|
||||
return this.emojiHTML1+this.emojiHTML2[skinTone]+this.emojiHTML3;
|
||||
};
|
||||
|
||||
var selectSkinTone = skinTone => {
|
||||
let selectedEle = this.currentKeyboard.children[1].querySelector("[data-tone='"+this.selectedSkinTone+"']");
|
||||
selectedEle && selectedEle.classList.remove("sel");
|
||||
|
||||
this.selectedSkinTone = skinTone;
|
||||
this.currentKeyboard.children[0].innerHTML = generateEmojiHTML(skinTone);
|
||||
this.currentKeyboard.children[1].querySelector("[data-tone='"+this.selectedSkinTone+"']").classList.add("sel");
|
||||
};
|
||||
|
||||
this.generateKeyboard = (input, left, top) => {
|
||||
var outer = document.createElement("div");
|
||||
outer.classList.add("emoji-keyboard");
|
||||
outer.style.left = left+"px";
|
||||
outer.style.top = top+"px";
|
||||
|
||||
var keyboard = document.createElement("div");
|
||||
keyboard.classList.add("emoji-keyboard-list");
|
||||
|
||||
keyboard.addEventListener("click", function(e){
|
||||
if (e.target.tagName === "IMG"){
|
||||
var val = input.val();
|
||||
var inserted = e.target.getAttribute("alt");
|
||||
var posStart = input[0].selectionStart;
|
||||
var posEnd = input[0].selectionEnd;
|
||||
|
||||
input.val(val.slice(0, posStart)+inserted+val.slice(posStart));
|
||||
input.trigger("change");
|
||||
input.focus();
|
||||
|
||||
input[0].selectionStart = posStart+inserted.length;
|
||||
input[0].selectionEnd = posEnd+inserted.length;
|
||||
}
|
||||
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
var skintones = document.createElement("div");
|
||||
skintones.innerHTML = me.skinToneData.map(entry => "<div data-tone='"+entry[0]+"' style='background-color:"+entry[1]+"'></div>").join("");
|
||||
skintones.classList.add("emoji-keyboard-skintones");
|
||||
|
||||
skintones.addEventListener("click", function(e){
|
||||
if (e.target.hasAttribute("data-tone")){
|
||||
selectSkinTone(e.target.getAttribute("data-tone") || "");
|
||||
}
|
||||
|
||||
e.stopPropagation();
|
||||
});
|
||||
|
||||
outer.appendChild(keyboard);
|
||||
outer.appendChild(skintones);
|
||||
document.body.appendChild(outer);
|
||||
|
||||
this.currentKeyboard = outer;
|
||||
selectSkinTone(this.selectedSkinTone);
|
||||
};
|
||||
|
||||
this.prevTryPasteImage = window.TDGF_tryPasteImage;
|
||||
var prevTryPasteImageF = this.prevTryPasteImage;
|
||||
|
||||
window.TDGF_tryPasteImage = function(){
|
||||
if (me.currentKeyboard){
|
||||
hideKeyboard();
|
||||
}
|
||||
|
||||
return prevTryPasteImageF.apply(this, arguments);
|
||||
};
|
||||
|
||||
// event handlers
|
||||
|
||||
this.emojiKeyboardButtonClickEvent = function(e){
|
||||
if (me.currentKeyboard){
|
||||
hideKeyboard();
|
||||
}
|
||||
else{
|
||||
var pos = $(this).offset();
|
||||
me.generateKeyboard($(".js-compose-text").first(), pos.left, pos.top+$(this).outerHeight()+8);
|
||||
|
||||
$(this).addClass("is-selected");
|
||||
}
|
||||
|
||||
$(this).blur();
|
||||
e.stopPropagation();
|
||||
};
|
||||
|
||||
this.documentClickEvent = function(e){
|
||||
if (me.currentKeyboard && !e.target.classList.contains("js-compose-text")){
|
||||
hideKeyboard();
|
||||
}
|
||||
};
|
||||
|
||||
this.documentKeyEvent = function(e){
|
||||
if (me.currentKeyboard && e.keyCode === 27){ // escape
|
||||
hideKeyboard();
|
||||
e.stopPropagation();
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* TODO
|
||||
* ----
|
||||
* add emoji search if I can be bothered
|
||||
* lazy emoji loading
|
||||
*/
|
||||
}
|
||||
|
||||
ready(){
|
||||
$(".emoji-keyboard-popup-btn").on("click", this.emojiKeyboardButtonClickEvent);
|
||||
$(document).on("click", this.documentClickEvent);
|
||||
$(document).on("keydown", this.documentKeyEvent);
|
||||
|
||||
// HTML generation
|
||||
|
||||
var convUnicode = function(codePt){
|
||||
if (codePt > 0xFFFF){
|
||||
codePt -= 0x10000;
|
||||
return String.fromCharCode(0xD800+(codePt>>10), 0xDC00+(codePt&0x3FF));
|
||||
}
|
||||
else{
|
||||
return String.fromCharCode(codePt);
|
||||
}
|
||||
};
|
||||
|
||||
$TDP.readFileRoot(this.$token, "emoji-ordering.txt").then(contents => {
|
||||
let generated1 = [];
|
||||
let generated2 = {};
|
||||
let generated3 = [];
|
||||
|
||||
for(let skinTone of this.skinToneList){
|
||||
generated2[skinTone] = [];
|
||||
}
|
||||
|
||||
// declaration inserters
|
||||
|
||||
let addDeclaration1 = decl => {
|
||||
generated1.push(decl.split(" ").map(pt => convUnicode(parseInt(pt, 16))).join(""));
|
||||
};
|
||||
|
||||
let addDeclaration2 = (tone, decl) => {
|
||||
let gen = decl.split(" ").map(pt => convUnicode(parseInt(pt, 16))).join("");
|
||||
|
||||
if (tone === null){
|
||||
for(let skinTone of this.skinToneList){
|
||||
generated2[skinTone].push(gen);
|
||||
}
|
||||
}
|
||||
else{
|
||||
generated2[tone].push(gen);
|
||||
}
|
||||
};
|
||||
|
||||
let addDeclaration3 = decl => {
|
||||
generated3.push(decl.split(" ").map(pt => convUnicode(parseInt(pt, 16))).join(""));
|
||||
};
|
||||
|
||||
// line reading
|
||||
|
||||
let skinToneState = 0;
|
||||
|
||||
for(let line of contents.split("\n")){
|
||||
if (line[0] === '@'){
|
||||
switch(skinToneState){
|
||||
case 0: generated1.push("___"); break;
|
||||
case 1: this.skinToneList.forEach(skinTone => generated2[skinTone].push("___")); break;
|
||||
case 2: generated3.push("___"); break;
|
||||
}
|
||||
|
||||
if (line[1] === '1'){
|
||||
skinToneState = 1;
|
||||
}
|
||||
else if (line[1] === '2'){
|
||||
skinToneState = 2;
|
||||
}
|
||||
}
|
||||
else if (skinToneState === 1){
|
||||
let decl = line.slice(0, line.indexOf(';'));
|
||||
let skinIndex = decl.indexOf('$');
|
||||
|
||||
if (skinIndex !== -1){
|
||||
let declPre = decl.slice(0, skinIndex);
|
||||
let declPost = decl.slice(skinIndex+1);
|
||||
|
||||
for(let skinTone of this.skinToneNonDefaultList){
|
||||
generated2[skinTone].pop();
|
||||
addDeclaration2(skinTone, declPre+skinTone+declPost);
|
||||
}
|
||||
}
|
||||
else{
|
||||
addDeclaration2(null, decl);
|
||||
}
|
||||
}
|
||||
else if (skinToneState === 2){
|
||||
addDeclaration3(line.slice(0, line.indexOf(';')));
|
||||
}
|
||||
else if (skinToneState === 0){
|
||||
addDeclaration1(line.slice(0, line.indexOf(';')));
|
||||
}
|
||||
}
|
||||
|
||||
// final processing
|
||||
|
||||
let replaceSeparators = str => str.replace(/___/g, "<div class='separator'></div>");
|
||||
|
||||
let start = "<p style='font-size:13px;color:#444;margin:4px;text-align:center'>Please, note that most emoji will not show up properly in the text box above, but they will display in the tweet.</p>";
|
||||
this.emojiHTML1 = start+replaceSeparators(TD.util.cleanWithEmoji(generated1.join("")));
|
||||
|
||||
for(let skinTone of this.skinToneList){
|
||||
this.emojiHTML2[skinTone] = replaceSeparators(TD.util.cleanWithEmoji(generated2[skinTone].join("")));
|
||||
}
|
||||
|
||||
this.emojiHTML3 = replaceSeparators(TD.util.cleanWithEmoji(generated3.join("")));
|
||||
}).catch(err => {
|
||||
$TD.alert("error", "Problem loading emoji keyboard: "+err.message);
|
||||
});
|
||||
}
|
||||
|
||||
disabled(){
|
||||
this.css.remove();
|
||||
|
||||
if (this.currentKeyboard){
|
||||
$(this.currentKeyboard).remove();
|
||||
}
|
||||
|
||||
window.TDGF_tryPasteImage = this.prevTryPasteImage;
|
||||
|
||||
$(".emoji-keyboard-popup-btn").off("click", this.emojiKeyboardButtonClickEvent);
|
||||
$(".emoji-keyboard-popup-btn").remove();
|
||||
|
||||
$(document).off("click", this.documentClickEvent);
|
||||
$(document).off("keydown", this.documentKeyEvent);
|
||||
TD.mustaches["compose/docked_compose.mustache"] = this.prevComposeMustache;
|
||||
}
|
1606
Resources/Plugins/emoji-keyboard/emoji-ordering.txt
Normal file
1606
Resources/Plugins/emoji-keyboard/emoji-ordering.txt
Normal file
File diff suppressed because it is too large
Load Diff
@@ -8,7 +8,7 @@ Custom reply account
|
||||
chylex
|
||||
|
||||
[version]
|
||||
1.2
|
||||
1.2.1
|
||||
|
||||
[website]
|
||||
https://tweetduck.chylex.com
|
||||
|
@@ -22,10 +22,19 @@ enabled(){
|
||||
var section = data.element.closest("section.column");
|
||||
|
||||
var column = TD.controller.columnManager.get(section.attr("data-column"));
|
||||
var header = $("h1.column-title", section);
|
||||
var header = $(".column-title", section);
|
||||
var title = header.children(".column-head-title");
|
||||
|
||||
var columnTitle = header.children(".column-head-title").text();
|
||||
var columnAccount = header.children(".attribution").text();
|
||||
var columnTitle, columnAccount;
|
||||
|
||||
if (title.length){
|
||||
columnTitle = title.text();
|
||||
columnAccount = header.children(".attribution").text();
|
||||
}
|
||||
else{
|
||||
columnTitle = header.children(".column-title-edit-box").val();
|
||||
columnAccount = "";
|
||||
}
|
||||
|
||||
try{
|
||||
query = configuration.customSelector(column.getColumnType(), columnTitle, columnAccount, column);
|
||||
@@ -134,4 +143,4 @@ disabled(){
|
||||
$(document).off("uiInlineComposeTweet", this.uiComposeTweetEvent);
|
||||
$(document).off("uiDockedComposeTweet", this.uiComposeTweetEvent);
|
||||
$(document).off("click", ".js-account-list .js-account-item", this.onSelectedAccountChanged);
|
||||
}
|
||||
}
|
||||
|
@@ -9,10 +9,10 @@ Polls in timelines
|
||||
chylex
|
||||
|
||||
[version]
|
||||
1.0
|
||||
1.0.1
|
||||
|
||||
[website]
|
||||
https://tweetduck.chylex.com
|
||||
|
||||
[requires]
|
||||
1.4.1
|
||||
1.7
|
@@ -16,7 +16,7 @@ enabled(){
|
||||
};
|
||||
|
||||
// add poll rendering to tweets
|
||||
injectLayout("status/tweet_single.mustache", "status/poll", "{{/quotedTweetMissing}} {{#translation}}", "{{/quotedTweetMissing}} <div class='timeline-poll-container'>{{#poll}}{{>duck/tweet_single/poll}}{{/poll}}</div> {{#translation}}");
|
||||
injectLayout("status/tweet_single.mustache", "status/poll", "{{/quotedTweetMissing}} {{#translation}}", "{{/quotedTweetMissing}} <div class='timeline-poll-container td-screenshot-remove'>{{#poll}}{{>duck/tweet_single/poll}}{{/poll}}</div> {{#translation}}");
|
||||
TD.mustaches["duck/tweet_single/poll.mustache"] = '<div class="js-poll margin-tl"> {{#poll}} <ul class="margin-b--12"> {{#choices}} <li class="position-rel margin-b--8 height-3"> <div class="poll-bar pin-top height-p--100 br-1 {{#isWinner}}poll-bar--winner{{/isWinner}} {{#hasTimeLeft}}br-left{{/hasTimeLeft}} width-p--{{percentage}}"/> <div class="poll-label position-rel padding-a--4"> <span class="txt-bold txt-right inline-block width-5 padding-r--4">{{percentage}}%</span> {{{label}}} {{#isSelectedChoice}} <i class="icon icon-check txt-size-variable--11"></i> {{/isSelectedChoice}} </div> </li> {{/choices}} </ul> <span class="inline-block txt-small padding-ls txt-seamful-deep-gray"> {{{prettyCount}}} · {{#hasTimeLeft}} {{{prettyTimeLeft}}} {{/hasTimeLeft}} {{^hasTimeLeft}} {{_i}}Final results{{/i}} {{/hasTimeLeft}} </span> {{/poll}} </div>';
|
||||
}
|
||||
|
||||
|
@@ -9,11 +9,14 @@ namespace TweetDck.Resources{
|
||||
static class ScriptLoader{
|
||||
private const string UrlPrefix = "td:";
|
||||
|
||||
public static string LoadResource(string name){
|
||||
public static string LoadResource(string name, bool silent = false){
|
||||
try{
|
||||
return File.ReadAllText(Path.Combine(Program.ScriptPath, name), Encoding.UTF8);
|
||||
}catch(Exception ex){
|
||||
MessageBox.Show("Unfortunately, "+Program.BrandName+" could not load the "+name+" file. The program will continue running with limited functionality.\r\n\r\n"+ex.Message, Program.BrandName+" Has Failed :(", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
if (!silent){
|
||||
MessageBox.Show("Unfortunately, "+Program.BrandName+" could not load the "+name+" file. The program will continue running with limited functionality.\r\n\r\n"+ex.Message, Program.BrandName+" Has Failed :(", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@@ -1,79 +1,45 @@
|
||||
(function($, $TD, TD){
|
||||
(function($, $TD, $TDX, TD){
|
||||
//
|
||||
// Variable: Current highlighted column jQuery object.
|
||||
// Variable: Current highlighted column jQuery & data objects.
|
||||
//
|
||||
var highlightedColumnEle;
|
||||
var highlightedColumnEle, highlightedColumnObj;
|
||||
|
||||
//
|
||||
// Variable: Currently highlighted tweet jQuery object.
|
||||
// Variable: Currently highlighted tweet jQuery & data objects.
|
||||
//
|
||||
var highlightedTweetEle;
|
||||
var highlightedTweetEle, highlightedTweetObj;
|
||||
|
||||
//
|
||||
// Function: Initializes TweetD*ck events. Called after the website app is loaded.
|
||||
// Variable: Array of functions called after the website app is loaded.
|
||||
//
|
||||
var initializeTweetDck = function(){
|
||||
// Settings button hook
|
||||
$("[data-action='settings-menu']").click(function(){
|
||||
setTimeout(function(){
|
||||
var menu = $(".js-dropdown-content").children("ul").first();
|
||||
if (menu.length === 0)return;
|
||||
|
||||
menu.children(".drp-h-divider").last().after([
|
||||
'<li class="is-selectable" data-std><a href="#" data-action="td-settings">'+$TD.brandName+' settings</a></li>',
|
||||
'<li class="is-selectable" data-std><a href="#" data-action="td-plugins">'+$TD.brandName+' plugins</a></li>',
|
||||
'<li class="drp-h-divider"></li>'
|
||||
].join(""));
|
||||
|
||||
var buttons = menu.children("[data-std]");
|
||||
|
||||
buttons.on("click", "a", function(){
|
||||
var action = $(this).attr("data-action");
|
||||
|
||||
if (action === "td-settings"){
|
||||
$TD.openSettingsMenu();
|
||||
}
|
||||
else if (action === "td-plugins"){
|
||||
$TD.openPluginsMenu();
|
||||
}
|
||||
});
|
||||
|
||||
buttons.hover(function(){
|
||||
$(this).addClass("is-selected");
|
||||
}, function(){
|
||||
$(this).removeClass("is-selected");
|
||||
});
|
||||
}, 0);
|
||||
});
|
||||
|
||||
// Notification handling
|
||||
$.subscribe("/notifications/new", function(obj){
|
||||
for(let index = obj.items.length-1; index >= 0; index--){
|
||||
onNewTweet(obj.column, obj.items[index]);
|
||||
}
|
||||
});
|
||||
|
||||
// Setup video element replacement and fix missing target in user links
|
||||
new MutationObserver(function(){
|
||||
$("video").each(function(){
|
||||
$(this).parent().replaceWith("<a href='"+$(this).attr("src")+"' rel='url' target='_blank' style='display:block; border:1px solid #555; padding:3px 6px'>► Open video in browser</a>");
|
||||
});
|
||||
|
||||
$("a[rel='user']").attr("target", "_blank");
|
||||
}).observe($(".js-app-columns")[0], {
|
||||
childList: true,
|
||||
subtree: true
|
||||
});
|
||||
|
||||
// Finish init and load plugins
|
||||
$TD.loadFontSizeClass(TD.settings.getFontSize());
|
||||
$TD.loadNotificationHeadContents(getNotificationHeadContents());
|
||||
|
||||
window.TD_APP_READY = true;
|
||||
|
||||
if (window.TD_PLUGINS){
|
||||
window.TD_PLUGINS.onReady();
|
||||
}
|
||||
var onAppReady = [];
|
||||
|
||||
//
|
||||
// Variable: DOM object containing the main app element.
|
||||
//
|
||||
var app = $(document.body).children(".js-app");
|
||||
|
||||
//
|
||||
// Constant: Column types mapped to their titles.
|
||||
//
|
||||
const columnTypes = {
|
||||
"col_home": "Home",
|
||||
"col_timeline" : "Home",
|
||||
"col_mentions": "Mentions",
|
||||
"col_me": "Mentions",
|
||||
"col_inbox": "Messages",
|
||||
"col_messages": "Messages",
|
||||
"col_interactions": "Notifications",
|
||||
"col_followers": "Followers",
|
||||
"col_activity": "Activity",
|
||||
"col_favorites": "Likes",
|
||||
"col_usertweets": "User",
|
||||
"col_search": "Search",
|
||||
"col_list": "List",
|
||||
"col_customtimeline": "Timeline",
|
||||
"col_dataminr": "Dataminr",
|
||||
"col_livevideo": "Live video",
|
||||
"col_scheduled": "Scheduled"
|
||||
};
|
||||
|
||||
//
|
||||
@@ -96,12 +62,27 @@
|
||||
};
|
||||
};
|
||||
|
||||
//
|
||||
// Function: Retrieves a property of an element with a specified class.
|
||||
//
|
||||
var getClassStyleProperty = function(cls, property){
|
||||
let column = document.createElement("div");
|
||||
column.classList.add(cls);
|
||||
column.style.display = "none";
|
||||
|
||||
document.body.appendChild(column);
|
||||
let value = window.getComputedStyle(column).getPropertyValue(property);
|
||||
document.body.removeChild(column);
|
||||
|
||||
return value;
|
||||
};
|
||||
|
||||
//
|
||||
// Function: Event callback for a new tweet.
|
||||
//
|
||||
var onNewTweet = function(column, tweet){
|
||||
if (column.model.getHasNotification()){
|
||||
var html = $(tweet.render({
|
||||
let html = $(tweet.render({
|
||||
withFooter: false,
|
||||
withTweetActions: false,
|
||||
withMediaPreview: true,
|
||||
@@ -112,10 +93,11 @@
|
||||
|
||||
html.css("border", "0");
|
||||
html.find("footer").last().remove(); // apparently withTweetActions breaks for certain tweets, nice
|
||||
html.find(".js-media").last().remove(); // and quoted tweets still show media previews, nice nice
|
||||
html.find(".js-quote-detail").removeClass("is-actionable");
|
||||
|
||||
var url = html.find("time").first().children("a").first().attr("href") || "";
|
||||
|
||||
$TD.onTweetPopup(html.html(), url, tweet.text.length); // TODO column
|
||||
let url = html.find("time").first().children("a").first().attr("href") || "";
|
||||
$TD.onTweetPopup(columnTypes[column.getColumnType()] || "", html.html(), url, tweet.text.length);
|
||||
}
|
||||
|
||||
if (column.model.getHasSound()){
|
||||
@@ -127,32 +109,21 @@
|
||||
// Function: Retrieves the tags to be put into <head> for notification HTML code.
|
||||
//
|
||||
var getNotificationHeadContents = function(){
|
||||
var tags = [];
|
||||
let tags = [];
|
||||
|
||||
$(document.head).children("link[rel='stylesheet'],meta[charset],meta[http-equiv]").each(function(){
|
||||
$(document.head).children("link[rel='stylesheet']:not([title]),link[title='"+TD.settings.getTheme()+"'],meta[charset],meta[http-equiv]").each(function(){
|
||||
tags.push($(this)[0].outerHTML);
|
||||
});
|
||||
|
||||
tags.push("<style type='text/css'>");
|
||||
tags.push("body { background-color: "+getClassStyleProperty("column", "background-color")+" }");
|
||||
tags.push("a[data-full-url] { word-break: break-all }");
|
||||
tags.push(".txt-base-smallest .badge-verified:before { height: 13px !important }");
|
||||
tags.push("</style>");
|
||||
|
||||
return tags.join("");
|
||||
};
|
||||
|
||||
//
|
||||
// Block: Observe the app <div> element and initialize TweetD*ck whenever possible.
|
||||
//
|
||||
var app = $("body").children(".js-app");
|
||||
|
||||
new MutationObserver(function(){
|
||||
if (window.TD_APP_READY && app.hasClass("is-hidden")){
|
||||
window.TD_APP_READY = false;
|
||||
}
|
||||
else if (!window.TD_APP_READY && !app.hasClass("is-hidden")){
|
||||
initializeTweetDck();
|
||||
}
|
||||
}).observe(app[0], {
|
||||
attributes: true,
|
||||
attributeFilter: [ "class" ]
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Hook into settings object to detect when the settings change.
|
||||
//
|
||||
@@ -167,7 +138,7 @@
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Force popup notification settings.
|
||||
// Block: Enable popup notifications.
|
||||
//
|
||||
TD.controller.notifications.hasNotifications = function(){
|
||||
return true;
|
||||
@@ -177,6 +148,38 @@
|
||||
return true;
|
||||
};
|
||||
|
||||
$.subscribe("/notifications/new", function(obj){
|
||||
for(let index = obj.items.length-1; index >= 0; index--){
|
||||
onNewTweet(obj.column, obj.items[index]);
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Add TweetDuck buttons to the settings menu.
|
||||
//
|
||||
onAppReady.push(function(){
|
||||
$("[data-action='settings-menu']").click(function(){
|
||||
setTimeout(function(){
|
||||
var menu = $(".js-dropdown-content").children("ul").first();
|
||||
if (menu.length === 0)return;
|
||||
|
||||
menu.children(".drp-h-divider").last().before('<li class="is-selectable" data-std><a href="#" data-action="tweetduck">TweetDuck</a></li>');
|
||||
|
||||
var button = menu.children("[data-std]");
|
||||
|
||||
button.on("click", "a", function(){
|
||||
$TD.openContextMenu();
|
||||
});
|
||||
|
||||
button.hover(function(){
|
||||
$(this).addClass("is-selected");
|
||||
}, function(){
|
||||
$(this).removeClass("is-selected");
|
||||
});
|
||||
}, 0);
|
||||
});
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Expand shortened links on hover or display tooltip.
|
||||
//
|
||||
@@ -198,7 +201,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if ($TD.expandLinksOnHover){
|
||||
if ($TDX.expandLinksOnHover){
|
||||
tooltipTimer = window.setTimeout(function(){
|
||||
var expanded = me.attr("data-full-url");
|
||||
expanded = cutStart(expanded, "https://");
|
||||
@@ -217,7 +220,7 @@
|
||||
}
|
||||
}
|
||||
else if (e.type === "mouseleave"){
|
||||
if ($TD.expandLinksOnHover){
|
||||
if ($TDX.expandLinksOnHover){
|
||||
var prevText = me.attr("td-prev-text");
|
||||
|
||||
if (prevText){
|
||||
@@ -256,47 +259,67 @@
|
||||
var soundEle = document.getElementById("update-sound");
|
||||
|
||||
soundEle.play = prependToFunction(soundEle.play, function(){
|
||||
return $TD.muteNotifications || $TD.hasCustomNotificationSound;
|
||||
return $TDX.muteNotifications || $TDX.hasCustomNotificationSound;
|
||||
});
|
||||
})();
|
||||
|
||||
//
|
||||
// Block: Update highlighted column.
|
||||
//
|
||||
app.delegate("section", "mouseenter mouseleave", function(e){
|
||||
if (e.type === "mouseenter"){
|
||||
highlightedColumnEle = $(this);
|
||||
}
|
||||
else if (e.type === "mouseleave"){
|
||||
highlightedColumnEle = null;
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Copy tweet address and update highlighted tweet.
|
||||
// Block: Update highlighted column and tweet for context menu and other functionality.
|
||||
//
|
||||
(function(){
|
||||
var lastTweet = "";
|
||||
|
||||
var updateHighlightedTweet = function(link, embeddedLink){
|
||||
var updateHighlightedColumn = function(ele){
|
||||
highlightedColumnEle = ele;
|
||||
highlightedColumnObj = ele ? TD.controller.columnManager.get(ele.attr("data-column")) : null;
|
||||
return !!highlightedColumnObj;
|
||||
};
|
||||
|
||||
var updateHighlightedTweet = function(ele, obj, link, embeddedLink){
|
||||
highlightedTweetEle = ele;
|
||||
highlightedTweetObj = obj;
|
||||
|
||||
if (lastTweet !== link){
|
||||
$TD.setLastHighlightedTweet(link, embeddedLink);
|
||||
lastTweet = link;
|
||||
}
|
||||
};
|
||||
|
||||
app.delegate("article.js-stream-item", "mouseenter mouseleave", function(e){
|
||||
app.delegate("section.js-column", "mouseenter mouseleave", function(e){
|
||||
if (e.type === "mouseenter"){
|
||||
highlightedTweetEle = $(this);
|
||||
|
||||
var link = $(this).parent().hasClass("js-tweet-detail") ? $(this).find("a[rel='url']").first() : $(this).find("time").first().children("a").first();
|
||||
var embedded = $(this).find(".quoted-tweet[data-tweet-id]").first();
|
||||
|
||||
updateHighlightedTweet(link.length > 0 ? link.attr("href") : "", embedded.length > 0 ? embedded.find(".account-link").first().attr("href")+"/status/"+embedded.attr("data-tweet-id") : "");
|
||||
if (!highlightedColumnObj){
|
||||
updateHighlightedColumn($(this));
|
||||
}
|
||||
}
|
||||
else if (e.type === "mouseleave"){
|
||||
highlightedTweetEle = null;
|
||||
updateHighlightedTweet("", "");
|
||||
updateHighlightedColumn(null);
|
||||
}
|
||||
});
|
||||
|
||||
app.delegate("article.js-stream-item", "mouseenter mouseleave", function(e){
|
||||
if (e.type === "mouseenter"){
|
||||
var me = $(this);
|
||||
|
||||
if (!me[0].hasAttribute("data-account-key") || (!highlightedColumnObj && !updateHighlightedColumn(me.closest("section.js-column")))){
|
||||
return;
|
||||
}
|
||||
|
||||
var tweet = highlightedColumnObj.findChirp(me.attr("data-tweet-id")) || highlightedColumnObj.findChirp(me.attr("data-key"));
|
||||
|
||||
if (tweet){
|
||||
if (tweet.chirpType === TD.services.ChirpBase.TWEET){
|
||||
var link = tweet.getChirpURL();
|
||||
var embedded = tweet.quotedTweet ? tweet.quotedTweet.getChirpURL() : "";
|
||||
|
||||
updateHighlightedTweet(me, tweet, link || "", embedded || "");
|
||||
}
|
||||
else{
|
||||
updateHighlightedTweet(me, tweet, "", "");
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (e.type === "mouseleave"){
|
||||
updateHighlightedTweet(null, null, "", "");
|
||||
}
|
||||
});
|
||||
})();
|
||||
@@ -326,27 +349,36 @@
|
||||
var isReply = !isDetail && (parent.hasClass("js-replies-to") || parent.hasClass("js-replies-before"));
|
||||
|
||||
selectedTweet = selectedTweet.clone();
|
||||
selectedTweet.children().first().addClass($(document.documentElement).attr("class")).css("padding-bottom", "12px");
|
||||
selectedTweet.children().first().addClass($(document.documentElement).attr("class")).css("padding-bottom", "0");
|
||||
|
||||
setImportantProperty(selectedTweet.find(".js-quote-detail"), "margin-bottom", "0");
|
||||
setImportantProperty(selectedTweet.find(".js-media-preview-container"), "margin-bottom", "0");
|
||||
setImportantProperty(selectedTweet.find(".js-tweet-text"), "margin-bottom", "8px");
|
||||
setImportantProperty(selectedTweet.find(".js-quote-detail"), "margin-bottom", "10px");
|
||||
setImportantProperty(selectedTweet.find(".js-poll-link").next(), "margin-bottom", "8px");
|
||||
|
||||
if (isDetail){
|
||||
setImportantProperty(selectedTweet.find(".js-tweet-media"), "margin-bottom", "0");
|
||||
if (selectedTweet.find("[class*='media-grid-']").length > 0){
|
||||
setImportantProperty(selectedTweet.find(".js-tweet-media"), "margin-bottom", "10px");
|
||||
}
|
||||
else{
|
||||
setImportantProperty(selectedTweet.find(".js-tweet-media"), "margin-bottom", "6px");
|
||||
}
|
||||
|
||||
setImportantProperty(selectedTweet.find(".js-media-preview-container"), "margin-bottom", "4px");
|
||||
selectedTweet.find(".js-translate-call-to-action").first().remove();
|
||||
selectedTweet.find(".js-cards-container").first().nextAll().remove();
|
||||
selectedTweet.find(".js-detail-view-inline").first().remove();
|
||||
selectedTweet.find(".js-tweet").first().nextAll().remove();
|
||||
selectedTweet.find("footer").last().prevUntil(":not(.txt-mute.txt-small)").addBack().remove(); // footer, date, location
|
||||
}
|
||||
else{
|
||||
setImportantProperty(selectedTweet.find(".js-media-preview-container"), "margin-bottom", "10px");
|
||||
selectedTweet.find("footer").last().remove();
|
||||
}
|
||||
|
||||
if (isReply){
|
||||
selectedTweet.find(".is-conversation").removeClass("is-conversation");
|
||||
selectedTweet.find(".timeline-poll-container").first().remove(); // fix for timeline polls plugin
|
||||
}
|
||||
|
||||
selectedTweet.find(".js-poll-link").remove();
|
||||
selectedTweet.find(".td-screenshot-remove").remove();
|
||||
|
||||
var testTweet = selectedTweet.clone().css({
|
||||
position: "absolute",
|
||||
@@ -374,6 +406,11 @@
|
||||
};
|
||||
|
||||
var clickUpload = function(){
|
||||
$(document).one("uiFilesAdded", function(){
|
||||
getScroller().scrollTop(prevScrollTop);
|
||||
$(".js-drawer").find(".js-compose-text").first()[0].focus();
|
||||
});
|
||||
|
||||
var button = $(".js-add-image-button").first();
|
||||
|
||||
var scroller = getScroller();
|
||||
@@ -386,7 +423,7 @@
|
||||
$TD.clickUploadImage(Math.floor(buttonPos.left), Math.floor(buttonPos.top));
|
||||
};
|
||||
|
||||
$(".js-app").delegate(".js-compose-text,.js-reply-tweetbox", "paste", function(){
|
||||
app.delegate(".js-compose-text,.js-reply-tweetbox", "paste", function(){
|
||||
lastPasteElement = $(this);
|
||||
$TD.tryPasteImage();
|
||||
});
|
||||
@@ -425,13 +462,6 @@
|
||||
lastPasteElement = null;
|
||||
}
|
||||
};
|
||||
|
||||
window.TDGF_tryPasteImageFinish = function(){
|
||||
setTimeout(function(){
|
||||
getScroller().scrollTop(prevScrollTop);
|
||||
$(".js-drawer").find(".js-compose-text").first()[0].focus();
|
||||
}, 10);
|
||||
};
|
||||
})();
|
||||
|
||||
//
|
||||
@@ -524,6 +554,32 @@
|
||||
});
|
||||
})();
|
||||
|
||||
//
|
||||
// Block: Swap shift key functionality for selecting accounts.
|
||||
//
|
||||
onAppReady.push(function(){
|
||||
$(".js-drawer[data-drawer='compose']").delegate(".js-account-list > .js-account-item", "click", function(e){
|
||||
e.shiftKey = !e.shiftKey;
|
||||
});
|
||||
|
||||
TD.components.AccountSelector.prototype.refreshPostingAccounts = appendToFunction(TD.components.AccountSelector.prototype.refreshPostingAccounts, function(){
|
||||
if (!this.$node.attr("td-account-selector-hook")){
|
||||
this.$node.attr("td-account-selector-hook", "1");
|
||||
|
||||
this.$node.delegate(".js-account-item", "click", function(e){
|
||||
e.shiftKey = !e.shiftKey;
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Work around clipboard HTML formatting.
|
||||
//
|
||||
$(document).on("copy", function(e){
|
||||
window.setTimeout($TD.fixClipboard, 0);
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Inject custom CSS and layout into the page.
|
||||
//
|
||||
@@ -536,12 +592,100 @@
|
||||
styleOfficial.sheet.insertRule(".txt-base-smallest .badge-verified:before { height: 13px !important; }", 0); // fix cut off badge icon
|
||||
styleOfficial.sheet.insertRule(".keyboard-shortcut-list { vertical-align: top; }", 0); // fix keyboard navigation alignment
|
||||
|
||||
if ($TD.hasCustomBrowserCSS){
|
||||
var styleCustom = document.createElement("style");
|
||||
styleCustom.innerHTML = $TD.customBrowserCSS;
|
||||
document.head.appendChild(styleCustom);
|
||||
}
|
||||
styleOfficial.sheet.insertRule(".is-video a:not([href*='youtu']), .is-gif .js-media-gif-container { cursor: alias; }", 0); // change cursor on unsupported videos
|
||||
styleOfficial.sheet.insertRule(".is-video a:not([href*='youtu']) .icon-bg-dot, .is-gif .icon-bg-dot { color: #bd3d37; }", 0); // change play icon color on unsupported videos
|
||||
|
||||
TD.services.TwitterActionRetweetedRetweet.prototype.iconClass = "icon-retweet icon-retweet-color txt-base-medium"; // fix retweet icon mismatch
|
||||
|
||||
window.TDGF_reinjectCustomCSS = function(styles){
|
||||
$("#tweetduck-custom-css").remove();
|
||||
|
||||
if (styles && styles.length){
|
||||
$(document.head).append("<style type='text/css' id='tweetduck-custom-css'>"+styles+"</style>");
|
||||
}
|
||||
};
|
||||
})();
|
||||
})($, $TD, TD);
|
||||
|
||||
//
|
||||
// Block: Setup unsupported video element hook.
|
||||
//
|
||||
(function(){
|
||||
var cancelModal = false;
|
||||
|
||||
TD.components.MediaGallery.prototype._loadTweet = appendToFunction(TD.components.MediaGallery.prototype._loadTweet, function(){
|
||||
var media = this.chirp.getMedia().find(media => media.mediaId === this.clickedMediaEntityId);
|
||||
|
||||
if (media && media.isVideo && media.service !== "youtube"){
|
||||
$TD.openBrowser(this.clickedLink);
|
||||
cancelModal = true;
|
||||
}
|
||||
});
|
||||
|
||||
TD.components.BaseModal.prototype.setAndShowContainer = prependToFunction(TD.components.BaseModal.prototype.setAndShowContainer, function(){
|
||||
if (cancelModal){
|
||||
cancelModal = false;
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
TD.ui.Column.prototype.playGifIfNotManuallyPaused = function(){};
|
||||
TD.mustaches["status/media_thumb.mustache"] = TD.mustaches["status/media_thumb.mustache"].replace("is-gif", "is-gif is-paused");
|
||||
|
||||
app.delegate(".js-gif-play", "click", function(e){
|
||||
var parent = $(e.target).closest(".js-tweet").first();
|
||||
var link = (parent.hasClass("tweet-detail") ? parent.find("a[rel='url']") : parent.find("time").first().children("a")).first();
|
||||
|
||||
$TD.openBrowser(link.attr("href"));
|
||||
e.stopPropagation();
|
||||
});
|
||||
})();
|
||||
|
||||
//
|
||||
// Block: Fix youtu.be previews not showing up for https links.
|
||||
//
|
||||
TD.services.TwitterMedia.YOUTUBE_TINY_RE = new RegExp(TD.services.TwitterMedia.YOUTUBE_TINY_RE.source.replace("http:", "https?:"));
|
||||
TD.services.TwitterMedia.YOUTUBE_RE = new RegExp(TD.services.TwitterMedia.YOUTUBE_LONG_RE.source+"|"+TD.services.TwitterMedia.YOUTUBE_TINY_RE.source);
|
||||
TD.services.TwitterMedia.SERVICES["youtube"] = TD.services.TwitterMedia.YOUTUBE_RE;
|
||||
|
||||
//
|
||||
// Block: Fix DM reply input box not getting focused after opening a conversation.
|
||||
//
|
||||
TD.components.ConversationDetailView.prototype.showChirp = appendToFunction(TD.components.ConversationDetailView.prototype.showChirp, function(){
|
||||
setTimeout(function(){
|
||||
$(".js-reply-tweetbox").first().focus();
|
||||
}, 100);
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Disable TweetDeck metrics.
|
||||
//
|
||||
TD.metrics.inflate = function(){};
|
||||
TD.metrics.inflateMetricTriple = function(){};
|
||||
TD.metrics.log = function(){};
|
||||
TD.metrics.makeKey = function(){};
|
||||
TD.metrics.send = function(){};
|
||||
|
||||
onAppReady.push(function(){
|
||||
let data = $._data(window);
|
||||
delete data.events["metric"];
|
||||
delete data.events["metricsFlush"];
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Register the TD.ready event, finish initialization, and load plugins.
|
||||
//
|
||||
$(document).one("TD.ready", function(){
|
||||
onAppReady.forEach(func => func());
|
||||
|
||||
$TD.loadFontSizeClass(TD.settings.getFontSize());
|
||||
$TD.loadNotificationHeadContents(getNotificationHeadContents());
|
||||
|
||||
if (window.TD_PLUGINS){
|
||||
window.TD_PLUGINS.onReady();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on("uiLoginFormImpression", function(){
|
||||
location.href = $("a.btn", ".js-login-form").first().attr("href");
|
||||
});
|
||||
})($, $TD, $TDX, TD);
|
||||
|
@@ -1,19 +0,0 @@
|
||||
(function($, $TD, TD){
|
||||
$(document).keydown(function(e){
|
||||
|
||||
// ==============================
|
||||
// F4 key - simulate notification
|
||||
// ==============================
|
||||
|
||||
if (e.keyCode === 115){
|
||||
var col = TD.controller.columnManager.getAllOrdered()[0];
|
||||
|
||||
$.publish("/notifications/new",[{
|
||||
column: col,
|
||||
items: [
|
||||
col.updateArray[Math.floor(Math.random()*col.updateArray.length)]
|
||||
]
|
||||
}]);
|
||||
}
|
||||
});
|
||||
})($, $TD, TD);
|
@@ -1,4 +1,4 @@
|
||||
(function($TD){
|
||||
(function($TD, $TDX){
|
||||
//
|
||||
// Variable: Collection of all <a> tags.
|
||||
//
|
||||
@@ -51,7 +51,7 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if ($TD.expandLinksOnHover){
|
||||
if ($TDX.expandLinksOnHover){
|
||||
tooltipTimer = window.setTimeout(function(){
|
||||
var expanded = url;
|
||||
expanded = cutStart(expanded, "https://");
|
||||
@@ -73,7 +73,7 @@
|
||||
addEventListener(links, "mouseleave", function(e){
|
||||
if (!e.currentTarget.hasAttribute("data-full-url"))return;
|
||||
|
||||
if ($TD.expandLinksOnHover){
|
||||
if ($TDX.expandLinksOnHover){
|
||||
var prevText = e.currentTarget.getAttribute("td-prev-text");
|
||||
|
||||
if (prevText){
|
||||
@@ -146,9 +146,4 @@
|
||||
document.body.addEventListener("mouseleave", function(){
|
||||
document.body.classList.remove("td-hover");
|
||||
});
|
||||
|
||||
//
|
||||
// Block: Page fully loaded.
|
||||
//
|
||||
$TD.onNotificationReady();
|
||||
})($TD);
|
||||
})($TD, $TDX);
|
||||
|
49
Resources/Scripts/pages/error.html
Normal file
49
Resources/Scripts/pages/error.html
Normal file
@@ -0,0 +1,49 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<style type="text/css">
|
||||
body {
|
||||
color: #e1e8ed;
|
||||
background-color: #1c6399;
|
||||
font-family: Helvetica, Arial, Verdana, sans-serif;
|
||||
font-weight: 300;
|
||||
font-size: 24px;
|
||||
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
position: absolute;
|
||||
display: table;
|
||||
}
|
||||
|
||||
center {
|
||||
display: table-cell;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 20px 0 24px;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 100px;
|
||||
height: 35px;
|
||||
border: 0;
|
||||
margin: 0 2px;
|
||||
font-size: 17px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<center>
|
||||
<h1>Connection Error</h1>
|
||||
<p>{err}</p>
|
||||
<button onclick="location.href = 'https://tweetdeck.twitter.com'; [].forEach.call(document.getElementsByTagName('button'), e => e.style.visibility = 'hidden')">Retry</button>
|
||||
<button onclick="window.close()">Exit</button>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
25
Resources/Scripts/pages/example.html
Normal file
25
Resources/Scripts/pages/example.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<article>
|
||||
<div class="js-stream-item-content item-box js-show-detail">
|
||||
<div class="js-tweet tweet">
|
||||
<header class="tweet-header">
|
||||
<time class="tweet-timestamp js-timestamp pull-right txt-mute">
|
||||
<a target="_blank" rel="url" href="https://twitter.com/chylexmc" class="txt-small">0s</a>
|
||||
</time>
|
||||
<a target="_blank" rel="user" href="https://twitter.com/chylexmc" class="account-link link-complex block">
|
||||
<div class="obj-left item-img tweet-img">
|
||||
<img width="48" height="48" alt="chylexmc's avatar" src="https://pbs.twimg.com/profile_images/765161905312980992/AhDP9iY-_normal.jpg" class="tweet-avatar avatar pull-right">
|
||||
</div>
|
||||
<div class="nbfc">
|
||||
<span class="account-inline txt-ellipsis">
|
||||
<b class="fullname link-complex-target">chylex</b>
|
||||
<span class="username txt-mute">@chylexmc</span>
|
||||
</span>
|
||||
</div>
|
||||
</a>
|
||||
</header>
|
||||
<div class="tweet-body">
|
||||
<p class="js-tweet-text tweet-text with-linebreaks">This is an example tweet, which lets you test the location and duration of popup notifications.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
@@ -40,7 +40,7 @@
|
||||
}
|
||||
|
||||
runWhenReady(plugin){
|
||||
if (window.TD_APP_READY){
|
||||
if (TD.ready){
|
||||
plugin.obj.ready();
|
||||
}
|
||||
else{
|
||||
@@ -49,19 +49,26 @@
|
||||
}
|
||||
|
||||
setState(plugin, enable){
|
||||
let reloading = plugin.obj.$pluginSettings.requiresPageReload;
|
||||
|
||||
if (enable && this.isDisabled(plugin)){
|
||||
this.disabled.splice(this.disabled.indexOf(plugin.id), 1);
|
||||
plugin.obj.enabled();
|
||||
this.runWhenReady(plugin);
|
||||
if (reloading){
|
||||
location.reload();
|
||||
}
|
||||
else{
|
||||
this.disabled.splice(this.disabled.indexOf(plugin.id), 1);
|
||||
plugin.obj.enabled();
|
||||
this.runWhenReady(plugin);
|
||||
}
|
||||
}
|
||||
else if (!enable && !this.isDisabled(plugin)){
|
||||
this.disabled.push(plugin.id);
|
||||
plugin.obj.disabled();
|
||||
}
|
||||
else return;
|
||||
|
||||
if (plugin.obj.$pluginSettings.requiresPageReload){
|
||||
window.location.reload();
|
||||
if (reloading){
|
||||
location.reload();
|
||||
}
|
||||
else{
|
||||
this.disabled.push(plugin.id);
|
||||
plugin.obj.disabled();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user