Skip to content

Commit

Permalink
Added documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
betsegaw committed Oct 28, 2014
1 parent 4bf3fae commit 65c4404
Show file tree
Hide file tree
Showing 6 changed files with 114 additions and 5 deletions.
18 changes: 15 additions & 3 deletions Window Walker/Window Walker/Components/InteropAndHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,9 @@ public enum ShowWindowCommands
ForceMinimize = 11
}

/// <summary>
/// The rendering policy to use for set window attribute
/// </summary>
[Flags]
public enum DwmNCRenderingPolicy
{
Expand All @@ -231,7 +234,9 @@ public enum DwmNCRenderingPolicy
Last
}


/// <summary>
/// Window attribute
/// </summary>
[Flags]
public enum DwmWindowAttribute
{
Expand All @@ -250,7 +255,9 @@ public enum DwmWindowAttribute
Last
}


/// <summary>
/// Flags for accessing the process in trying to get icon for the process
/// </summary>
[Flags]
public enum ProcessAccessFlags
{
Expand Down Expand Up @@ -406,6 +413,9 @@ public static WINDOWPLACEMENT Default
}
}

/// <summary>
/// Required pointless variables that we don't use in making a windows show
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
Expand Down Expand Up @@ -502,7 +512,9 @@ public override string ToString()
}
}


/// <summary>
/// Same as the RECT struct above
/// </summary>
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
Expand Down
8 changes: 8 additions & 0 deletions Window Walker/Window Walker/Components/OpenWindows.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class OpenWindows
/// </summary>
private List<Window> windows = new List<Window>();

/// <summary>
/// An instance of the class OpenWindows
/// </summary>
private static OpenWindows instance;

#endregion
Expand All @@ -47,6 +50,11 @@ public List<Window> Windows
get { return new List<Window>(windows); }
}

/// <summary>
/// An instance property of this class that makes sure that
/// the first instance gets created and that all the requests
/// end up at that one instance
/// </summary>
public static OpenWindows Instance
{
get
Expand Down
19 changes: 19 additions & 0 deletions Window Walker/Window Walker/Components/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,40 @@

namespace WindowWalker.Components
{
/// <summary>
/// Class that represents all the settings and
/// can be serialized into JSON for easy saving
/// </summary>
class Settings
{
/// <summary>
/// The version of the settings file
/// </summary>
public string Version { get; set; }

/// <summary>
/// A list of all the shortcuts
/// </summary>
public Dictionary<string, List<string>> Shortcuts { get; set; }

/// <summary>
/// The location of the search windows (the top left point)
/// </summary>
public Point WindowLocation { get; set; }

/// <summary>
/// Constructer to initialize some default values
/// </summary>
public Settings()
{
this.Version = string.Empty;
this.Shortcuts = new Dictionary<string,List<string>>();
this.WindowLocation = new Point() { X = 0, Y = 0 };
}

/// <summary>
/// Custom point class to ease storing a point
/// </summary>
public class Point
{
public double X { get; set; }
Expand Down
44 changes: 43 additions & 1 deletion Window Walker/Window Walker/Components/SettingsManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,29 @@ namespace WindowWalker.Components
/// </summary>
class SettingsManager
{
/// <summary>
/// The path to the shortcut file
/// </summary>
private static readonly string ShortcutsFile = Path.GetTempPath() + "WindowWalkerShortcuts.ini";

/// <summary>
/// Reference to a serializer for saving the settings
/// </summary>
private static readonly JavaScriptSerializer Serializer = new JavaScriptSerializer();

/// <summary>
/// An instance of the settings class representing the current settings
/// </summary>
public static Settings SettingsInstance = new Settings();

/// <summary>
/// Instance of the manager itself
/// </summary>
private static SettingsManager instance;


/// <summary>
/// Implements Singlton pattern
/// </summary>
public static SettingsManager Instance
{
get
Expand All @@ -35,6 +50,10 @@ public static SettingsManager Instance
}
}

/// <summary>
/// Static constructor
/// </summary>
/// <remarks>Not sure why we have this AND a singlton pattern</remarks>
static SettingsManager()
{
if (File.Exists(ShortcutsFile))
Expand All @@ -47,11 +66,22 @@ static SettingsManager()
}
}

/// <summary>
/// Contructor that does nothing?
/// </summary>
private SettingsManager()
{
return;
}

/// <summary>
/// Adds a shortcut to the settings
/// </summary>
/// <param name="before">what the user types</param>
/// <param name="after">what the resulting search string is going to be</param>
/// <returns>Returns true if it succeeds, false otherwise</returns>
/// <remarks>Proably not usefull to actually do the true/false return since
/// we can now have multiple shortcuts</remarks>
public bool AddShortcut(string before, string after)
{
if (!SettingsManager.SettingsInstance.Shortcuts.ContainsKey(before))
Expand All @@ -67,6 +97,13 @@ public bool AddShortcut(string before, string after)
return true;
}

/// <summary>
/// Removes a shortcut
/// </summary>
/// <param name="input">the input shortcut string</param>
/// <returns>true if it succeeds, false otherwise</returns>
/// <remarks>Probably has a bug since you can now a single input
/// mapping to multiple outputs</remarks>
public bool RemoveShortcut(string input)
{
if (!SettingsManager.SettingsInstance.Shortcuts.ContainsKey(input))
Expand All @@ -82,6 +119,11 @@ public bool RemoveShortcut(string input)
return true;
}

/// <summary>
/// Retrieves a shortcut and returns all possible mappings
/// </summary>
/// <param name="input">the input string for the shortcuts</param>
/// <returns>A list of all the shortcut strings that result from the user input</returns>
public List<string> GetShortcut(string input)
{
return (SettingsManager.SettingsInstance.Shortcuts.ContainsKey(input) ? SettingsManager.SettingsInstance.Shortcuts[input] : new List<string>());
Expand Down
14 changes: 14 additions & 0 deletions Window Walker/Window Walker/Components/Window.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ public String ClassName
}
}

/// <summary>
/// Represents the Window Icon for the specified window
/// </summary>
public ImageSource WindowIcon
{
get
Expand Down Expand Up @@ -236,11 +239,19 @@ public void SwitchToWindow()
InteropAndHelpers.FlashWindow(this.Hwnd, true);
}

/// <summary>
/// Converts the window name to string along with the process name
/// </summary>
/// <returns>The title of the window</returns>
public override string ToString()
{
return this.Title + " (" + this.ProcessName.ToUpper() + ")";
}

/// <summary>
/// Returns what the window size is
/// </summary>
/// <returns>The state (minimized, maximized, etc..) of the window</returns>
public WindowSizeState GetWindowSizeState()
{
InteropAndHelpers.WINDOWPLACEMENT placement = new InteropAndHelpers.WINDOWPLACEMENT();
Expand Down Expand Up @@ -277,6 +288,9 @@ public class WindowListUpdateEventArgs : EventArgs

#region Enums

/// <summary>
/// Enum to simplify the state of the window
/// </summary>
public enum WindowSizeState
{
Normal,
Expand Down
16 changes: 15 additions & 1 deletion Window Walker/Window Walker/Components/WindowSearch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,11 @@ public void SearchTextUpdated()
}

#region Event Handlers

/// <summary>
/// Event handler called when the OpenWindows list changes
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
public void OpenWindowsUpdateHandler(object sender, Window.WindowListUpdateEventArgs e)
{
this.SyncOpenWindowsWithModelAsync();
Expand Down Expand Up @@ -145,6 +149,11 @@ private async void SyncOpenWindowsWithModelAsync()
}
}

/// <summary>
/// Redirecting method for Fuzzy searching
/// </summary>
/// <param name="openWindows"></param>
/// <returns></returns>
private Task<List<WindowSearchResult>> FuzzySearchOpenWindowsAsync(List<Window> openWindows)
{
return Task.Run(
Expand All @@ -153,6 +162,11 @@ private Task<List<WindowSearchResult>> FuzzySearchOpenWindowsAsync(List<Window>
);
}

/// <summary>
/// Search method that matches the title of windows with the user search text
/// </summary>
/// <param name="openWindows"></param>
/// <returns></returns>
private List<WindowSearchResult> FuzzySearchOpenWindows(List<Window> openWindows)
{
List<WindowSearchResult> result = new List<WindowSearchResult>();
Expand Down

0 comments on commit 65c4404

Please sign in to comment.