Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions FreshTools/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.7.3.0")]
[assembly: AssemblyFileVersion("0.7.3.0")]
[assembly: AssemblyVersion("0.7.4.0")]
[assembly: AssemblyFileVersion("0.7.4.0")]
15 changes: 14 additions & 1 deletion FreshTools/code/FreshTools.cs
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,9 @@ static void Main(string[] args)
public void LoadConfig()
{
settingsFile = new VariablesFile(configFilePath, null, false);
UpdateConfigFile();
VariableLibrary vars = settingsFile.variables;

//load variables
WindowManager.LoadSnapSizes(settingsFile);
WindowManager.LoadHotKeys(settingsFile);
Expand All @@ -149,6 +150,18 @@ public void LoadConfig()
SaveConfig();
}

public void UpdateConfigFile()
{
//attempt to fix script file
//rename old variables to match
settingsFile = new VariablesFile(configFilePath, null, false);
settingsFile.RenameVariable("HotKey_DecreaseWindowTranspancy", "HotKey_DecreaseWindowTransparency");
settingsFile.RenameVariable("HotKey_IncreaseWindowTranspancy", "HotKey_IncreaseWindowTransparency");

//remove dead variables

}

/// <summary>
/// Make sure config variables that can be changed are updated in config file
/// </summary>
Expand Down
2 changes: 2 additions & 0 deletions FreshTools/code/Scripting/VariableLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@ public class VariableLibrary : IEnumerable
private VariablesComparator variablesComparator;
private bool variableListSorted = true;
private Variable searchDummy;
public readonly bool CaseSensitive;

public VariableLibrary(bool caseSensitive)
{
this.CaseSensitive = caseSensitive;
variablesComparator = new VariablesComparator(caseSensitive);
variables = new List<Variable>();
}
Expand Down
42 changes: 40 additions & 2 deletions FreshTools/code/Scripting/VariablesFile.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.IO;

namespace FreshTools
Expand Down Expand Up @@ -66,9 +67,46 @@ public void LoadFile(string fileName)
streamReader.Close();
}
Profiler.Stop();
}
}

public void RenameVariable(string oldName, string newName)
{
for (int i = 0; i < lines.Count; i++)
{
try
{
string varName = lines[i].Content;
if (varName == null || varName.Trim().Length == 0 || varName.Substring(0, 2) == "//")
continue;
varName = varName.Replace("var ", "").Trim();
varName = varName.Substring(0, varName.IndexOf("=")).Trim();
StringComparison sc = StringComparison.CurrentCulture;
if (variables.CaseSensitive)
sc = StringComparison.CurrentCultureIgnoreCase;

if (varName.Equals(oldName, sc))
{
variables.RemoveVariable(oldName);

if (newName != null)
{
//TODO not sure this should properly recursively scan through other script files.
lines[i] = new ScriptLine("var " + newName + " = " + lines[i].Content.Substring(lines[i].Content.IndexOf("=")+1), this, parent);
variables.Add(lines[i].Variable);
}
else//remove variable
lines.RemoveAt(i--);
break;
}
}
catch (ArgumentOutOfRangeException) { }
}
}

public void RemoveVariable(string name)
{
RenameVariable(name, null);
}

//preserve comments and such by preserving all original text... not done
public string SaveString()
Expand Down
3 changes: 2 additions & 1 deletion FreshTools/code/Systems/MouseListener.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,8 @@ private static void ConsumeKeyAsync()
Thread.Sleep(3);
}
var item = queue.Dequeue();
if (item is bool) break;
if (item is bool)
break;

if(item!=null)
MListener_MouseEvent(item as RawMouseEventArgs);
Expand Down
43 changes: 21 additions & 22 deletions FreshTools/code/Systems/WindowManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ public static class WindowManager
//alpha control variables
private static IntPtr lastWindowAlphaHandle = IntPtr.Zero;
private static byte lastWindowAlpha = 0;
private const byte WindowAlphaIncrement = 32;
private const byte MinWindowAlpha = 32;
private const byte WindowAlphaIncrement = 16;
private const byte MinWindowAlpha = 16;

#region Setup and teardown
static WindowManager()
Expand Down Expand Up @@ -254,7 +254,6 @@ public static void LoadHotKeys(VariablesFile settingsFile)
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_RestoreLayout3", "|^!D3").String, out hk))
snapHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, RestoreLayout3));
//corner move hotkeys - with defaults
//if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_MoveActiveWindowToBottomLeft", "|^+G").String, out hk))
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_MoveActiveWindowToBottomLeft", "|^!End").String, out hk))
snapHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, MoveActiveWindowToBottomLeft));
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_MoveActiveWindowToBottomRight", "|^!PageDown").String, out hk))
Expand All @@ -263,8 +262,8 @@ public static void LoadHotKeys(VariablesFile settingsFile)
snapHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, MoveActiveWindowToTopLeft));
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_MoveActiveWindowToTopRight", "|^!PageUp").String, out hk))
snapHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, MoveActiveWindowToTopRight));
//if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_MoveActiveWindowToCenter", "|^!+NumPad5").String, out hk)) //broken because of shift numpad
// snapHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, MoveActiveWindowToTopRight));
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_MoveActiveWindowToCenter", "|^!Multiply").String, out hk))
snapHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, MoveActiveWindowToCenter));

//altsnap hotkeys - with defaults
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_Alt_SnapActiveWindowToBottomLeft", "|^!Oemcomma").String, out hk))
Expand All @@ -291,10 +290,10 @@ public static void LoadHotKeys(VariablesFile settingsFile)
miscHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, MoveActiveWindowToLeftScreen));
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_MoveActiveWindowToRightScreen", "|^+S").String, out hk))
miscHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, MoveActiveWindowToRightScreen));
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_IncreaseWindowTranspancy", "^!Add").String, out hk))
miscHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, IncreaseWindowTranspancy));
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_DecreaseWindowTranspancy", "^!Subtract").String, out hk))
miscHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, DecreaseWindowTranspancy));
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_IncreaseWindowTransparency", "^!Add").String, out hk))
miscHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, IncreaseWindowTransparency));
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_DecreaseWindowTransparency", "^!Subtract").String, out hk))
miscHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, DecreaseWindowTransparency));
if (HotKey.TryParseHotKey(settingsFile.variables.GetVariable("HotKey_SendActiveWindowToBack", "|^!W").String, out hk))
miscHotKeys.Add(new HotKey(hk.Modifiers, hk.Key, SendActiveWindowToBack));

Expand Down Expand Up @@ -595,7 +594,7 @@ private static void MoveActiveWindowTo(int x, int y, int newWidth, int newHeight
}
}

private static void SetWindowTransparancy(int d)
private static void SetWindowTransparency(int d)
{
byte a;
IntPtr handle = GetForegroundWindow();
Expand Down Expand Up @@ -623,7 +622,7 @@ private static void SetWindowTransparancy(int d)

//Enable extended layered style on window if not enabled
SetWindowLong(handle, GWL_EXSTYLE, GetWindowLong(handle, GWL_EXSTYLE) | WS_EX_LAYERED);
//set window transparency
//set window Transparency
SetLayeredWindowAttributes(handle, 0, a, LWA_ALPHA);

lastWindowAlpha = a;
Expand Down Expand Up @@ -729,7 +728,7 @@ private static void SnapActiveWindow(SnapDirection dir)
}


private static void MoveActiveWindowToCorner(SnapDirection dir)
private static void MoveActiveWindowTo(SnapDirection dir)
{
//keep window size and move to a given corner or center
if (!(dir == SnapDirection.TopLeft || dir == SnapDirection.TopRight || dir == SnapDirection.BottomLeft || dir == SnapDirection.BottomRight || dir == SnapDirection.Center))
Expand Down Expand Up @@ -807,30 +806,30 @@ public static void SnapActiveWindowToBottomRight(object o, HotKeyEventArgs args)
}
#endregion

#region Move active window to all 4 corners
#region Move active window to all 4 corners & center
public static void MoveActiveWindowToTopLeft(object o, HotKeyEventArgs args)
{
MoveActiveWindowToCorner(SnapDirection.TopLeft);
MoveActiveWindowTo(SnapDirection.TopLeft);
}

public static void MoveActiveWindowToTopRight(object o, HotKeyEventArgs args)
{
MoveActiveWindowToCorner(SnapDirection.TopRight);
MoveActiveWindowTo(SnapDirection.TopRight);
}

public static void MoveActiveWindowToBottomLeft(object o, HotKeyEventArgs args)
{
MoveActiveWindowToCorner(SnapDirection.BottomLeft);
MoveActiveWindowTo(SnapDirection.BottomLeft);
}

public static void MoveActiveWindowToBottomRight(object o, HotKeyEventArgs args)
{
MoveActiveWindowToCorner(SnapDirection.BottomRight);
MoveActiveWindowTo(SnapDirection.BottomRight);
}

public static void MoveActiveWindowToCenter(object o, HotKeyEventArgs args)
{
MoveActiveWindowToCorner(SnapDirection.Center);
MoveActiveWindowTo(SnapDirection.Center);
}
#endregion

Expand All @@ -839,14 +838,14 @@ public static void SendActiveWindowToBack(object sender = null, HotKeyEventArgs
SendActiveWindowToBack();
}

public static void IncreaseWindowTranspancy(object sender = null, HotKeyEventArgs e = null)
public static void IncreaseWindowTransparency(object sender = null, HotKeyEventArgs e = null)
{
SetWindowTransparancy(1);
SetWindowTransparency(1);
}

public static void DecreaseWindowTranspancy(object sender = null, HotKeyEventArgs e = null)
public static void DecreaseWindowTransparency(object sender = null, HotKeyEventArgs e = null)
{
SetWindowTransparancy(-1);
SetWindowTransparency(-1);
}

public static void SaveLayout1(object sender = null, HotKeyEventArgs e = null)
Expand Down
3 changes: 2 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Fresh Tools
### Description
v.0.7.3
v.0.7.4

This is a collection of tools and code archives for doing usefull stuff that can be controlled via notification icon.

Expand Down Expand Up @@ -40,6 +40,7 @@ Snap | CTRL ALT Home | Move window to top left corner
Snap | CTRL ALT PageUp | Move window to top right corner
Snap | CTRL ALT End | Move window to bottom left corner
Snap | CTRL ALT PageDown | Move window to bottom right corner
Snap | CTRL ALT Multiply | Move window to Center
Snap Alt | CTRL ALT comma | Snap window to bottom left corner
Snap Alt | CTRL ALT period | Snap window to bottom
Snap Alt | CTRL ALT slash | Snap window to bottom right corner
Expand Down