Internal code cleanup
This commit is contained in:
@@ -12,8 +12,8 @@ namespace EveOPreview
|
||||
// So this dumb and non elegant approach is used
|
||||
sealed class ExceptionHandler
|
||||
{
|
||||
private const string ExceptionDumpFileName = "EVE-O Preview.log";
|
||||
private const string ExceptionMessage = "EVE-O Preview has encountered a problem and needs to close. Additional information has been saved in the crash log file.";
|
||||
private const string EXCEPTION_DUMP_FILE_NAME = "EVE-O Preview.log";
|
||||
private const string EXCEPTION_MESSAGE = "EVE-O Preview has encountered a problem and needs to close. Additional information has been saved in the crash log file.";
|
||||
|
||||
public void SetupExceptionHandlers()
|
||||
{
|
||||
@@ -39,9 +39,9 @@ namespace EveOPreview
|
||||
try
|
||||
{
|
||||
String exceptionMessage = exception.ToString();
|
||||
File.WriteAllText(ExceptionHandler.ExceptionDumpFileName, exceptionMessage);
|
||||
File.WriteAllText(ExceptionHandler.EXCEPTION_DUMP_FILE_NAME, exceptionMessage);
|
||||
|
||||
MessageBox.Show(ExceptionHandler.ExceptionMessage, @"EVE-O Preview", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
MessageBox.Show(ExceptionHandler.EXCEPTION_MESSAGE, @"EVE-O Preview", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
@@ -5,7 +5,7 @@ namespace EveOPreview.Configuration.Implementation
|
||||
{
|
||||
class ConfigurationStorage : IConfigurationStorage
|
||||
{
|
||||
private const string ConfigurationFileName = "EVE-O Preview.json";
|
||||
private const string CONFIGURATION_FILE_NAME = "EVE-O Preview.json";
|
||||
|
||||
private readonly IAppConfig _appConfig;
|
||||
private readonly IThumbnailConfiguration _thumbnailConfiguration;
|
||||
@@ -50,7 +50,7 @@ namespace EveOPreview.Configuration.Implementation
|
||||
|
||||
private string GetConfigFileName()
|
||||
{
|
||||
return string.IsNullOrEmpty(this._appConfig.ConfigFileName) ? ConfigurationStorage.ConfigurationFileName : this._appConfig.ConfigFileName;
|
||||
return string.IsNullOrEmpty(this._appConfig.ConfigFileName) ? ConfigurationStorage.CONFIGURATION_FILE_NAME : this._appConfig.ConfigFileName;
|
||||
}
|
||||
}
|
||||
}
|
@@ -214,7 +214,6 @@
|
||||
<None Include="packages.config">
|
||||
<SubType>Designer</SubType>
|
||||
</None>
|
||||
<None Include="Resources\icon.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="FodyWeavers.xml" />
|
||||
|
@@ -7,7 +7,7 @@ namespace EveOPreview.UI.Hotkeys
|
||||
class HotkeyHandler : IMessageFilter, IDisposable
|
||||
{
|
||||
private static int _currentId;
|
||||
private const int MaxId = 0xBFFF;
|
||||
private const int MAX_ID = 0xBFFF;
|
||||
|
||||
#region Private fields
|
||||
private readonly int _hotkeyId;
|
||||
@@ -17,7 +17,7 @@ namespace EveOPreview.UI.Hotkeys
|
||||
public HotkeyHandler(IntPtr target, Keys hotkey)
|
||||
{
|
||||
this._hotkeyId = HotkeyHandler._currentId;
|
||||
HotkeyHandler._currentId = (HotkeyHandler._currentId + 1) & HotkeyHandler.MaxId;
|
||||
HotkeyHandler._currentId = (HotkeyHandler._currentId + 1) & HotkeyHandler.MAX_ID;
|
||||
|
||||
this._hotkeyTarget = target;
|
||||
|
||||
@@ -106,10 +106,7 @@ namespace EveOPreview.UI.Hotkeys
|
||||
Application.RemoveMessageFilter(this);
|
||||
|
||||
// Clean up after ourselves
|
||||
if (!HotkeyHandlerNativeMethods.UnregisterHotKey(this._hotkeyTarget, this._hotkeyId))
|
||||
{
|
||||
return;
|
||||
}
|
||||
HotkeyHandlerNativeMethods.UnregisterHotKey(this._hotkeyTarget, this._hotkeyId);
|
||||
}
|
||||
|
||||
#region IMessageFilter
|
||||
|
@@ -12,7 +12,7 @@ namespace EveOPreview.Presenters
|
||||
public class MainFormPresenter : Presenter<IMainFormView>, IMainFormPresenter
|
||||
{
|
||||
#region Private constants
|
||||
private const string ForumUrl = @"https://forum.eveonline.com/t/4202";
|
||||
private const string FORUM_URL = @"https://forum.eveonline.com/t/4202";
|
||||
#endregion
|
||||
|
||||
#region Private fields
|
||||
@@ -50,7 +50,7 @@ namespace EveOPreview.Presenters
|
||||
private void Activate()
|
||||
{
|
||||
this.LoadApplicationSettings();
|
||||
this.View.SetDocumentationUrl(MainFormPresenter.ForumUrl);
|
||||
this.View.SetDocumentationUrl(MainFormPresenter.FORUM_URL);
|
||||
this.View.SetVersionInfo(this.GetApplicationVersion());
|
||||
if (this._configuration.MinimizeToTray)
|
||||
{
|
||||
@@ -225,7 +225,7 @@ namespace EveOPreview.Presenters
|
||||
private void OpenDocumentationLink()
|
||||
{
|
||||
// TODO Move out to a separate service / presenter / message handler
|
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(new Uri(MainFormPresenter.ForumUrl).AbsoluteUri);
|
||||
ProcessStartInfo processStartInfo = new ProcessStartInfo(new Uri(MainFormPresenter.FORUM_URL).AbsoluteUri);
|
||||
Process.Start(processStartInfo);
|
||||
}
|
||||
|
||||
|
@@ -7,7 +7,7 @@ namespace EveOPreview.Services.Implementation
|
||||
sealed class ProcessMonitor : IProcessMonitor
|
||||
{
|
||||
#region Private constants
|
||||
private const string DefaultProcessName = "ExeFile";
|
||||
private const string DEFAULT_PROCESS_NAME = "ExeFile";
|
||||
#endregion
|
||||
|
||||
#region Private fields
|
||||
@@ -22,7 +22,7 @@ namespace EveOPreview.Services.Implementation
|
||||
private bool IsMonitoredProcess(string processName)
|
||||
{
|
||||
// This is a possible extension point
|
||||
return String.Equals(processName, ProcessMonitor.DefaultProcessName, StringComparison.OrdinalIgnoreCase);
|
||||
return String.Equals(processName, ProcessMonitor.DEFAULT_PROCESS_NAME, StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
public void GetUpdatedProcesses(out ICollection<IProcessInfo> addedProcesses, out ICollection<IProcessInfo> updatedProcesses, out ICollection<IProcessInfo> removedProcesses)
|
||||
@@ -62,7 +62,7 @@ namespace EveOPreview.Services.Implementation
|
||||
if (cachedTitle != mainWindowTitle)
|
||||
{
|
||||
this._processCache[mainWindowHandle] = mainWindowTitle;
|
||||
updatedProcesses.Add((IProcessInfo)new ProcessInfo(mainWindowHandle, mainWindowTitle));
|
||||
updatedProcesses.Add(new ProcessInfo(mainWindowHandle, mainWindowTitle));
|
||||
}
|
||||
|
||||
knownProcesses.Remove(mainWindowHandle);
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Threading;
|
||||
using EveOPreview.Configuration;
|
||||
@@ -14,13 +13,13 @@ namespace EveOPreview.Services
|
||||
class ThumbnailManager : IThumbnailManager
|
||||
{
|
||||
#region Private constants
|
||||
private const int WindowPositionThresholdLow = -10_000;
|
||||
private const int WindowPositionThresholdHigh = 31_000;
|
||||
private const int WindowSizeThreshold = 10;
|
||||
private const int ForcedRefreshCycleThreshold = 2;
|
||||
private const int DefaultLocationChangeNotificationDelay = 2;
|
||||
private const int WINDOW_POSITION_THRESHOLD_LOW = -10_000;
|
||||
private const int WINDOW_POSITION_THRESHOLD_HIGH = 31_000;
|
||||
private const int WINDOW_SIZE_THRESHOLD = 10;
|
||||
private const int FORCED_REFRESH_CYCLE_THRESHOLD = 2;
|
||||
private const int DEFAULT_LOCATION_CHANGE_NOTIFICATION_DELAY = 2;
|
||||
|
||||
private const string DefaultClientTitle = "EVE";
|
||||
private const string DEFAULT_CLIENT_TITLE = "EVE";
|
||||
#endregion
|
||||
|
||||
#region Private fields
|
||||
@@ -51,7 +50,7 @@ namespace EveOPreview.Services
|
||||
this._configuration = configuration;
|
||||
this._thumbnailViewFactory = factory;
|
||||
|
||||
this._activeClient = (IntPtr.Zero, ThumbnailManager.DefaultClientTitle);
|
||||
this._activeClient = (IntPtr.Zero, ThumbnailManager.DEFAULT_CLIENT_TITLE);
|
||||
|
||||
this.EnableViewEvents();
|
||||
this._isHoverEffectActive = false;
|
||||
@@ -121,7 +120,7 @@ namespace EveOPreview.Services
|
||||
this.ApplyClientLayout(view.Id, view.Title);
|
||||
|
||||
// TODO Add extension filter here later
|
||||
if (view.Title != ThumbnailManager.DefaultClientTitle)
|
||||
if (view.Title != ThumbnailManager.DEFAULT_CLIENT_TITLE)
|
||||
{
|
||||
viewsAdded.Add(view.Title);
|
||||
}
|
||||
@@ -154,7 +153,7 @@ namespace EveOPreview.Services
|
||||
IThumbnailView view = this._thumbnailViews[process.Handle];
|
||||
|
||||
this._thumbnailViews.Remove(view.Id);
|
||||
if (view.Title != ThumbnailManager.DefaultClientTitle)
|
||||
if (view.Title != ThumbnailManager.DEFAULT_CLIENT_TITLE)
|
||||
{
|
||||
viewsRemoved.Add(view.Title);
|
||||
}
|
||||
@@ -203,7 +202,7 @@ namespace EveOPreview.Services
|
||||
this._refreshCycleCount++;
|
||||
|
||||
bool forceRefresh;
|
||||
if (this._refreshCycleCount >= ThumbnailManager.ForcedRefreshCycleThreshold)
|
||||
if (this._refreshCycleCount >= ThumbnailManager.FORCED_REFRESH_CYCLE_THRESHOLD)
|
||||
{
|
||||
this._refreshCycleCount = 0;
|
||||
forceRefresh = true;
|
||||
@@ -223,11 +222,11 @@ namespace EveOPreview.Services
|
||||
{
|
||||
this.SnapThumbnailView(view);
|
||||
|
||||
this.RaiseThumbnailLocationUpdatedNotification(view.Title, this._activeClient.Title, view.ThumbnailLocation);
|
||||
this.RaiseThumbnailLocationUpdatedNotification(view.Title);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.RaiseThumbnailLocationUpdatedNotification(locationChange.Title, locationChange.ActiveClient, locationChange.Location);
|
||||
this.RaiseThumbnailLocationUpdatedNotification(locationChange.Title);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -609,7 +608,7 @@ namespace EveOPreview.Services
|
||||
{
|
||||
if (this._enqueuedLocationChangeNotification.Handle == IntPtr.Zero)
|
||||
{
|
||||
this._enqueuedLocationChangeNotification = (view.Id, view.Title, activeClientTitle, view.ThumbnailLocation, ThumbnailManager.DefaultLocationChangeNotificationDelay);
|
||||
this._enqueuedLocationChangeNotification = (view.Id, view.Title, activeClientTitle, view.ThumbnailLocation, ThumbnailManager.DEFAULT_LOCATION_CHANGE_NOTIFICATION_DELAY);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -617,12 +616,12 @@ namespace EveOPreview.Services
|
||||
if ((this._enqueuedLocationChangeNotification.Handle == view.Id) &&
|
||||
(this._enqueuedLocationChangeNotification.ActiveClient == activeClientTitle))
|
||||
{
|
||||
this._enqueuedLocationChangeNotification.Delay = ThumbnailManager.DefaultLocationChangeNotificationDelay;
|
||||
this._enqueuedLocationChangeNotification.Delay = ThumbnailManager.DEFAULT_LOCATION_CHANGE_NOTIFICATION_DELAY;
|
||||
return;
|
||||
}
|
||||
|
||||
this.RaiseThumbnailLocationUpdatedNotification(this._enqueuedLocationChangeNotification.Title, activeClientTitle, this._enqueuedLocationChangeNotification.Location);
|
||||
this._enqueuedLocationChangeNotification = (view.Id, view.Title, activeClientTitle, view.ThumbnailLocation, ThumbnailManager.DefaultLocationChangeNotificationDelay);
|
||||
this.RaiseThumbnailLocationUpdatedNotification(this._enqueuedLocationChangeNotification.Title);
|
||||
this._enqueuedLocationChangeNotification = (view.Id, view.Title, activeClientTitle, view.ThumbnailLocation, ThumbnailManager.DEFAULT_LOCATION_CHANGE_NOTIFICATION_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -651,9 +650,9 @@ namespace EveOPreview.Services
|
||||
}
|
||||
}
|
||||
|
||||
private async void RaiseThumbnailLocationUpdatedNotification(string title, string activeClient, Point location)
|
||||
private async void RaiseThumbnailLocationUpdatedNotification(string title)
|
||||
{
|
||||
if (string.IsNullOrEmpty(title) || (title == ThumbnailManager.DefaultClientTitle))
|
||||
if (string.IsNullOrEmpty(title) || (title == ThumbnailManager.DEFAULT_CLIENT_TITLE))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -665,15 +664,15 @@ namespace EveOPreview.Services
|
||||
// TODO Move to a service (?)
|
||||
private bool IsManageableThumbnail(IThumbnailView view)
|
||||
{
|
||||
return view.Title != ThumbnailManager.DefaultClientTitle;
|
||||
return view.Title != ThumbnailManager.DEFAULT_CLIENT_TITLE;
|
||||
}
|
||||
|
||||
// Quick sanity check that the window is not minimized
|
||||
private bool IsValidWindowPosition(int letf, int top, int width, int height)
|
||||
{
|
||||
return (letf > ThumbnailManager.WindowPositionThresholdLow) && (letf < ThumbnailManager.WindowPositionThresholdHigh)
|
||||
&& (top > ThumbnailManager.WindowPositionThresholdLow) && (top < ThumbnailManager.WindowPositionThresholdHigh)
|
||||
&& (width > ThumbnailManager.WindowSizeThreshold) && (height > ThumbnailManager.WindowSizeThreshold);
|
||||
return (letf > ThumbnailManager.WINDOW_POSITION_THRESHOLD_LOW) && (letf < ThumbnailManager.WINDOW_POSITION_THRESHOLD_HIGH)
|
||||
&& (top > ThumbnailManager.WINDOW_POSITION_THRESHOLD_LOW) && (top < ThumbnailManager.WINDOW_POSITION_THRESHOLD_HIGH)
|
||||
&& (width > ThumbnailManager.WINDOW_SIZE_THRESHOLD) && (height > ThumbnailManager.WINDOW_SIZE_THRESHOLD);
|
||||
}
|
||||
}
|
||||
}
|
@@ -10,7 +10,7 @@ namespace EveOPreview.View
|
||||
public partial class ThumbnailView : Form, IThumbnailView
|
||||
{
|
||||
#region Private constants
|
||||
private const int ResizeEventTimeout = 500;
|
||||
private const int RESIZE_EVENT_TIMEOUT = 500;
|
||||
#endregion
|
||||
|
||||
#region Private fields
|
||||
@@ -388,7 +388,7 @@ namespace EveOPreview.View
|
||||
{
|
||||
// Workaround for WinForms issue with the Resize event being fired with inconsistent ClientSize value
|
||||
// Any Resize events fired before this timestamp will be ignored
|
||||
this._suppressResizeEventsTimestamp = DateTime.UtcNow.AddMilliseconds(ThumbnailView.ResizeEventTimeout);
|
||||
this._suppressResizeEventsTimestamp = DateTime.UtcNow.AddMilliseconds(ThumbnailView.RESIZE_EVENT_TIMEOUT);
|
||||
}
|
||||
|
||||
#region GUI events
|
||||
|
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using EveOPreview.UI;
|
||||
|
||||
namespace EveOPreview.View
|
||||
{
|
||||
|
Reference in New Issue
Block a user