From d5e5736d517c14512c066965587beeca5ae79cf0 Mon Sep 17 00:00:00 2001 From: CreepyCrafter24 <33260128+CreepyCrafter24@users.noreply.github.com> Date: Sun, 8 Mar 2020 13:55:21 +0100 Subject: [PATCH] Switch to .NET Core --- .idea/.idea.Resizor/.idea/.gitignore | 2 + .idea/.idea.Resizor/.idea/encodings.xml | 4 + Resizor.sln | 6 - Resizor/Immediate Resize.Designer.cs | 4 +- Resizor/Immediate Resize.cs | 140 +++++++++++------------- Resizor/Program.cs | 140 +++++++++++------------- Resizor/Properties/AssemblyInfo.cs | 3 +- Resizor/Resizor.csproj | 101 ++--------------- Resizor/SettingsForm.cs | 39 +++---- Resizor/WindowSizeSetter.cs | 19 ++-- Resizor/packages.config | 4 + 11 files changed, 180 insertions(+), 282 deletions(-) create mode 100644 .idea/.idea.Resizor/.idea/.gitignore create mode 100644 .idea/.idea.Resizor/.idea/encodings.xml create mode 100644 Resizor/packages.config diff --git a/.idea/.idea.Resizor/.idea/.gitignore b/.idea/.idea.Resizor/.idea/.gitignore new file mode 100644 index 0000000..0110b99 --- /dev/null +++ b/.idea/.idea.Resizor/.idea/.gitignore @@ -0,0 +1,2 @@ +# Default ignored files +/workspace.xml \ No newline at end of file diff --git a/.idea/.idea.Resizor/.idea/encodings.xml b/.idea/.idea.Resizor/.idea/encodings.xml new file mode 100644 index 0000000..df87cf9 --- /dev/null +++ b/.idea/.idea.Resizor/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/Resizor.sln b/Resizor.sln index 786a39c..faf7b86 100644 --- a/Resizor.sln +++ b/Resizor.sln @@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.29230.47 MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Resizor", "Resizor\Resizor.csproj", "{EED8B478-D539-41D2-9A39-8349099B298A}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "W32", "..\CC-Functions\W32\W32.csproj", "{23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}" -EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -17,10 +15,6 @@ Global {EED8B478-D539-41D2-9A39-8349099B298A}.Debug|Any CPU.Build.0 = Debug|Any CPU {EED8B478-D539-41D2-9A39-8349099B298A}.Release|Any CPU.ActiveCfg = Release|Any CPU {EED8B478-D539-41D2-9A39-8349099B298A}.Release|Any CPU.Build.0 = Release|Any CPU - {23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}.Debug|Any CPU.Build.0 = Debug|Any CPU - {23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}.Release|Any CPU.ActiveCfg = Release|Any CPU - {23DE4AE0-5075-4CCC-8440-4D131CA0FBBA}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Resizor/Immediate Resize.Designer.cs b/Resizor/Immediate Resize.Designer.cs index c167cee..b775b19 100644 --- a/Resizor/Immediate Resize.Designer.cs +++ b/Resizor/Immediate Resize.Designer.cs @@ -1,6 +1,6 @@ namespace Resizor { - partial class immResize + partial class ImmResize { /// /// Required designer variable. @@ -55,7 +55,7 @@ this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None; this.MaximizeBox = false; this.MinimizeBox = false; - this.Name = "immResize"; + this.Name = "ImmResize"; this.Opacity = 0.5D; this.ShowIcon = false; this.ShowInTaskbar = false; diff --git a/Resizor/Immediate Resize.cs b/Resizor/Immediate Resize.cs index b99cd42..0a04570 100644 --- a/Resizor/Immediate Resize.cs +++ b/Resizor/Immediate Resize.cs @@ -1,47 +1,49 @@ using System; -using System.Data; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Windows.Forms; using CC_Functions.W32; +using CC_Functions.W32.Hooks; using Resizor.Properties; namespace Resizor { - public partial class immResize : Form + public partial class ImmResize : Form { - bool down; - Point startP; - Wnd32 window; - Rectangle prevR; - Rectangle screen = Screen.PrimaryScreen.WorkingArea; - public immResize() + private readonly Wnd32 _window; + private bool _down; + private Rectangle _prevR; + private Rectangle _screen = Screen.PrimaryScreen.WorkingArea; + private Point _startP; + + public ImmResize() { - prevR = new Rectangle(); - window = Wnd32.foreground(); + _prevR = new Rectangle(); + _window = Wnd32.Foreground; InitializeComponent(); - Program.kh.OnKeyPress += onKeyDown; - Rectangle tmp = window.position; + Program.Kh.OnKeyPress += OnKeyDown; + Rectangle tmp = _window.Position; forcePos.Location = new Point((tmp.X + (tmp.Width / 2)) - (forcePos.Width / 2), tmp.Y); - forcePos.Checked = Program.ctx.windowSizeSetters.Where(Window => Window.Window == window).ToArray().Length > 0; + forcePos.Checked = Program.Ctx.WindowSizeSetters.Where(s => s.Window == _window).ToArray().Length > 0; } - private void onKeyDown(KeyboardHookEventArgs _args) + private void OnKeyDown(KeyboardHookEventArgs args) { - if (_args.Key == Keys.Escape) + if (args.Key == Keys.Escape) Close(); } - private void ImmResize_FormClosed(object sender, FormClosedEventArgs e) => Program.kh.OnKeyPress -= onKeyDown; + private void ImmResize_FormClosed(object sender, FormClosedEventArgs e) => Program.Kh.OnKeyPress -= OnKeyDown; private void Form1_Load(object sender, EventArgs e) { - Wnd32 self = Wnd32.fromForm(this); - self.MakeOverlay(); - if (self != window) - self.isForeground = true; + Wnd32 self = this.GetWnd32(); + self.Overlay = true; + if (self != _window) + self.IsForeground = true; } + private void Form1_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; @@ -51,69 +53,63 @@ namespace Resizor g.CompositingQuality = CompositingQuality.HighSpeed; g.PixelOffsetMode = PixelOffsetMode.None; PointF divisor = Settings.Default.ResizeDividor; - Rectangle rect; - if (down) - rect = FRect(); - else - rect = CRect(); + Rectangle rect = _down ? FRect() : CRect(); g.FillRectangle(new SolidBrush(Color.LightBlue), rect); Pen gridPen = new Pen(Color.Black, 2); - PointF div = getDiv(); - for (int x = 0; x < divisor.X; x++) - { - g.DrawLine(gridPen, x * div.X, 0, x * div.X, screen.Height); - } - for (int y = 0; y < divisor.Y; y++) - { - g.DrawLine(gridPen, 0, y * div.Y, screen.Width, y * div.Y); - } + PointF div = GetDiv(); + for (int x = 0; x < divisor.X; x++) g.DrawLine(gridPen, x * div.X, 0, x * div.X, _screen.Height); + for (int y = 0; y < divisor.Y; y++) g.DrawLine(gridPen, 0, y * div.Y, _screen.Width, y * div.Y); g.DrawRectangle(new Pen(Color.Blue, 2), rect); - g.DrawRectangle(new Pen(Color.Red, 2), window.position); + g.DrawRectangle(new Pen(Color.Red, 2), _window.Position); } - PointF getDiv() => new PointF(screen.Width / Settings.Default.ResizeDividor.X, screen.Height / Settings.Default.ResizeDividor.Y); - Rectangle CRect() => p2r(f2s(MousePosition, getDiv()), c2s(MousePosition, getDiv())); - Rectangle FRect() + + private PointF GetDiv() => new PointF(_screen.Width / (float) Settings.Default.ResizeDividor.X, + _screen.Height / (float) Settings.Default.ResizeDividor.Y); + + private Rectangle CRect() => P2R(F2S(MousePosition, GetDiv()), C2S(MousePosition, GetDiv())); + + private Rectangle FRect() { - Point min = f2s(new Point(Math.Min(MousePosition.X, startP.X), Math.Min(MousePosition.Y, startP.Y)), getDiv()); - Point max = c2s(new Point(Math.Max(MousePosition.X, startP.X), Math.Max(MousePosition.Y, startP.Y)), getDiv()); - return p2r(min, max); + Point min = F2S(new Point(Math.Min(MousePosition.X, _startP.X), Math.Min(MousePosition.Y, _startP.Y)), + GetDiv()); + Point max = C2S(new Point(Math.Max(MousePosition.X, _startP.X), Math.Max(MousePosition.Y, _startP.Y)), + GetDiv()); + return P2R(min, max); } - Point f2s(Point p, PointF step) => new Point(f2s(p.X, step.X), f2s(p.Y, step.Y)); - Point c2s(Point p, PointF step) => new Point(c2s(p.X, step.X), c2s(p.Y, step.Y)); - Rectangle p2r(Point p1, Point p2) => new Rectangle(Math.Min(p1.X, p2.X), Math.Min(p1.Y, p2.Y), Math.Abs(p1.X - p2.X), Math.Abs(p1.Y - p2.Y)); - int f2s(int f, double step) => (int)d2f(Math.Floor(f / step) * step); - int c2s(int f, double step) => (int)d2f(Math.Ceiling(f / step) * step); - float d2f(double f) + + private static Point F2S(Point p, PointF step) => new Point(F2S(p.X, step.X), F2S(p.Y, step.Y)); + private static Point C2S(Point p, PointF step) => new Point(C2S(p.X, step.X), C2S(p.Y, step.Y)); + + private static Rectangle P2R(Point p1, Point p2) => new Rectangle(Math.Min(p1.X, p2.X), Math.Min(p1.Y, p2.Y), + Math.Abs(p1.X - p2.X), Math.Abs(p1.Y - p2.Y)); + + private static int F2S(int f, double step) => (int) D2F(Math.Floor(f / step) * step); + private static int C2S(int f, double step) => (int) D2F(Math.Ceiling(f / step) * step); + + private static float D2F(double f) { - float result = (float)f; - if (float.IsPositiveInfinity(result)) - return float.MaxValue; - else if (float.IsNegativeInfinity(result)) - return float.MinValue; - return result; + float result = (float) f; + return float.IsPositiveInfinity(result) ? float.MaxValue : + float.IsNegativeInfinity(result) ? float.MinValue : result; } private void Form1_MouseDown(object sender, MouseEventArgs e) { - down = true; - startP = MousePosition; + _down = true; + _startP = MousePosition; } private void Form1_MouseMove(object sender, MouseEventArgs e) { - Rectangle rect; - if (down) - rect = FRect(); - else - rect = CRect(); - if (prevR != rect) + Rectangle rect = _down ? FRect() : CRect(); + if (_prevR != rect) Invalidate(); - prevR = rect; + _prevR = rect; } private void Form1_MouseUp(object sender, MouseEventArgs e) { - window.position = FRect(); + _window.Position = FRect(); Close(); } @@ -121,20 +117,16 @@ namespace Resizor { if (forcePos.Checked) { - if (Program.ctx.windowSizeSetters.Where(Window => Window.Window == window).ToArray().Length == 0) - { - WindowSizeSetter.make(window, window.position); - Close(); - } + if (Program.Ctx.WindowSizeSetters.Any(s => s.Window == _window)) return; + WindowSizeSetter.Make(_window, _window.Position); + Close(); } else { - if (Program.ctx.windowSizeSetters.Where(Window => Window.Window == window).ToArray().Length > 0) - { - WindowSizeSetter.TryRemove(window); - Close(); - } + if (Program.Ctx.WindowSizeSetters.All(s => s.Window != _window)) return; + WindowSizeSetter.TryRemove(_window); + Close(); } } } -} +} \ No newline at end of file diff --git a/Resizor/Program.cs b/Resizor/Program.cs index 6491cc2..af7e4fb 100644 --- a/Resizor/Program.cs +++ b/Resizor/Program.cs @@ -6,112 +6,102 @@ using System.Security.AccessControl; using System.Security.Principal; using System.Threading; using System.Windows.Forms; -using CC_Functions.W32; +using CC_Functions.W32.Hooks; using Resizor.Properties; using Timer = System.Windows.Forms.Timer; namespace Resizor { - static class Program + internal static class Program { - public static KeyboardHook kh; - public static NIApplicationContext ctx; - public static immResize rez; + public static KeyboardHook Kh; + public static NiApplicationContext Ctx; + private static ImmResize _rez; + + private static NotifyIcon _notifyIcon; + [STAThread] - static void Main() + private static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); - string appGuid = ((GuidAttribute)Assembly.GetExecutingAssembly().GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value.ToString(); - string mutexId = string.Format("Global\\{{{0}}}", appGuid); - bool createdNew; - var allowEveryoneRule = new MutexAccessRule(new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, AccessControlType.Allow); - var securitySettings = new MutexSecurity(); + string appGuid = ((GuidAttribute) Assembly.GetExecutingAssembly() + .GetCustomAttributes(typeof(GuidAttribute), false).GetValue(0)).Value; + MutexAccessRule allowEveryoneRule = new MutexAccessRule( + new SecurityIdentifier(WellKnownSidType.WorldSid, null), MutexRights.FullControl, + AccessControlType.Allow); + MutexSecurity securitySettings = new MutexSecurity(); securitySettings.AddAccessRule(allowEveryoneRule); - using (var mutex = new Mutex(false, mutexId, out createdNew, securitySettings)) + using Mutex mutex = new Mutex(false, $"Global\\{{{appGuid}}}", out bool _); + bool hasHandle = false; + try { - var hasHandle = false; try { - try - { - hasHandle = mutex.WaitOne(5000, false); - if (hasHandle == false) - throw new TimeoutException("Timeout waiting for exclusive access"); - } - catch (AbandonedMutexException) - { -#if DEBUG - Console.WriteLine("Mutex abandoned"); -#endif - hasHandle = true; - } - notifyIcon = new NotifyIcon(); - ContextMenu contextMenu = new ContextMenu(); - MenuItem settings = new MenuItem(); - MenuItem exititem = new MenuItem(); - contextMenu.MenuItems.AddRange(new MenuItem[] { settings, exititem }); - settings.Index = 0; - settings.Text = "Settings"; - settings.Click += new EventHandler(openSettings); - exititem.Index = 1; - exititem.Text = "Exit"; - exititem.Click += new EventHandler(exit); - notifyIcon.Icon = Resources.Resizor; - notifyIcon.Text = "Resizor"; - notifyIcon.ContextMenu = contextMenu; - notifyIcon.Visible = true; - kh = new KeyboardHook(); - kh.OnKeyPress += keyDown; - ctx = new NIApplicationContext(); - Application.Run(ctx); - kh.Dispose(); - notifyIcon.Visible = false; + hasHandle = mutex.WaitOne(5000, false); + if (hasHandle == false) + throw new TimeoutException("Timeout waiting for exclusive access"); } - finally + catch (AbandonedMutexException) { - if (hasHandle) - mutex.ReleaseMutex(); +#if DEBUG + Console.WriteLine("Mutex abandoned"); +#endif + hasHandle = true; } + _notifyIcon = new NotifyIcon(); + ContextMenuStrip contextMenu = new ContextMenuStrip(); + contextMenu.Items.Add("Settings").Click += OpenSettings; + contextMenu.Items.Add("Exit").Click += Exit; + _notifyIcon.Icon = Resources.Resizor; + _notifyIcon.Text = "Resizor"; + _notifyIcon.ContextMenuStrip = contextMenu; + _notifyIcon.Visible = true; + Kh = new KeyboardHook(); + Kh.OnKeyPress += KeyDown; + Ctx = new NiApplicationContext(); + Application.Run(Ctx); + Kh.Dispose(); + _notifyIcon.Visible = false; + } + finally + { + if (hasHandle) + mutex.ReleaseMutex(); } } - private static void keyDown(KeyboardHookEventArgs e) + private static void KeyDown(KeyboardHookEventArgs e) { - if (e.Key == Settings.Default.ImmediateResizeKey && (rez == null || rez.IsDisposed)) - { - rez = new immResize(); - rez.Show(); - } + if (e.Key != Settings.Default.ImmediateResizeKey || (_rez != null && !_rez.IsDisposed)) return; + _rez = new ImmResize(); + _rez.Show(); } - private static NotifyIcon notifyIcon; - private static void openSettings(object sender, EventArgs e) => new SettingsForm().Show(); - private static void exit(object Sender, EventArgs e) => Application.Exit(); - public class NIApplicationContext : ApplicationContext + private static void OpenSettings(object sender, EventArgs e) => new SettingsForm().Show(); + private static void Exit(object sender, EventArgs e) => Application.Exit(); + + public class NiApplicationContext : ApplicationContext { - public List windowSizeSetters = new List(); - Timer tim; - public NIApplicationContext() + public readonly List WindowSizeSetters = new List(); + + public NiApplicationContext() { - tim = new Timer(); - tim.Enabled = true; - tim.Interval = 100; - tim.Tick += tick; + Timer tim = new Timer {Enabled = true, Interval = 100}; + tim.Tick += Tick; } - private void tick(object sender, EventArgs e) + + private void Tick(object sender, EventArgs e) { List toRemove = new List(); - for (int i = 0; i < windowSizeSetters.Count; i++) - { - if (windowSizeSetters[i].Window.stillExists) - windowSizeSetters[i].Window.position = windowSizeSetters[i].Pos; + for (int i = 0; i < WindowSizeSetters.Count; i++) + if (WindowSizeSetters[i].Window.StillExists) + WindowSizeSetters[i].Window.Position = WindowSizeSetters[i].Pos; else toRemove.Add(i); - } for (int i = 0; i < toRemove.Count; i++) - windowSizeSetters.RemoveAt(toRemove[i]); + WindowSizeSetters.RemoveAt(toRemove[i]); } } } -} +} \ No newline at end of file diff --git a/Resizor/Properties/AssemblyInfo.cs b/Resizor/Properties/AssemblyInfo.cs index 87a4cd5..b8825e8 100644 --- a/Resizor/Properties/AssemblyInfo.cs +++ b/Resizor/Properties/AssemblyInfo.cs @@ -1,5 +1,4 @@ using System.Reflection; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; // General Information about an assembly is controlled through the following @@ -33,4 +32,4 @@ using System.Runtime.InteropServices; // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] [assembly: AssemblyVersion("1.0.0.1")] -[assembly: AssemblyFileVersion("1.0.0.1")] +[assembly: AssemblyFileVersion("1.0.0.1")] \ No newline at end of file diff --git a/Resizor/Resizor.csproj b/Resizor/Resizor.csproj index 6a1c1d1..628be91 100644 --- a/Resizor/Resizor.csproj +++ b/Resizor/Resizor.csproj @@ -1,106 +1,19 @@ - - - + - Debug - AnyCPU - {EED8B478-D539-41D2-9A39-8349099B298A} + netcoreapp3.1 WinExe - Resizor - Resizor - v4.7.2 - 512 - true - true - - - AnyCPU - true - full - false - bin\Debug\ - DEBUG;TRACE - prompt - 4 - - - AnyCPU - pdbonly - true - bin\Release\ - TRACE - prompt - 4 + false + true Resizor.ico - - - - - - - - - - - - - - - - Form - - - Immediate Resize.cs - - - - - Form - - - SettingsForm.cs - - - - Immediate Resize.cs - - - ResXFileCodeGenerator - Resources.Designer.cs - Designer - - - True - Resources.resx - True - - - SettingsForm.cs - - - SettingsSingleFileGenerator - Settings.Designer.cs - - - True - Settings.settings - True - - - - - - - {23de4ae0-5075-4ccc-8440-4d131ca0fbba} - W32 - + + + - \ No newline at end of file diff --git a/Resizor/SettingsForm.cs b/Resizor/SettingsForm.cs index acf2877..9c4bdc1 100644 --- a/Resizor/SettingsForm.cs +++ b/Resizor/SettingsForm.cs @@ -1,33 +1,34 @@ -using CC_Functions.W32; -using System; +using System; using System.Drawing; using System.Windows.Forms; -using Resizor.Properties; +using CC_Functions.W32.Hooks; using Microsoft.Win32; +using Resizor.Properties; namespace Resizor { public partial class SettingsForm : Form { - RegistryKey rkApp; - string appName = "Rasizor"; + private const string AppName = "Resizor"; + private readonly RegistryKey _rkApp; + public SettingsForm() { InitializeComponent(); - Program.kh = new KeyboardHook(); + Program.Kh = new KeyboardHook(); keySelectButton.Text = Settings.Default.ImmediateResizeKey.ToString(); keySelectButton.Tag = false; rowsSelect.Value = Settings.Default.ResizeDividor.Y; columnsSelect.Value = Settings.Default.ResizeDividor.X; - rkApp = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true); - startupBox.Checked = rkApp.GetValue(appName) != null; + _rkApp = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Run", true); + startupBox.Checked = _rkApp.GetValue(AppName) != null; } private void KeySelectButton_Click(object sender, EventArgs e) { - if ((bool)keySelectButton.Tag) + if ((bool) keySelectButton.Tag) { - Program.kh.OnKeyPress -= Hook_OnKeyPress; + Program.Kh.OnKeyPress -= Hook_OnKeyPress; keySelectButton.BackColor = SystemColors.Control; keySelectButton.Tag = false; keySelectButton.Text = Settings.Default.ImmediateResizeKey.ToString(); @@ -37,13 +38,13 @@ namespace Resizor keySelectButton.BackColor = Color.Red; keySelectButton.Text = "Cancel"; keySelectButton.Tag = true; - Program.kh.OnKeyPress += Hook_OnKeyPress; + Program.Kh.OnKeyPress += Hook_OnKeyPress; } } private void Hook_OnKeyPress(KeyboardHookEventArgs e) { - Program.kh.OnKeyPress -= Hook_OnKeyPress; + Program.Kh.OnKeyPress -= Hook_OnKeyPress; keySelectButton.BackColor = SystemColors.Control; if (e.Key != Keys.Escape) { @@ -57,7 +58,7 @@ namespace Resizor private void RowsSelect_ValueChanged(object sender, EventArgs e) { Point tmp = Settings.Default.ResizeDividor; - tmp.Y = (int)rowsSelect.Value; + tmp.Y = (int) rowsSelect.Value; Settings.Default.ResizeDividor = tmp; Settings.Default.Save(); } @@ -65,7 +66,7 @@ namespace Resizor private void ColumnsSelect_ValueChanged(object sender, EventArgs e) { Point tmp = Settings.Default.ResizeDividor; - tmp.X = (int)columnsSelect.Value; + tmp.X = (int) columnsSelect.Value; Settings.Default.ResizeDividor = tmp; Settings.Default.Save(); } @@ -75,16 +76,16 @@ namespace Resizor try { if (startupBox.Checked) - rkApp.SetValue(appName, Application.ExecutablePath.ToString()); + _rkApp.SetValue(AppName, Application.ExecutablePath); else - rkApp.DeleteValue(appName, false); - startupBox.Checked = rkApp.GetValue(appName) != null; + _rkApp.DeleteValue(AppName, false); + startupBox.Checked = _rkApp.GetValue(AppName) != null; } catch (Exception e1) { - startupBox.Checked = rkApp.GetValue(appName) != null; + startupBox.Checked = _rkApp.GetValue(AppName) != null; MessageBox.Show(e1.ToString(), "Failed"); } } } -} +} \ No newline at end of file diff --git a/Resizor/WindowSizeSetter.cs b/Resizor/WindowSizeSetter.cs index 0ad2b71..21dd2ac 100644 --- a/Resizor/WindowSizeSetter.cs +++ b/Resizor/WindowSizeSetter.cs @@ -8,40 +8,39 @@ namespace Resizor { public readonly Wnd32 Window; public Rectangle Pos; - WindowSizeSetter(Wnd32 window, Rectangle pos) + + private WindowSizeSetter(Wnd32 window, Rectangle pos) { Window = window; Pos = pos; } - public static void make(Wnd32 window, Rectangle pos) + public static void Make(Wnd32 window, Rectangle pos) { - WindowSizeSetter[] match = Program.ctx.windowSizeSetters.Where(Window => Window.Window == window).ToArray(); + WindowSizeSetter[] match = Program.Ctx.WindowSizeSetters.Where(s => s.Window == window).ToArray(); switch (match.Length) { case 0: - Program.ctx.windowSizeSetters.Add(new WindowSizeSetter(window, pos)); + Program.Ctx.WindowSizeSetters.Add(new WindowSizeSetter(window, pos)); break; case 1: match[0].Pos = pos; break; default: for (int i = 0; i < match.Length; i++) - { if (i == match.Length - 1) match[0].Pos = pos; else - Program.ctx.windowSizeSetters.Remove(match[i]); - } + Program.Ctx.WindowSizeSetters.Remove(match[i]); break; } } public static void TryRemove(Wnd32 window) { - WindowSizeSetter[] match = Program.ctx.windowSizeSetters.Where(Window => Window.Window == window).ToArray(); + WindowSizeSetter[] match = Program.Ctx.WindowSizeSetters.Where(s => s.Window == window).ToArray(); if (match.Length > 0) - Program.ctx.windowSizeSetters.RemoveAll(Window => Window.Window == window); + Program.Ctx.WindowSizeSetters.RemoveAll(s => s.Window == window); } } -} +} \ No newline at end of file diff --git a/Resizor/packages.config b/Resizor/packages.config new file mode 100644 index 0000000..905c4b8 --- /dev/null +++ b/Resizor/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file