Skip to content

Commit

Permalink
Add documentation comments
Browse files Browse the repository at this point in the history
  • Loading branch information
giosali committed Feb 26, 2022
1 parent 3257482 commit 8b6f627
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion HotkeyUtility/HotkeyUtility.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Windows.Input;
using System.Windows.Interop;
using HotkeyUtility.Input;
Expand Down Expand Up @@ -32,6 +31,10 @@ protected HotkeyUtility()

private Dictionary<ushort, Hotkey> Keys { get; set; } = new();

/// <summary>
/// Returns a single, global instance of the HotkeyUtility.
/// </summary>
/// <returns>A single, global instance of the HotkeyUtility.</returns>
public static HotkeyUtility GetHotkeyUtility()
{
if (Instance is null)
Expand All @@ -48,6 +51,12 @@ public static HotkeyUtility GetHotkeyUtility()
return Instance;
}

/// <summary>
/// Attempts to add the specified <see cref="Hotkey"/> to a dictionary, using its Id property as the key, and registers it.
/// </summary>
/// <param name="hotkey">The <see cref="Hotkey"/> to add.</param>
/// <returns><see langword="true"/> if <paramref name="hotkey"/> was added to the dictionary successfully; otherwise, <see langword="false"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="hotkey"/> is <see langword="null"/>.</exception>
public bool TryAddHotkey(Hotkey hotkey)
{
if (hotkey is null)
Expand All @@ -67,6 +76,12 @@ public bool TryAddHotkey(Hotkey hotkey)
return success;
}

/// <summary>
/// Attempts to remove the specified <see cref="Hotkey"/> from a dictionary and unregisters it.
/// </summary>
/// <param name="hotkey">The <see cref="Hotkey"/> to remove.</param>
/// <returns><see langword="true"/> if <paramref name="hotkey"/> was remove from the dictionary successfully; otherwise, <see langword="false"/>.</returns>
/// <exception cref="ArgumentNullException"><paramref name="hotkey"/> is <see langword="null"/>.</exception>
public bool TryRemoveHotkey(Hotkey hotkey)
{
if (hotkey is null)
Expand All @@ -86,6 +101,11 @@ public bool TryRemoveHotkey(Hotkey hotkey)
return success;
}

/// <summary>
/// Unregisters the existing <paramref name="hotkey"/> and registers its new Key and Modifiers properties.
/// </summary>
/// <param name="hotkey">The <see cref="Hotkey"/> to replace.</param>
/// <exception cref="ArgumentNullException"><paramref name="hotkey"/> is <see langword="null"/>.</exception>
public void ReplaceHotkey(Hotkey hotkey)
{
if (hotkey is null)
Expand All @@ -107,6 +127,10 @@ public void ReplaceHotkey(Hotkey hotkey)
}
}

/// <summary>
/// Returns a <see cref="Dictionary{TKey, TValue}.ValueCollection"/> of hotkeys.
/// </summary>
/// <returns>A <see cref="Dictionary{TKey, TValue}.ValueCollection"/> of <see cref="Hotkey"/></returns>
public Dictionary<ushort, Hotkey>.ValueCollection GetHotkeys()
{
return Keys.Values;
Expand Down

0 comments on commit 8b6f627

Please sign in to comment.