mirror of
https://github.com/chylex/TweetDuck.git
synced 2025-06-07 20:34:08 +02:00
Fix missing spaces in C#/F# code
This commit is contained in:
parent
bd0be65038
commit
19f104239a
Core
Bridge
Controls
FormBrowser.csHandling
Management
Notification
Example
FormNotificationBase.csFormNotificationMain.csFormNotificationTweet.csScreenshot
SoundNotification.csOther
Utils
Plugins
Program.csReporter.csResources
Updates
lib
TweetLib.Communication
TweetLib.Core
Collections
Data
Serialization
Utils
TweetTest.System/Data
TweetTest.Unit/Core
video
@ -9,7 +9,7 @@ public enum Environment{
|
|||||||
|
|
||||||
public static string GenerateScript(Environment environment){
|
public static string GenerateScript(Environment environment){
|
||||||
static string Bool(bool value) => value ? "true;" : "false;";
|
static string Bool(bool value) => value ? "true;" : "false;";
|
||||||
static string Str(string value) => '"'+value+"\";";
|
static string Str(string value) => $"\"{value}\";";
|
||||||
|
|
||||||
UserConfig config = Program.Config.User;
|
UserConfig config = Program.Config.User;
|
||||||
StringBuilder build = new StringBuilder(128).Append("(function(x){");
|
StringBuilder build = new StringBuilder(128).Append("(function(x){");
|
||||||
|
@ -30,17 +30,17 @@ public static bool IsFullyOutsideView(this Form form){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void MoveToCenter(this Form targetForm, Form parentForm){
|
public static void MoveToCenter(this Form targetForm, Form parentForm){
|
||||||
targetForm.Location = new Point(parentForm.Location.X+parentForm.Width/2-targetForm.Width/2, parentForm.Location.Y+parentForm.Height/2-targetForm.Height/2);
|
targetForm.Location = new Point(parentForm.Location.X + (parentForm.Width / 2) - (targetForm.Width / 2), parentForm.Location.Y + (parentForm.Height / 2) - (targetForm.Height / 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetValueInstant(this ProgressBar bar, int value){
|
public static void SetValueInstant(this ProgressBar bar, int value){
|
||||||
if (value == bar.Maximum){
|
if (value == bar.Maximum){
|
||||||
bar.Value = value;
|
bar.Value = value;
|
||||||
bar.Value = value-1;
|
bar.Value = value - 1;
|
||||||
bar.Value = value;
|
bar.Value = value;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
bar.Value = value+1;
|
bar.Value = value + 1;
|
||||||
bar.Value = value;
|
bar.Value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -59,7 +59,7 @@ public static void SetValueSafe(this TrackBar trackBar, int value){
|
|||||||
|
|
||||||
public static bool AlignValueToTick(this TrackBar trackBar){
|
public static bool AlignValueToTick(this TrackBar trackBar){
|
||||||
if (trackBar.Value % trackBar.SmallChange != 0){
|
if (trackBar.Value % trackBar.SmallChange != 0){
|
||||||
trackBar.Value = trackBar.SmallChange*(int)Math.Floor(((double)trackBar.Value/trackBar.SmallChange)+0.5);
|
trackBar.Value = trackBar.SmallChange * (int)Math.Floor(((double)trackBar.Value / trackBar.SmallChange) + 0.5);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ protected override void OnPaint(PaintEventArgs e){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Rectangle rect = e.ClipRectangle;
|
Rectangle rect = e.ClipRectangle;
|
||||||
rect.Width = (int)(rect.Width*((double)Value/Maximum));
|
rect.Width = (int)(rect.Width * ((double)Value / Maximum));
|
||||||
e.Graphics.FillRectangle(brush, rect);
|
e.Graphics.FillRectangle(brush, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,12 +7,12 @@ sealed class LabelVertical : Label{
|
|||||||
public int LineHeight { get; set; }
|
public int LineHeight { get; set; }
|
||||||
|
|
||||||
protected override void OnPaint(PaintEventArgs e){
|
protected override void OnPaint(PaintEventArgs e){
|
||||||
int y = (int)Math.Floor((ClientRectangle.Height-Text.Length*LineHeight)/2F)-1;
|
int y = (int)Math.Floor((ClientRectangle.Height - Text.Length * LineHeight) / 2F) - 1;
|
||||||
using Brush brush = new SolidBrush(ForeColor);
|
using Brush brush = new SolidBrush(ForeColor);
|
||||||
|
|
||||||
foreach(char chr in Text){
|
foreach(char chr in Text){
|
||||||
string str = chr.ToString();
|
string str = chr.ToString();
|
||||||
float x = (ClientRectangle.Width-e.Graphics.MeasureString(str, Font).Width)/2F;
|
float x = (ClientRectangle.Width - e.Graphics.MeasureString(str, Font).Width) / 2F;
|
||||||
|
|
||||||
e.Graphics.DrawString(str, Font, brush, x, y);
|
e.Graphics.DrawString(str, Font, brush, x, y);
|
||||||
y += LineHeight;
|
y += LineHeight;
|
||||||
|
@ -289,7 +289,7 @@ void OnFinished(){
|
|||||||
UpdateInstallerPath = update.InstallerPath;
|
UpdateInstallerPath = update.InstallerPath;
|
||||||
ForceClose();
|
ForceClose();
|
||||||
}
|
}
|
||||||
else if (status != UpdateDownloadStatus.Canceled && FormMessage.Error("Update Has Failed", "Could not automatically download the update: "+(update.DownloadError?.Message ?? "unknown error")+"\n\nWould you like to open the website and try downloading the update manually?", FormMessage.Yes, FormMessage.No)){
|
else if (status != UpdateDownloadStatus.Canceled && FormMessage.Error("Update Has Failed", "Could not automatically download the update: " + (update.DownloadError?.Message ?? "unknown error") + "\n\nWould you like to open the website and try downloading the update manually?", FormMessage.Yes, FormMessage.No)){
|
||||||
BrowserUtils.OpenExternalBrowser(Program.Website);
|
BrowserUtils.OpenExternalBrowser(Program.Website);
|
||||||
ForceClose();
|
ForceClose();
|
||||||
}
|
}
|
||||||
|
@ -56,9 +56,9 @@ public virtual void OnBeforeContextMenu(IWebBrowser browserControl, IBrowser bro
|
|||||||
model.AddSeparator();
|
model.AddSeparator();
|
||||||
}
|
}
|
||||||
|
|
||||||
static string TextOpen(string name) => "Open "+name+" in browser";
|
static string TextOpen(string name) => "Open " + name + " in browser";
|
||||||
static string TextCopy(string name) => "Copy "+name+" address";
|
static string TextCopy(string name) => "Copy " + name + " address";
|
||||||
static string TextSave(string name) => "Save "+name+" as...";
|
static string TextSave(string name) => "Save " + name + " as...";
|
||||||
|
|
||||||
if (Context.Types.HasFlag(ContextInfo.ContextType.Link) && !Context.UnsafeLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal)){
|
if (Context.Types.HasFlag(ContextInfo.ContextType.Link) && !Context.UnsafeLinkUrl.EndsWith("tweetdeck.twitter.com/#", StringComparison.Ordinal)){
|
||||||
if (TwitterUrls.RegexAccount.IsMatch(Context.UnsafeLinkUrl)){
|
if (TwitterUrls.RegexAccount.IsMatch(Context.UnsafeLinkUrl)){
|
||||||
@ -206,7 +206,7 @@ protected static void SetClipboardText(Control control, string text){
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static void InsertSelectionSearchItem(IMenuModel model, CefMenuCommand insertCommand, string insertLabel){
|
protected static void InsertSelectionSearchItem(IMenuModel model, CefMenuCommand insertCommand, string insertLabel){
|
||||||
model.InsertItemAt(model.GetIndexOf(MenuSearchInBrowser)+1, insertCommand, insertLabel);
|
model.InsertItemAt(model.GetIndexOf(MenuSearchInBrowser) + 1, insertCommand, insertLabel);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void AddDebugMenuItems(IMenuModel model){
|
protected static void AddDebugMenuItems(IMenuModel model){
|
||||||
@ -217,13 +217,13 @@ protected static void AddDebugMenuItems(IMenuModel model){
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected static void RemoveSeparatorIfLast(IMenuModel model){
|
protected static void RemoveSeparatorIfLast(IMenuModel model){
|
||||||
if (model.Count > 0 && model.GetTypeAt(model.Count-1) == MenuItemType.Separator){
|
if (model.Count > 0 && model.GetTypeAt(model.Count - 1) == MenuItemType.Separator){
|
||||||
model.RemoveAt(model.Count-1);
|
model.RemoveAt(model.Count - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static void AddSeparator(IMenuModel model){
|
protected static void AddSeparator(IMenuModel model){
|
||||||
if (model.Count > 0 && model.GetTypeAt(model.Count-1) != MenuItemType.Separator){ // do not add separators if there is nothing to separate
|
if (model.Count > 0 && model.GetTypeAt(model.Count - 1) != MenuItemType.Separator){ // do not add separators if there is nothing to separate
|
||||||
model.AddSeparator();
|
model.AddSeparator();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ sealed class ContextMenuBrowser : ContextMenuBase{
|
|||||||
private const string TitleMuteNotifications = "Mute notifications";
|
private const string TitleMuteNotifications = "Mute notifications";
|
||||||
private const string TitleSettings = "Options";
|
private const string TitleSettings = "Options";
|
||||||
private const string TitlePlugins = "Plugins";
|
private const string TitlePlugins = "Plugins";
|
||||||
private const string TitleAboutProgram = "About "+Program.BrandName;
|
private const string TitleAboutProgram = "About " + Program.BrandName;
|
||||||
|
|
||||||
private readonly FormBrowser form;
|
private readonly FormBrowser form;
|
||||||
|
|
||||||
|
@ -25,7 +25,7 @@ FilterStatus IResponseFilter.Filter(Stream dataIn, out long dataInRead, Stream d
|
|||||||
int responseLength = responseData.Length;
|
int responseLength = responseData.Length;
|
||||||
|
|
||||||
if (state == State.Reading){
|
if (state == State.Reading){
|
||||||
int bytesToRead = Math.Min(responseLength-offset, (int)Math.Min(dataIn?.Length ?? 0, int.MaxValue));
|
int bytesToRead = Math.Min(responseLength - offset, (int)Math.Min(dataIn?.Length ?? 0, int.MaxValue));
|
||||||
|
|
||||||
dataIn?.Read(responseData, offset, bytesToRead);
|
dataIn?.Read(responseData, offset, bytesToRead);
|
||||||
offset += bytesToRead;
|
offset += bytesToRead;
|
||||||
@ -42,7 +42,7 @@ FilterStatus IResponseFilter.Filter(Stream dataIn, out long dataInRead, Stream d
|
|||||||
return FilterStatus.NeedMoreData;
|
return FilterStatus.NeedMoreData;
|
||||||
}
|
}
|
||||||
else if (state == State.Writing){
|
else if (state == State.Writing){
|
||||||
int bytesToWrite = Math.Min(responseLength-offset, (int)Math.Min(dataOut.Length, int.MaxValue));
|
int bytesToWrite = Math.Min(responseLength - offset, (int)Math.Min(dataOut.Length, int.MaxValue));
|
||||||
|
|
||||||
if (bytesToWrite > 0){
|
if (bytesToWrite > 0){
|
||||||
dataOut.Write(responseData, offset, bytesToWrite);
|
dataOut.Write(responseData, offset, bytesToWrite);
|
||||||
|
@ -53,13 +53,13 @@ bool IJsDialogHandler.OnJSDialog(IWebBrowser browserControl, IBrowser browser, s
|
|||||||
input = new TextBox{
|
input = new TextBox{
|
||||||
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
|
Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom,
|
||||||
Font = SystemFonts.MessageBoxFont,
|
Font = SystemFonts.MessageBoxFont,
|
||||||
Location = new Point(BrowserUtils.Scale(22+inputPad, dpiScale), form.ActionPanelY-BrowserUtils.Scale(46, dpiScale)),
|
Location = new Point(BrowserUtils.Scale(22 + inputPad, dpiScale), form.ActionPanelY - BrowserUtils.Scale(46, dpiScale)),
|
||||||
Size = new Size(form.ClientSize.Width-BrowserUtils.Scale(44+inputPad, dpiScale), BrowserUtils.Scale(23, dpiScale))
|
Size = new Size(form.ClientSize.Width - BrowserUtils.Scale(44 + inputPad, dpiScale), BrowserUtils.Scale(23, dpiScale))
|
||||||
};
|
};
|
||||||
|
|
||||||
form.Controls.Add(input);
|
form.Controls.Add(input);
|
||||||
form.ActiveControl = input;
|
form.ActiveControl = input;
|
||||||
form.Height += input.Size.Height+input.Margin.Vertical;
|
form.Height += input.Size.Height + input.Margin.Vertical;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
callback.Continue(false);
|
callback.Continue(false);
|
||||||
|
@ -22,7 +22,7 @@ protected virtual bool HandleRawKey(IWebBrowser browserControl, IBrowser browser
|
|||||||
extraMessage = "Please download the installer, and tick 'Install dev tools' during the installation process. The installer will automatically find and update your current installation of TweetDuck.";
|
extraMessage = "Please download the installer, and tick 'Install dev tools' during the installation process. The installer will automatically find and update your current installation of TweetDuck.";
|
||||||
}
|
}
|
||||||
|
|
||||||
FormMessage.Information("Dev Tools", "You do not have dev tools installed. "+extraMessage, FormMessage.OK);
|
FormMessage.Information("Dev Tools", "You do not have dev tools installed. " + extraMessage, FormMessage.OK);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public static void RefreshTimer(){
|
|||||||
AutoClearTimer = new Timer(state => {
|
AutoClearTimer = new Timer(state => {
|
||||||
if (AutoClearTimer != null){
|
if (AutoClearTimer != null){
|
||||||
try{
|
try{
|
||||||
if (CalculateCacheSize() >= Program.Config.System.ClearCacheThreshold*1024L*1024L){
|
if (CalculateCacheSize() >= Program.Config.System.ClearCacheThreshold * 1024L * 1024L){
|
||||||
SetClearOnExit();
|
SetClearOnExit();
|
||||||
}
|
}
|
||||||
}catch(Exception){
|
}catch(Exception){
|
||||||
|
@ -49,7 +49,7 @@ public bool Export(Items items){
|
|||||||
try{
|
try{
|
||||||
stream.WriteFile(new string[]{ "plugin.data", plugin.Identifier, path.Relative }, path.Full);
|
stream.WriteFile(new string[]{ "plugin.data", plugin.Identifier, path.Relative }, path.Full);
|
||||||
}catch(ArgumentOutOfRangeException e){
|
}catch(ArgumentOutOfRangeException e){
|
||||||
FormMessage.Warning("Export Profile", "Could not include a plugin file in the export. "+e.Message, FormMessage.OK);
|
FormMessage.Warning("Export Profile", "Could not include a plugin file in the export. " + e.Message, FormMessage.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ public bool Import(Items items){
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (missingPlugins.Count > 0){
|
if (missingPlugins.Count > 0){
|
||||||
FormMessage.Information("Profile Import", "Detected missing plugins when importing plugin data:\n"+string.Join("\n", missingPlugins), FormMessage.OK);
|
FormMessage.Information("Profile Import", "Detected missing plugins when importing plugin data:\n" + string.Join("\n", missingPlugins), FormMessage.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -40,7 +40,7 @@ public void Launch(string url, string username){
|
|||||||
|
|
||||||
if ((process = Process.Start(new ProcessStartInfo{
|
if ((process = Process.Start(new ProcessStartInfo{
|
||||||
FileName = Path.Combine(Program.ProgramPath, "TweetDuck.Video.exe"),
|
FileName = Path.Combine(Program.ProgramPath, "TweetDuck.Video.exe"),
|
||||||
Arguments = $"{owner.Handle} {(int)Math.Floor(100F*owner.GetDPIScale())} {Config.VideoPlayerVolume} \"{url}\" \"{pipe.GenerateToken()}\"",
|
Arguments = $"{owner.Handle} {(int)Math.Floor(100F * owner.GetDPIScale())} {Config.VideoPlayerVolume} \"{url}\" \"{pipe.GenerateToken()}\"",
|
||||||
UseShellExecute = false,
|
UseShellExecute = false,
|
||||||
RedirectStandardOutput = true
|
RedirectStandardOutput = true
|
||||||
})) != null){
|
})) != null){
|
||||||
@ -135,7 +135,7 @@ private void owner_FormClosing(object sender, FormClosingEventArgs e){
|
|||||||
|
|
||||||
private void process_OutputDataReceived(object sender, DataReceivedEventArgs e){
|
private void process_OutputDataReceived(object sender, DataReceivedEventArgs e){
|
||||||
if (!string.IsNullOrEmpty(e.Data)){
|
if (!string.IsNullOrEmpty(e.Data)){
|
||||||
Program.Reporter.LogVerbose("[VideoPlayer] "+e.Data);
|
Program.Reporter.LogVerbose("[VideoPlayer] " + e.Data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ protected override FormBorderStyle NotificationBorderStyle{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override string BodyClasses => base.BodyClasses+" td-example";
|
protected override string BodyClasses => base.BodyClasses + " td-example";
|
||||||
|
|
||||||
public event EventHandler Ready;
|
public event EventHandler Ready;
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ protected virtual Point PrimaryLocation{
|
|||||||
Screen screen;
|
Screen screen;
|
||||||
|
|
||||||
if (Config.NotificationDisplay > 0 && Config.NotificationDisplay <= Screen.AllScreens.Length){
|
if (Config.NotificationDisplay > 0 && Config.NotificationDisplay <= Screen.AllScreens.Length){
|
||||||
screen = Screen.AllScreens[Config.NotificationDisplay-1];
|
screen = Screen.AllScreens[Config.NotificationDisplay - 1];
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
screen = Screen.FromControl(owner);
|
screen = Screen.FromControl(owner);
|
||||||
@ -46,20 +46,20 @@ protected virtual Point PrimaryLocation{
|
|||||||
|
|
||||||
switch(Config.NotificationPosition){
|
switch(Config.NotificationPosition){
|
||||||
case DesktopNotification.Position.TopLeft:
|
case DesktopNotification.Position.TopLeft:
|
||||||
return new Point(screen.WorkingArea.X+edgeDist, screen.WorkingArea.Y+edgeDist);
|
return new Point(screen.WorkingArea.X + edgeDist, screen.WorkingArea.Y + edgeDist);
|
||||||
|
|
||||||
case DesktopNotification.Position.TopRight:
|
case DesktopNotification.Position.TopRight:
|
||||||
return new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+edgeDist);
|
return new Point(screen.WorkingArea.X + screen.WorkingArea.Width - edgeDist - Width, screen.WorkingArea.Y + edgeDist);
|
||||||
|
|
||||||
case DesktopNotification.Position.BottomLeft:
|
case DesktopNotification.Position.BottomLeft:
|
||||||
return new Point(screen.WorkingArea.X+edgeDist, screen.WorkingArea.Y+screen.WorkingArea.Height-edgeDist-Height);
|
return new Point(screen.WorkingArea.X + edgeDist, screen.WorkingArea.Y + screen.WorkingArea.Height - edgeDist - Height);
|
||||||
|
|
||||||
case DesktopNotification.Position.BottomRight:
|
case DesktopNotification.Position.BottomRight:
|
||||||
return new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+screen.WorkingArea.Height-edgeDist-Height);
|
return new Point(screen.WorkingArea.X + screen.WorkingArea.Width - edgeDist - Width, screen.WorkingArea.Y + screen.WorkingArea.Height - edgeDist - Height);
|
||||||
|
|
||||||
case DesktopNotification.Position.Custom:
|
case DesktopNotification.Position.Custom:
|
||||||
if (!Config.IsCustomNotificationPositionSet){
|
if (!Config.IsCustomNotificationPositionSet){
|
||||||
Config.CustomNotificationPosition = new Point(screen.WorkingArea.X+screen.WorkingArea.Width-edgeDist-Width, screen.WorkingArea.Y+edgeDist);
|
Config.CustomNotificationPosition = new Point(screen.WorkingArea.X + screen.WorkingArea.Width - edgeDist - Width, screen.WorkingArea.Y + edgeDist);
|
||||||
Config.Save();
|
Config.Save();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ protected virtual FormBorderStyle NotificationBorderStyle{
|
|||||||
protected override bool ShowWithoutActivation => true;
|
protected override bool ShowWithoutActivation => true;
|
||||||
|
|
||||||
protected float DpiScale { get; }
|
protected float DpiScale { get; }
|
||||||
protected double SizeScale => DpiScale*Config.ZoomLevel/100.0;
|
protected double SizeScale => DpiScale * Config.ZoomLevel / 100.0;
|
||||||
|
|
||||||
protected readonly FormBrowser owner;
|
protected readonly FormBrowser owner;
|
||||||
protected readonly ChromiumWebBrowser browser;
|
protected readonly ChromiumWebBrowser browser;
|
||||||
|
@ -61,7 +61,7 @@ private int BaseClientHeight{
|
|||||||
|
|
||||||
protected virtual string BodyClasses => IsCursorOverBrowser ? "td-notification td-hover" : "td-notification";
|
protected virtual string BodyClasses => IsCursorOverBrowser ? "td-notification td-hover" : "td-notification";
|
||||||
|
|
||||||
public Size BrowserSize => Config.DisplayNotificationTimer ? new Size(ClientSize.Width, ClientSize.Height-timerBarHeight) : ClientSize;
|
public Size BrowserSize => Config.DisplayNotificationTimer ? new Size(ClientSize.Width, ClientSize.Height - timerBarHeight) : ClientSize;
|
||||||
|
|
||||||
protected FormNotificationMain(FormBrowser owner, PluginManager pluginManager, bool enableContextMenu) : base(owner, enableContextMenu){
|
protected FormNotificationMain(FormBrowser owner, PluginManager pluginManager, bool enableContextMenu) : base(owner, enableContextMenu){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@ -102,7 +102,7 @@ private IntPtr MouseHookProc(int nCode, IntPtr wParam, IntPtr lParam){
|
|||||||
int eventType = wParam.ToInt32();
|
int eventType = wParam.ToInt32();
|
||||||
|
|
||||||
if (eventType == NativeMethods.WM_MOUSEWHEEL && IsCursorOverBrowser){
|
if (eventType == NativeMethods.WM_MOUSEWHEEL && IsCursorOverBrowser){
|
||||||
browser.SendMouseWheelEvent(0, 0, 0, BrowserUtils.Scale(NativeMethods.GetMouseHookData(lParam), Config.NotificationScrollSpeed*0.01), CefEventFlags.None);
|
browser.SendMouseWheelEvent(0, 0, 0, BrowserUtils.Scale(NativeMethods.GetMouseHookData(lParam), Config.NotificationScrollSpeed * 0.01), CefEventFlags.None);
|
||||||
return NativeMethods.HOOK_HANDLED;
|
return NativeMethods.HOOK_HANDLED;
|
||||||
}
|
}
|
||||||
else if (eventType == NativeMethods.WM_XBUTTONDOWN && DesktopBounds.Contains(Cursor.Position)){
|
else if (eventType == NativeMethods.WM_XBUTTONDOWN && DesktopBounds.Contains(Cursor.Position)){
|
||||||
@ -172,8 +172,8 @@ private void timerHideProgress_Tick(object sender, EventArgs e){
|
|||||||
|
|
||||||
timeLeft -= timerProgress.Interval;
|
timeLeft -= timerProgress.Interval;
|
||||||
|
|
||||||
int value = BrowserUtils.Scale(progressBarTimer.Maximum+25, (totalTime-timeLeft)/(double)totalTime);
|
int value = BrowserUtils.Scale(progressBarTimer.Maximum + 25, (totalTime - timeLeft) / (double)totalTime);
|
||||||
progressBarTimer.SetValueInstant(Config.NotificationTimerCountDown ? progressBarTimer.Maximum-value : value);
|
progressBarTimer.SetValueInstant(Config.NotificationTimerCountDown ? progressBarTimer.Maximum - value : value);
|
||||||
|
|
||||||
if (timeLeft <= 0){
|
if (timeLeft <= 0){
|
||||||
FinishCurrentNotification();
|
FinishCurrentNotification();
|
||||||
@ -239,7 +239,7 @@ protected override void LoadTweet(DesktopNotification tweet){
|
|||||||
|
|
||||||
protected override void SetNotificationSize(int width, int height){
|
protected override void SetNotificationSize(int width, int height){
|
||||||
if (Config.DisplayNotificationTimer){
|
if (Config.DisplayNotificationTimer){
|
||||||
ClientSize = new Size(width, height+timerBarHeight);
|
ClientSize = new Size(width, height + timerBarHeight);
|
||||||
progressBarTimer.Visible = true;
|
progressBarTimer.Visible = true;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -154,7 +154,7 @@ protected override void UpdateTitle(){
|
|||||||
base.UpdateTitle();
|
base.UpdateTitle();
|
||||||
|
|
||||||
if (tweetQueue.Count > 0){
|
if (tweetQueue.Count > 0){
|
||||||
Text = Text+" ("+tweetQueue.Count+" more left)";
|
Text = Text + " (" + tweetQueue.Count + " more left)";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,9 +134,9 @@ private void StartDebugger(){
|
|||||||
private void debugger_Tick(object sender, EventArgs e){
|
private void debugger_Tick(object sender, EventArgs e){
|
||||||
if (frameCounter < 63 && screenshot.TakeScreenshot(true)){
|
if (frameCounter < 63 && screenshot.TakeScreenshot(true)){
|
||||||
try{
|
try{
|
||||||
Clipboard.GetImage()?.Save(Path.Combine(DebugScreenshotPath, "frame_"+(++frameCounter)+".png"), ImageFormat.Png);
|
Clipboard.GetImage()?.Save(Path.Combine(DebugScreenshotPath, "frame_" + (++frameCounter) + ".png"), ImageFormat.Png);
|
||||||
}catch{
|
}catch{
|
||||||
System.Diagnostics.Debug.WriteLine("Failed generating frame "+frameCounter);
|
System.Diagnostics.Debug.WriteLine("Failed generating frame " + frameCounter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
|
@ -28,12 +28,12 @@ public static IResourceHandler CreateFileHandler(string path){
|
|||||||
FormBrowser browser = FormManager.TryFind<FormBrowser>();
|
FormBrowser browser = FormManager.TryFind<FormBrowser>();
|
||||||
|
|
||||||
browser?.InvokeAsyncSafe(() => {
|
browser?.InvokeAsyncSafe(() => {
|
||||||
using(FormMessage form = new FormMessage("Sound Notification Error", "Could not find custom notification sound file:\n"+path, MessageBoxIcon.Error)){
|
using(FormMessage form = new FormMessage("Sound Notification Error", "Could not find custom notification sound file:\n" + path, MessageBoxIcon.Error)){
|
||||||
form.AddButton(FormMessage.Ignore, ControlType.Cancel | ControlType.Focused);
|
form.AddButton(FormMessage.Ignore, ControlType.Cancel | ControlType.Focused);
|
||||||
|
|
||||||
Button btnViewOptions = form.AddButton("View Options");
|
Button btnViewOptions = form.AddButton("View Options");
|
||||||
btnViewOptions.Width += 16;
|
btnViewOptions.Width += 16;
|
||||||
btnViewOptions.Location = new Point(btnViewOptions.Location.X-16, btnViewOptions.Location.Y);
|
btnViewOptions.Location = new Point(btnViewOptions.Location.X - 16, btnViewOptions.Location.Y);
|
||||||
|
|
||||||
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions){
|
if (form.ShowDialog() == DialogResult.OK && form.ClickedButton == btnViewOptions){
|
||||||
browser.OpenSettings(typeof(TabSettingsSounds));
|
browser.OpenSettings(typeof(TabSettingsSounds));
|
||||||
|
@ -90,9 +90,9 @@ private void SetLastDataCollectionTime(DateTime dt, string message = null){
|
|||||||
|
|
||||||
private void RestartTimer(){
|
private void RestartTimer(){
|
||||||
TimeSpan diff = DateTime.Now.Subtract(File.LastDataCollection);
|
TimeSpan diff = DateTime.Now.Subtract(File.LastDataCollection);
|
||||||
int minutesTillNext = (int)(CollectionInterval.TotalMinutes-Math.Floor(diff.TotalMinutes));
|
int minutesTillNext = (int)(CollectionInterval.TotalMinutes - Math.Floor(diff.TotalMinutes));
|
||||||
|
|
||||||
currentTimer.Interval = Math.Max(minutesTillNext, 2)*60000;
|
currentTimer.Interval = Math.Max(minutesTillNext, 2) * 60000;
|
||||||
currentTimer.Start();
|
currentTimer.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,7 +139,7 @@ private void SendReport(){
|
|||||||
|
|
||||||
case WebExceptionStatus.ProtocolError:
|
case WebExceptionStatus.ProtocolError:
|
||||||
HttpWebResponse response = e.Response as HttpWebResponse;
|
HttpWebResponse response = e.Response as HttpWebResponse;
|
||||||
message = "HTTP Error "+(response != null ? $"{(int)response.StatusCode} ({response.StatusDescription})" : "(unknown code)");
|
message = "HTTP Error " + (response != null ? $"{(int)response.StatusCode} ({response.StatusDescription})" : "(unknown code)");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ private void SendReport(){
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
ScheduleReportIn(TimeSpan.FromHours(4), message ?? "Error: "+(task.Exception.InnerException?.Message ?? task.Exception.Message));
|
ScheduleReportIn(TimeSpan.FromHours(4), message ?? "Error: " + (task.Exception.InnerException?.Message ?? task.Exception.Message));
|
||||||
}
|
}
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public override string ToString(){
|
|||||||
build.AppendLine();
|
build.AppendLine();
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
build.AppendLine(entry.Key+": "+entry.Value);
|
build.AppendLine(entry.Key + ": " + entry.Value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,9 +126,9 @@ public static AnalyticsReport Create(AnalyticsFile file, ExternalInfo info, Plug
|
|||||||
|
|
||||||
private static string Bool(bool value) => value ? "on" : "off";
|
private static string Bool(bool value) => value ? "on" : "off";
|
||||||
private static string Exact(int value) => value.ToString();
|
private static string Exact(int value) => value.ToString();
|
||||||
private static string RoundUp(int value, int multiple) => (multiple*(int)Math.Ceiling((double)value/multiple)).ToString();
|
private static string RoundUp(int value, int multiple) => (multiple * (int)Math.Ceiling((double)value / multiple)).ToString();
|
||||||
private static string LogRound(int value, int logBase) => (value <= 0 ? 0 : (int)Math.Pow(logBase, Math.Floor(Math.Log(value, logBase)))).ToString();
|
private static string LogRound(int value, int logBase) => (value <= 0 ? 0 : (int)Math.Pow(logBase, Math.Floor(Math.Log(value, logBase)))).ToString();
|
||||||
private static string Plugin(Plugin plugin) => plugin.Group.GetIdentifierPrefixShort()+plugin.Identifier.Substring(plugin.Group.GetIdentifierPrefix().Length);
|
private static string Plugin(Plugin plugin) => plugin.Group.GetIdentifierPrefixShort() + plugin.Identifier.Substring(plugin.Group.GetIdentifierPrefix().Length);
|
||||||
private static string Dict(Dictionary<string, string> dict, string key, string def = "(unknown)") => dict.TryGetValue(key, out string value) ? value : def;
|
private static string Dict(Dictionary<string, string> dict, string key, string def = "(unknown)") => dict.TryGetValue(key, out string value) ? value : def;
|
||||||
private static string List(IEnumerable<string> list) => string.Join("|", list.DefaultIfEmpty("(none)"));
|
private static string List(IEnumerable<string> list) => string.Join("|", list.DefaultIfEmpty("(none)"));
|
||||||
|
|
||||||
@ -170,7 +170,7 @@ static AnalyticsReportGenerator(){
|
|||||||
using ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Capacity FROM Win32_PhysicalMemory");
|
using ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT Capacity FROM Win32_PhysicalMemory");
|
||||||
|
|
||||||
foreach(ManagementBaseObject obj in searcher.Get()){
|
foreach(ManagementBaseObject obj in searcher.Get()){
|
||||||
RamSize += (int)((ulong)obj["Capacity"]/(1024L*1024L));
|
RamSize += (int)((ulong)obj["Capacity"] / (1024L * 1024L));
|
||||||
}
|
}
|
||||||
}catch{
|
}catch{
|
||||||
RamSize = 0;
|
RamSize = 0;
|
||||||
@ -285,7 +285,7 @@ private static string ReplyAccountConfigFromPlugin{
|
|||||||
}
|
}
|
||||||
|
|
||||||
string accType = matchType.Groups[1].Value == "#" ? matchType.Groups[2].Value : "account";
|
string accType = matchType.Groups[1].Value == "#" ? matchType.Groups[2].Value : "account";
|
||||||
return matchAdvanced.Success && !matchAdvanced.Value.Contains("false") ? "advanced/"+accType : accType;
|
return matchAdvanced.Success && !matchAdvanced.Value.Contains("false") ? "advanced/" + accType : accType;
|
||||||
}catch{
|
}catch{
|
||||||
return "(unknown)";
|
return "(unknown)";
|
||||||
}
|
}
|
||||||
@ -306,7 +306,7 @@ public static ExternalInfo From(Form form){
|
|||||||
}
|
}
|
||||||
|
|
||||||
return new ExternalInfo{
|
return new ExternalInfo{
|
||||||
Resolution = screen.Bounds.Width+"x"+screen.Bounds.Height,
|
Resolution = screen.Bounds.Width + "x" + screen.Bounds.Height,
|
||||||
DPI = dpi
|
DPI = dpi
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ sealed partial class FormAbout : Form, FormManager.IAppDialog{
|
|||||||
public FormAbout(){
|
public FormAbout(){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Text = "About "+Program.BrandName+" "+Program.VersionTag;
|
Text = "About " + Program.BrandName + " " + Program.VersionTag;
|
||||||
|
|
||||||
labelDescription.Text = "TweetDuck was created by chylex as a replacement to the discontinued official TweetDeck client for Windows.\n\nThe program is available for free under the open source MIT license.";
|
labelDescription.Text = "TweetDuck was created by chylex as a replacement to the discontinued official TweetDeck client for Windows.\n\nThe program is available for free under the open source MIT license.";
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public static bool CheckGuideUrl(string url, out string hash){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void Show(string hash = null){
|
public static void Show(string hash = null){
|
||||||
string url = GuideUrl+(hash ?? string.Empty);
|
string url = GuideUrl + (hash ?? string.Empty);
|
||||||
FormGuide guide = FormManager.TryFind<FormGuide>();
|
FormGuide guide = FormManager.TryFind<FormGuide>();
|
||||||
|
|
||||||
if (guide == null){
|
if (guide == null){
|
||||||
@ -60,8 +60,8 @@ public static void Show(string hash = null){
|
|||||||
private FormGuide(string url, FormBrowser owner){
|
private FormGuide(string url, FormBrowser owner){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Text = Program.BrandName+" Guide";
|
Text = Program.BrandName + " Guide";
|
||||||
Size = new Size(owner.Size.Width*3/4, owner.Size.Height*3/4);
|
Size = new Size(owner.Size.Width * 3 / 4, owner.Size.Height * 3 / 4);
|
||||||
VisibleChanged += (sender, args) => this.MoveToCenter(owner);
|
VisibleChanged += (sender, args) => this.MoveToCenter(owner);
|
||||||
|
|
||||||
ResourceHandlerFactory resourceHandlerFactory = new ResourceHandlerFactory();
|
ResourceHandlerFactory resourceHandlerFactory = new ResourceHandlerFactory();
|
||||||
|
@ -133,7 +133,7 @@ public Button AddButton(string title, DialogResult result = DialogResult.OK, Con
|
|||||||
Font = SystemFonts.MessageBoxFont,
|
Font = SystemFonts.MessageBoxFont,
|
||||||
Location = new Point(0, 12),
|
Location = new Point(0, 12),
|
||||||
Size = new Size(BrowserUtils.Scale(88, dpiScale), BrowserUtils.Scale(26, dpiScale)),
|
Size = new Size(BrowserUtils.Scale(88, dpiScale), BrowserUtils.Scale(26, dpiScale)),
|
||||||
TabIndex = 256-buttonCount,
|
TabIndex = 256 - buttonCount,
|
||||||
Text = title,
|
Text = title,
|
||||||
UseVisualStyleBackColor = true
|
UseVisualStyleBackColor = true
|
||||||
};
|
};
|
||||||
@ -171,17 +171,17 @@ public void AddActionControl(Control control){
|
|||||||
|
|
||||||
control.Size = new Size(BrowserUtils.Scale(control.Width, dpiScale), BrowserUtils.Scale(control.Height, dpiScale));
|
control.Size = new Size(BrowserUtils.Scale(control.Width, dpiScale), BrowserUtils.Scale(control.Height, dpiScale));
|
||||||
|
|
||||||
minFormWidth += control.Width+control.Margin.Horizontal;
|
minFormWidth += control.Width + control.Margin.Horizontal;
|
||||||
ClientWidth = Math.Max(realFormWidth, minFormWidth);
|
ClientWidth = Math.Max(realFormWidth, minFormWidth);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RecalculateButtonLocation(){
|
private void RecalculateButtonLocation(){
|
||||||
int dist = ButtonDistance;
|
int dist = ButtonDistance;
|
||||||
int start = ClientWidth-dist;
|
int start = ClientWidth - dist;
|
||||||
|
|
||||||
for(int index = 0; index < buttonCount; index++){
|
for(int index = 0; index < buttonCount; index++){
|
||||||
Control control = panelActions.Controls[index];
|
Control control = panelActions.Controls[index];
|
||||||
control.Location = new Point(start-index*dist, control.Location.Y);
|
control.Location = new Point(start - index * dist, control.Location.Y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,17 +194,17 @@ private void labelMessage_SizeChanged(object sender, EventArgs e){
|
|||||||
int labelOffset = BrowserUtils.Scale(8, dpiScale);
|
int labelOffset = BrowserUtils.Scale(8, dpiScale);
|
||||||
|
|
||||||
if (isMultiline && !wasLabelMultiline){
|
if (isMultiline && !wasLabelMultiline){
|
||||||
labelMessage.Location = new Point(labelMessage.Location.X, labelMessage.Location.Y-labelOffset);
|
labelMessage.Location = new Point(labelMessage.Location.X, labelMessage.Location.Y - labelOffset);
|
||||||
prevLabelHeight += labelOffset;
|
prevLabelHeight += labelOffset;
|
||||||
}
|
}
|
||||||
else if (!isMultiline && wasLabelMultiline){
|
else if (!isMultiline && wasLabelMultiline){
|
||||||
labelMessage.Location = new Point(labelMessage.Location.X, labelMessage.Location.Y+labelOffset);
|
labelMessage.Location = new Point(labelMessage.Location.X, labelMessage.Location.Y + labelOffset);
|
||||||
prevLabelHeight -= labelOffset;
|
prevLabelHeight -= labelOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
realFormWidth = ClientWidth-(icon == null ? BrowserUtils.Scale(50, dpiScale) : 0)+labelMessage.Width-prevLabelWidth;
|
realFormWidth = ClientWidth - (icon == null ? BrowserUtils.Scale(50, dpiScale) : 0) + labelMessage.Width - prevLabelWidth;
|
||||||
ClientWidth = Math.Max(realFormWidth, minFormWidth);
|
ClientWidth = Math.Max(realFormWidth, minFormWidth);
|
||||||
Height += labelMessage.Height-prevLabelHeight;
|
Height += labelMessage.Height - prevLabelHeight;
|
||||||
|
|
||||||
prevLabelWidth = labelMessage.Width;
|
prevLabelWidth = labelMessage.Width;
|
||||||
prevLabelHeight = labelMessage.Height;
|
prevLabelHeight = labelMessage.Height;
|
||||||
@ -213,7 +213,7 @@ private void labelMessage_SizeChanged(object sender, EventArgs e){
|
|||||||
|
|
||||||
protected override void OnPaint(PaintEventArgs e){
|
protected override void OnPaint(PaintEventArgs e){
|
||||||
if (icon != null){
|
if (icon != null){
|
||||||
e.Graphics.DrawIcon(icon, BrowserUtils.Scale(25, dpiScale), 1+BrowserUtils.Scale(25, dpiScale));
|
e.Graphics.DrawIcon(icon, BrowserUtils.Scale(25, dpiScale), 1 + BrowserUtils.Scale(25, dpiScale));
|
||||||
}
|
}
|
||||||
|
|
||||||
base.OnPaint(e);
|
base.OnPaint(e);
|
||||||
|
@ -16,7 +16,7 @@ sealed partial class FormPlugins : Form, FormManager.IAppDialog{
|
|||||||
public FormPlugins(){
|
public FormPlugins(){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Text = Program.BrandName+" Plugins";
|
Text = Program.BrandName + " Plugins";
|
||||||
}
|
}
|
||||||
|
|
||||||
public FormPlugins(PluginManager pluginManager) : this(){
|
public FormPlugins(PluginManager pluginManager) : this(){
|
||||||
@ -69,8 +69,8 @@ private void timerLayout_Tick(object sender, EventArgs e){
|
|||||||
timerLayout.Stop();
|
timerLayout.Stop();
|
||||||
|
|
||||||
// stupid WinForms scrollbars and panels
|
// stupid WinForms scrollbars and panels
|
||||||
Padding = new Padding(Padding.Left, Padding.Top, Padding.Right+1, Padding.Bottom+1);
|
Padding = new Padding(Padding.Left, Padding.Top, Padding.Right + 1, Padding.Bottom + 1);
|
||||||
Padding = new Padding(Padding.Left, Padding.Top, Padding.Right-1, Padding.Bottom-1);
|
Padding = new Padding(Padding.Left, Padding.Top, Padding.Right - 1, Padding.Bottom - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void flowLayoutPlugins_Resize(object sender, EventArgs e){
|
public void flowLayoutPlugins_Resize(object sender, EventArgs e){
|
||||||
@ -80,17 +80,17 @@ public void flowLayoutPlugins_Resize(object sender, EventArgs e){
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool showScrollBar = lastPlugin.Location.Y+lastPlugin.Height+1 >= flowLayoutPlugins.Height;
|
bool showScrollBar = lastPlugin.Location.Y + lastPlugin.Height + 1 >= flowLayoutPlugins.Height;
|
||||||
int horizontalOffset = showScrollBar ? SystemInformation.VerticalScrollBarWidth : 0;
|
int horizontalOffset = showScrollBar ? SystemInformation.VerticalScrollBarWidth : 0;
|
||||||
|
|
||||||
flowLayoutPlugins.AutoScroll = showScrollBar;
|
flowLayoutPlugins.AutoScroll = showScrollBar;
|
||||||
flowLayoutPlugins.VerticalScroll.Visible = showScrollBar;
|
flowLayoutPlugins.VerticalScroll.Visible = showScrollBar;
|
||||||
|
|
||||||
foreach(Control control in flowLayoutPlugins.Controls){
|
foreach(Control control in flowLayoutPlugins.Controls){
|
||||||
control.Width = flowLayoutPlugins.Width-control.Margin.Horizontal-horizontalOffset;
|
control.Width = flowLayoutPlugins.Width - control.Margin.Horizontal - horizontalOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
flowLayoutPlugins.Controls[flowLayoutPlugins.Controls.Count-1].Visible = !showScrollBar;
|
flowLayoutPlugins.Controls[flowLayoutPlugins.Controls.Count - 1].Visible = !showScrollBar;
|
||||||
flowLayoutPlugins.Focus();
|
flowLayoutPlugins.Focus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ sealed partial class FormSettings : Form, FormManager.IAppDialog{
|
|||||||
public FormSettings(FormBrowser browser, PluginManager plugins, UpdateHandler updates, AnalyticsManager analytics, Type startTab){
|
public FormSettings(FormBrowser browser, PluginManager plugins, UpdateHandler updates, AnalyticsManager analytics, Type startTab){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Text = Program.BrandName+" Options";
|
Text = Program.BrandName + " Options";
|
||||||
|
|
||||||
this.browser = browser;
|
this.browser = browser;
|
||||||
this.browser.PauseNotification();
|
this.browser.PauseNotification();
|
||||||
@ -110,7 +110,7 @@ private void AddButton<T>(string title, Func<T> constructor) where T : BaseTabSe
|
|||||||
BackColor = SystemColors.Control,
|
BackColor = SystemColors.Control,
|
||||||
FlatStyle = FlatStyle.Flat,
|
FlatStyle = FlatStyle.Flat,
|
||||||
Font = SystemFonts.MessageBoxFont,
|
Font = SystemFonts.MessageBoxFont,
|
||||||
Location = new Point(0, (buttonHeight+1)*(panelButtons.Controls.Count/2)),
|
Location = new Point(0, (buttonHeight + 1) * (panelButtons.Controls.Count / 2)),
|
||||||
Margin = new Padding(0),
|
Margin = new Padding(0),
|
||||||
Size = new Size(panelButtons.Width, buttonHeight),
|
Size = new Size(panelButtons.Width, buttonHeight),
|
||||||
Text = title,
|
Text = title,
|
||||||
@ -125,7 +125,7 @@ private void AddButton<T>(string title, Func<T> constructor) where T : BaseTabSe
|
|||||||
|
|
||||||
panelButtons.Controls.Add(new Panel{
|
panelButtons.Controls.Add(new Panel{
|
||||||
BackColor = Color.DimGray,
|
BackColor = Color.DimGray,
|
||||||
Location = new Point(0, panelButtons.Controls[panelButtons.Controls.Count-1].Location.Y+buttonHeight),
|
Location = new Point(0, panelButtons.Controls[panelButtons.Controls.Count - 1].Location.Y + buttonHeight),
|
||||||
Margin = new Padding(0),
|
Margin = new Padding(0),
|
||||||
Size = new Size(panelButtons.Width, 1)
|
Size = new Size(panelButtons.Width, 1)
|
||||||
});
|
});
|
||||||
@ -157,8 +157,8 @@ private void SelectTab(SettingsTab tab){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tab.Control.Height < panelContents.Height-2){
|
if (tab.Control.Height < panelContents.Height - 2){
|
||||||
tab.Control.Height = panelContents.Height-2; // fixes off-by-pixel error on high DPI
|
tab.Control.Height = panelContents.Height - 2; // fixes off-by-pixel error on high DPI
|
||||||
}
|
}
|
||||||
|
|
||||||
tab.Control.OnReady();
|
tab.Control.OnReady();
|
||||||
|
@ -8,7 +8,7 @@ sealed partial class DialogSettingsAnalytics : Form{
|
|||||||
public DialogSettingsAnalytics(AnalyticsReport report){
|
public DialogSettingsAnalytics(AnalyticsReport report){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Text = Program.BrandName+" Options - Analytics Report";
|
Text = Program.BrandName + " Options - Analytics Report";
|
||||||
|
|
||||||
textBoxReport.EnableMultilineShortcuts();
|
textBoxReport.EnableMultilineShortcuts();
|
||||||
textBoxReport.Text = report.ToString().TrimEnd();
|
textBoxReport.Text = report.ToString().TrimEnd();
|
||||||
|
@ -16,7 +16,7 @@ sealed partial class DialogSettingsCSS : Form{
|
|||||||
public DialogSettingsCSS(string browserCSS, string notificationCSS, Action<string> reinjectBrowserCSS, Action openDevTools){
|
public DialogSettingsCSS(string browserCSS, string notificationCSS, Action<string> reinjectBrowserCSS, Action openDevTools){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Text = Program.BrandName+" Options - CSS";
|
Text = Program.BrandName + " Options - CSS";
|
||||||
|
|
||||||
this.reinjectBrowserCSS = reinjectBrowserCSS;
|
this.reinjectBrowserCSS = reinjectBrowserCSS;
|
||||||
this.openDevTools = openDevTools;
|
this.openDevTools = openDevTools;
|
||||||
@ -64,21 +64,21 @@ private void textBoxCSS_KeyDown(object sender, KeyEventArgs e){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(deleteTo < text.Length-1 && text[deleteTo] == '\r' && text[deleteTo+1] == '\n')){
|
if (!(deleteTo < text.Length - 1 && text[deleteTo] == '\r' && text[deleteTo + 1] == '\n')){
|
||||||
++deleteTo;
|
++deleteTo;
|
||||||
}
|
}
|
||||||
|
|
||||||
tb.Select(deleteTo, tb.SelectionLength+tb.SelectionStart-deleteTo);
|
tb.Select(deleteTo, tb.SelectionLength + tb.SelectionStart - deleteTo);
|
||||||
tb.SelectedText = string.Empty;
|
tb.SelectedText = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (e.KeyCode == Keys.Back && e.Modifiers == Keys.None){
|
else if (e.KeyCode == Keys.Back && e.Modifiers == Keys.None){
|
||||||
int deleteTo = tb.SelectionStart;
|
int deleteTo = tb.SelectionStart;
|
||||||
|
|
||||||
if (deleteTo > 1 && text[deleteTo-1] == ' ' && text[deleteTo-2] == ' '){
|
if (deleteTo > 1 && text[deleteTo - 1] == ' ' && text[deleteTo - 2] == ' '){
|
||||||
e.SuppressKeyPress = true;
|
e.SuppressKeyPress = true;
|
||||||
|
|
||||||
tb.Select(deleteTo-2, 2);
|
tb.Select(deleteTo - 2, 2);
|
||||||
tb.SelectedText = string.Empty;
|
tb.SelectedText = string.Empty;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,28 +89,28 @@ private void textBoxCSS_KeyDown(object sender, KeyEventArgs e){
|
|||||||
if (insertAt == 0){
|
if (insertAt == 0){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (text[insertAt-1] == '{'){
|
else if (text[insertAt - 1] == '{'){
|
||||||
insertText = Environment.NewLine+" ";
|
insertText = Environment.NewLine + " ";
|
||||||
|
|
||||||
int nextBracket = insertAt < text.Length ? text.IndexOfAny(new char[]{ '{', '}' }, insertAt+1) : -1;
|
int nextBracket = insertAt < text.Length ? text.IndexOfAny(new char[]{ '{', '}' }, insertAt + 1) : -1;
|
||||||
|
|
||||||
if (nextBracket == -1 || text[nextBracket] == '{'){
|
if (nextBracket == -1 || text[nextBracket] == '{'){
|
||||||
string insertExtra = Environment.NewLine+"}";
|
string insertExtra = Environment.NewLine + "}";
|
||||||
insertText += insertExtra;
|
insertText += insertExtra;
|
||||||
cursorOffset -= insertExtra.Length;
|
cursorOffset -= insertExtra.Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
int lineStart = text.LastIndexOf('\n', tb.SelectionStart-1);
|
int lineStart = text.LastIndexOf('\n', tb.SelectionStart - 1);
|
||||||
|
|
||||||
Match match = Regex.Match(text.Substring(lineStart == -1 ? 0 : lineStart+1), "^([ \t]+)");
|
Match match = Regex.Match(text.Substring(lineStart == -1 ? 0 : lineStart + 1), "^([ \t]+)");
|
||||||
insertText = match.Success ? Environment.NewLine+match.Groups[1].Value : null;
|
insertText = match.Success ? Environment.NewLine + match.Groups[1].Value : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(insertText)){
|
if (!string.IsNullOrEmpty(insertText)){
|
||||||
e.SuppressKeyPress = true;
|
e.SuppressKeyPress = true;
|
||||||
tb.Text = text.Insert(insertAt, insertText);
|
tb.Text = text.Insert(insertAt, insertText);
|
||||||
tb.SelectionStart = insertAt+cursorOffset+insertText.Length;
|
tb.SelectionStart = insertAt + cursorOffset + insertText.Length;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ sealed partial class DialogSettingsCefArgs : Form{
|
|||||||
public DialogSettingsCefArgs(string args){
|
public DialogSettingsCefArgs(string args){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Text = Program.BrandName+" Options - CEF Arguments";
|
Text = Program.BrandName + " Options - CEF Arguments";
|
||||||
|
|
||||||
textBoxArgs.EnableMultilineShortcuts();
|
textBoxArgs.EnableMultilineShortcuts();
|
||||||
textBoxArgs.Text = initialArgs = args ?? "";
|
textBoxArgs.Text = initialArgs = args ?? "";
|
||||||
@ -32,7 +32,7 @@ private void btnApply_Click(object sender, EventArgs e){
|
|||||||
}
|
}
|
||||||
|
|
||||||
int count = CommandLineArgs.ReadCefArguments(CefArgs).Count;
|
int count = CommandLineArgs.ReadCefArguments(CefArgs).Count;
|
||||||
string prompt = count == 0 && !string.IsNullOrWhiteSpace(initialArgs) ? "All current arguments will be removed. Continue?" : count+(count == 1 ? " argument was" : " arguments were")+" detected. Continue?";
|
string prompt = count == 0 && !string.IsNullOrWhiteSpace(initialArgs) ? "All current arguments will be removed. Continue?" : count + (count == 1 ? " argument was" : " arguments were") + " detected. Continue?";
|
||||||
|
|
||||||
if (FormMessage.Question("Confirm CEF Arguments", prompt, FormMessage.OK, FormMessage.Cancel)){
|
if (FormMessage.Question("Confirm CEF Arguments", prompt, FormMessage.OK, FormMessage.Cancel)){
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
|
@ -124,7 +124,7 @@ private void btnContinue_Click(object sender, EventArgs e){
|
|||||||
// Continue...
|
// Continue...
|
||||||
panelDecision.Visible = false;
|
panelDecision.Visible = false;
|
||||||
panelSelection.Visible = true;
|
panelSelection.Visible = true;
|
||||||
Height += panelSelection.Height-panelDecision.Height;
|
Height += panelSelection.Height - panelDecision.Height;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case State.Reset:
|
case State.Reset:
|
||||||
|
@ -24,7 +24,7 @@ public DialogSettingsRestart(CommandLineArgs currentArgs){
|
|||||||
|
|
||||||
control_Change(this, EventArgs.Empty);
|
control_Change(this, EventArgs.Empty);
|
||||||
|
|
||||||
Text = Program.BrandName+" Arguments";
|
Text = Program.BrandName + " Arguments";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void control_Change(object sender, EventArgs e){
|
private void control_Change(object sender, EventArgs e){
|
||||||
|
@ -8,7 +8,7 @@ sealed partial class DialogSettingsSearchEngine : Form{
|
|||||||
public DialogSettingsSearchEngine(){
|
public DialogSettingsSearchEngine(){
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Text = Program.BrandName+" Options - Custom Search Engine";
|
Text = Program.BrandName + " Options - Custom Search Engine";
|
||||||
|
|
||||||
textBoxUrl.Text = Program.Config.User.SearchEngineUrl ?? "";
|
textBoxUrl.Text = Program.Config.User.SearchEngineUrl ?? "";
|
||||||
textBoxUrl.Select(textBoxUrl.Text.Length, 0);
|
textBoxUrl.Select(textBoxUrl.Text.Length, 0);
|
||||||
|
@ -36,7 +36,7 @@ public TabSettingsAdvanced(Action<string> reinjectBrowserCSS, Action openDevTool
|
|||||||
numClearCacheThreshold.SetValueSafe(SysConfig.ClearCacheThreshold);
|
numClearCacheThreshold.SetValueSafe(SysConfig.ClearCacheThreshold);
|
||||||
|
|
||||||
BrowserCache.GetCacheSize(task => {
|
BrowserCache.GetCacheSize(task => {
|
||||||
string text = task.Status == TaskStatus.RanToCompletion ? (int)Math.Ceiling(task.Result/(1024.0*1024.0))+" MB" : "unknown";
|
string text = task.Status == TaskStatus.RanToCompletion ? (int)Math.Ceiling(task.Result / (1024.0 * 1024.0)) + " MB" : "unknown";
|
||||||
this.InvokeSafe(() => btnClearCache.Text = $"Clear Cache ({text})");
|
this.InvokeSafe(() => btnClearCache.Text = $"Clear Cache ({text})");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -24,7 +24,7 @@ public TabSettingsFeedback(AnalyticsManager analytics, AnalyticsReportGenerator.
|
|||||||
|
|
||||||
if (analytics != null){
|
if (analytics != null){
|
||||||
string collectionTime = analyticsFile.LastCollectionMessage;
|
string collectionTime = analyticsFile.LastCollectionMessage;
|
||||||
labelDataCollectionMessage.Text = string.IsNullOrEmpty(collectionTime) ? "No collection yet" : "Last collection: "+collectionTime;
|
labelDataCollectionMessage.Text = string.IsNullOrEmpty(collectionTime) ? "No collection yet" : "Last collection: " + collectionTime;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public TabSettingsGeneral(Action reloadColumns, UpdateHandler updates){
|
|||||||
checkAnimatedAvatars.Checked = Config.EnableAnimatedImages;
|
checkAnimatedAvatars.Checked = Config.EnableAnimatedImages;
|
||||||
|
|
||||||
trackBarZoom.SetValueSafe(Config.ZoomLevel);
|
trackBarZoom.SetValueSafe(Config.ZoomLevel);
|
||||||
labelZoomValue.Text = trackBarZoom.Value+"%";
|
labelZoomValue.Text = trackBarZoom.Value + "%";
|
||||||
|
|
||||||
// system tray
|
// system tray
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ public TabSettingsGeneral(Action reloadColumns, UpdateHandler updates){
|
|||||||
comboBoxTrayType.Items.Add("Minimize to Tray");
|
comboBoxTrayType.Items.Add("Minimize to Tray");
|
||||||
comboBoxTrayType.Items.Add("Close to Tray");
|
comboBoxTrayType.Items.Add("Close to Tray");
|
||||||
comboBoxTrayType.Items.Add("Combined");
|
comboBoxTrayType.Items.Add("Combined");
|
||||||
comboBoxTrayType.SelectedIndex = Math.Min(Math.Max((int)Config.TrayBehavior, 0), comboBoxTrayType.Items.Count-1);
|
comboBoxTrayType.SelectedIndex = Math.Min(Math.Max((int)Config.TrayBehavior, 0), comboBoxTrayType.Items.Count - 1);
|
||||||
|
|
||||||
checkTrayHighlight.Enabled = Config.TrayBehavior.ShouldDisplayIcon();
|
checkTrayHighlight.Enabled = Config.TrayBehavior.ShouldDisplayIcon();
|
||||||
checkTrayHighlight.Checked = Config.EnableTrayHighlight;
|
checkTrayHighlight.Checked = Config.EnableTrayHighlight;
|
||||||
@ -189,7 +189,7 @@ private void trackBarZoom_ValueChanged(object sender, EventArgs e){
|
|||||||
if (trackBarZoom.AlignValueToTick()){
|
if (trackBarZoom.AlignValueToTick()){
|
||||||
zoomUpdateTimer.Stop();
|
zoomUpdateTimer.Stop();
|
||||||
zoomUpdateTimer.Start();
|
zoomUpdateTimer.Start();
|
||||||
labelZoomValue.Text = trackBarZoom.Value+"%";
|
labelZoomValue.Text = trackBarZoom.Value + "%";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ public TabSettingsNotifications(FormNotificationExample notification){
|
|||||||
checkTimerCountDown.Checked = Config.NotificationTimerCountDown;
|
checkTimerCountDown.Checked = Config.NotificationTimerCountDown;
|
||||||
|
|
||||||
trackBarDuration.SetValueSafe(Config.NotificationDurationValue);
|
trackBarDuration.SetValueSafe(Config.NotificationDurationValue);
|
||||||
labelDurationValue.Text = Config.NotificationDurationValue+" ms/c";
|
labelDurationValue.Text = Config.NotificationDurationValue + " ms/c";
|
||||||
|
|
||||||
// location
|
// location
|
||||||
|
|
||||||
@ -77,13 +77,13 @@ public TabSettingsNotifications(FormNotificationExample notification){
|
|||||||
comboBoxDisplay.Items.Add("(Same as TweetDuck)");
|
comboBoxDisplay.Items.Add("(Same as TweetDuck)");
|
||||||
|
|
||||||
foreach(Screen screen in Screen.AllScreens){
|
foreach(Screen screen in Screen.AllScreens){
|
||||||
comboBoxDisplay.Items.Add(screen.DeviceName.TrimStart('\\', '.')+" ("+screen.Bounds.Width+"x"+screen.Bounds.Height+")");
|
comboBoxDisplay.Items.Add($"{screen.DeviceName.TrimStart('\\', '.')} ({screen.Bounds.Width}x{screen.Bounds.Height})");
|
||||||
}
|
}
|
||||||
|
|
||||||
comboBoxDisplay.SelectedIndex = Math.Min(comboBoxDisplay.Items.Count-1, Config.NotificationDisplay);
|
comboBoxDisplay.SelectedIndex = Math.Min(comboBoxDisplay.Items.Count - 1, Config.NotificationDisplay);
|
||||||
|
|
||||||
trackBarEdgeDistance.SetValueSafe(Config.NotificationEdgeDistance);
|
trackBarEdgeDistance.SetValueSafe(Config.NotificationEdgeDistance);
|
||||||
labelEdgeDistanceValue.Text = trackBarEdgeDistance.Value+" px";
|
labelEdgeDistanceValue.Text = trackBarEdgeDistance.Value + " px";
|
||||||
|
|
||||||
// size
|
// size
|
||||||
|
|
||||||
@ -96,7 +96,7 @@ public TabSettingsNotifications(FormNotificationExample notification){
|
|||||||
}
|
}
|
||||||
|
|
||||||
trackBarScrollSpeed.SetValueSafe(Config.NotificationScrollSpeed);
|
trackBarScrollSpeed.SetValueSafe(Config.NotificationScrollSpeed);
|
||||||
labelScrollSpeedValue.Text = trackBarScrollSpeed.Value+"%";
|
labelScrollSpeedValue.Text = trackBarScrollSpeed.Value + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnReady(){
|
public override void OnReady(){
|
||||||
@ -195,7 +195,7 @@ private void trackBarDuration_ValueChanged(object sender, EventArgs e){
|
|||||||
durationUpdateTimer.Start();
|
durationUpdateTimer.Start();
|
||||||
|
|
||||||
Config.NotificationDurationValue = trackBarDuration.Value;
|
Config.NotificationDurationValue = trackBarDuration.Value;
|
||||||
labelDurationValue.Text = Config.NotificationDurationValue+" ms/c";
|
labelDurationValue.Text = Config.NotificationDurationValue + " ms/c";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnDurationShort_Click(object sender, EventArgs e){
|
private void btnDurationShort_Click(object sender, EventArgs e){
|
||||||
@ -255,7 +255,7 @@ private void comboBoxDisplay_SelectedValueChanged(object sender, EventArgs e){
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void trackBarEdgeDistance_ValueChanged(object sender, EventArgs e){
|
private void trackBarEdgeDistance_ValueChanged(object sender, EventArgs e){
|
||||||
labelEdgeDistanceValue.Text = trackBarEdgeDistance.Value+" px";
|
labelEdgeDistanceValue.Text = trackBarEdgeDistance.Value + " px";
|
||||||
Config.NotificationEdgeDistance = trackBarEdgeDistance.Value;
|
Config.NotificationEdgeDistance = trackBarEdgeDistance.Value;
|
||||||
notification.ShowExampleNotification(false);
|
notification.ShowExampleNotification(false);
|
||||||
}
|
}
|
||||||
@ -282,7 +282,7 @@ private void radioSizeCustom_Click(object sender, EventArgs e){
|
|||||||
|
|
||||||
private void trackBarScrollSpeed_ValueChanged(object sender, EventArgs e){
|
private void trackBarScrollSpeed_ValueChanged(object sender, EventArgs e){
|
||||||
if (trackBarScrollSpeed.AlignValueToTick()){
|
if (trackBarScrollSpeed.AlignValueToTick()){
|
||||||
labelScrollSpeedValue.Text = trackBarScrollSpeed.Value+"%";
|
labelScrollSpeedValue.Text = trackBarScrollSpeed.Value + "%";
|
||||||
Config.NotificationScrollSpeed = trackBarScrollSpeed.Value;
|
Config.NotificationScrollSpeed = trackBarScrollSpeed.Value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,7 +20,7 @@ public TabSettingsSounds(Action playSoundNotification){
|
|||||||
toolTip.SetToolTip(tbCustomSound, "When empty, the default TweetDeck sound notification is used.");
|
toolTip.SetToolTip(tbCustomSound, "When empty, the default TweetDeck sound notification is used.");
|
||||||
|
|
||||||
trackBarVolume.SetValueSafe(Config.NotificationSoundVolume);
|
trackBarVolume.SetValueSafe(Config.NotificationSoundVolume);
|
||||||
labelVolumeValue.Text = trackBarVolume.Value+"%";
|
labelVolumeValue.Text = trackBarVolume.Value + "%";
|
||||||
|
|
||||||
tbCustomSound.Text = Config.NotificationSoundPath;
|
tbCustomSound.Text = Config.NotificationSoundPath;
|
||||||
tbCustomSound_TextChanged(tbCustomSound, EventArgs.Empty);
|
tbCustomSound_TextChanged(tbCustomSound, EventArgs.Empty);
|
||||||
@ -83,7 +83,7 @@ private void btnResetSound_Click(object sender, EventArgs e){
|
|||||||
private void trackBarVolume_ValueChanged(object sender, EventArgs e){
|
private void trackBarVolume_ValueChanged(object sender, EventArgs e){
|
||||||
volumeUpdateTimer.Stop();
|
volumeUpdateTimer.Stop();
|
||||||
volumeUpdateTimer.Start();
|
volumeUpdateTimer.Start();
|
||||||
labelVolumeValue.Text = trackBarVolume.Value+"%";
|
labelVolumeValue.Text = trackBarVolume.Value + "%";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void volumeUpdateTimer_Tick(object sender, EventArgs e){
|
private void volumeUpdateTimer_Tick(object sender, EventArgs e){
|
||||||
|
@ -29,7 +29,7 @@ public static void SetupCefArgs(IDictionary<string, string> args){
|
|||||||
args["disable-threaded-scrolling"] = "1";
|
args["disable-threaded-scrolling"] = "1";
|
||||||
|
|
||||||
if (args.TryGetValue("disable-features", out string disabledFeatures)){
|
if (args.TryGetValue("disable-features", out string disabledFeatures)){
|
||||||
args["disable-features"] = "TouchpadAndWheelScrollLatching,"+disabledFeatures;
|
args["disable-features"] = "TouchpadAndWheelScrollLatching," + disabledFeatures;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
args["disable-features"] = "TouchpadAndWheelScrollLatching";
|
args["disable-features"] = "TouchpadAndWheelScrollLatching";
|
||||||
@ -48,7 +48,7 @@ public static void SetupCefArgs(IDictionary<string, string> args){
|
|||||||
args["enable-system-flash"] = "0";
|
args["enable-system-flash"] = "0";
|
||||||
|
|
||||||
if (args.TryGetValue("js-flags", out string jsFlags)){
|
if (args.TryGetValue("js-flags", out string jsFlags)){
|
||||||
args["js-flags"] = "--expose-gc "+jsFlags;
|
args["js-flags"] = "--expose-gc " + jsFlags;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
args["js-flags"] = "--expose-gc";
|
args["js-flags"] = "--expose-gc";
|
||||||
@ -108,7 +108,7 @@ public static void OpenExternalBrowser(string url){
|
|||||||
goto case TwitterUrls.UrlType.Fine;
|
goto case TwitterUrls.UrlType.Fine;
|
||||||
}
|
}
|
||||||
|
|
||||||
using(FormMessage form = new FormMessage("Blocked URL", "TweetDuck has blocked a tracking url due to privacy concerns. Do you want to visit it anyway?\n"+url, MessageBoxIcon.Warning)){
|
using(FormMessage form = new FormMessage("Blocked URL", "TweetDuck has blocked a tracking url due to privacy concerns. Do you want to visit it anyway?\n" + url, MessageBoxIcon.Warning)){
|
||||||
form.AddButton(FormMessage.No, DialogResult.No, ControlType.Cancel | ControlType.Focused);
|
form.AddButton(FormMessage.No, DialogResult.No, ControlType.Cancel | ControlType.Focused);
|
||||||
form.AddButton(FormMessage.Yes, DialogResult.Yes, ControlType.Accept);
|
form.AddButton(FormMessage.Yes, DialogResult.Yes, ControlType.Accept);
|
||||||
form.AddButton("Always Visit", DialogResult.Ignore);
|
form.AddButton("Always Visit", DialogResult.Ignore);
|
||||||
@ -128,7 +128,7 @@ public static void OpenExternalBrowser(string url){
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case TwitterUrls.UrlType.Invalid:
|
case TwitterUrls.UrlType.Invalid:
|
||||||
FormMessage.Warning("Blocked URL", "A potentially malicious URL was blocked from opening:\n"+url, FormMessage.OK);
|
FormMessage.Warning("Blocked URL", "A potentially malicious URL was blocked from opening:\n" + url, FormMessage.OK);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -158,12 +158,12 @@ public static void OpenExternalSearch(string query){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
OpenExternalBrowser(searchUrl+Uri.EscapeUriString(query));
|
OpenExternalBrowser(searchUrl + Uri.EscapeUriString(query));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int Scale(int baseValue, double scaleFactor){
|
public static int Scale(int baseValue, double scaleFactor){
|
||||||
return (int)Math.Round(baseValue*scaleFactor);
|
return (int)Math.Round(baseValue * scaleFactor);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -133,7 +133,7 @@ public static int GetIdleSeconds(){
|
|||||||
ticks = (uint)Environment.TickCount;
|
ticks = (uint)Environment.TickCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
int seconds = (int)Math.Floor(TimeSpan.FromMilliseconds(ticks-info.dwTime).TotalSeconds);
|
int seconds = (int)Math.Floor(TimeSpan.FromMilliseconds(ticks - info.dwTime).TotalSeconds);
|
||||||
return Math.Max(0, seconds); // ignore rollover after several weeks of uptime
|
return Math.Max(0, seconds); // ignore rollover after several weeks of uptime
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ static void ViewImageInternal(string path){
|
|||||||
WindowsUtils.OpenAssociatedProgram(path);
|
WindowsUtils.OpenAssociatedProgram(path);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
FormMessage.Error("Image Download", "Invalid file extension "+ext, FormMessage.OK);
|
FormMessage.Error("Image Download", "Invalid file extension " + ext, FormMessage.OK);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ static void ViewImageInternal(string path){
|
|||||||
DownloadFileAuth(TwitterUrls.GetMediaLink(url, quality), file, () => {
|
DownloadFileAuth(TwitterUrls.GetMediaLink(url, quality), file, () => {
|
||||||
ViewImageInternal(file);
|
ViewImageInternal(file);
|
||||||
}, ex => {
|
}, ex => {
|
||||||
FormMessage.Error("Image Download", "An error occurred while downloading the image: "+ex.Message, FormMessage.OK);
|
FormMessage.Error("Image Download", "An error occurred while downloading the image: " + ex.Message, FormMessage.OK);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -69,12 +69,12 @@ public static void DownloadImages(string[] urls, string username, ImageQuality q
|
|||||||
AutoUpgradeEnabled = true,
|
AutoUpgradeEnabled = true,
|
||||||
OverwritePrompt = urls.Length == 1,
|
OverwritePrompt = urls.Length == 1,
|
||||||
Title = "Save Image",
|
Title = "Save Image",
|
||||||
FileName = qualityIndex == -1 ? filename : $"{username} {Path.ChangeExtension(filename, null)} {firstImageLink.Substring(qualityIndex+1)}".Trim()+ext,
|
FileName = qualityIndex == -1 ? filename : $"{username} {Path.ChangeExtension(filename, null)} {firstImageLink.Substring(qualityIndex + 1)}".Trim() + ext,
|
||||||
Filter = (urls.Length == 1 ? "Image" : "Images")+(string.IsNullOrEmpty(ext) ? " (unknown)|*.*" : $" (*{ext})|*{ext}")
|
Filter = (urls.Length == 1 ? "Image" : "Images") + (string.IsNullOrEmpty(ext) ? " (unknown)|*.*" : $" (*{ext})|*{ext}")
|
||||||
}){
|
}){
|
||||||
if (dialog.ShowDialog() == DialogResult.OK){
|
if (dialog.ShowDialog() == DialogResult.OK){
|
||||||
static void OnFailure(Exception ex){
|
static void OnFailure(Exception ex){
|
||||||
FormMessage.Error("Image Download", "An error occurred while downloading the image: "+ex.Message, FormMessage.OK);
|
FormMessage.Error("Image Download", "An error occurred while downloading the image: " + ex.Message, FormMessage.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (urls.Length == 1){
|
if (urls.Length == 1){
|
||||||
@ -85,7 +85,7 @@ static void OnFailure(Exception ex){
|
|||||||
string pathExt = Path.GetExtension(dialog.FileName);
|
string pathExt = Path.GetExtension(dialog.FileName);
|
||||||
|
|
||||||
for(int index = 0; index < urls.Length; index++){
|
for(int index = 0; index < urls.Length; index++){
|
||||||
DownloadFileAuth(TwitterUrls.GetMediaLink(urls[index], quality), $"{pathBase} {index+1}{pathExt}", null, OnFailure);
|
DownloadFileAuth(TwitterUrls.GetMediaLink(urls[index], quality), $"{pathBase} {index + 1}{pathExt}", null, OnFailure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,11 +101,11 @@ public static void DownloadVideo(string url, string username){
|
|||||||
OverwritePrompt = true,
|
OverwritePrompt = true,
|
||||||
Title = "Save Video",
|
Title = "Save Video",
|
||||||
FileName = string.IsNullOrEmpty(username) ? filename : $"{username} {filename}".TrimStart(),
|
FileName = string.IsNullOrEmpty(username) ? filename : $"{username} {filename}".TrimStart(),
|
||||||
Filter = "Video"+(string.IsNullOrEmpty(ext) ? " (unknown)|*.*" : $" (*{ext})|*{ext}")
|
Filter = "Video" + (string.IsNullOrEmpty(ext) ? " (unknown)|*.*" : $" (*{ext})|*{ext}")
|
||||||
}){
|
}){
|
||||||
if (dialog.ShowDialog() == DialogResult.OK){
|
if (dialog.ShowDialog() == DialogResult.OK){
|
||||||
DownloadFileAuth(url, dialog.FileName, null, ex => {
|
DownloadFileAuth(url, dialog.FileName, null, ex => {
|
||||||
FormMessage.Error("Video Download", "An error occurred while downloading the video: "+ex.Message, FormMessage.OK);
|
FormMessage.Error("Video Download", "An error occurred while downloading the video: " + ex.Message, FormMessage.OK);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -37,7 +37,7 @@ public static bool OpenAssociatedProgram(string file, string arguments = "", boo
|
|||||||
}catch(Win32Exception e) when (e.NativeErrorCode == 0x000004C7){ // operation canceled by the user
|
}catch(Win32Exception e) when (e.NativeErrorCode == 0x000004C7){ // operation canceled by the user
|
||||||
return false;
|
return false;
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
Program.Reporter.HandleException("Error Opening Program", "Could not open the associated program for "+file, true, e);
|
Program.Reporter.HandleException("Error Opening Program", "Could not open the associated program for " + file, true, e);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -79,8 +79,8 @@ public static void ClipboardStripHtmlStyles(){
|
|||||||
|
|
||||||
string updatedHtml = RegexStripHtmlStyles.Value.Replace(originalHtml, string.Empty);
|
string updatedHtml = RegexStripHtmlStyles.Value.Replace(originalHtml, string.Empty);
|
||||||
|
|
||||||
int removed = originalHtml.Length-updatedHtml.Length;
|
int removed = originalHtml.Length - updatedHtml.Length;
|
||||||
updatedHtml = RegexOffsetClipboardHtml.Value.Replace(updatedHtml, match => (int.Parse(match.Value)-removed).ToString().PadLeft(match.Value.Length, '0'));
|
updatedHtml = RegexOffsetClipboardHtml.Value.Replace(updatedHtml, match => (int.Parse(match.Value) - removed).ToString().PadLeft(match.Value.Length, '0'));
|
||||||
|
|
||||||
DataObject obj = new DataObject();
|
DataObject obj = new DataObject();
|
||||||
obj.SetText(originalText, TextDataFormat.UnicodeText);
|
obj.SetText(originalText, TextDataFormat.UnicodeText);
|
||||||
@ -130,8 +130,8 @@ static IEnumerable<Browser> ReadBrowsersFromKey(RegistryHive hive){
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (browserPath[0] == '"' && browserPath[browserPath.Length-1] == '"'){
|
if (browserPath[0] == '"' && browserPath[browserPath.Length - 1] == '"'){
|
||||||
browserPath = browserPath.Substring(1, browserPath.Length-2);
|
browserPath = browserPath.Substring(1, browserPath.Length - 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
yield return new Browser(browserName, browserPath);
|
yield return new Browser(browserName, browserPath);
|
||||||
|
@ -27,7 +27,7 @@ public PluginControl(PluginManager pluginManager, Plugin plugin) : this(){
|
|||||||
float dpiScale = this.GetDPIScale();
|
float dpiScale = this.GetDPIScale();
|
||||||
|
|
||||||
if (dpiScale > 1F){
|
if (dpiScale > 1F){
|
||||||
Size = MaximumSize = new Size(MaximumSize.Width, MaximumSize.Height+3);
|
Size = MaximumSize = new Size(MaximumSize.Width, MaximumSize.Height + 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.labelName.Text = plugin.Name;
|
this.labelName.Text = plugin.Name;
|
||||||
|
12
Program.cs
12
Program.cs
@ -84,7 +84,7 @@ private static void Main(){
|
|||||||
WindowRestoreMessage = NativeMethods.RegisterWindowMessage("TweetDuckRestore");
|
WindowRestoreMessage = NativeMethods.RegisterWindowMessage("TweetDuckRestore");
|
||||||
|
|
||||||
if (!FileUtils.CheckFolderWritePermission(StoragePath)){
|
if (!FileUtils.CheckFolderWritePermission(StoragePath)){
|
||||||
FormMessage.Warning("Permission Error", "TweetDuck does not have write permissions to the storage folder: "+StoragePath, FormMessage.OK);
|
FormMessage.Warning("Permission Error", "TweetDuck does not have write permissions to the storage folder: " + StoragePath, FormMessage.OK);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,7 +143,7 @@ private static void Main(){
|
|||||||
try{
|
try{
|
||||||
RequestHandlerBase.LoadResourceRewriteRules(Arguments.GetValue(Arguments.ArgFreeze));
|
RequestHandlerBase.LoadResourceRewriteRules(Arguments.GetValue(Arguments.ArgFreeze));
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
FormMessage.Error("Resource Freeze", "Error parsing resource rewrite rules: "+e.Message, FormMessage.OK);
|
FormMessage.Error("Resource Freeze", "Error parsing resource rewrite rules: " + e.Message, FormMessage.OK);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -154,7 +154,7 @@ private static void Main(){
|
|||||||
|
|
||||||
CefSettings settings = new CefSettings{
|
CefSettings settings = new CefSettings{
|
||||||
UserAgent = BrowserUtils.UserAgentChrome,
|
UserAgent = BrowserUtils.UserAgentChrome,
|
||||||
BrowserSubprocessPath = BrandName+".Browser.exe",
|
BrowserSubprocessPath = BrandName + ".Browser.exe",
|
||||||
CachePath = StoragePath,
|
CachePath = StoragePath,
|
||||||
UserDataPath = CefDataPath,
|
UserDataPath = CefDataPath,
|
||||||
LogFile = ConsoleLogFilePath,
|
LogFile = ConsoleLogFilePath,
|
||||||
@ -178,7 +178,7 @@ private static void Main(){
|
|||||||
ExitCleanup();
|
ExitCleanup();
|
||||||
|
|
||||||
// ProgramPath has a trailing backslash
|
// ProgramPath has a trailing backslash
|
||||||
string updaterArgs = "/SP- /SILENT /FORCECLOSEAPPLICATIONS /UPDATEPATH=\""+ProgramPath+"\" /RUNARGS=\""+Arguments.GetCurrentForInstallerCmd()+"\""+(IsPortable ? " /PORTABLE=1" : "");
|
string updaterArgs = "/SP- /SILENT /FORCECLOSEAPPLICATIONS /UPDATEPATH=\"" + ProgramPath + "\" /RUNARGS=\"" + Arguments.GetCurrentForInstallerCmd() + "\"" + (IsPortable ? " /PORTABLE=1" : "");
|
||||||
bool runElevated = !IsPortable || !FileUtils.CheckFolderWritePermission(ProgramPath);
|
bool runElevated = !IsPortable || !FileUtils.CheckFolderWritePermission(ProgramPath);
|
||||||
|
|
||||||
if (WindowsUtils.OpenAssociatedProgram(mainForm.UpdateInstallerPath, updaterArgs, runElevated)){
|
if (WindowsUtils.OpenAssociatedProgram(mainForm.UpdateInstallerPath, updaterArgs, runElevated)){
|
||||||
@ -195,10 +195,10 @@ private static string GetDataStoragePath(){
|
|||||||
|
|
||||||
if (custom != null && (custom.Contains(Path.DirectorySeparatorChar) || custom.Contains(Path.AltDirectorySeparatorChar))){
|
if (custom != null && (custom.Contains(Path.DirectorySeparatorChar) || custom.Contains(Path.AltDirectorySeparatorChar))){
|
||||||
if (Path.GetInvalidPathChars().Any(custom.Contains)){
|
if (Path.GetInvalidPathChars().Any(custom.Contains)){
|
||||||
Reporter.HandleEarlyFailure("Data Folder Invalid", "The data folder contains invalid characters:\n"+custom);
|
Reporter.HandleEarlyFailure("Data Folder Invalid", "The data folder contains invalid characters:\n" + custom);
|
||||||
}
|
}
|
||||||
else if (!Path.IsPathRooted(custom)){
|
else if (!Path.IsPathRooted(custom)){
|
||||||
Reporter.HandleEarlyFailure("Data Folder Invalid", "The data folder has to be either a simple folder name, or a full path:\n"+custom);
|
Reporter.HandleEarlyFailure("Data Folder Invalid", "The data folder has to be either a simple folder name, or a full path:\n" + custom);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Environment.ExpandEnvironmentVariables(custom);
|
return Environment.ExpandEnvironmentVariables(custom);
|
||||||
|
@ -58,8 +58,8 @@ bool IAppErrorHandler.Log(string text){
|
|||||||
public void HandleException(string caption, string message, bool canIgnore, Exception e){
|
public void HandleException(string caption, string message, bool canIgnore, Exception e){
|
||||||
bool loggedSuccessfully = LogImportant(e.ToString());
|
bool loggedSuccessfully = LogImportant(e.ToString());
|
||||||
|
|
||||||
string exceptionText = e is ExpandedLogException ? e.Message+"\n\nDetails with potentially sensitive information are in the Error Log." : e.Message;
|
string exceptionText = e is ExpandedLogException ? e.Message + "\n\nDetails with potentially sensitive information are in the Error Log." : e.Message;
|
||||||
FormMessage form = new FormMessage(caption, message+"\nError: "+exceptionText, canIgnore ? MessageBoxIcon.Warning : MessageBoxIcon.Error);
|
FormMessage form = new FormMessage(caption, message + "\nError: " + exceptionText, canIgnore ? MessageBoxIcon.Warning : MessageBoxIcon.Error);
|
||||||
|
|
||||||
Button btnExit = form.AddButton(FormMessage.Exit);
|
Button btnExit = form.AddButton(FormMessage.Exit);
|
||||||
Button btnIgnore = form.AddButton(FormMessage.Ignore, DialogResult.Ignore, ControlType.Cancel);
|
Button btnIgnore = form.AddButton(FormMessage.Ignore, DialogResult.Ignore, ControlType.Cancel);
|
||||||
@ -115,7 +115,7 @@ public ExpandedLogException(Exception source, string details) : base(source.Mess
|
|||||||
this.details = details;
|
this.details = details;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override string ToString() => base.ToString()+"\r\n"+details;
|
public override string ToString() => base.ToString() + "\r\n" + details;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -62,7 +62,7 @@ private string LoadInternal(string path, bool silent){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
separator = contents.IndexOf('\n');
|
separator = contents.IndexOf('\n');
|
||||||
string fileVersion = contents.Substring(1, separator-1).TrimEnd();
|
string fileVersion = contents.Substring(1, separator - 1).TrimEnd();
|
||||||
|
|
||||||
if (fileVersion != Program.VersionTag){
|
if (fileVersion != Program.VersionTag){
|
||||||
ShowLoadError(silent ? null : sync, $"File {path} is made for a different version of TweetDuck ({fileVersion}) and may not function correctly in this version, please try reinstalling the app.");
|
ShowLoadError(silent ? null : sync, $"File {path} is made for a different version of TweetDuck ({fileVersion}) and may not function correctly in this version, please try reinstalling the app.");
|
||||||
|
@ -11,8 +11,8 @@ public FormUpdateDownload(UpdateInfo info){
|
|||||||
|
|
||||||
this.updateInfo = info;
|
this.updateInfo = info;
|
||||||
|
|
||||||
Text = "Updating "+Program.BrandName;
|
Text = "Updating " + Program.BrandName;
|
||||||
labelDescription.Text = "Downloading version "+info.VersionTag+"...";
|
labelDescription.Text = $"Downloading version {info.VersionTag}...";
|
||||||
timerDownloadCheck.Start();
|
timerDownloadCheck.Start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ public static Server CreateServer(){
|
|||||||
|
|
||||||
public static Client CreateClient(string token){
|
public static Client CreateClient(string token){
|
||||||
int space = token.IndexOf(' ');
|
int space = token.IndexOf(' ');
|
||||||
return new Client(token.Substring(0, space), token.Substring(space+1));
|
return new Client(token.Substring(0, space), token.Substring(space + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected readonly PipeStream pipeIn;
|
protected readonly PipeStream pipeIn;
|
||||||
@ -74,7 +74,7 @@ public sealed class Server : DuplexPipe{
|
|||||||
internal Server() : base(new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable), new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.Inheritable)){}
|
internal Server() : base(new AnonymousPipeServerStream(PipeDirection.In, HandleInheritability.Inheritable), new AnonymousPipeServerStream(PipeDirection.Out, HandleInheritability.Inheritable)){}
|
||||||
|
|
||||||
public string GenerateToken(){
|
public string GenerateToken(){
|
||||||
return ServerPipeIn.GetClientHandleAsString()+" "+ServerPipeOut.GetClientHandleAsString();
|
return ServerPipeIn.GetClientHandleAsString() + " " + ServerPipeOut.GetClientHandleAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DisposeToken(){
|
public void DisposeToken(){
|
||||||
@ -100,7 +100,7 @@ internal PipeReadEventArgs(string line){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
Key = line.Substring(0, separatorIndex);
|
Key = line.Substring(0, separatorIndex);
|
||||||
Data = line.Substring(separatorIndex+1);
|
Data = line.Substring(separatorIndex + 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ public static void ReadStringArray(char entryChar, string[] array, CommandLineAr
|
|||||||
|
|
||||||
if (entry.Length > 0 && entry[0] == entryChar){
|
if (entry.Length > 0 && entry[0] == entryChar){
|
||||||
if (index < array.Length - 1){
|
if (index < array.Length - 1){
|
||||||
string potentialValue = array[index+1];
|
string potentialValue = array[index + 1];
|
||||||
|
|
||||||
if (potentialValue.Length > 0 && potentialValue[0] == entryChar){
|
if (potentialValue.Length > 0 && potentialValue[0] == entryChar){
|
||||||
targetArgs.AddFlag(entry);
|
targetArgs.AddFlag(entry);
|
||||||
|
@ -21,7 +21,7 @@ public void WriteFile(string identifier, string path){
|
|||||||
byte[] name = Encoding.UTF8.GetBytes(identifier);
|
byte[] name = Encoding.UTF8.GetBytes(identifier);
|
||||||
|
|
||||||
if (name.Length > 255){
|
if (name.Length > 255){
|
||||||
throw new ArgumentOutOfRangeException("Identifier cannot be 256 or more characters long: "+identifier);
|
throw new ArgumentOutOfRangeException("Identifier cannot be 256 or more characters long: " + identifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
byte[] contents;
|
byte[] contents;
|
||||||
@ -103,7 +103,7 @@ public string KeyName{
|
|||||||
public string[] KeyValue{
|
public string[] KeyValue{
|
||||||
get{
|
get{
|
||||||
int index = Identifier.IndexOf(KeySeparator);
|
int index = Identifier.IndexOf(KeySeparator);
|
||||||
return index == -1 ? StringUtils.EmptyArray : Identifier.Substring(index+1).Split(KeySeparator);
|
return index == -1 ? StringUtils.EmptyArray : Identifier.Substring(index + 1).Split(KeySeparator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,25 +24,25 @@ private static string UnescapeStream(StreamReader reader){
|
|||||||
while(true){
|
while(true){
|
||||||
int nextIndex = data.IndexOf('\\', index);
|
int nextIndex = data.IndexOf('\\', index);
|
||||||
|
|
||||||
if (nextIndex == -1 || nextIndex+1 >= data.Length){
|
if (nextIndex == -1 || nextIndex + 1 >= data.Length){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
build.Append(data.Substring(index, nextIndex-index));
|
build.Append(data.Substring(index, nextIndex - index));
|
||||||
|
|
||||||
char next = data[nextIndex+1];
|
char next = data[nextIndex + 1];
|
||||||
|
|
||||||
if (next == '\\'){ // convert double backslash to single backslash
|
if (next == '\\'){ // convert double backslash to single backslash
|
||||||
build.Append('\\');
|
build.Append('\\');
|
||||||
index = nextIndex+2;
|
index = nextIndex + 2;
|
||||||
}
|
}
|
||||||
else if (next == '\r' && nextIndex+2 < data.Length && data[nextIndex+2] == '\n'){ // convert backslash followed by CRLF to custom new line
|
else if (next == '\r' && nextIndex + 2 < data.Length && data[nextIndex + 2] == '\n'){ // convert backslash followed by CRLF to custom new line
|
||||||
build.Append(NewLineCustom);
|
build.Append(NewLineCustom);
|
||||||
index = nextIndex+3;
|
index = nextIndex + 3;
|
||||||
}
|
}
|
||||||
else{ // single backslash
|
else{ // single backslash
|
||||||
build.Append('\\');
|
build.Append('\\');
|
||||||
index = nextIndex+1;
|
index = nextIndex + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -125,8 +125,8 @@ public void Read(string file, T obj){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
line = contents.Substring(currentPos, nextPos-currentPos);
|
line = contents.Substring(currentPos, nextPos - currentPos);
|
||||||
currentPos = nextPos+NewLineReal.Length;
|
currentPos = nextPos + NewLineReal.Length;
|
||||||
}
|
}
|
||||||
|
|
||||||
int space = line.IndexOf(' ');
|
int space = line.IndexOf(' ');
|
||||||
@ -137,7 +137,7 @@ public void Read(string file, T obj){
|
|||||||
}
|
}
|
||||||
|
|
||||||
string property = line.Substring(0, space);
|
string property = line.Substring(0, space);
|
||||||
string value = UnescapeLine(line.Substring(space+1));
|
string value = UnescapeLine(line.Substring(space + 1));
|
||||||
|
|
||||||
if (props.TryGetValue(property, out PropertyInfo info)){
|
if (props.TryGetValue(property, out PropertyInfo info)){
|
||||||
if (!converters.TryGetValue(info.PropertyType, out ITypeConverter serializer)){
|
if (!converters.TryGetValue(info.PropertyType, out ITypeConverter serializer)){
|
||||||
|
@ -7,7 +7,7 @@ public static void CreateDirectoryForFile(string file){
|
|||||||
string dir = Path.GetDirectoryName(file);
|
string dir = Path.GetDirectoryName(file);
|
||||||
|
|
||||||
if (dir == null){
|
if (dir == null){
|
||||||
throw new ArgumentException("Invalid file path: "+file);
|
throw new ArgumentException("Invalid file path: " + file);
|
||||||
}
|
}
|
||||||
else if (dir.Length > 0){
|
else if (dir.Length > 0){
|
||||||
Directory.CreateDirectory(dir);
|
Directory.CreateDirectory(dir);
|
||||||
|
@ -68,7 +68,7 @@ public void TestEmptyFiles(){
|
|||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestTextFilesAndComplexKeys(){
|
public void TestTextFilesAndComplexKeys(){
|
||||||
File.WriteAllText("input_text_1", "Hello World!"+Environment.NewLine);
|
File.WriteAllText("input_text_1", "Hello World!" + Environment.NewLine);
|
||||||
|
|
||||||
using(CombinedFileStream cfs = new CombinedFileStream(File.OpenWrite("text_files"))){
|
using(CombinedFileStream cfs = new CombinedFileStream(File.OpenWrite("text_files"))){
|
||||||
cfs.WriteFile(new string[]{ "key1", "a", "bb", "ccc", "dddd" }, "input_text_1");
|
cfs.WriteFile(new string[]{ "key1", "a", "bb", "ccc", "dddd" }, "input_text_1");
|
||||||
@ -93,7 +93,7 @@ public void TestTextFilesAndComplexKeys(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
Assert.IsTrue(File.Exists("text_file_1"));
|
Assert.IsTrue(File.Exists("text_file_1"));
|
||||||
Assert.AreEqual("Hello World!"+Environment.NewLine, File.ReadAllText("text_file_1"));
|
Assert.AreEqual("Hello World!" + Environment.NewLine, File.ReadAllText("text_file_1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
|
@ -30,7 +30,7 @@ public void TestBasicWriteRead(){
|
|||||||
TestBool = true,
|
TestBool = true,
|
||||||
TestInt = -100,
|
TestInt = -100,
|
||||||
TestStringBasic = "hello123",
|
TestStringBasic = "hello123",
|
||||||
TestStringNewLine = "abc"+Environment.NewLine+"def"+Environment.NewLine,
|
TestStringNewLine = "abc" + Environment.NewLine + "def" + Environment.NewLine,
|
||||||
TestStringBackslash = @"C:\Test\\\Abc\",
|
TestStringBackslash = @"C:\Test\\\Abc\",
|
||||||
TestStringNull = null,
|
TestStringNull = null,
|
||||||
TestEnum = TestEnum.D
|
TestEnum = TestEnum.D
|
||||||
@ -45,7 +45,7 @@ public void TestBasicWriteRead(){
|
|||||||
Assert.IsTrue(read.TestBool);
|
Assert.IsTrue(read.TestBool);
|
||||||
Assert.AreEqual(-100, read.TestInt);
|
Assert.AreEqual(-100, read.TestInt);
|
||||||
Assert.AreEqual("hello123", read.TestStringBasic);
|
Assert.AreEqual("hello123", read.TestStringBasic);
|
||||||
Assert.AreEqual("abc"+Environment.NewLine+"def"+Environment.NewLine, read.TestStringNewLine);
|
Assert.AreEqual("abc" + Environment.NewLine + "def" + Environment.NewLine, read.TestStringNewLine);
|
||||||
Assert.AreEqual(@"C:\Test\\\Abc\", read.TestStringBackslash);
|
Assert.AreEqual(@"C:\Test\\\Abc\", read.TestStringBackslash);
|
||||||
Assert.IsNull(read.TestStringNull);
|
Assert.IsNull(read.TestStringNull);
|
||||||
Assert.AreEqual(TestEnum.D, read.TestEnum);
|
Assert.AreEqual(TestEnum.D, read.TestEnum);
|
||||||
|
@ -85,15 +85,15 @@ module GetMediaLink_Default =
|
|||||||
|
|
||||||
[<Fact>]
|
[<Fact>]
|
||||||
let ``does not modify URL w/o extension`` () =
|
let ``does not modify URL w/o extension`` () =
|
||||||
Assert.Equal(domain+"/media/123", getMediaLinkDefault(domain+"/media/123"))
|
Assert.Equal(domain + "/media/123", getMediaLinkDefault(domain + "/media/123"))
|
||||||
|
|
||||||
[<Fact>]
|
[<Fact>]
|
||||||
let ``does not modify URL w/o quality suffix`` () =
|
let ``does not modify URL w/o quality suffix`` () =
|
||||||
Assert.Equal(domain+"/media/123.jpg", getMediaLinkDefault(domain+"/media/123.jpg"))
|
Assert.Equal(domain + "/media/123.jpg", getMediaLinkDefault(domain + "/media/123.jpg"))
|
||||||
|
|
||||||
[<Fact>]
|
[<Fact>]
|
||||||
let ``does not modify URL with quality suffix`` () =
|
let ``does not modify URL with quality suffix`` () =
|
||||||
Assert.Equal(domain+"/media/123.jpg:small", getMediaLinkDefault(domain+"/media/123.jpg:small"))
|
Assert.Equal(domain + "/media/123.jpg:small", getMediaLinkDefault(domain + "/media/123.jpg:small"))
|
||||||
|
|
||||||
|
|
||||||
module GetMediaLink_Orig =
|
module GetMediaLink_Orig =
|
||||||
@ -102,19 +102,19 @@ module GetMediaLink_Orig =
|
|||||||
|
|
||||||
[<Fact>]
|
[<Fact>]
|
||||||
let ``appends :orig to valid URL w/o quality suffix`` () =
|
let ``appends :orig to valid URL w/o quality suffix`` () =
|
||||||
Assert.Equal(domain+"/media/123.jpg:orig", getMediaLinkOrig(domain+"/media/123.jpg"))
|
Assert.Equal(domain + "/media/123.jpg:orig", getMediaLinkOrig(domain + "/media/123.jpg"))
|
||||||
|
|
||||||
[<Fact>]
|
[<Fact>]
|
||||||
let ``rewrites :orig into valid URL with quality suffix`` () =
|
let ``rewrites :orig into valid URL with quality suffix`` () =
|
||||||
Assert.Equal(domain+"/media/123.jpg:orig", getMediaLinkOrig(domain+"/media/123.jpg:small"))
|
Assert.Equal(domain + "/media/123.jpg:orig", getMediaLinkOrig(domain + "/media/123.jpg:small"))
|
||||||
|
|
||||||
[<Fact>]
|
[<Fact>]
|
||||||
let ``does not modify unknown URL w/o quality suffix`` () =
|
let ``does not modify unknown URL w/o quality suffix`` () =
|
||||||
Assert.Equal(domain+"/profile_images/123.jpg", getMediaLinkOrig(domain+"/profile_images/123.jpg"))
|
Assert.Equal(domain + "/profile_images/123.jpg", getMediaLinkOrig(domain + "/profile_images/123.jpg"))
|
||||||
|
|
||||||
[<Fact>]
|
[<Fact>]
|
||||||
let ``rewrites :orig into unknown URL with quality suffix`` () =
|
let ``rewrites :orig into unknown URL with quality suffix`` () =
|
||||||
Assert.Equal(domain+"/profile_images/123.jpg:orig", getMediaLinkOrig(domain+"/profile_images/123.jpg:small"))
|
Assert.Equal(domain + "/profile_images/123.jpg:orig", getMediaLinkOrig(domain + "/profile_images/123.jpg:small"))
|
||||||
|
|
||||||
|
|
||||||
module GetImageFileName =
|
module GetImageFileName =
|
||||||
@ -165,13 +165,13 @@ module RegexAccount_IsMatch =
|
|||||||
[<InlineData("search-home")>]
|
[<InlineData("search-home")>]
|
||||||
[<InlineData("search-advanced")>]
|
[<InlineData("search-advanced")>]
|
||||||
let ``rejects reserved page names`` (name: string) =
|
let ``rejects reserved page names`` (name: string) =
|
||||||
Assert.False(isMatch("https://twitter.com/"+name))
|
Assert.False(isMatch("https://twitter.com/" + name))
|
||||||
|
|
||||||
[<Theory>]
|
[<Theory>]
|
||||||
[<InlineData("tosser")>]
|
[<InlineData("tosser")>]
|
||||||
[<InlineData("searching")>]
|
[<InlineData("searching")>]
|
||||||
let ``accepts accounts starting with reserved page names`` (name: string) =
|
let ``accepts accounts starting with reserved page names`` (name: string) =
|
||||||
Assert.True(isMatch("https://twitter.com/"+name))
|
Assert.True(isMatch("https://twitter.com/" + name))
|
||||||
|
|
||||||
|
|
||||||
[<Collection("RegexAccount")>]
|
[<Collection("RegexAccount")>]
|
||||||
|
@ -28,9 +28,9 @@ public void AttachTooltip(Control control, bool followCursor, Func<MouseEventArg
|
|||||||
|
|
||||||
Text = text;
|
Text = text;
|
||||||
|
|
||||||
Point loc = form.PointToClient(control.Parent.PointToScreen(new Point(control.Location.X+(followCursor ? args.X : control.Width/2), 0)));
|
Point loc = form.PointToClient(control.Parent.PointToScreen(new Point(control.Location.X + (followCursor ? args.X : control.Width / 2), 0)));
|
||||||
loc.X = Math.Max(0, Math.Min(form.Width-Width, loc.X-Width/2));
|
loc.X = Math.Max(0, Math.Min(form.Width - Width, loc.X - Width / 2));
|
||||||
loc.Y -= Height-Margin.Top+Margin.Bottom;
|
loc.Y -= Height - Margin.Top + Margin.Bottom;
|
||||||
Location = loc;
|
Location = loc;
|
||||||
|
|
||||||
ResumeLayout();
|
ResumeLayout();
|
||||||
|
@ -19,21 +19,21 @@ public SeekBar(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double GetProgress(int clientX){
|
public double GetProgress(int clientX){
|
||||||
return clientX/(Width-1.0);
|
return clientX / (Width - 1.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnPaint(PaintEventArgs e){
|
protected override void OnPaint(PaintEventArgs e){
|
||||||
if (brushFore.Color != ForeColor){
|
if (brushFore.Color != ForeColor){
|
||||||
brushFore.Color = ForeColor;
|
brushFore.Color = ForeColor;
|
||||||
brushHover.Color = Color.FromArgb(128, ForeColor);
|
brushHover.Color = Color.FromArgb(128, ForeColor);
|
||||||
brushOverlap.Color = Color.FromArgb(80+ForeColor.R*11/16, 80+ForeColor.G*11/16, 80+ForeColor.B*11/16);
|
brushOverlap.Color = Color.FromArgb(80 + ForeColor.R * 11 / 16, 80 + ForeColor.G * 11 / 16, 80 + ForeColor.B * 11 / 16);
|
||||||
brushBack.Color = Parent.BackColor;
|
brushBack.Color = Parent.BackColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
Rectangle rect = new Rectangle(0, 0, Width, Height);
|
Rectangle rect = new Rectangle(0, 0, Width, Height);
|
||||||
Point cursor = PointToClient(Cursor.Position);
|
Point cursor = PointToClient(Cursor.Position);
|
||||||
int width = rect.Width-1;
|
int width = rect.Width - 1;
|
||||||
int progress = (int)(width*((double)Value/Maximum));
|
int progress = (int)(width * ((double)Value / Maximum));
|
||||||
|
|
||||||
rect.Width = progress;
|
rect.Width = progress;
|
||||||
rect.Height -= 1;
|
rect.Height -= 1;
|
||||||
@ -46,7 +46,7 @@ protected override void OnPaint(PaintEventArgs e){
|
|||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
rect.X = progress;
|
rect.X = progress;
|
||||||
rect.Width = cursor.X-rect.X;
|
rect.Width = cursor.X - rect.X;
|
||||||
e.Graphics.FillRectangle(brushHover, rect);
|
e.Graphics.FillRectangle(brushHover, rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,7 +57,7 @@ protected override void OnPaint(PaintEventArgs e){
|
|||||||
e.Graphics.FillRectangle(brushBack, rect);
|
e.Graphics.FillRectangle(brushBack, rect);
|
||||||
|
|
||||||
rect.X = 0;
|
rect.X = 0;
|
||||||
rect.Y = rect.Height-1;
|
rect.Y = rect.Height - 1;
|
||||||
rect.Width = width;
|
rect.Width = width;
|
||||||
rect.Height = 1;
|
rect.Height = 1;
|
||||||
e.Graphics.FillRectangle(brushBack, rect);
|
e.Graphics.FillRectangle(brushBack, rect);
|
||||||
|
@ -42,7 +42,7 @@ public FormPlayer(IntPtr handle, int dpi, int volume, string url, string token){
|
|||||||
|
|
||||||
if (NativeMethods.GetWindowRect(ownerHandle, out NativeMethods.RECT rect)){
|
if (NativeMethods.GetWindowRect(ownerHandle, out NativeMethods.RECT rect)){
|
||||||
ClientSize = new Size(0, 0);
|
ClientSize = new Size(0, 0);
|
||||||
Location = new Point((rect.Left+rect.Right)/2, (rect.Top+rect.Bottom)/2);
|
Location = new Point((rect.Left + rect.Right) / 2, (rect.Top + rect.Bottom) / 2);
|
||||||
Opacity = 0;
|
Opacity = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,11 +71,11 @@ public FormPlayer(IntPtr handle, int dpi, int volume, string url, string token){
|
|||||||
}
|
}
|
||||||
|
|
||||||
IWMPMedia media = Player.currentMedia;
|
IWMPMedia media = Player.currentMedia;
|
||||||
int progress = (int)(media.duration*progressSeek.GetProgress(args.X));
|
int progress = (int)(media.duration * progressSeek.GetProgress(args.X));
|
||||||
|
|
||||||
Marshal.ReleaseComObject(media);
|
Marshal.ReleaseComObject(media);
|
||||||
|
|
||||||
return $"{(progress/60).ToString("00")}:{(progress%60).ToString("00")}";
|
return $"{(progress / 60).ToString("00")}:{(progress % 60).ToString("00")}";
|
||||||
});
|
});
|
||||||
|
|
||||||
labelTooltip.AttachTooltip(trackBarVolume, false, args => $"Volume : {trackBarVolume.Value}%");
|
labelTooltip.AttachTooltip(trackBarVolume, false, args => $"Volume : {trackBarVolume.Value}%");
|
||||||
@ -90,7 +90,7 @@ public FormPlayer(IntPtr handle, int dpi, int volume, string url, string token){
|
|||||||
// Layout
|
// Layout
|
||||||
|
|
||||||
private int DpiScaled(int value){
|
private int DpiScaled(int value){
|
||||||
return (int)Math.Round(value*ownerDpi);
|
return (int)Math.Round(value * ownerDpi);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshControlPanel(){
|
private void RefreshControlPanel(){
|
||||||
@ -197,8 +197,8 @@ private void timerSync_Tick(object sender, EventArgs e){
|
|||||||
|
|
||||||
int ownerLeft = rect.Left;
|
int ownerLeft = rect.Left;
|
||||||
int ownerTop = rect.Top;
|
int ownerTop = rect.Top;
|
||||||
int ownerWidth = rect.Right-rect.Left+1;
|
int ownerWidth = rect.Right - rect.Left + 1;
|
||||||
int ownerHeight = rect.Bottom-rect.Top+1;
|
int ownerHeight = rect.Bottom - rect.Top + 1;
|
||||||
|
|
||||||
// roughly matches MinimumSize for client bounds, adjusted a bit for weirdness with higher DPI
|
// roughly matches MinimumSize for client bounds, adjusted a bit for weirdness with higher DPI
|
||||||
int minWidth = DpiScaled(356);
|
int minWidth = DpiScaled(356);
|
||||||
@ -209,13 +209,13 @@ private void timerSync_Tick(object sender, EventArgs e){
|
|||||||
minHeight = Math.Min(minHeight, clientSize.Bottom);
|
minHeight = Math.Min(minHeight, clientSize.Bottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
int maxWidth = Math.Min(DpiScaled(media.imageSourceWidth), ownerWidth*3/4);
|
int maxWidth = Math.Min(DpiScaled(media.imageSourceWidth), ownerWidth * 3 / 4);
|
||||||
int maxHeight = Math.Min(DpiScaled(media.imageSourceHeight), ownerHeight*3/4);
|
int maxHeight = Math.Min(DpiScaled(media.imageSourceHeight), ownerHeight * 3 / 4);
|
||||||
|
|
||||||
bool isCursorInside = ClientRectangle.Contains(PointToClient(Cursor.Position));
|
bool isCursorInside = ClientRectangle.Contains(PointToClient(Cursor.Position));
|
||||||
|
|
||||||
Size newSize = new Size(Math.Max(minWidth+2, maxWidth), Math.Max(minHeight+2, maxHeight));
|
Size newSize = new Size(Math.Max(minWidth + 2, maxWidth), Math.Max(minHeight + 2, maxHeight));
|
||||||
Point newLocation = new Point(ownerLeft+(ownerWidth-newSize.Width)/2, ownerTop+(ownerHeight-newSize.Height+SystemInformation.CaptionHeight)/2);
|
Point newLocation = new Point(ownerLeft + (ownerWidth - newSize.Width) / 2, ownerTop + (ownerHeight - newSize.Height + SystemInformation.CaptionHeight) / 2);
|
||||||
|
|
||||||
if (ClientSize != newSize || Location != newLocation){
|
if (ClientSize != newSize || Location != newLocation){
|
||||||
ClientSize = newSize;
|
ClientSize = newSize;
|
||||||
@ -226,15 +226,15 @@ private void timerSync_Tick(object sender, EventArgs e){
|
|||||||
if (isCursorInside || isDragging){
|
if (isCursorInside || isDragging){
|
||||||
labelTime.Text = $"{controls.currentPositionString} / {media.durationString}";
|
labelTime.Text = $"{controls.currentPositionString} / {media.durationString}";
|
||||||
|
|
||||||
int value = (int)Math.Round(progressSeek.Maximum*controls.currentPosition/media.duration);
|
int value = (int)Math.Round(progressSeek.Maximum * controls.currentPosition / media.duration);
|
||||||
|
|
||||||
if (value >= progressSeek.Maximum){
|
if (value >= progressSeek.Maximum){
|
||||||
progressSeek.Value = progressSeek.Maximum;
|
progressSeek.Value = progressSeek.Maximum;
|
||||||
progressSeek.Value = progressSeek.Maximum-1;
|
progressSeek.Value = progressSeek.Maximum - 1;
|
||||||
progressSeek.Value = progressSeek.Maximum;
|
progressSeek.Value = progressSeek.Maximum;
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
progressSeek.Value = value+1;
|
progressSeek.Value = value + 1;
|
||||||
progressSeek.Value = value;
|
progressSeek.Value = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -296,7 +296,7 @@ private void progressSeek_MouseDown(object sender, MouseEventArgs e){
|
|||||||
IWMPMedia media = Player.currentMedia;
|
IWMPMedia media = Player.currentMedia;
|
||||||
IWMPControls controls = Player.controls;
|
IWMPControls controls = Player.controls;
|
||||||
|
|
||||||
controls.currentPosition = media.duration*progressSeek.GetProgress(progressSeek.PointToClient(Cursor.Position).X);
|
controls.currentPosition = media.duration * progressSeek.GetProgress(progressSeek.PointToClient(Cursor.Position).X);
|
||||||
|
|
||||||
Marshal.ReleaseComObject(media);
|
Marshal.ReleaseComObject(media);
|
||||||
Marshal.ReleaseComObject(controls);
|
Marshal.ReleaseComObject(controls);
|
||||||
|
Loading…
Reference in New Issue
Block a user