本文整理汇总了C#中System.Windows.Window.GetHashCode方法的典型用法代码示例。如果您正苦于以下问题:C# Window.GetHashCode方法的具体用法?C# Window.GetHashCode怎么用?C# Window.GetHashCode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Window
的用法示例。
在下文中一共展示了Window.GetHashCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RegisterKeysFor
//TODO: allow for other hotkey
internal static void RegisterKeysFor(Window window)
{
Contract.Requires(window != null);
int id = window.GetHashCode() + TILDE.GetHashCode() + MOD_WIN.GetHashCode();
var hWnd = new WindowInteropHelper(window).Handle;
window.Closing += (_, e) => UnregisterHotKey(hWnd, id);
RegisterHotKey(hWnd, id, MOD_WIN, TILDE);
}
示例2: RegisterHotKey
public static void RegisterHotKey(Window w, Key key)
{
IntPtr handle = new WindowInteropHelper(w).Handle;
int modifiers = 0;
if ((key & Key.LeftAlt) == Key.LeftAlt)
modifiers = modifiers | TextSelecting.MOD_ALT;
if ((key & Key.LeftCtrl) == Key.LeftCtrl)
modifiers = modifiers | TextSelecting.MOD_CONTROL;
if ((key & Key.LeftShift) == Key.LeftShift)
modifiers = modifiers | TextSelecting.MOD_SHIFT;
Key k = key & ~Key.LeftCtrl & ~Key.LeftShift & ~Key.LeftAlt;
keyId = w.GetHashCode(); // this should be a key unique ID, modify this if you want more than one hotkey
RegisterHotKey(handle, keyId, (int)modifiers, (int)k);
}