mirror of
https://github.com/ZuneDev/MicrosoftIris.git
synced 2026-07-27 13:13:29 -07:00
Add project files.
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.BeginDragPolicy
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal enum BeginDragPolicy
|
||||
{
|
||||
Down,
|
||||
Move,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.Characters
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal static class Characters
|
||||
{
|
||||
public const char Back = '\b';
|
||||
public const char Enter = '\r';
|
||||
public const char Escape = '\x001B';
|
||||
public const char Space = ' ';
|
||||
public const char Delete = '\x007F';
|
||||
public const char Null = '\0';
|
||||
public const char SOH = '\x0001';
|
||||
public const char STX = '\x0002';
|
||||
public const char ETX = '\x0003';
|
||||
public const char EOT = '\x0004';
|
||||
public const char ENQ = '\x0005';
|
||||
public const char ACK = '\x0006';
|
||||
public const char BELL = '\a';
|
||||
public const char Tab = '\t';
|
||||
public const char LineFeed = '\n';
|
||||
public const char VT = '\v';
|
||||
public const char FF = '\f';
|
||||
public const char SO = '\x000E';
|
||||
public const char SI = '\x000F';
|
||||
public const char DLE = '\x0010';
|
||||
public const char DC1 = '\x0011';
|
||||
public const char DC2 = '\x0012';
|
||||
public const char DC3 = '\x0013';
|
||||
public const char DC4 = '\x0014';
|
||||
public const char NAK = '\x0015';
|
||||
public const char SYN = '\x0016';
|
||||
public const char ETB = '\x0017';
|
||||
public const char Cancel = '\x0018';
|
||||
public const char EM = '\x0019';
|
||||
public const char SUB = '\x001A';
|
||||
public const char FS = '\x001C';
|
||||
public const char GS = '\x001D';
|
||||
public const char RS = '\x001E';
|
||||
public const char US = '\x001F';
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.ClickCount
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal enum ClickCount
|
||||
{
|
||||
Single,
|
||||
Double,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,482 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.ClickHandler
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.ModelItems;
|
||||
using Microsoft.Iris.OS;
|
||||
using Microsoft.Iris.Session;
|
||||
using Microsoft.Iris.UI;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal class ClickHandler : ModifierInputHandler
|
||||
{
|
||||
private static int s_defaultRepeatDelay = Win32Api.GetDefaultKeyDelay();
|
||||
private static int s_defaultRepeatRate = Win32Api.GetDefaultKeyRepeat();
|
||||
private ClickCount _clickCount;
|
||||
private ClickType _clickType;
|
||||
private int _repeatDelay;
|
||||
private int _repeatRate;
|
||||
private IUICommand _command;
|
||||
private WeakReference _eventContext;
|
||||
private ClickType _clickTypeInProgress;
|
||||
private DispatcherTimer _repeatTimer;
|
||||
private bool _clickValidPosition;
|
||||
private bool _handleEscape;
|
||||
private bool _handle;
|
||||
private bool _repeat;
|
||||
|
||||
public ClickHandler()
|
||||
{
|
||||
_clickType = ClickType.Key | ClickType.GamePad | ClickType.LeftMouse;
|
||||
_clickCount = ClickCount.Single;
|
||||
_repeat = true;
|
||||
_repeatDelay = DefaultRepeatDelay;
|
||||
_repeatRate = DefaultRepeatRate;
|
||||
_handle = true;
|
||||
}
|
||||
|
||||
protected override void OnDispose()
|
||||
{
|
||||
if (_repeatTimer != null)
|
||||
_repeatTimer.Enabled = false;
|
||||
base.OnDispose();
|
||||
}
|
||||
|
||||
protected override void ConfigureInteractivity()
|
||||
{
|
||||
base.ConfigureInteractivity();
|
||||
if (!HandleDirect)
|
||||
return;
|
||||
if (ShouldHandleEvent(ClickType.Mouse))
|
||||
UI.MouseInteractive = true;
|
||||
if (!ShouldHandleEvent(ClickType.Key | ClickType.GamePad))
|
||||
return;
|
||||
UI.KeyInteractive = true;
|
||||
}
|
||||
|
||||
public ClickType ClickType
|
||||
{
|
||||
get => _clickType;
|
||||
set
|
||||
{
|
||||
if (_clickType == value)
|
||||
return;
|
||||
_clickType = value;
|
||||
FireNotification(NotificationID.ClickType);
|
||||
}
|
||||
}
|
||||
|
||||
public ClickCount ClickCount
|
||||
{
|
||||
get => _clickCount;
|
||||
set
|
||||
{
|
||||
if (_clickCount == value)
|
||||
return;
|
||||
_clickCount = value;
|
||||
FireNotification(NotificationID.ClickCount);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Repeat
|
||||
{
|
||||
get => _repeat;
|
||||
set
|
||||
{
|
||||
if (_repeat == value)
|
||||
return;
|
||||
_repeat = value;
|
||||
FireNotification(NotificationID.Repeat);
|
||||
}
|
||||
}
|
||||
|
||||
public int RepeatDelay
|
||||
{
|
||||
get => _repeatDelay;
|
||||
set
|
||||
{
|
||||
if (_repeatDelay == value)
|
||||
return;
|
||||
_repeatDelay = value;
|
||||
FireNotification(NotificationID.RepeatDelay);
|
||||
}
|
||||
}
|
||||
|
||||
public int RepeatRate
|
||||
{
|
||||
get => _repeatRate;
|
||||
set
|
||||
{
|
||||
if (_repeatRate == value)
|
||||
return;
|
||||
_repeatRate = value;
|
||||
FireNotification(NotificationID.RepeatRate);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Clicking => _clickTypeInProgress != ClickType.None && _clickValidPosition;
|
||||
|
||||
public object EventContext => CheckEventContext(ref _eventContext);
|
||||
|
||||
public IUICommand Command
|
||||
{
|
||||
get => _command;
|
||||
set
|
||||
{
|
||||
if (_command == value)
|
||||
return;
|
||||
_command = value;
|
||||
FireNotification(NotificationID.Command);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Handle
|
||||
{
|
||||
get => _handle;
|
||||
set
|
||||
{
|
||||
if (_handle == value)
|
||||
return;
|
||||
_handle = value;
|
||||
FireNotification(NotificationID.Handle);
|
||||
}
|
||||
}
|
||||
|
||||
private void InvokeCommand()
|
||||
{
|
||||
FireNotification(NotificationID.Invoked);
|
||||
if (_command == null)
|
||||
return;
|
||||
_command.Invoke();
|
||||
}
|
||||
|
||||
private void BeginClick(ClickType clickType, bool validPosition)
|
||||
{
|
||||
if (_clickTypeInProgress == ClickType.None)
|
||||
{
|
||||
_clickTypeInProgress = clickType;
|
||||
_clickValidPosition = validPosition;
|
||||
if (validPosition)
|
||||
FireNotification(NotificationID.Clicking);
|
||||
}
|
||||
else if (_clickTypeInProgress != clickType)
|
||||
CancelClick(ClickType.Any);
|
||||
SetEventContext(null, ref _eventContext, NotificationID.EventContext);
|
||||
}
|
||||
|
||||
private void EndClick(ICookedInputSite clickTarget, ClickType clickType)
|
||||
{
|
||||
if (_clickTypeInProgress == ClickType.None)
|
||||
return;
|
||||
SetEventContext(clickTarget, ref _eventContext, NotificationID.EventContext);
|
||||
if (_clickTypeInProgress == clickType && _clickValidPosition)
|
||||
InvokeCommand();
|
||||
CancelClick(ClickType.Any);
|
||||
}
|
||||
|
||||
private void UpdateClickValidPosition(bool validPosition)
|
||||
{
|
||||
bool clicking = Clicking;
|
||||
_clickValidPosition = validPosition;
|
||||
if (Clicking == clicking)
|
||||
return;
|
||||
FireNotification(NotificationID.Clicking);
|
||||
}
|
||||
|
||||
private void CancelClick(ClickType clickType)
|
||||
{
|
||||
if (_clickTypeInProgress != ClickType.None && Library.Bits.TestAllFlags((uint)clickType, (uint)_clickTypeInProgress))
|
||||
{
|
||||
bool clicking = Clicking;
|
||||
_clickTypeInProgress = ClickType.None;
|
||||
if (Clicking != clicking)
|
||||
FireNotification(NotificationID.Clicking);
|
||||
}
|
||||
if (_repeatTimer == null)
|
||||
return;
|
||||
_repeatTimer.Enabled = false;
|
||||
}
|
||||
|
||||
private bool ShouldHandleEvent(
|
||||
ClickType type,
|
||||
InputHandlerModifiers modifiers,
|
||||
ClickCount count)
|
||||
{
|
||||
return ShouldHandleEvent(type) && _clickCount == count && ShouldHandleEvent(modifiers);
|
||||
}
|
||||
|
||||
private bool ShouldHandleEvent(ClickType type) => Library.Bits.TestAnyFlags((uint)_clickType, (uint)type);
|
||||
|
||||
private bool OnClickEvent(
|
||||
ICookedInputSite clickTarget,
|
||||
ClickType type,
|
||||
InputHandlerTransition transition,
|
||||
InputHandlerModifiers modifiers)
|
||||
{
|
||||
return OnClickEvent(clickTarget, type, transition, modifiers, ClickCount.Single);
|
||||
}
|
||||
|
||||
private bool OnClickEvent(
|
||||
ICookedInputSite clickTarget,
|
||||
ClickType type,
|
||||
InputHandlerTransition transition,
|
||||
InputHandlerModifiers modifiers,
|
||||
ClickCount count)
|
||||
{
|
||||
if (!ShouldHandleEvent(type, modifiers, count))
|
||||
return false;
|
||||
if (transition == InputHandlerTransition.Up)
|
||||
{
|
||||
if (HandlerTransition != InputHandlerTransition.Down)
|
||||
EndClick(clickTarget, type);
|
||||
if (_repeatTimer != null)
|
||||
_repeatTimer.Enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
BeginClick(type, true);
|
||||
if (HandlerTransition == InputHandlerTransition.Down)
|
||||
{
|
||||
EndClick(clickTarget, type);
|
||||
StartRepeat(new ClickHandler.ClickInfo()
|
||||
{
|
||||
type = type,
|
||||
transition = transition,
|
||||
modifiers = modifiers,
|
||||
count = count,
|
||||
target = clickTarget
|
||||
});
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private ClickType GetClickType(MouseButtons buttons)
|
||||
{
|
||||
ClickType clickType = ClickType.None;
|
||||
if ((buttons & MouseButtons.Left) != MouseButtons.None)
|
||||
clickType |= ClickType.LeftMouse;
|
||||
if ((buttons & MouseButtons.Right) != MouseButtons.None)
|
||||
clickType |= ClickType.RightMouse;
|
||||
if ((buttons & MouseButtons.Middle) != MouseButtons.None)
|
||||
clickType |= ClickType.MiddleMouse;
|
||||
return clickType;
|
||||
}
|
||||
|
||||
private void StartRepeat(ClickHandler.ClickInfo clickInfo)
|
||||
{
|
||||
if (!Repeat)
|
||||
return;
|
||||
if (_repeatTimer == null)
|
||||
{
|
||||
_repeatTimer = new DispatcherTimer();
|
||||
_repeatTimer.Tick += new EventHandler(SimulateClickEvent);
|
||||
_repeatTimer.AutoRepeat = true;
|
||||
}
|
||||
_repeatTimer.Interval = RepeatDelay;
|
||||
_repeatTimer.UserData = clickInfo;
|
||||
_repeatTimer.Enabled = true;
|
||||
}
|
||||
|
||||
private void SimulateClickEvent(object sender, EventArgs args)
|
||||
{
|
||||
bool flag = false;
|
||||
ClickHandler.ClickInfo userData = (ClickHandler.ClickInfo)_repeatTimer.UserData;
|
||||
if (Enabled && Repeat && _clickValidPosition && (userData.target == null || userData.target.IsValid))
|
||||
{
|
||||
OnClickEvent(userData.target, userData.type, userData.transition, userData.modifiers, userData.count);
|
||||
flag = true;
|
||||
}
|
||||
if (flag)
|
||||
{
|
||||
_repeatTimer.Enabled = false;
|
||||
_repeatTimer = null;
|
||||
StartRepeat(userData);
|
||||
_repeatTimer.Interval = RepeatRate;
|
||||
}
|
||||
else
|
||||
{
|
||||
_repeatTimer.Enabled = false;
|
||||
_repeatTimer = null;
|
||||
}
|
||||
}
|
||||
|
||||
private static int DefaultRepeatDelay => s_defaultRepeatDelay;
|
||||
|
||||
private static int DefaultRepeatRate => s_defaultRepeatRate;
|
||||
|
||||
protected override void OnMousePrimaryDown(UIClass ui, MouseButtonInfo info)
|
||||
{
|
||||
if (!OnClickEvent(info.Target, GetClickType(info.Button), InputHandlerTransition.Down, GetModifiers(info.Modifiers)) || !_handle)
|
||||
return;
|
||||
info.MarkHandled();
|
||||
}
|
||||
|
||||
protected override void OnMouseSecondaryDown(UIClass ui, MouseButtonInfo info)
|
||||
{
|
||||
if (!OnClickEvent(info.Target, GetClickType(info.Button), InputHandlerTransition.Down, GetModifiers(info.Modifiers)) || !_handle)
|
||||
return;
|
||||
info.MarkHandled();
|
||||
}
|
||||
|
||||
protected override void OnMousePrimaryUp(UIClass ui, MouseButtonInfo info)
|
||||
{
|
||||
if (!OnClickEvent(info.Target, GetClickType(info.Button), InputHandlerTransition.Up, GetModifiers(info.Modifiers)) || !_handle)
|
||||
return;
|
||||
info.MarkHandled();
|
||||
}
|
||||
|
||||
protected override void OnMouseSecondaryUp(UIClass ui, MouseButtonInfo info)
|
||||
{
|
||||
if (!OnClickEvent(info.Target, GetClickType(info.Button), InputHandlerTransition.Up, GetModifiers(info.Modifiers)) || !_handle)
|
||||
return;
|
||||
info.MarkHandled();
|
||||
}
|
||||
|
||||
protected override void OnMouseDoubleClick(UIClass ui, MouseButtonInfo info)
|
||||
{
|
||||
ClickType clickType = GetClickType(info.Button);
|
||||
if (!OnClickEvent(info.Target, clickType, InputHandlerTransition.Down, GetModifiers(info.Modifiers), ClickCount.Double))
|
||||
return;
|
||||
OnClickEvent(info.Target, clickType, InputHandlerTransition.Up, GetModifiers(info.Modifiers), ClickCount.Double);
|
||||
if (!_handle)
|
||||
return;
|
||||
info.MarkHandled();
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(UIClass ui, MouseMoveInfo info)
|
||||
{
|
||||
if (!ShouldHandleEvent(ClickType.Mouse))
|
||||
return;
|
||||
UpdateClickValidPosition(UI.HasDescendant(info.NaturalTarget as UIClass));
|
||||
}
|
||||
|
||||
protected override void OnLoseMouseFocus(UIClass ui, MouseFocusInfo info)
|
||||
{
|
||||
if (!ShouldHandleEvent(ClickType.Mouse))
|
||||
return;
|
||||
CancelClick(ClickType.Mouse);
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(UIClass ui, KeyStateInfo info)
|
||||
{
|
||||
if (info.RepeatCount > 1U)
|
||||
return;
|
||||
switch (info.Key)
|
||||
{
|
||||
case Keys.Enter:
|
||||
if (!OnClickEvent(info.Target, ClickType.EnterKey, InputHandlerTransition.Down, GetModifiers(info.Modifiers)) || !_handle)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
case Keys.Escape:
|
||||
if (!Clicking)
|
||||
break;
|
||||
CancelClick(ClickType.Any);
|
||||
if (_handle)
|
||||
info.MarkHandled();
|
||||
_handleEscape = true;
|
||||
break;
|
||||
case Keys.Space:
|
||||
if (!OnClickEvent(info.Target, ClickType.SpaceKey, InputHandlerTransition.Down, GetModifiers(info.Modifiers)) || !_handle)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
case Keys.GamePadA:
|
||||
if (!OnClickEvent(info.Target, ClickType.GamePadA, InputHandlerTransition.Down, GetModifiers(info.Modifiers)) || !_handle)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
case Keys.GamePadStart:
|
||||
if (!OnClickEvent(info.Target, ClickType.GamePadStart, InputHandlerTransition.Down, GetModifiers(info.Modifiers)) || !_handle)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnKeyUp(UIClass ui, KeyStateInfo info)
|
||||
{
|
||||
switch (info.Key)
|
||||
{
|
||||
case Keys.Enter:
|
||||
if (!OnClickEvent(info.Target, ClickType.EnterKey, InputHandlerTransition.Up, GetModifiers(info.Modifiers)) || !_handle)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
case Keys.Escape:
|
||||
if (!_handleEscape)
|
||||
break;
|
||||
if (_handle)
|
||||
info.MarkHandled();
|
||||
_handleEscape = false;
|
||||
break;
|
||||
case Keys.Space:
|
||||
if (!OnClickEvent(info.Target, ClickType.SpaceKey, InputHandlerTransition.Up, GetModifiers(info.Modifiers)) || !_handle)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
case Keys.GamePadA:
|
||||
if (!OnClickEvent(info.Target, ClickType.GamePadA, InputHandlerTransition.Up, GetModifiers(info.Modifiers)) || !_handle)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
case Keys.GamePadStart:
|
||||
if (!OnClickEvent(info.Target, ClickType.GamePadStart, InputHandlerTransition.Up, GetModifiers(info.Modifiers)) || !_handle)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnKeyCharacter(UIClass ui, KeyCharacterInfo info)
|
||||
{
|
||||
switch (info.Character)
|
||||
{
|
||||
case '\r':
|
||||
if (!ShouldHandleEvent(ClickType.EnterKey, GetModifiers(info.Modifiers), ClickCount.Single) || !_handle)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
case '\x001B':
|
||||
if (!_handleEscape || !_handle)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
case ' ':
|
||||
if (!ShouldHandleEvent(ClickType.SpaceKey, GetModifiers(info.Modifiers), ClickCount.Single) || !_handle)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLoseKeyFocus(UIClass ui, KeyFocusInfo info)
|
||||
{
|
||||
if (ShouldHandleEvent(ClickType.SpaceKey))
|
||||
CancelClick(ClickType.SpaceKey);
|
||||
if (ShouldHandleEvent(ClickType.EnterKey))
|
||||
CancelClick(ClickType.EnterKey);
|
||||
if (ShouldHandleEvent(ClickType.GamePadA))
|
||||
CancelClick(ClickType.GamePadA);
|
||||
if (ShouldHandleEvent(ClickType.GamePadStart))
|
||||
CancelClick(ClickType.GamePadStart);
|
||||
_handleEscape = false;
|
||||
}
|
||||
|
||||
private struct ClickInfo
|
||||
{
|
||||
public ClickType type;
|
||||
public InputHandlerTransition transition;
|
||||
public InputHandlerModifiers modifiers;
|
||||
public ClickCount count;
|
||||
public ICookedInputSite target;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.ClickType
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
[Flags]
|
||||
internal enum ClickType
|
||||
{
|
||||
None = 0,
|
||||
LeftMouse = 1,
|
||||
RightMouse = 2,
|
||||
MiddleMouse = 4,
|
||||
SpaceKey = 8,
|
||||
EnterKey = 16, // 0x00000010
|
||||
GamePadA = 32, // 0x00000020
|
||||
GamePadStart = 64, // 0x00000040
|
||||
Mouse = MiddleMouse | RightMouse | LeftMouse, // 0x00000007
|
||||
Key = EnterKey | SpaceKey, // 0x00000018
|
||||
GamePad = GamePadStart | GamePadA, // 0x00000060
|
||||
Any = GamePad | Key | Mouse, // 0x0000007F
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.DragDropHelper
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Session;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal static class DragDropHelper
|
||||
{
|
||||
private static bool _draggingInternally;
|
||||
private static DragSourceHandler _sourceHandler;
|
||||
private static DropTargetHandler _targetHandler;
|
||||
private static DropAction _dropAction;
|
||||
|
||||
public static bool DraggingInternally => _draggingInternally;
|
||||
|
||||
public static DragSourceHandler SourceHandler => _sourceHandler;
|
||||
|
||||
public static DropTargetHandler TargetHandler
|
||||
{
|
||||
get => _targetHandler;
|
||||
set
|
||||
{
|
||||
if (_targetHandler == value)
|
||||
return;
|
||||
DropTargetHandler targetHandler = _targetHandler;
|
||||
_targetHandler = value;
|
||||
OnAllowedDropActionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public static DropAction AllowedDropActions => _targetHandler == null ? DropAction.None : _targetHandler.AllowedDropActions;
|
||||
|
||||
public static InputModifiers Modifiers => UISession.Default.InputManager.DragModifiers;
|
||||
|
||||
public static void OnAllowedDropActionsChanged()
|
||||
{
|
||||
if (DraggingInternally)
|
||||
{
|
||||
_sourceHandler.UpdateCurrentAction();
|
||||
}
|
||||
else
|
||||
{
|
||||
uint allowedDropActions = (uint)AllowedDropActions;
|
||||
UISession.Default.Form.SetDragDropResult(allowedDropActions, allowedDropActions);
|
||||
}
|
||||
}
|
||||
|
||||
public static void BeginDrag(
|
||||
DragSourceHandler sourceHandler,
|
||||
ICookedInputSite source,
|
||||
IRawInputSite target,
|
||||
int formX,
|
||||
int formY,
|
||||
InputModifiers modifiers)
|
||||
{
|
||||
_sourceHandler = sourceHandler;
|
||||
_draggingInternally = true;
|
||||
UISession.Default.Form.IsDragInProgress = true;
|
||||
UISession.Default.InputManager.SimulateDragEnter(source, target, _sourceHandler.Value, formX, formY, modifiers);
|
||||
}
|
||||
|
||||
public static void Requery(InputModifiers modifiers)
|
||||
{
|
||||
UISession.Default.InputManager.SimulateDragOver(modifiers);
|
||||
_sourceHandler.UpdateCurrentAction();
|
||||
}
|
||||
|
||||
public static void Requery(
|
||||
IRawInputSite target,
|
||||
int formX,
|
||||
int formY,
|
||||
InputModifiers modifiers)
|
||||
{
|
||||
UISession.Default.InputManager.SimulateDragOver(target, formX, formY, modifiers);
|
||||
}
|
||||
|
||||
public static void EndDrag(IRawInputSite target, InputModifiers modifiers, DropAction action)
|
||||
{
|
||||
DragOperation formOperation = DragOperation.Drop;
|
||||
_dropAction = action;
|
||||
_draggingInternally = false;
|
||||
if (action == DropAction.None)
|
||||
{
|
||||
target = null;
|
||||
formOperation = DragOperation.Leave;
|
||||
}
|
||||
UISession.Default.InputManager.SimulateDragEnd(target, modifiers, formOperation);
|
||||
UISession.Default.Form.IsDragInProgress = false;
|
||||
}
|
||||
|
||||
public static void OnDragComplete()
|
||||
{
|
||||
_sourceHandler.OnEndDrag(_dropAction);
|
||||
_sourceHandler = null;
|
||||
_dropAction = DropAction.None;
|
||||
}
|
||||
|
||||
public static object GetValue() => UISession.Default.InputManager.GetDragDropValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,473 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.DragHandler
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Layout;
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.OS;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.RenderAPI.Drawing;
|
||||
using Microsoft.Iris.Session;
|
||||
using Microsoft.Iris.UI;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal class DragHandler : InputHandler
|
||||
{
|
||||
private CursorID _dragCursor;
|
||||
private BeginDragPolicy _beginDragPolicy;
|
||||
private bool _pendingDrag;
|
||||
private bool _inDrag;
|
||||
private bool _hasRelativeTo;
|
||||
private Vector2 _initialPosition;
|
||||
private Point _initialScreenPosition;
|
||||
private Vector2 _beginPosition;
|
||||
private Vector2 _endPosition;
|
||||
private Point _screenBeginPosition;
|
||||
private Point _screenEndPosition;
|
||||
private Size _lastKnownSize;
|
||||
private InputHandlerModifiers _activeModifiers;
|
||||
private bool _cancelOnEscape;
|
||||
private ViewItem _relativeTo;
|
||||
private RectangleF _contextBounds;
|
||||
private List<object> _addedContexts;
|
||||
private List<object> _removedContexts;
|
||||
|
||||
public DragHandler() => _beginDragPolicy = BeginDragPolicy.Down;
|
||||
|
||||
public override void OnZoneDetached()
|
||||
{
|
||||
CancelDrag();
|
||||
base.OnZoneDetached();
|
||||
}
|
||||
|
||||
protected override void ConfigureInteractivity()
|
||||
{
|
||||
base.ConfigureInteractivity();
|
||||
if (HandleDirect)
|
||||
UI.MouseInteractive = true;
|
||||
if (_relativeTo != null)
|
||||
return;
|
||||
SetRelativeTo(null);
|
||||
}
|
||||
|
||||
public BeginDragPolicy BeginDragPolicy
|
||||
{
|
||||
get => _beginDragPolicy;
|
||||
set
|
||||
{
|
||||
if (_beginDragPolicy == value)
|
||||
return;
|
||||
_beginDragPolicy = value;
|
||||
FireNotification(NotificationID.BeginDragPolicy);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Dragging => _inDrag;
|
||||
|
||||
private void SetDragging(bool value)
|
||||
{
|
||||
if (_inDrag == value)
|
||||
return;
|
||||
_inDrag = value;
|
||||
FireNotification(NotificationID.Dragging);
|
||||
}
|
||||
|
||||
public Vector2 BeginPosition => NormalizeCoordinates(_beginPosition);
|
||||
|
||||
private void SetBeginPosition(Vector2 relativeCoordinate)
|
||||
{
|
||||
if (!(_beginPosition != relativeCoordinate))
|
||||
return;
|
||||
_beginPosition = relativeCoordinate;
|
||||
FireNotification(NotificationID.BeginPosition);
|
||||
FireNotification(NotificationID.RelativeDragSize);
|
||||
}
|
||||
|
||||
public Vector2 EndPosition => NormalizeCoordinates(_endPosition);
|
||||
|
||||
private void SetEndPosition(Vector2 relativeCoordinate)
|
||||
{
|
||||
if (!(_endPosition != relativeCoordinate))
|
||||
return;
|
||||
_endPosition = relativeCoordinate;
|
||||
FireNotification(NotificationID.EndPosition);
|
||||
FireNotification(NotificationID.RelativeDragSize);
|
||||
}
|
||||
|
||||
public Size ScreenDragSize => (ScreenEndPosition - ScreenBeginPosition).ToSize();
|
||||
|
||||
public Vector2 LocalDragSize
|
||||
{
|
||||
get
|
||||
{
|
||||
Size screenDragSize = ScreenDragSize;
|
||||
Vector3 vector3 = _relativeTo != null ? _relativeTo.ComputeEffectiveScale() : Vector3.UnitVector;
|
||||
return new Vector2(screenDragSize.Width / vector3.X, screenDragSize.Height / vector3.Y);
|
||||
}
|
||||
}
|
||||
|
||||
public Vector2 RelativeDragSize => EndPosition - BeginPosition;
|
||||
|
||||
public InputHandlerModifiers ActiveModifiers => _activeModifiers;
|
||||
|
||||
private void SetActiveModifiers(InputHandlerModifiers value)
|
||||
{
|
||||
if (_activeModifiers == value)
|
||||
return;
|
||||
_activeModifiers = value;
|
||||
FireNotification(NotificationID.ActiveModifiers);
|
||||
}
|
||||
|
||||
public CursorID DragCursor
|
||||
{
|
||||
get => _dragCursor;
|
||||
set
|
||||
{
|
||||
if (_dragCursor == value)
|
||||
return;
|
||||
_dragCursor = value;
|
||||
FireNotification(NotificationID.DragCursor);
|
||||
}
|
||||
}
|
||||
|
||||
private Point ScreenBeginPosition
|
||||
{
|
||||
get => _screenBeginPosition;
|
||||
set
|
||||
{
|
||||
if (!(_screenBeginPosition != value))
|
||||
return;
|
||||
_screenBeginPosition = value;
|
||||
FireNotification(NotificationID.ScreenDragSize);
|
||||
FireNotification(NotificationID.LocalDragSize);
|
||||
}
|
||||
}
|
||||
|
||||
private Point ScreenEndPosition
|
||||
{
|
||||
get => _screenEndPosition;
|
||||
set
|
||||
{
|
||||
if (!(_screenEndPosition != value))
|
||||
return;
|
||||
_screenEndPosition = value;
|
||||
FireNotification(NotificationID.ScreenDragSize);
|
||||
FireNotification(NotificationID.LocalDragSize);
|
||||
}
|
||||
}
|
||||
|
||||
public bool CancelOnEscape
|
||||
{
|
||||
get => _cancelOnEscape;
|
||||
set
|
||||
{
|
||||
if (_cancelOnEscape == value)
|
||||
return;
|
||||
if (Dragging)
|
||||
HookSessionInput(value);
|
||||
_cancelOnEscape = value;
|
||||
FireNotification(NotificationID.CancelOnEscape);
|
||||
}
|
||||
}
|
||||
|
||||
public ViewItem RelativeTo
|
||||
{
|
||||
get => !_hasRelativeTo ? null : _relativeTo;
|
||||
set
|
||||
{
|
||||
bool hasRelativeTo = _hasRelativeTo;
|
||||
_hasRelativeTo = value != null;
|
||||
ViewItem relativeTo = _relativeTo;
|
||||
SetRelativeTo(value);
|
||||
if (hasRelativeTo == _hasRelativeTo && relativeTo == _relativeTo)
|
||||
return;
|
||||
FireNotification(NotificationID.RelativeTo);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetRelativeTo(ViewItem relativeTo)
|
||||
{
|
||||
if (_relativeTo == relativeTo && relativeTo != null)
|
||||
return;
|
||||
LayoutCompleteEventHandler completeEventHandler = new LayoutCompleteEventHandler(OnRelativeToLayoutComplete);
|
||||
if (_relativeTo != null)
|
||||
_relativeTo.LayoutComplete -= completeEventHandler;
|
||||
_relativeTo = relativeTo;
|
||||
if (_relativeTo == null && UI != null)
|
||||
_relativeTo = UI.RootItem;
|
||||
if (_relativeTo == null)
|
||||
return;
|
||||
_relativeTo.LayoutComplete += completeEventHandler;
|
||||
}
|
||||
|
||||
public void ResetDragOrigin()
|
||||
{
|
||||
SetBeginPosition(_endPosition);
|
||||
ScreenBeginPosition = ScreenEndPosition;
|
||||
}
|
||||
|
||||
private void BeginDrag(
|
||||
Vector2 relativeBegin,
|
||||
Vector2 relativeEnd,
|
||||
Point screenBegin,
|
||||
Point screenEnd,
|
||||
InputHandlerModifiers modifiers)
|
||||
{
|
||||
SetDragging(true);
|
||||
_pendingDrag = false;
|
||||
_contextBounds = RectangleF.Zero;
|
||||
if (CancelOnEscape)
|
||||
HookSessionInput(true);
|
||||
SetBeginPosition(relativeBegin);
|
||||
SetEndPosition(relativeEnd);
|
||||
ScreenBeginPosition = screenBegin;
|
||||
ScreenEndPosition = screenEnd;
|
||||
SetActiveModifiers(modifiers);
|
||||
FireNotification(NotificationID.Started);
|
||||
UpdateCursor();
|
||||
}
|
||||
|
||||
private void EndDrag(bool completed)
|
||||
{
|
||||
if (Dragging)
|
||||
{
|
||||
if (CancelOnEscape)
|
||||
HookSessionInput(false);
|
||||
SetDragging(false);
|
||||
if (completed)
|
||||
FireNotification(NotificationID.Ended);
|
||||
else
|
||||
FireNotification(NotificationID.Canceled);
|
||||
UpdateCursor();
|
||||
}
|
||||
_pendingDrag = false;
|
||||
}
|
||||
|
||||
private void InDrag(Vector2 uiPoint, Point screenPoint, InputHandlerModifiers modifiers)
|
||||
{
|
||||
if (screenPoint != ScreenEndPosition)
|
||||
{
|
||||
SetEndPosition(TransformToRelative(uiPoint));
|
||||
ScreenEndPosition = screenPoint;
|
||||
}
|
||||
SetActiveModifiers(modifiers);
|
||||
}
|
||||
|
||||
protected override void OnMousePrimaryDown(UIClass ui, MouseButtonInfo info)
|
||||
{
|
||||
if (!Dragging)
|
||||
{
|
||||
Vector2 relative = TransformToRelative(TransformToUI(new Point(info.X, info.Y), (UIClass)info.Target));
|
||||
Point point = new Point(info.ScreenX, info.ScreenY);
|
||||
if (BeginDragPolicy == BeginDragPolicy.Down)
|
||||
{
|
||||
BeginDrag(relative, relative, point, point, GetModifiers(info.Modifiers));
|
||||
info.MarkHandled();
|
||||
}
|
||||
else
|
||||
{
|
||||
_pendingDrag = true;
|
||||
_initialPosition = relative;
|
||||
_initialScreenPosition = point;
|
||||
}
|
||||
}
|
||||
base.OnMousePrimaryDown(ui, info);
|
||||
}
|
||||
|
||||
protected override void OnMousePrimaryUp(UIClass ui, MouseButtonInfo info)
|
||||
{
|
||||
bool dragging = Dragging;
|
||||
if (dragging || _pendingDrag)
|
||||
{
|
||||
EndDrag(true);
|
||||
if (dragging)
|
||||
info.MarkHandled();
|
||||
}
|
||||
base.OnMousePrimaryUp(ui, info);
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(UIClass ui, MouseMoveInfo info)
|
||||
{
|
||||
if ((info.Modifiers & InputModifiers.LeftMouse) == InputModifiers.None)
|
||||
EndDrag(true);
|
||||
else if (Dragging || _pendingDrag)
|
||||
{
|
||||
Vector2 ui1 = TransformToUI(new Point(info.X, info.Y), (UIClass)info.Target);
|
||||
Point point = new Point(info.ScreenX, info.ScreenY);
|
||||
if (Dragging)
|
||||
{
|
||||
InDrag(ui1, point, GetModifiers(info.Modifiers));
|
||||
info.MarkHandled();
|
||||
}
|
||||
else if (Math.Abs(point.X - _initialScreenPosition.X) >= Win32Api.GetSystemMetrics(68) || Math.Abs(point.Y - _initialScreenPosition.Y) >= Win32Api.GetSystemMetrics(69))
|
||||
{
|
||||
BeginDrag(_initialPosition, TransformToRelative(ui1), _initialScreenPosition, point, GetModifiers(info.Modifiers));
|
||||
info.MarkHandled();
|
||||
}
|
||||
}
|
||||
base.OnMouseMove(ui, info);
|
||||
}
|
||||
|
||||
protected override void OnLoseMouseFocus(UIClass ui, MouseFocusInfo info)
|
||||
{
|
||||
CancelDrag();
|
||||
base.OnLoseMouseFocus(ui, info);
|
||||
}
|
||||
|
||||
private void OnRelativeToLayoutComplete(object sender) => SetLastLayoutSize(_relativeTo.LayoutSize);
|
||||
|
||||
protected void SetLastLayoutSize(Size size)
|
||||
{
|
||||
Vector2 beginPosition = BeginPosition;
|
||||
Vector2 endPosition = EndPosition;
|
||||
Vector2 relativeDragSize = RelativeDragSize;
|
||||
_lastKnownSize = size;
|
||||
if (!Dragging)
|
||||
return;
|
||||
Point client = _relativeTo.ScreenToClient(_screenEndPosition);
|
||||
SetEndPosition(new Vector2(client.X, client.Y));
|
||||
if (beginPosition != BeginPosition)
|
||||
FireNotification(NotificationID.BeginPosition);
|
||||
if (endPosition != EndPosition)
|
||||
FireNotification(NotificationID.EndPosition);
|
||||
if (!(relativeDragSize != RelativeDragSize))
|
||||
return;
|
||||
FireNotification(NotificationID.RelativeDragSize);
|
||||
}
|
||||
|
||||
private void HookSessionInput(bool hook)
|
||||
{
|
||||
if (hook)
|
||||
UI.SessionInput += new SessionInputHandler(OnSessionInput);
|
||||
else
|
||||
UI.SessionInput -= new SessionInputHandler(OnSessionInput);
|
||||
}
|
||||
|
||||
private void OnSessionInput(InputInfo originalEvent, EventRouteStages stageHandled)
|
||||
{
|
||||
if (!(originalEvent is KeyStateInfo keyStateInfo))
|
||||
return;
|
||||
if (keyStateInfo.Key == Keys.Escape)
|
||||
CancelDrag();
|
||||
keyStateInfo.MarkHandled();
|
||||
}
|
||||
|
||||
private Vector2 TransformToRelative(Vector2 uiPoint)
|
||||
{
|
||||
if (_relativeTo != null)
|
||||
{
|
||||
RectangleF rectangleF = _relativeTo.TransformFromAncestor(UI.RootItem, new RectangleF(uiPoint.X, uiPoint.Y, 0.0f, 0.0f));
|
||||
uiPoint.X = rectangleF.X;
|
||||
uiPoint.Y = rectangleF.Y;
|
||||
}
|
||||
return uiPoint;
|
||||
}
|
||||
|
||||
private RectangleF TransformFromRelative(RectangleF relativeBounds)
|
||||
{
|
||||
RectangleF rectangleF = relativeBounds;
|
||||
if (_relativeTo != null)
|
||||
rectangleF = _relativeTo.TransformToAncestor(UI.RootItem, relativeBounds);
|
||||
return rectangleF;
|
||||
}
|
||||
|
||||
private Vector2 TransformToUI(Point uiPoint, UIClass reference)
|
||||
{
|
||||
float x = uiPoint.X;
|
||||
float y = uiPoint.Y;
|
||||
if (reference != UI)
|
||||
{
|
||||
RectangleF rect = new RectangleF(x, y, 0.0f, 0.0f);
|
||||
RectangleF ancestor = reference.RootItem.TransformToAncestor(UI.RootItem, rect);
|
||||
x = ancestor.X;
|
||||
y = ancestor.Y;
|
||||
}
|
||||
return new Vector2(x, y);
|
||||
}
|
||||
|
||||
private Vector2 NormalizeCoordinates(Vector2 pt) => _lastKnownSize.Width == 0 || _lastKnownSize.Height == 0 ? Vector2.Zero : new Vector2(pt.X / _lastKnownSize.Width, pt.Y / _lastKnownSize.Height);
|
||||
|
||||
internal override CursorID GetCursor() => _dragCursor != CursorID.NotSpecified && Dragging ? _dragCursor : CursorID.NotSpecified;
|
||||
|
||||
public void CancelDrag() => EndDrag(false);
|
||||
|
||||
private void GetDragBounds(out RectangleF relativeBounds, out RectangleF uiBounds)
|
||||
{
|
||||
relativeBounds = new RectangleF(Math.Min(_beginPosition.X, _endPosition.X), Math.Min(_beginPosition.Y, _endPosition.Y), Math.Abs(_beginPosition.X - _endPosition.X), Math.Abs(_beginPosition.Y - _endPosition.Y));
|
||||
uiBounds = TransformFromRelative(relativeBounds);
|
||||
}
|
||||
|
||||
public IList GetEventContexts()
|
||||
{
|
||||
IList added = new List<object>();
|
||||
RectangleF uiBounds;
|
||||
GetDragBounds(out RectangleF _, out uiBounds);
|
||||
GetEventContexts(UI, added, null, RectangleF.Zero, uiBounds);
|
||||
return added;
|
||||
}
|
||||
|
||||
public IList GetAddedEventContexts()
|
||||
{
|
||||
UpdateEventContexts();
|
||||
return _addedContexts;
|
||||
}
|
||||
|
||||
public IList GetRemovedEventContexts()
|
||||
{
|
||||
UpdateEventContexts();
|
||||
return _removedContexts;
|
||||
}
|
||||
|
||||
private void UpdateEventContexts()
|
||||
{
|
||||
RectangleF relativeBounds;
|
||||
RectangleF uiBounds;
|
||||
GetDragBounds(out relativeBounds, out uiBounds);
|
||||
if (!(relativeBounds != _contextBounds))
|
||||
return;
|
||||
_addedContexts = new List<object>();
|
||||
_removedContexts = new List<object>();
|
||||
GetEventContexts(UI, _addedContexts, _removedContexts, TransformFromRelative(_contextBounds), uiBounds);
|
||||
_contextBounds = relativeBounds;
|
||||
}
|
||||
|
||||
private static void GetEventContexts(
|
||||
UIClass node,
|
||||
IList added,
|
||||
IList removed,
|
||||
RectangleF oldBounds,
|
||||
RectangleF newBounds)
|
||||
{
|
||||
ViewItem rootItem = node.RootItem;
|
||||
if (rootItem == null)
|
||||
return;
|
||||
object eventContext = node.GetEventContext();
|
||||
if (eventContext != null && rootItem.Parent != null)
|
||||
{
|
||||
RectangleF rectangleF = new RectangleF(Point.Zero, rootItem.Parent.LayoutSize);
|
||||
bool flag1 = rectangleF.IntersectsWith(oldBounds);
|
||||
bool flag2 = rectangleF.IntersectsWith(newBounds);
|
||||
if (flag2 && !flag1)
|
||||
added.Add(eventContext);
|
||||
else if (removed != null && flag1 && !flag2)
|
||||
removed.Add(eventContext);
|
||||
}
|
||||
for (UIClass node1 = (UIClass)node.FirstChild; node1 != null; node1 = (UIClass)node1.NextSibling)
|
||||
{
|
||||
if (node1.RootItem != null)
|
||||
{
|
||||
RectangleF oldBounds1 = node1.RootItem.Parent.TransformFromAncestor(rootItem.Parent, oldBounds);
|
||||
RectangleF newBounds1 = node1.RootItem.Parent.TransformFromAncestor(rootItem.Parent, newBounds);
|
||||
GetEventContexts(node1, added, removed, oldBounds1, newBounds1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,279 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.DragSourceHandler
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.OS;
|
||||
using Microsoft.Iris.Session;
|
||||
using Microsoft.Iris.UI;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal class DragSourceHandler : InputHandler
|
||||
{
|
||||
private object _value;
|
||||
private DropAction _allowedDropActions;
|
||||
private DropAction _currentDropAction;
|
||||
private bool _pendingDrag;
|
||||
private bool _dragCanceled;
|
||||
private int _initialX;
|
||||
private int _initialY;
|
||||
private CursorID _moveCursor;
|
||||
private CursorID _copyCursor;
|
||||
private CursorID _cancelCursor;
|
||||
|
||||
internal DragSourceHandler()
|
||||
{
|
||||
_moveCursor = CursorID.Move;
|
||||
_copyCursor = CursorID.Copy;
|
||||
_cancelCursor = CursorID.Cancel;
|
||||
}
|
||||
|
||||
public override void OnZoneDetached()
|
||||
{
|
||||
if (Dragging)
|
||||
EndDrag(null, InputModifiers.None, DropAction.None);
|
||||
base.OnZoneDetached();
|
||||
}
|
||||
|
||||
protected override void ConfigureInteractivity()
|
||||
{
|
||||
base.ConfigureInteractivity();
|
||||
if (!HandleDirect)
|
||||
return;
|
||||
UI.MouseInteractive = true;
|
||||
}
|
||||
|
||||
public object Value
|
||||
{
|
||||
get => _value;
|
||||
set
|
||||
{
|
||||
if (_value == value)
|
||||
return;
|
||||
_value = value;
|
||||
FireNotification(NotificationID.Value);
|
||||
}
|
||||
}
|
||||
|
||||
public DropAction AllowedDropActions
|
||||
{
|
||||
get => _allowedDropActions;
|
||||
set
|
||||
{
|
||||
if (_allowedDropActions == value)
|
||||
return;
|
||||
_allowedDropActions = value;
|
||||
FireNotification(NotificationID.AllowedDropActions);
|
||||
}
|
||||
}
|
||||
|
||||
public DropAction CurrentDropAction => _currentDropAction;
|
||||
|
||||
private void SetCurrentDropAction(DropAction value)
|
||||
{
|
||||
if (_currentDropAction == value)
|
||||
return;
|
||||
_currentDropAction = value;
|
||||
FireNotification(NotificationID.CurrentDropAction);
|
||||
UpdateCursor();
|
||||
}
|
||||
|
||||
public bool Dragging => DragDropHelper.DraggingInternally && DragDropHelper.SourceHandler == this;
|
||||
|
||||
public CursorID MoveCursor
|
||||
{
|
||||
get => _moveCursor;
|
||||
set
|
||||
{
|
||||
if (_moveCursor == value)
|
||||
return;
|
||||
_moveCursor = value;
|
||||
FireNotification(NotificationID.MoveCursor);
|
||||
}
|
||||
}
|
||||
|
||||
public CursorID CopyCursor
|
||||
{
|
||||
get => _copyCursor;
|
||||
set
|
||||
{
|
||||
if (_copyCursor == value)
|
||||
return;
|
||||
_copyCursor = value;
|
||||
FireNotification(NotificationID.CopyCursor);
|
||||
}
|
||||
}
|
||||
|
||||
public CursorID CancelCursor
|
||||
{
|
||||
get => _cancelCursor;
|
||||
set
|
||||
{
|
||||
if (_cancelCursor == value)
|
||||
return;
|
||||
_cancelCursor = value;
|
||||
FireNotification(NotificationID.CancelCursor);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMousePrimaryDown(UIClass ui, MouseButtonInfo info)
|
||||
{
|
||||
_pendingDrag = true;
|
||||
_initialX = info.ScreenX;
|
||||
_initialY = info.ScreenY;
|
||||
base.OnMousePrimaryDown(ui, info);
|
||||
}
|
||||
|
||||
protected override void OnMouseMove(UIClass ui, MouseMoveInfo info)
|
||||
{
|
||||
if (Dragging)
|
||||
{
|
||||
DragDropHelper.Requery(info.NaturalHit, info.ScreenX, info.ScreenY, info.Modifiers);
|
||||
info.MarkHandled();
|
||||
}
|
||||
else if (_pendingDrag)
|
||||
{
|
||||
if (Math.Abs(info.ScreenX - _initialX) >= Win32Api.GetSystemMetrics(68) || Math.Abs(info.ScreenY - _initialY) >= Win32Api.GetSystemMetrics(69))
|
||||
{
|
||||
_pendingDrag = false;
|
||||
DragDropHelper.BeginDrag(this, info.Target, info.NaturalHit, 0, 0, info.Modifiers);
|
||||
UI.SessionInput += new SessionInputHandler(OnSessionInput);
|
||||
FireNotification(NotificationID.Dragging);
|
||||
FireNotification(NotificationID.Started);
|
||||
UpdateCursor();
|
||||
info.MarkHandled();
|
||||
}
|
||||
}
|
||||
else if (_dragCanceled)
|
||||
info.MarkHandled();
|
||||
base.OnMouseMove(ui, info);
|
||||
}
|
||||
|
||||
protected override void OnMousePrimaryUp(UIClass sender, MouseButtonInfo info)
|
||||
{
|
||||
_pendingDrag = false;
|
||||
if (Dragging)
|
||||
{
|
||||
EndDrag(info?.NaturalHit, info.Modifiers, CurrentDropAction);
|
||||
info.MarkHandled();
|
||||
}
|
||||
else if (_dragCanceled)
|
||||
{
|
||||
_dragCanceled = false;
|
||||
info.MarkHandled();
|
||||
}
|
||||
base.OnMousePrimaryUp(sender, info);
|
||||
}
|
||||
|
||||
protected override void OnDragComplete(UIClass sender, DragDropInfo info)
|
||||
{
|
||||
DragDropHelper.OnDragComplete();
|
||||
info.MarkHandled();
|
||||
base.OnDragComplete(sender, info);
|
||||
}
|
||||
|
||||
private void OnSessionInput(InputInfo originalEvent, EventRouteStages handledStage)
|
||||
{
|
||||
switch (originalEvent)
|
||||
{
|
||||
case KeyStateInfo keyStateInfo:
|
||||
switch (keyStateInfo.Key)
|
||||
{
|
||||
case Keys.ControlKey:
|
||||
InputModifiers modifiers = keyStateInfo.Modifiers;
|
||||
if (keyStateInfo.Action == KeyAction.Down)
|
||||
modifiers |= InputModifiers.ControlKey;
|
||||
DragDropHelper.Requery(modifiers);
|
||||
break;
|
||||
case Keys.Escape:
|
||||
EndDrag(null, keyStateInfo.Modifiers, DropAction.None);
|
||||
_dragCanceled = true;
|
||||
break;
|
||||
}
|
||||
keyStateInfo.MarkHandled();
|
||||
break;
|
||||
case MouseButtonInfo mouseButtonInfo:
|
||||
if (mouseButtonInfo.Button == MouseButtons.Left)
|
||||
break;
|
||||
mouseButtonInfo.MarkHandled();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnLoseKeyFocus(UIClass sender, KeyFocusInfo info)
|
||||
{
|
||||
_pendingDrag = false;
|
||||
if (Dragging)
|
||||
EndDrag(null, DragDropHelper.Modifiers, DropAction.None);
|
||||
base.OnLoseKeyFocus(sender, info);
|
||||
}
|
||||
|
||||
protected override void OnLoseMouseFocus(UIClass sender, MouseFocusInfo info)
|
||||
{
|
||||
_pendingDrag = false;
|
||||
if (Dragging)
|
||||
EndDrag(null, DragDropHelper.Modifiers, DropAction.None);
|
||||
base.OnLoseMouseFocus(sender, info);
|
||||
}
|
||||
|
||||
private void EndDrag(IRawInputSite target, InputModifiers modifiers, DropAction action)
|
||||
{
|
||||
UI.SessionInput -= new SessionInputHandler(OnSessionInput);
|
||||
DragDropHelper.EndDrag(target, modifiers, action);
|
||||
}
|
||||
|
||||
internal void OnEndDrag(DropAction action)
|
||||
{
|
||||
FireNotification(NotificationID.Dragging);
|
||||
switch (action)
|
||||
{
|
||||
case DropAction.None:
|
||||
FireNotification(NotificationID.Canceled);
|
||||
break;
|
||||
case DropAction.Copy:
|
||||
FireNotification(NotificationID.Copied);
|
||||
break;
|
||||
case DropAction.Move:
|
||||
FireNotification(NotificationID.Moved);
|
||||
break;
|
||||
}
|
||||
UpdateCursor();
|
||||
}
|
||||
|
||||
internal void UpdateCurrentAction()
|
||||
{
|
||||
DropAction dropAction = DragDropHelper.AllowedDropActions & AllowedDropActions;
|
||||
if ((dropAction & DropAction.All) == DropAction.All)
|
||||
{
|
||||
if ((DragDropHelper.Modifiers & InputModifiers.ControlKey) == InputModifiers.ControlKey)
|
||||
SetCurrentDropAction(DropAction.Copy);
|
||||
else
|
||||
SetCurrentDropAction(DropAction.Move);
|
||||
}
|
||||
else
|
||||
SetCurrentDropAction(dropAction);
|
||||
}
|
||||
|
||||
internal override CursorID GetCursor()
|
||||
{
|
||||
if (Dragging)
|
||||
{
|
||||
switch (CurrentDropAction)
|
||||
{
|
||||
case DropAction.None:
|
||||
return CancelCursor;
|
||||
case DropAction.Copy:
|
||||
return CopyCursor;
|
||||
case DropAction.Move:
|
||||
return MoveCursor;
|
||||
}
|
||||
}
|
||||
return CursorID.NotSpecified;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.DropAction
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
[Flags]
|
||||
internal enum DropAction
|
||||
{
|
||||
None = 0,
|
||||
Copy = 1,
|
||||
Move = 2,
|
||||
All = Move | Copy, // 0x00000003
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,102 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.DropTargetHandler
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.Session;
|
||||
using Microsoft.Iris.UI;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal class DropTargetHandler : InputHandler
|
||||
{
|
||||
private bool _dragging;
|
||||
private DropAction _allowedDropActions;
|
||||
private WeakReference _eventContext;
|
||||
|
||||
internal DropTargetHandler() => UISession.Default.Form.EnableExternalDragDrop = true;
|
||||
|
||||
protected override void ConfigureInteractivity()
|
||||
{
|
||||
base.ConfigureInteractivity();
|
||||
if (!HandleDirect)
|
||||
return;
|
||||
UI.MouseInteractive = true;
|
||||
}
|
||||
|
||||
public DropAction AllowedDropActions
|
||||
{
|
||||
get => _allowedDropActions;
|
||||
set
|
||||
{
|
||||
if (_allowedDropActions == value)
|
||||
return;
|
||||
_allowedDropActions = value;
|
||||
FireNotification(NotificationID.AllowedDropActions);
|
||||
if (!Dragging)
|
||||
return;
|
||||
DragDropHelper.OnAllowedDropActionsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public bool Dragging => _dragging;
|
||||
|
||||
public object EventContext => CheckEventContext(ref _eventContext);
|
||||
|
||||
protected override void OnDragEnter(UIClass ui, DragDropInfo info)
|
||||
{
|
||||
_dragging = true;
|
||||
DragDropHelper.TargetHandler = this;
|
||||
FireNotification(NotificationID.Dragging);
|
||||
FireNotification(NotificationID.DragEnter);
|
||||
SetEventContext(info.Target, ref _eventContext, NotificationID.EventContext);
|
||||
info.MarkHandled();
|
||||
base.OnDragEnter(ui, info);
|
||||
}
|
||||
|
||||
protected override void OnDragOver(UIClass ui, DragDropInfo info)
|
||||
{
|
||||
if (Dragging)
|
||||
{
|
||||
FireNotification(NotificationID.DragOver);
|
||||
info.MarkHandled();
|
||||
}
|
||||
base.OnDragOver(ui, info);
|
||||
}
|
||||
|
||||
protected override void OnDragLeave(UIClass ui, DragDropInfo info)
|
||||
{
|
||||
if (Dragging)
|
||||
{
|
||||
EndDrag(NotificationID.DragLeave);
|
||||
info.MarkHandled();
|
||||
SetEventContext(null, ref _eventContext, NotificationID.EventContext);
|
||||
}
|
||||
base.OnDragLeave(ui, info);
|
||||
}
|
||||
|
||||
protected override void OnDropped(UIClass ui, DragDropInfo info)
|
||||
{
|
||||
if (Dragging)
|
||||
{
|
||||
EndDrag(NotificationID.Dropped);
|
||||
info.MarkHandled();
|
||||
}
|
||||
base.OnDropped(ui, info);
|
||||
}
|
||||
|
||||
private void EndDrag(string eventName)
|
||||
{
|
||||
_dragging = false;
|
||||
FireNotification(NotificationID.Dragging);
|
||||
FireNotification(eventName);
|
||||
DragDropHelper.TargetHandler = null;
|
||||
}
|
||||
|
||||
public object GetValue() => DragDropHelper.GetValue();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.EventContext
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.UI;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal class EventContext : InputHandler
|
||||
{
|
||||
private object _value;
|
||||
|
||||
protected override void ConfigureInteractivity() => UI.SetEventContext(this);
|
||||
|
||||
public object Value
|
||||
{
|
||||
get => _value;
|
||||
set
|
||||
{
|
||||
if (_value == value)
|
||||
return;
|
||||
_value = value;
|
||||
FireNotification(NotificationID.Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.FocusChangeReason
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
[Flags]
|
||||
internal enum FocusChangeReason
|
||||
{
|
||||
Mouse = 1,
|
||||
Directional = 2,
|
||||
Tab = 4,
|
||||
Key = Tab | Directional, // 0x00000006
|
||||
Other = 8,
|
||||
Any = Other | Key | Mouse, // 0x0000000F
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.FocusHandler
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.Session;
|
||||
using Microsoft.Iris.UI;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal class FocusHandler : ModifierInputHandler
|
||||
{
|
||||
private FocusChangeReason _changeReason;
|
||||
private WeakReference _gainedEventContext;
|
||||
private WeakReference _lostEventContext;
|
||||
|
||||
public FocusHandler() => _changeReason = FocusChangeReason.Any;
|
||||
|
||||
protected override void ConfigureInteractivity()
|
||||
{
|
||||
base.ConfigureInteractivity();
|
||||
if (!HandleDirect)
|
||||
return;
|
||||
UI.KeyInteractive = true;
|
||||
}
|
||||
|
||||
public FocusChangeReason Reason
|
||||
{
|
||||
get => _changeReason;
|
||||
set
|
||||
{
|
||||
if (_changeReason == value)
|
||||
return;
|
||||
_changeReason = value;
|
||||
FireNotification(NotificationID.Reason);
|
||||
}
|
||||
}
|
||||
|
||||
public object GainedEventContext => CheckEventContext(ref _gainedEventContext);
|
||||
|
||||
public object LostEventContext => CheckEventContext(ref _lostEventContext);
|
||||
|
||||
protected override void OnGainKeyFocus(UIClass ui, KeyFocusInfo info)
|
||||
{
|
||||
if (!ShouldHandleEvent(info))
|
||||
return;
|
||||
SetEventContext(info.Target, ref _gainedEventContext, NotificationID.GainedEventContext);
|
||||
FireNotification(NotificationID.GainedFocus);
|
||||
}
|
||||
|
||||
protected override void OnLoseKeyFocus(UIClass ui, KeyFocusInfo info)
|
||||
{
|
||||
if (!ShouldHandleEvent(info))
|
||||
return;
|
||||
SetEventContext(info.Target, ref _lostEventContext, NotificationID.LostEventContext);
|
||||
FireNotification(NotificationID.LostFocus);
|
||||
}
|
||||
|
||||
private bool ShouldHandleEvent(KeyFocusInfo info) => Library.Bits.TestAnyFlags((uint)Reason, (uint)GetFocusChangeReason(info)) && ShouldHandleEvent(GetModifiers(UISession.Default.InputManager.Modifiers));
|
||||
|
||||
private static FocusChangeReason GetFocusChangeReason(KeyFocusInfo info)
|
||||
{
|
||||
switch (info.FocusReason)
|
||||
{
|
||||
case KeyFocusReason.Directional:
|
||||
return FocusChangeReason.Directional;
|
||||
case KeyFocusReason.Tab:
|
||||
return FocusChangeReason.Tab;
|
||||
case KeyFocusReason.MouseDown:
|
||||
case KeyFocusReason.MouseEnter:
|
||||
return FocusChangeReason.Mouse;
|
||||
default:
|
||||
return FocusChangeReason.Other;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,273 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.KeyHandler
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Library;
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.ModelItems;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.Session;
|
||||
using Microsoft.Iris.UI;
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal class KeyHandler : ModifierInputHandler
|
||||
{
|
||||
private ArrayList _invokedKeys;
|
||||
private KeyHandlerKey _key;
|
||||
private IUICommand _command;
|
||||
private bool _pressing;
|
||||
private bool _handle;
|
||||
private bool _stopRoute;
|
||||
private bool _repeat;
|
||||
private WeakReference _eventContext;
|
||||
|
||||
public KeyHandler()
|
||||
{
|
||||
_handle = true;
|
||||
HandlerTransition = InputHandlerTransition.Down;
|
||||
_key = KeyHandlerKey.None;
|
||||
_repeat = true;
|
||||
}
|
||||
|
||||
protected override void ConfigureInteractivity()
|
||||
{
|
||||
base.ConfigureInteractivity();
|
||||
if (!HandleDirect)
|
||||
return;
|
||||
UI.KeyInteractive = true;
|
||||
}
|
||||
|
||||
public bool Pressing => _pressing;
|
||||
|
||||
public KeyHandlerKey Key
|
||||
{
|
||||
get => _key;
|
||||
set
|
||||
{
|
||||
if (_key == value)
|
||||
return;
|
||||
_key = value;
|
||||
FireNotification(NotificationID.Key);
|
||||
}
|
||||
}
|
||||
|
||||
public IUICommand Command
|
||||
{
|
||||
get => _command;
|
||||
set
|
||||
{
|
||||
if (_command == value)
|
||||
return;
|
||||
_command = value;
|
||||
FireNotification(NotificationID.Command);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Handle
|
||||
{
|
||||
get => _handle;
|
||||
set
|
||||
{
|
||||
if (_handle == value)
|
||||
return;
|
||||
_handle = value;
|
||||
FireNotification(NotificationID.Handle);
|
||||
}
|
||||
}
|
||||
|
||||
public bool StopRoute
|
||||
{
|
||||
get => _stopRoute;
|
||||
set
|
||||
{
|
||||
_stopRoute = value;
|
||||
FireNotification(NotificationID.StopRoute);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Repeat
|
||||
{
|
||||
get => _repeat;
|
||||
set
|
||||
{
|
||||
if (_repeat == value)
|
||||
return;
|
||||
_repeat = value;
|
||||
FireNotification(NotificationID.Repeat);
|
||||
}
|
||||
}
|
||||
|
||||
public object EventContext => CheckEventContext(ref _eventContext);
|
||||
|
||||
public bool TrackInvokedKeys
|
||||
{
|
||||
get => _invokedKeys != null;
|
||||
set
|
||||
{
|
||||
if (TrackInvokedKeys == value)
|
||||
return;
|
||||
_invokedKeys = !value ? null : new ArrayList();
|
||||
FireNotification(NotificationID.TrackInvokedKeys);
|
||||
}
|
||||
}
|
||||
|
||||
public void GetInvokedKeys(IList copyTo)
|
||||
{
|
||||
if (TrackInvokedKeys)
|
||||
{
|
||||
foreach (object invokedKey in _invokedKeys)
|
||||
copyTo.Add(invokedKey);
|
||||
_invokedKeys.Clear();
|
||||
}
|
||||
else
|
||||
ErrorManager.ReportError("KeyHandler needs to be marked TrackInvokedKeys=\"true\" in order to call GetInvokedKeys()");
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(UIClass ui, KeyStateInfo info)
|
||||
{
|
||||
Keys key = info.Key;
|
||||
InputHandlerModifiers modifiers = GetModifiers(info.Modifiers);
|
||||
if (key != (Keys)_key)
|
||||
TranslateKey(ref key, ref modifiers);
|
||||
if (!KeyMatches(key) || !ShouldHandleEvent(modifiers))
|
||||
return;
|
||||
bool flag;
|
||||
if (!_pressing)
|
||||
{
|
||||
_pressing = true;
|
||||
FireNotification(NotificationID.Pressing);
|
||||
flag = true;
|
||||
}
|
||||
else
|
||||
flag = _repeat;
|
||||
if (flag)
|
||||
{
|
||||
if (HandlerTransition == InputHandlerTransition.Down)
|
||||
InvokeCommand(key);
|
||||
if (_handle)
|
||||
info.MarkHandled();
|
||||
}
|
||||
if (_stopRoute)
|
||||
info.TruncateRoute();
|
||||
SetEventContext(info.Target, ref _eventContext, NotificationID.EventContext);
|
||||
}
|
||||
|
||||
protected override void OnKeyUp(UIClass ui, KeyStateInfo info)
|
||||
{
|
||||
Keys key = info.Key;
|
||||
InputHandlerModifiers modifiers = GetModifiers(info.Modifiers);
|
||||
if (key != (Keys)_key)
|
||||
TranslateKey(ref key, ref modifiers);
|
||||
if (!KeyMatches(key) || !ShouldHandleEvent(modifiers))
|
||||
return;
|
||||
_pressing = false;
|
||||
FireNotification(NotificationID.Pressing);
|
||||
if (HandlerTransition == InputHandlerTransition.Up)
|
||||
InvokeCommand(key);
|
||||
if (_handle)
|
||||
info.MarkHandled();
|
||||
if (_stopRoute)
|
||||
info.TruncateRoute();
|
||||
SetEventContext(info.Target, ref _eventContext, NotificationID.EventContext);
|
||||
}
|
||||
|
||||
protected override void OnLoseKeyFocus(UIClass ui, KeyFocusInfo info)
|
||||
{
|
||||
if (!_pressing)
|
||||
return;
|
||||
_pressing = false;
|
||||
FireNotification(NotificationID.Pressing);
|
||||
}
|
||||
|
||||
private bool KeyMatches(Keys candidate)
|
||||
{
|
||||
if (_key >= KeyHandlerKey.None)
|
||||
return candidate == (Keys)_key;
|
||||
return _key == KeyHandlerKey.Any && candidate != Keys.None;
|
||||
}
|
||||
|
||||
public static void TranslateKey(ref Keys key, ref InputHandlerModifiers modifiers) => TranslateKey(ref key, ref modifiers, Orientation.Horizontal);
|
||||
|
||||
public static void TranslateKey(
|
||||
ref Keys key,
|
||||
ref InputHandlerModifiers modifiers,
|
||||
Orientation orientation)
|
||||
{
|
||||
InputHandlerModifiers handlerModifiers = modifiers;
|
||||
modifiers = InputHandlerModifiers.None;
|
||||
switch (key)
|
||||
{
|
||||
case Keys.GamePadA:
|
||||
case Keys.GamePadStart:
|
||||
key = Keys.Enter;
|
||||
break;
|
||||
case Keys.GamePadB:
|
||||
case Keys.GamePadBack:
|
||||
key = Keys.Back;
|
||||
break;
|
||||
case Keys.GamePadRShoulder:
|
||||
key = Keys.Tab;
|
||||
break;
|
||||
case Keys.GamePadLShoulder:
|
||||
key = Keys.Tab;
|
||||
modifiers = InputHandlerModifiers.Shift;
|
||||
break;
|
||||
case Keys.GamePadLTrigger:
|
||||
key = Keys.PageUp;
|
||||
break;
|
||||
case Keys.GamePadRTrigger:
|
||||
key = Keys.Next;
|
||||
break;
|
||||
case Keys.GamePadDPadUp:
|
||||
case Keys.GamePadLThumbUp:
|
||||
key = Keys.Up;
|
||||
break;
|
||||
case Keys.GamePadDPadDown:
|
||||
case Keys.GamePadLThumbDown:
|
||||
key = Keys.Down;
|
||||
break;
|
||||
case Keys.GamePadDPadLeft:
|
||||
case Keys.GamePadLThumbLeft:
|
||||
key = Keys.Left;
|
||||
break;
|
||||
case Keys.GamePadDPadRight:
|
||||
case Keys.GamePadLThumbRight:
|
||||
key = Keys.Right;
|
||||
break;
|
||||
case Keys.GamePadLThumbUpLeft:
|
||||
key = orientation == Orientation.Vertical ? Keys.Up : Keys.Left;
|
||||
break;
|
||||
case Keys.GamePadLThumbUpRight:
|
||||
key = orientation == Orientation.Vertical ? Keys.Up : Keys.Right;
|
||||
break;
|
||||
case Keys.GamePadLThumbDownRight:
|
||||
key = orientation == Orientation.Vertical ? Keys.Down : Keys.Right;
|
||||
break;
|
||||
case Keys.GamePadLThumbDownLeft:
|
||||
key = orientation == Orientation.Vertical ? Keys.Down : Keys.Left;
|
||||
break;
|
||||
default:
|
||||
modifiers = handlerModifiers;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void InvokeCommand(Keys key)
|
||||
{
|
||||
FireNotification(NotificationID.Invoked);
|
||||
if (_command != null)
|
||||
_command.Invoke();
|
||||
if (!TrackInvokedKeys)
|
||||
return;
|
||||
_invokedKeys.Add((KeyHandlerKey)key);
|
||||
}
|
||||
|
||||
public override string ToString() => InvariantString.Format("{0}({1})", GetType().Name, _key);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,155 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.KeyHandlerKey
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal enum KeyHandlerKey
|
||||
{
|
||||
Any = -1, // 0xFFFFFFFF
|
||||
None = 0,
|
||||
Backspace = 8,
|
||||
Tab = 9,
|
||||
Clear = 12, // 0x0000000C
|
||||
Enter = 13, // 0x0000000D
|
||||
Shift = 16, // 0x00000010
|
||||
Control = 17, // 0x00000011
|
||||
Alt = 18, // 0x00000012
|
||||
CapsLock = 20, // 0x00000014
|
||||
Escape = 27, // 0x0000001B
|
||||
Space = 32, // 0x00000020
|
||||
PageUp = 33, // 0x00000021
|
||||
PageDown = 34, // 0x00000022
|
||||
End = 35, // 0x00000023
|
||||
Home = 36, // 0x00000024
|
||||
Left = 37, // 0x00000025
|
||||
Up = 38, // 0x00000026
|
||||
Right = 39, // 0x00000027
|
||||
Down = 40, // 0x00000028
|
||||
PrintScreen = 44, // 0x0000002C
|
||||
Insert = 45, // 0x0000002D
|
||||
Delete = 46, // 0x0000002E
|
||||
D0 = 48, // 0x00000030
|
||||
D1 = 49, // 0x00000031
|
||||
D2 = 50, // 0x00000032
|
||||
D3 = 51, // 0x00000033
|
||||
D4 = 52, // 0x00000034
|
||||
D5 = 53, // 0x00000035
|
||||
D6 = 54, // 0x00000036
|
||||
D7 = 55, // 0x00000037
|
||||
D8 = 56, // 0x00000038
|
||||
D9 = 57, // 0x00000039
|
||||
A = 65, // 0x00000041
|
||||
B = 66, // 0x00000042
|
||||
C = 67, // 0x00000043
|
||||
D = 68, // 0x00000044
|
||||
E = 69, // 0x00000045
|
||||
F = 70, // 0x00000046
|
||||
G = 71, // 0x00000047
|
||||
H = 72, // 0x00000048
|
||||
I = 73, // 0x00000049
|
||||
J = 74, // 0x0000004A
|
||||
K = 75, // 0x0000004B
|
||||
L = 76, // 0x0000004C
|
||||
M = 77, // 0x0000004D
|
||||
N = 78, // 0x0000004E
|
||||
O = 79, // 0x0000004F
|
||||
P = 80, // 0x00000050
|
||||
Q = 81, // 0x00000051
|
||||
R = 82, // 0x00000052
|
||||
S = 83, // 0x00000053
|
||||
T = 84, // 0x00000054
|
||||
U = 85, // 0x00000055
|
||||
V = 86, // 0x00000056
|
||||
W = 87, // 0x00000057
|
||||
X = 88, // 0x00000058
|
||||
Y = 89, // 0x00000059
|
||||
Z = 90, // 0x0000005A
|
||||
Apps = 93, // 0x0000005D
|
||||
NumPad0 = 96, // 0x00000060
|
||||
NumPad1 = 97, // 0x00000061
|
||||
NumPad2 = 98, // 0x00000062
|
||||
NumPad3 = 99, // 0x00000063
|
||||
NumPad4 = 100, // 0x00000064
|
||||
NumPad5 = 101, // 0x00000065
|
||||
NumPad6 = 102, // 0x00000066
|
||||
NumPad7 = 103, // 0x00000067
|
||||
NumPad8 = 104, // 0x00000068
|
||||
NumPad9 = 105, // 0x00000069
|
||||
Multiply = 106, // 0x0000006A
|
||||
Add = 107, // 0x0000006B
|
||||
Subtract = 109, // 0x0000006D
|
||||
Divide = 111, // 0x0000006F
|
||||
F1 = 112, // 0x00000070
|
||||
F2 = 113, // 0x00000071
|
||||
F3 = 114, // 0x00000072
|
||||
F4 = 115, // 0x00000073
|
||||
F5 = 116, // 0x00000074
|
||||
F6 = 117, // 0x00000075
|
||||
F7 = 118, // 0x00000076
|
||||
F8 = 119, // 0x00000077
|
||||
F9 = 120, // 0x00000078
|
||||
F10 = 121, // 0x00000079
|
||||
F11 = 122, // 0x0000007A
|
||||
F12 = 123, // 0x0000007B
|
||||
F13 = 124, // 0x0000007C
|
||||
F14 = 125, // 0x0000007D
|
||||
F15 = 126, // 0x0000007E
|
||||
F16 = 127, // 0x0000007F
|
||||
F17 = 128, // 0x00000080
|
||||
F18 = 129, // 0x00000081
|
||||
F19 = 130, // 0x00000082
|
||||
F20 = 131, // 0x00000083
|
||||
F21 = 132, // 0x00000084
|
||||
F22 = 133, // 0x00000085
|
||||
F23 = 134, // 0x00000086
|
||||
F24 = 135, // 0x00000087
|
||||
NumLock = 144, // 0x00000090
|
||||
Semicolon = 186, // 0x000000BA
|
||||
Equals = 187, // 0x000000BB
|
||||
Comma = 188, // 0x000000BC
|
||||
Underscore = 189, // 0x000000BD
|
||||
Period = 190, // 0x000000BE
|
||||
QuestionMark = 191, // 0x000000BF
|
||||
Tilde = 192, // 0x000000C0
|
||||
OpenBrace = 219, // 0x000000DB
|
||||
Pipe = 220, // 0x000000DC
|
||||
CloseBrace = 221, // 0x000000DD
|
||||
Quotes = 222, // 0x000000DE
|
||||
Backslash = 226, // 0x000000E2
|
||||
GamePadA = 22528, // 0x00005800
|
||||
GamePadB = 22529, // 0x00005801
|
||||
GamePadX = 22530, // 0x00005802
|
||||
GamePadY = 22531, // 0x00005803
|
||||
GamePadRShoulder = 22532, // 0x00005804
|
||||
GamePadLShoulder = 22533, // 0x00005805
|
||||
GamePadLTrigger = 22534, // 0x00005806
|
||||
GamePadRTrigger = 22535, // 0x00005807
|
||||
GamePadDPadUp = 22544, // 0x00005810
|
||||
GamePadDPadDown = 22545, // 0x00005811
|
||||
GamePadDPadLeft = 22546, // 0x00005812
|
||||
GamePadDPadRight = 22547, // 0x00005813
|
||||
GamePadStart = 22548, // 0x00005814
|
||||
GamePadLThumbPress = 22550, // 0x00005816
|
||||
GamePadRThumbPress = 22551, // 0x00005817
|
||||
GamePadLThumbUp = 22560, // 0x00005820
|
||||
GamePadLThumbDown = 22561, // 0x00005821
|
||||
GamePadLThumbRight = 22562, // 0x00005822
|
||||
GamePadLThumbLeft = 22563, // 0x00005823
|
||||
GamePadLThumbUpLeft = 22564, // 0x00005824
|
||||
GamePadLThumbUpRight = 22565, // 0x00005825
|
||||
GamePadLThumbDownRight = 22566, // 0x00005826
|
||||
GamePadLThumbDownLeft = 22567, // 0x00005827
|
||||
GamePadRThumbUp = 22576, // 0x00005830
|
||||
GamePadRThumbDown = 22577, // 0x00005831
|
||||
GamePadRThumbRight = 22578, // 0x00005832
|
||||
GamePadRThumbLeft = 22579, // 0x00005833
|
||||
GamePadRThumbUpLeft = 22580, // 0x00005834
|
||||
GamePadRThumbUpRight = 22581, // 0x00005835
|
||||
GamePadRThumbDownRight = 22582, // 0x00005836
|
||||
GamePadRThumbDownLeft = 22583, // 0x00005837
|
||||
GamePadBack = 22597, // 0x00005845
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.ModifierInputHandler
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.UI;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal class ModifierInputHandler : InputHandler
|
||||
{
|
||||
private InputHandlerModifiers _requiredModifiers;
|
||||
private InputHandlerModifiers _disallowedModifiers;
|
||||
private InputHandlerTransition _handlerTransition;
|
||||
|
||||
public ModifierInputHandler()
|
||||
{
|
||||
_handlerTransition = InputHandlerTransition.Up;
|
||||
_requiredModifiers = InputHandlerModifiers.None;
|
||||
_disallowedModifiers = InputHandlerModifiers.None;
|
||||
}
|
||||
|
||||
public InputHandlerTransition HandlerTransition
|
||||
{
|
||||
get => _handlerTransition;
|
||||
set
|
||||
{
|
||||
if (_handlerTransition == value)
|
||||
return;
|
||||
_handlerTransition = value;
|
||||
FireNotification(NotificationID.HandlerTransition);
|
||||
}
|
||||
}
|
||||
|
||||
public InputHandlerModifiers RequiredModifiers
|
||||
{
|
||||
get => _requiredModifiers;
|
||||
set
|
||||
{
|
||||
if (_requiredModifiers == value)
|
||||
return;
|
||||
_requiredModifiers = value;
|
||||
FireNotification(NotificationID.RequiredModifiers);
|
||||
}
|
||||
}
|
||||
|
||||
public InputHandlerModifiers DisallowedModifiers
|
||||
{
|
||||
get => _disallowedModifiers;
|
||||
set
|
||||
{
|
||||
if (_disallowedModifiers == value)
|
||||
return;
|
||||
_disallowedModifiers = value;
|
||||
FireNotification(NotificationID.DisallowedModifiers);
|
||||
}
|
||||
}
|
||||
|
||||
protected bool ShouldHandleEvent(InputHandlerModifiers modifiers) => (_disallowedModifiers == InputHandlerModifiers.None || !Library.Bits.TestAnyFlags((uint)modifiers, (uint)_disallowedModifiers)) && (_requiredModifiers == InputHandlerModifiers.None || Library.Bits.TestAllFlags((uint)modifiers, (uint)_requiredModifiers));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.MouseWheelHandler
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.UI;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal class MouseWheelHandler : InputHandler
|
||||
{
|
||||
private bool _handle;
|
||||
|
||||
public MouseWheelHandler() => _handle = true;
|
||||
|
||||
protected override void ConfigureInteractivity()
|
||||
{
|
||||
base.ConfigureInteractivity();
|
||||
if (!HandleDirect)
|
||||
return;
|
||||
UI.MouseInteractive = true;
|
||||
UI.KeyInteractive = true;
|
||||
}
|
||||
|
||||
public bool Handle
|
||||
{
|
||||
get => _handle;
|
||||
set
|
||||
{
|
||||
if (_handle == value)
|
||||
return;
|
||||
_handle = value;
|
||||
FireNotification(NotificationID.Handle);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseWheel(UIClass ui, MouseWheelInfo info)
|
||||
{
|
||||
if (info.WheelDelta > 0)
|
||||
FireNotification(NotificationID.UpInvoked);
|
||||
else
|
||||
FireNotification(NotificationID.DownInvoked);
|
||||
if (!_handle)
|
||||
return;
|
||||
info.MarkHandled();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,366 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.ScrollingHandler
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.ModelItems;
|
||||
using Microsoft.Iris.Render;
|
||||
using Microsoft.Iris.UI;
|
||||
using Microsoft.Iris.ViewItems;
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal class ScrollingHandler : InputHandler
|
||||
{
|
||||
private ScrollModel _model;
|
||||
private bool _handleDirectionalKeysFlag;
|
||||
private bool _handlePageKeysFlag;
|
||||
private bool _handleHomeEndKeysFlag;
|
||||
private bool _handlePageCommandsFlag;
|
||||
private bool _handleMouseWheelFlag;
|
||||
private bool _useFocusBehavior;
|
||||
private Keys _currentCampingKey;
|
||||
private int _cumulativeMouseWheelDelta;
|
||||
|
||||
public ScrollingHandler()
|
||||
{
|
||||
_handleDirectionalKeysFlag = true;
|
||||
_handlePageKeysFlag = true;
|
||||
_handlePageCommandsFlag = true;
|
||||
_handleHomeEndKeysFlag = true;
|
||||
_handleMouseWheelFlag = true;
|
||||
_useFocusBehavior = true;
|
||||
HandlerStage = InputHandlerStage.Direct | InputHandlerStage.Bubbled;
|
||||
}
|
||||
|
||||
protected override void ConfigureInteractivity()
|
||||
{
|
||||
base.ConfigureInteractivity();
|
||||
if (!HandleDirect)
|
||||
return;
|
||||
if (_handleDirectionalKeysFlag || _handlePageKeysFlag || (_handleHomeEndKeysFlag || _handlePageCommandsFlag))
|
||||
UI.KeyInteractive = true;
|
||||
if (!_handleMouseWheelFlag)
|
||||
return;
|
||||
UI.MouseInteractive = true;
|
||||
}
|
||||
|
||||
public bool HandleDirectionalKeys
|
||||
{
|
||||
get => _handleDirectionalKeysFlag;
|
||||
set
|
||||
{
|
||||
if (_handleDirectionalKeysFlag == value)
|
||||
return;
|
||||
_handleDirectionalKeysFlag = value;
|
||||
FireNotification(NotificationID.HandleDirectionalKeys);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HandlePageKeys
|
||||
{
|
||||
get => _handlePageKeysFlag;
|
||||
set
|
||||
{
|
||||
if (_handlePageKeysFlag == value)
|
||||
return;
|
||||
_handlePageKeysFlag = value;
|
||||
FireNotification(NotificationID.HandlePageKeys);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HandleHomeEndKeys
|
||||
{
|
||||
get => _handleHomeEndKeysFlag;
|
||||
set
|
||||
{
|
||||
if (_handleHomeEndKeysFlag == value)
|
||||
return;
|
||||
_handleHomeEndKeysFlag = value;
|
||||
FireNotification(NotificationID.HandleHomeEndKeys);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HandlePageCommands
|
||||
{
|
||||
get => _handlePageCommandsFlag;
|
||||
set
|
||||
{
|
||||
if (_handlePageCommandsFlag == value)
|
||||
return;
|
||||
_handlePageCommandsFlag = value;
|
||||
FireNotification(NotificationID.HandlePageCommands);
|
||||
}
|
||||
}
|
||||
|
||||
public bool HandleMouseWheel
|
||||
{
|
||||
get => _handleMouseWheelFlag;
|
||||
set
|
||||
{
|
||||
if (_handleMouseWheelFlag == value)
|
||||
return;
|
||||
_handleMouseWheelFlag = value;
|
||||
FireNotification(NotificationID.HandleMouseWheel);
|
||||
}
|
||||
}
|
||||
|
||||
public ScrollModel ScrollModel
|
||||
{
|
||||
get => _model;
|
||||
set
|
||||
{
|
||||
if (_model == value)
|
||||
return;
|
||||
_model = value;
|
||||
FireNotification(NotificationID.ScrollModel);
|
||||
}
|
||||
}
|
||||
|
||||
public bool UseFocusBehavior
|
||||
{
|
||||
get => _useFocusBehavior;
|
||||
set
|
||||
{
|
||||
if (_useFocusBehavior == value)
|
||||
return;
|
||||
_useFocusBehavior = value;
|
||||
FireNotification(NotificationID.UseFocusBehavior);
|
||||
}
|
||||
}
|
||||
|
||||
private bool ValidScrollModel => _model != null && _model.Enabled;
|
||||
|
||||
protected override void OnGainKeyFocus(UIClass sender, KeyFocusInfo info)
|
||||
{
|
||||
if (!ValidScrollModel || !_useFocusBehavior)
|
||||
return;
|
||||
_model.NotifyFocusChange(info.Target as UIClass);
|
||||
}
|
||||
|
||||
protected override void OnKeyDown(UIClass ui, KeyStateInfo info)
|
||||
{
|
||||
if (!ValidScrollModel)
|
||||
return;
|
||||
if (info.Key != _currentCampingKey)
|
||||
EndCamp();
|
||||
Keys key = info.Key;
|
||||
InputHandlerModifiers modifiers = GetModifiers(info.Modifiers);
|
||||
KeyHandler.TranslateKey(ref key, ref modifiers, Orientation);
|
||||
switch (ShouldHandleKey(key))
|
||||
{
|
||||
case HandleKeyPolicy.None:
|
||||
return;
|
||||
case HandleKeyPolicy.Up:
|
||||
_model.ScrollUp(_useFocusBehavior);
|
||||
break;
|
||||
case HandleKeyPolicy.Down:
|
||||
_model.ScrollDown(_useFocusBehavior);
|
||||
break;
|
||||
case HandleKeyPolicy.PageUp:
|
||||
_model.PageUp(_useFocusBehavior);
|
||||
break;
|
||||
case HandleKeyPolicy.PageDown:
|
||||
_model.PageDown(_useFocusBehavior);
|
||||
break;
|
||||
case HandleKeyPolicy.Home:
|
||||
_model.Home(_useFocusBehavior);
|
||||
break;
|
||||
case HandleKeyPolicy.End:
|
||||
_model.End(_useFocusBehavior);
|
||||
break;
|
||||
}
|
||||
BeginCamp(info.Key);
|
||||
info.MarkHandled();
|
||||
}
|
||||
|
||||
private void BeginCamp(Keys key)
|
||||
{
|
||||
if (!IsCamping)
|
||||
_model.BeginCamp();
|
||||
_currentCampingKey = key;
|
||||
}
|
||||
|
||||
private void EndCamp()
|
||||
{
|
||||
if (!IsCamping)
|
||||
return;
|
||||
_model.EndCamp();
|
||||
_currentCampingKey = Keys.None;
|
||||
}
|
||||
|
||||
private bool IsCamping => _currentCampingKey != Keys.None;
|
||||
|
||||
protected override void OnKeyUp(UIClass ui, KeyStateInfo info)
|
||||
{
|
||||
if (!ValidScrollModel)
|
||||
return;
|
||||
if (info.Key == _currentCampingKey)
|
||||
EndCamp();
|
||||
Keys key = info.Key;
|
||||
InputHandlerModifiers modifiers = GetModifiers(info.Modifiers);
|
||||
KeyHandler.TranslateKey(ref key, ref modifiers, Orientation);
|
||||
if (ShouldHandleKey(key) == HandleKeyPolicy.None)
|
||||
return;
|
||||
info.MarkHandled();
|
||||
}
|
||||
|
||||
protected override void OnLoseDeepKeyFocus() => EndCamp();
|
||||
|
||||
protected override void OnCommandDown(UIClass ui, KeyCommandInfo info)
|
||||
{
|
||||
if (!ValidScrollModel || info.Action != KeyAction.Down)
|
||||
return;
|
||||
switch (info.Command)
|
||||
{
|
||||
case CommandCode.ChannelUp:
|
||||
if (!_handlePageCommandsFlag)
|
||||
break;
|
||||
_model.PageUp();
|
||||
info.MarkHandled();
|
||||
break;
|
||||
case CommandCode.ChannelDown:
|
||||
if (!_handlePageCommandsFlag)
|
||||
break;
|
||||
_model.PageDown();
|
||||
info.MarkHandled();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnCommandUp(UIClass ui, KeyCommandInfo info)
|
||||
{
|
||||
switch (info.Command)
|
||||
{
|
||||
case CommandCode.ChannelUp:
|
||||
case CommandCode.ChannelDown:
|
||||
if (!_handlePageCommandsFlag)
|
||||
break;
|
||||
info.MarkHandled();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnMouseWheel(UIClass ui, MouseWheelInfo info)
|
||||
{
|
||||
if (!_handleMouseWheelFlag || !ValidScrollModel || InputHasKeyModifiers(info))
|
||||
return;
|
||||
_cumulativeMouseWheelDelta += -info.WheelDelta;
|
||||
if (Math.Abs(_cumulativeMouseWheelDelta) >= 120)
|
||||
{
|
||||
if (_cumulativeMouseWheelDelta > 0)
|
||||
_model.ScrollDown(_cumulativeMouseWheelDelta / 120);
|
||||
else
|
||||
_model.ScrollUp(Math.Abs(_cumulativeMouseWheelDelta / 120));
|
||||
_cumulativeMouseWheelDelta %= 120;
|
||||
}
|
||||
info.MarkHandled();
|
||||
}
|
||||
|
||||
private ScrollingHandler.HandleKeyPolicy ShouldHandleKey(Keys key)
|
||||
{
|
||||
ScrollingHandler.HandleKeyPolicy handleKeyPolicy = HandleKeyPolicy.None;
|
||||
switch (key)
|
||||
{
|
||||
case Keys.PageUp:
|
||||
if (_handlePageKeysFlag)
|
||||
{
|
||||
handleKeyPolicy = HandleKeyPolicy.PageUp;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Keys.Next:
|
||||
if (_handlePageKeysFlag)
|
||||
{
|
||||
handleKeyPolicy = HandleKeyPolicy.PageDown;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Keys.End:
|
||||
if (_handleHomeEndKeysFlag)
|
||||
{
|
||||
handleKeyPolicy = HandleKeyPolicy.End;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Keys.Home:
|
||||
if (_handleHomeEndKeysFlag)
|
||||
{
|
||||
handleKeyPolicy = HandleKeyPolicy.Home;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Keys.Left:
|
||||
if (_handleDirectionalKeysFlag && Orientation == Orientation.Horizontal)
|
||||
{
|
||||
handleKeyPolicy = UI.Zone.Session.IsRtl ? HandleKeyPolicy.Down : HandleKeyPolicy.Up;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Keys.Up:
|
||||
if (_handleDirectionalKeysFlag && Orientation == Orientation.Vertical)
|
||||
{
|
||||
handleKeyPolicy = HandleKeyPolicy.Up;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Keys.Right:
|
||||
if (_handleDirectionalKeysFlag && Orientation == Orientation.Horizontal)
|
||||
{
|
||||
handleKeyPolicy = UI.Zone.Session.IsRtl ? HandleKeyPolicy.Up : HandleKeyPolicy.Down;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case Keys.Down:
|
||||
if (_handleDirectionalKeysFlag && Orientation == Orientation.Vertical)
|
||||
{
|
||||
handleKeyPolicy = HandleKeyPolicy.Down;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
return handleKeyPolicy;
|
||||
}
|
||||
|
||||
private Orientation Orientation
|
||||
{
|
||||
get
|
||||
{
|
||||
Orientation orientation = Orientation.Horizontal;
|
||||
if (_model.TargetViewItem is Scroller targetViewItem)
|
||||
orientation = targetViewItem.Orientation;
|
||||
return orientation;
|
||||
}
|
||||
}
|
||||
|
||||
private bool InputHasKeyModifiers(InputInfo info)
|
||||
{
|
||||
InputModifiers inputModifiers = InputModifiers.None;
|
||||
switch (info)
|
||||
{
|
||||
case KeyStateInfo _:
|
||||
inputModifiers = ((KeyActionInfo)info).Modifiers;
|
||||
break;
|
||||
case MouseActionInfo _:
|
||||
inputModifiers = ((MouseActionInfo)info).Modifiers;
|
||||
break;
|
||||
}
|
||||
return (inputModifiers & InputModifiers.AllKeys) != InputModifiers.None;
|
||||
}
|
||||
|
||||
private enum HandleKeyPolicy
|
||||
{
|
||||
None,
|
||||
Up,
|
||||
Down,
|
||||
PageUp,
|
||||
PageDown,
|
||||
Home,
|
||||
End,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,94 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.ShortcutHandler
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
using Microsoft.Iris.Input;
|
||||
using Microsoft.Iris.Library;
|
||||
using Microsoft.Iris.Markup;
|
||||
using Microsoft.Iris.ModelItems;
|
||||
using Microsoft.Iris.UI;
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal class ShortcutHandler : InputHandler
|
||||
{
|
||||
private ShortcutHandlerCommand _shortcut;
|
||||
private IUICommand _command;
|
||||
private bool _handle;
|
||||
|
||||
public ShortcutHandler() => _handle = true;
|
||||
|
||||
protected override void ConfigureInteractivity()
|
||||
{
|
||||
base.ConfigureInteractivity();
|
||||
if (!HandleDirect)
|
||||
return;
|
||||
UI.KeyInteractive = true;
|
||||
}
|
||||
|
||||
public ShortcutHandlerCommand Shortcut
|
||||
{
|
||||
get => _shortcut;
|
||||
set
|
||||
{
|
||||
if (_shortcut == value)
|
||||
return;
|
||||
_shortcut = value;
|
||||
FireNotification(NotificationID.Shortcut);
|
||||
}
|
||||
}
|
||||
|
||||
public IUICommand Command
|
||||
{
|
||||
get => _command;
|
||||
set
|
||||
{
|
||||
if (_command == value)
|
||||
return;
|
||||
_command = value;
|
||||
FireNotification(NotificationID.Command);
|
||||
}
|
||||
}
|
||||
|
||||
public bool Handle
|
||||
{
|
||||
get => _handle;
|
||||
set
|
||||
{
|
||||
if (_handle == value)
|
||||
return;
|
||||
_handle = value;
|
||||
FireNotification(NotificationID.Handle);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnCommandDown(UIClass ui, KeyCommandInfo info)
|
||||
{
|
||||
if (info.Command != (CommandCode)_shortcut)
|
||||
return;
|
||||
InvokeCommand();
|
||||
if (!_handle)
|
||||
return;
|
||||
info.MarkHandled();
|
||||
}
|
||||
|
||||
protected override void OnCommandUp(UIClass ui, KeyCommandInfo info)
|
||||
{
|
||||
if (info.Command != (CommandCode)_shortcut || !_handle)
|
||||
return;
|
||||
info.MarkHandled();
|
||||
}
|
||||
|
||||
private void InvokeCommand()
|
||||
{
|
||||
FireNotification(NotificationID.Invoked);
|
||||
if (_command == null)
|
||||
return;
|
||||
_command.Invoke();
|
||||
}
|
||||
|
||||
public override string ToString() => InvariantString.Format("{0}({1})", GetType().Name, _shortcut);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
// Decompiled with JetBrains decompiler
|
||||
// Type: Microsoft.Iris.InputHandlers.ShortcutHandlerCommand
|
||||
// Assembly: UIX, Version=4.8.0.0, Culture=neutral, PublicKeyToken=ddd0da4d3e678217
|
||||
// MVID: A56C6C9D-B7F6-46A9-8BDE-B3D9B8D60B11
|
||||
// Assembly location: C:\Program Files\Zune\UIX.dll
|
||||
|
||||
namespace Microsoft.Iris.InputHandlers
|
||||
{
|
||||
internal enum ShortcutHandlerCommand
|
||||
{
|
||||
None = 0,
|
||||
ChannelUp = 2,
|
||||
PageUp = 2,
|
||||
ChannelDown = 3,
|
||||
PageDown = 3,
|
||||
Play = 4,
|
||||
Pause = 5,
|
||||
Record = 6,
|
||||
FastForward = 7,
|
||||
Rewind = 8,
|
||||
SkipForward = 9,
|
||||
SkipBack = 10, // 0x0000000A
|
||||
Stop = 11, // 0x0000000B
|
||||
Back = 16, // 0x00000010
|
||||
Clear = 26, // 0x0000001A
|
||||
PlayPause = 30, // 0x0000001E
|
||||
Enter = 36, // 0x00000024
|
||||
OEMExtensibility0 = 73, // 0x00000049
|
||||
OEMExtensibility1 = 74, // 0x0000004A
|
||||
OEMExtensibility2 = 75, // 0x0000004B
|
||||
OEMExtensibility3 = 76, // 0x0000004C
|
||||
OEMExtensibility4 = 77, // 0x0000004D
|
||||
OEMExtensibility5 = 78, // 0x0000004E
|
||||
OEMExtensibility6 = 79, // 0x0000004F
|
||||
OEMExtensibility7 = 80, // 0x00000050
|
||||
OEMExtensibility8 = 81, // 0x00000051
|
||||
OEMExtensibility9 = 82, // 0x00000052
|
||||
OEMExtensibility10 = 83, // 0x00000053
|
||||
OEMExtensibility11 = 84, // 0x00000054
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user