1
0
mirror of https://github.com/chylex/TweetDuck.git synced 2025-05-05 02:34:07 +02:00

Refactor -32000 location to a static Point object

This commit is contained in:
chylex 2016-12-23 23:27:37 +01:00
parent ae99fee440
commit eb4ce18e31
6 changed files with 14 additions and 10 deletions

View File

@ -4,6 +4,7 @@
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using TweetDck.Core;
using TweetDck.Core.Controls;
using TweetDck.Core.Handling;
using TweetDck.Core.Utils;
using TweetDck.Plugins;
@ -45,7 +46,7 @@ sealed class UserConfig{
public bool IsCustomNotificationPositionSet{
get{
return CustomNotificationPosition.X != -32000 && CustomNotificationPosition.X != 32000;
return CustomNotificationPosition != ControlExtensions.InvisibleLocation;
}
}
@ -103,7 +104,7 @@ private UserConfig(string file){
DisplayNotificationTimer = true;
NotificationDuration = TweetNotification.Duration.Medium;
NotificationPosition = TweetNotification.Position.TopRight;
CustomNotificationPosition = new Point(-32000, -32000);
CustomNotificationPosition = ControlExtensions.InvisibleLocation;
NotificationEdgeDistance = 8;
NotificationDurationValue = 25;
EnableUpdateCheck = true;

View File

@ -5,6 +5,8 @@
namespace TweetDck.Core.Controls{
static class ControlExtensions{
public static readonly Point InvisibleLocation = new Point(-32000, -32000);
public static void InvokeSafe(this Control control, Action func){
if (control.InvokeRequired){
control.Invoke(func);

View File

@ -38,7 +38,7 @@ private void InitializeComponent() {
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(324, 386);
this.Icon = Properties.Resources.icon;
this.Location = new System.Drawing.Point(-32000, -32000);
this.Location = TweetDck.Core.Controls.ControlExtensions.InvisibleLocation;
this.MinimumSize = new System.Drawing.Size(340, 424);
this.Name = "FormBrowser";
this.StartPosition = System.Windows.Forms.FormStartPosition.Manual;

View File

@ -158,7 +158,7 @@ private void FormBrowser_Resize(object sender, EventArgs e){
private void FormBrowser_ResizeEnd(object sender, EventArgs e){ // also triggers when the window moves
if (!isLoaded)return;
if (Location.X != -32000){
if (Location != ControlExtensions.InvisibleLocation){
Config.BrowserWindow.Save(this);
Config.Save();
}
@ -304,7 +304,7 @@ public void OnTweetScreenshotReady(string html, int width, int height){
prevNotificationLocation = notification.Location;
prevFreezeTimer = notification.FreezeTimer;
notification.Location = new Point(-32000, -32000);
notification.Location = ControlExtensions.InvisibleLocation;
notification.FreezeTimer = true;
}

View File

@ -70,7 +70,7 @@ private void InitializeComponent() {
this.Controls.Add(this.progressBarTimer);
this.Controls.Add(this.panelBrowser);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Location = new System.Drawing.Point(-32000, -32000);
this.Location = TweetDck.Core.Controls.ControlExtensions.InvisibleLocation;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "FormNotification";

View File

@ -11,6 +11,7 @@
using TweetDck.Core.Utils.Notification;
using TweetDck.Plugins;
using TweetDck.Plugins.Enums;
using TweetDck.Core.Controls;
namespace TweetDck.Core{
sealed partial class FormNotification : Form{
@ -23,7 +24,7 @@ sealed partial class FormNotification : Form{
public bool IsNotificationVisible{
get{
return Location.X != -32000;
return Location != ControlExtensions.InvisibleLocation;
}
}
@ -266,7 +267,7 @@ public void ShowNotificationForScreenshot(TweetNotification tweet, int width, in
browser.LoadHtml(tweet.GenerateHtml(false), "http://tweetdeck.twitter.com/?"+DateTime.Now.Ticks);
Location = new Point(-32000, -32000);
Location = ControlExtensions.InvisibleLocation;
ClientSize = new Size(width, height);
progressBarTimer.Visible = false;
panelBrowser.Height = height;
@ -285,7 +286,7 @@ public void HideNotification(bool loadBlank){
browser.LoadHtml("", "about:blank");
}
Location = new Point(-32000, -32000);
Location = ControlExtensions.InvisibleLocation;
progressBarTimer.Value = Program.UserConfig.NotificationTimerCountDown ? 1000 : 0;
timerProgress.Stop();
totalTime = 0;
@ -339,7 +340,7 @@ private void MoveToVisibleLocation(){
screen = Screen.AllScreens[config.NotificationDisplay-1];
}
bool needsReactivating = Location.X == -32000;
bool needsReactivating = Location == ControlExtensions.InvisibleLocation;
int edgeDist = config.NotificationEdgeDistance;
switch(config.NotificationPosition){