[Feature] CodeBuity&Refactor #49, [Feature] Code review tool #10

This commit is contained in:
Markus Hofknecht 2020-03-23 12:32:47 +01:00
parent a59a38d3b7
commit 039fd92e26
21 changed files with 93 additions and 92 deletions

View file

@ -799,7 +799,7 @@ namespace SystemTrayMenu.Controls
// <summary>
// things to do when the selected tab is changed
// </summary>
class ListViewItemComparer : System.Collections.IComparer
private class ListViewItemComparer : System.Collections.IComparer
{
private int _intCol;
private bool _IsAscending = true;

View file

@ -12,7 +12,7 @@ using SystemTrayMenu.Helper;
namespace SystemTrayMenu.Controls
{
class AppContextMenu
internal class AppContextMenu
{
public event EventHandler ClickedChangeFolder;
public event EventHandler ClickedOpenLog;

View file

@ -9,7 +9,7 @@ using Timer = System.Windows.Forms.Timer;
namespace SystemTrayMenu
{
class MenuNotifyIcon : IDisposable
internal class MenuNotifyIcon : IDisposable
{
public event EventHandler HandleClick;
public event EventHandler ChangeFolder;
@ -17,12 +17,12 @@ namespace SystemTrayMenu
public event EventHandler Restart;
public event EventHandler Exit;
NotifyIcon notifyIcon = new NotifyIcon();
private NotifyIcon notifyIcon = new NotifyIcon();
private DateTime timeLoadingStart;
int threadsLoading = 0;
Timer load = new Timer();
int loadCount = 0, indexLoad = 0;
List<Icon> bitmapsLoading = new List<Icon>() { R.L010, R.L020, R.L030,
private int threadsLoading = 0;
private Timer load = new Timer();
private int loadCount = 0, indexLoad = 0;
private List<Icon> bitmapsLoading = new List<Icon>() { R.L010, R.L020, R.L030,
R.L040, R.L050, R.L060, R.L070, R.L080, R.L090, R.L100, R.L110, R.L120,
R.L130, R.L140, R.L150, R.L160, R.L170, R.L180};

View file

@ -42,8 +42,8 @@ namespace SystemTrayMenu
}
public int Level = 0;
FadeForm FadeForm = null;
bool autoResizeRowsDone = false;
private FadeForm FadeForm = null;
private bool autoResizeRowsDone = false;
public enum MenuType { Default, DisposedFake };
@ -67,7 +67,7 @@ namespace SystemTrayMenu
}
}
static void SetDoubleBuffer(Control ctl, bool DoubleBuffered)
private static void SetDoubleBuffer(Control ctl, bool DoubleBuffered)
{
typeof(Control).InvokeMember("DoubleBuffered",
BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.SetProperty,

View file

@ -37,10 +37,9 @@ namespace SystemTrayMenu.Controls
public string TargetFilePathOrig;
public string Text;
public int RowIndex;
WaitMenuOpen waitMenuOpen = new WaitMenuOpen();
Icon icon = null;
bool isDisposed = false;
private WaitMenuOpen waitMenuOpen = new WaitMenuOpen();
private Icon icon = null;
private bool isDisposed = false;
public RowData()
{
@ -153,7 +152,7 @@ namespace SystemTrayMenu.Controls
}
[DllImport("shell32.dll", CharSet = CharSet.Unicode)]
static extern int FindExecutable(string lpFile, string lpDirectory, [Out] StringBuilder lpResult);
private static extern int FindExecutable(string lpFile, string lpDirectory, [Out] StringBuilder lpResult);
private bool SetSln()
{
bool handled = false;

View file

@ -6,7 +6,7 @@ using SystemTrayMenu.Helper;
namespace SystemTrayMenu.Handler
{
class KeyboardInput : IDisposable
internal class KeyboardInput : IDisposable
{
public event EventHandler HotKeyPressed;
public event EventHandler ClosePressed;
@ -15,12 +15,11 @@ namespace SystemTrayMenu.Handler
public event EventHandler Cleared;
private Menu[] menus;
KeyboardHook hook = new KeyboardHook();
Timer timerKeySearch = new Timer();
private KeyboardHook hook = new KeyboardHook();
private Timer timerKeySearch = new Timer();
public int iRowKey = -1;
public int iMenuKey = 0;
string KeySearchString = string.Empty;
private string KeySearchString = string.Empty;
public bool InUse = false;

View file

@ -3,11 +3,11 @@ using Timer = System.Windows.Forms.Timer;
namespace SystemTrayMenu.Handler
{
class WaitFastLeave : IDisposable
internal class WaitFastLeave : IDisposable
{
public event EventHandler Leave;
Timer timerSecondLeaveCheck = new Timer();
private Timer timerSecondLeaveCheck = new Timer();
public WaitFastLeave()
{

View file

@ -3,14 +3,14 @@ using Timer = System.Windows.Forms.Timer;
namespace SystemTrayMenu.Handler
{
class WaitMenuOpen : IDisposable
internal class WaitMenuOpen : IDisposable
{
public event EventHandler DoOpen;
Timer waitOpen = new Timer();
bool waitedDone = false;
bool clicked = false;
bool menuLoaded = false;
private Timer waitOpen = new Timer();
private bool waitedDone = false;
private bool clicked = false;
private bool menuLoaded = false;
public WaitMenuOpen()
{

View file

@ -9,7 +9,7 @@ namespace SystemTrayMenu.Helper
{
public static event EventHandler BeforeRestarting;
static void Restart(string reason)
private static void Restart(string reason)
{
BeforeRestarting?.Invoke();
Log.Info($"Restart by '{reason}'");
@ -19,7 +19,7 @@ namespace SystemTrayMenu.Helper
}
[MethodImpl(MethodImplOptions.NoInlining)]
static string GetCurrentMethod()
private static string GetCurrentMethod()
{
var st = new StackTrace();
var sf = st.GetFrame(1);

View file

@ -7,7 +7,7 @@ namespace SystemTrayMenu.Helper
public class WindowToTop
{
[DllImport("user32.dll")]
static extern bool IsIconic(IntPtr hWnd);
private static extern bool IsIconic(IntPtr hWnd);
//DLL's for ForceForgroundWindow
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
@ -25,7 +25,7 @@ namespace SystemTrayMenu.Helper
[DllImport("user32.dll")]
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
const int SW_RESTORE = 9;
private const int SW_RESTORE = 9;
public static void ForceProcessToForeground(string processName)
{

View file

@ -22,12 +22,11 @@ namespace SystemTrayMenu
}
}
Timer timerFadeIn = new Timer();
Timer timerFadeOut = new Timer();
Timer timerFadeHalf = new Timer();
Form form = null;
bool stopFadeInByHalf = false;
private Timer timerFadeIn = new Timer();
private Timer timerFadeOut = new Timer();
private Timer timerFadeHalf = new Timer();
private Form form = null;
private bool stopFadeInByHalf = false;
public FadeForm(Form form)
{
@ -146,7 +145,7 @@ namespace SystemTrayMenu
private const uint SWP_NOACTIVATE = 0x0010;
[DllImport("user32.dll", EntryPoint = "SetWindowPos")]
static extern bool SetWindowPos(
private static extern bool SetWindowPos(
int hWnd, // Window handle
int hWndInsertAfter, // Placement-order handle
int X, // Horizontal position
@ -156,9 +155,9 @@ namespace SystemTrayMenu
uint uFlags); // Window positioning flags
[DllImport("user32.dll")]
static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
static void ShowInactiveTopmost(Form frm)
private static void ShowInactiveTopmost(Form frm)
{
ShowWindow(frm.Handle, SW_SHOWNOACTIVATE);
SetWindowPos(frm.Handle.ToInt32(), HWND_TOPMOST,

View file

@ -7,7 +7,7 @@ namespace SystemTrayMenu.Helper
{
public class FileIni
{
Dictionary<string, string> values;
private Dictionary<string, string> values;
public FileIni(string path)
{
values = File.ReadLines(path)

View file

@ -5,7 +5,7 @@ using System.Text;
namespace SystemTrayMenu
{
class LnkHelper
internal class LnkHelper
{
#region Signitures imported from http://pinvoke.net
@ -13,7 +13,7 @@ namespace SystemTrayMenu
internal static extern int SHGetFolderPath(IntPtr hwndOwner, int nFolder, IntPtr hToken, int dwFlags, StringBuilder lpszPath);
[Flags()]
enum SLGP_FLAGS
private enum SLGP_FLAGS
{
/// <summary>Retrieves the standard short (8.3 format) file name</summary>
SLGP_SHORTPATH = 0x1,
@ -24,7 +24,7 @@ namespace SystemTrayMenu
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
struct WIN32_FIND_DATAW
private struct WIN32_FIND_DATAW
{
public uint dwFileAttributes;
public long ftCreationTime;
@ -41,7 +41,7 @@ namespace SystemTrayMenu
}
[Flags()]
enum SLR_FLAGS
private enum SLR_FLAGS
{
/// <summary>
/// Do not display a dialog box if the link cannot be resolved. When SLR_NO_UI is set,
@ -76,7 +76,7 @@ namespace SystemTrayMenu
/// <summary>The IShellLink interface allows Shell links to be created, modified, and resolved</summary>
[ComImport(), InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("000214F9-0000-0000-C000-000000000046")]
interface IShellLinkW
private interface IShellLinkW
{
/// <summary>Retrieves the path and file name of a Shell link object</summary>
void GetPath([Out(), MarshalAs(UnmanagedType.LPWStr)] StringBuilder pszFile, int cchMaxPath, out WIN32_FIND_DATAW pfd, SLGP_FLAGS fFlags);
@ -149,8 +149,8 @@ namespace SystemTrayMenu
void GetCurFile([In, MarshalAs(UnmanagedType.LPWStr)] string ppszFileName);
}
const uint STGM_READ = 0;
const int MAX_PATH = 260;
private const uint STGM_READ = 0;
private const int MAX_PATH = 260;
// CLSID_ShellLink from ShlGuid.h
[

View file

@ -19,7 +19,7 @@ namespace SystemTrayMenu.Helper
/// </example>
public class IconReader
{
static ConcurrentDictionary<string, Icon> dictIconCache = new ConcurrentDictionary<string, Icon>();
private static ConcurrentDictionary<string, Icon> dictIconCache = new ConcurrentDictionary<string, Icon>();
/// <summary>
/// Options to specify the size of icons to return.

View file

@ -6,9 +6,9 @@ namespace SystemTrayMenu.Helper
{
internal static class FolderOptions
{
static bool hideHiddenEntries = false;
static bool hideSystemEntries = false;
static IShellDispatch4 iShellDispatch4 = null;
private static bool hideHiddenEntries = false;
private static bool hideSystemEntries = false;
private static IShellDispatch4 iShellDispatch4 = null;
internal static void Initialize()
{

View file

@ -8,7 +8,7 @@ namespace SystemTrayMenu.Helper
{
internal static class Log
{
static Logger log = new Logger("");
private static Logger log = new Logger("");
internal static void Initialize()
{
Logger.Start(new FileInfo(GetLogFilePath()));

View file

@ -5,17 +5,17 @@ namespace SystemTrayMenu
{
public delegate void EventHandler();
class MessageFilter : IMessageFilter
internal class MessageFilter : IMessageFilter
{
const int WM_MOUSELEAVE = 0x02A3;
const int WM_MOUSEMOVE = 0x0200;
const int WM_NCMOUSEMOVE = 0x00A0;
private const int WM_MOUSELEAVE = 0x02A3;
private const int WM_MOUSEMOVE = 0x0200;
private const int WM_NCMOUSEMOVE = 0x00A0;
public event EventHandler MouseLeave;
public event EventHandler MouseMove;
public event EventHandler ScrollBarMouseMove;
Point cursorPosition = new Point();
bool messageFilterAdded = false;
private Point cursorPosition = new Point();
private bool messageFilterAdded = false;
public bool PreFilterMessage(ref Message message)
{

View file

@ -15,14 +15,16 @@ namespace SystemTrayMenu.Helper
}
[DllImport("gdi32.dll")]
static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
enum DeviceCap
private static extern int GetDeviceCaps(IntPtr hdc, int nIndex);
private enum DeviceCap
{
VERTRES = 10,
DESKTOPVERTRES = 117,
// http://pinvoke.net/default.aspx/gdi32/GetDeviceCaps.html
}
static void CalculateScalingFactor()
private static void CalculateScalingFactor()
{
Graphics g = Graphics.FromHwnd(IntPtr.Zero);
IntPtr desktop = g.GetHdc();
@ -34,8 +36,9 @@ namespace SystemTrayMenu.Helper
}
[DllImport("user32.dll")]
static extern bool SetProcessDPIAware();
static void SetProcessDPIAwareWhenNecessary()
private static extern bool SetProcessDPIAware();
private static void SetProcessDPIAwareWhenNecessary()
{
if (Environment.OSVersion.Version.Major >= 6)
{

View file

@ -4,10 +4,10 @@ using System.Runtime.InteropServices;
namespace SystemTrayMenu.Helper
{
class WindowsExplorerSort : IComparer<string>
internal class WindowsExplorerSort : IComparer<string>
{
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode, ExactSpelling = true)]
static extern int StrCmpLogicalW(String x, String y);
private static extern int StrCmpLogicalW(String x, String y);
public int Compare(string x, string y)
{

View file

@ -6,10 +6,10 @@ using SystemTrayMenu.Helper;
namespace SystemTrayMenu
{
static class Program
internal static class Program
{
[STAThread]
static void Main()
private static void Main()
{
try
{

View file

@ -13,20 +13,21 @@ using SystemTrayMenu.Helper;
namespace SystemTrayMenu
{
class SystemTrayMenu : IDisposable
internal class SystemTrayMenu : IDisposable
{
enum OpenCloseState { Default, Opening, Closing };
OpenCloseState openCloseState = OpenCloseState.Default;
MessageFilter messageFilter = new MessageFilter();
MenuNotifyIcon menuNotifyIcon = null;
Menu[] menus = new Menu[MenuDefines.MenusMax];
BackgroundWorker worker = new BackgroundWorker();
Screen screen = Screen.PrimaryScreen;
WaitFastLeave fastLeave = new WaitFastLeave();
KeyboardInput keyboardInput;
DataGridView dgvFromLastMouseEvent = null;
DataGridViewCellEventArgs cellEventArgsFromLastMouseEvent = null;
int clicksInQueue = 0;
private enum OpenCloseState { Default, Opening, Closing };
private OpenCloseState openCloseState = OpenCloseState.Default;
private MessageFilter messageFilter = new MessageFilter();
private MenuNotifyIcon menuNotifyIcon = null;
private Menu[] menus = new Menu[MenuDefines.MenusMax];
private BackgroundWorker worker = new BackgroundWorker();
private Screen screen = Screen.PrimaryScreen;
private WaitFastLeave fastLeave = new WaitFastLeave();
private KeyboardInput keyboardInput;
private DataGridView dgvFromLastMouseEvent = null;
private DataGridViewCellEventArgs cellEventArgsFromLastMouseEvent = null;
private int clicksInQueue = 0;
public SystemTrayMenu()
{
@ -169,7 +170,7 @@ namespace SystemTrayMenu
fastLeave.Leave += FadeHalfOrOutIfNeeded;
}
void FadeInIfNeeded()
private void FadeInIfNeeded()
{
if (menus[0].Visible &&
!menus[0].IsFadingIn &&
@ -182,7 +183,7 @@ namespace SystemTrayMenu
}
}
void FadeHalfOrOutIfNeeded()
private void FadeHalfOrOutIfNeeded()
{
Point mousePosition = Control.MousePosition;
bool isMouseOnAnyMenu =
@ -215,7 +216,7 @@ namespace SystemTrayMenu
DisposeMenu(menus[0]);
}
void DisposeMenu(Menu menuToDispose)
private void DisposeMenu(Menu menuToDispose)
{
if (menuToDispose != null)
{
@ -231,7 +232,7 @@ namespace SystemTrayMenu
}
}
void DisposeWhenHidden(object sender, EventArgs e)
private void DisposeWhenHidden(object sender, EventArgs e)
{
Menu menuToDispose = (Menu)sender;
if (!menuToDispose.Visible)
@ -244,7 +245,7 @@ namespace SystemTrayMenu
}
}
void AdjustSubMenusLocationAndSize()
private void AdjustSubMenusLocationAndSize()
{
int heightMax = screen.Bounds.Height -
new Taskbar().Size.Height;
@ -282,7 +283,7 @@ namespace SystemTrayMenu
}
}
void OpenSubMenu(object sender, EventArgs e)
private void OpenSubMenu(object sender, EventArgs e)
{
RowData trigger = (RowData)sender;
Menu menuTriggered = trigger.SubMenu;
@ -318,7 +319,7 @@ namespace SystemTrayMenu
IsAnyMenuActive();
}
bool IsAnyMenuActive()
private bool IsAnyMenuActive()
{
bool isAnyMenuActive = Form.ActiveForm is Menu;
if (!isAnyMenuActive)
@ -623,12 +624,12 @@ namespace SystemTrayMenu
}
}
IEnumerable<Menu> Menus()
private IEnumerable<Menu> Menus()
{
return menus.Where(m => m != null && !m.IsDisposed);
}
void MenusFadeOut()
private void MenusFadeOut()
{
messageFilter.StopListening();
@ -642,7 +643,7 @@ namespace SystemTrayMenu
});
}
Menu CreateMenu(MenuData menuData, string title = null)
private Menu CreateMenu(MenuData menuData, string title = null)
{
Menu menu = new Menu();
if (title != null)