本文整理汇总了C#中MediaPortal.UI.Control.InputManager.Key类的典型用法代码示例。如果您正苦于以下问题:C# Key类的具体用法?C# Key怎么用?C# Key使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Key类属于MediaPortal.UI.Control.InputManager命名空间,在下文中一共展示了Key类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: SerializeKey
protected static string SerializeKey(Key key)
{
if (key.IsPrintableKey)
return "P:" + key.RawCode;
else if (key.IsSpecialKey)
return "S:" + key.Name;
else
throw new NotImplementedException(string.Format("Cannot serialize key '{0}', it is neither a printable nor a special key", key));
}
开发者ID:joconno4,项目名称:MediaPortal-2,代码行数:9,代码来源:MappedKeyCode.cs
示例2: OnKeyPreview
public override void OnKeyPreview(ref Key key)
{
base.OnKeyPreview(ref key);
if (!HasFocus)
return;
// We handle "normal" button presses in the KeyPreview event, because the "Default" event needs
// to be handled after the focused button was able to consume the event
if (key == Key.None) return;
if (key == Key.Ok)
{
Execute();
key = Key.None;
}
}
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:14,代码来源:Button.cs
示例3: RegisterKeyBinding
protected void RegisterKeyBinding()
{
if (_registeredScreen != null)
return;
if (Key == null)
return;
Screen screen = Screen;
if (screen == null)
return;
_registeredScreen = screen;
_registeredKey = Key;
_registeredScreen.AddKeyBinding(_registeredKey, new KeyActionDlgt(Execute));
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:13,代码来源:KeyBinding.cs
示例4: AvoidDuplicateKeys
protected void AvoidDuplicateKeys(Key key)
{
if (_workflowActionShortcuts.ContainsKey(key))
throw new ArgumentException(string.Format("A global shortcut for Key '{0}' was already registered with action '{1}'", key, _workflowActionShortcuts[key].Name));
if (_workflowStateShortcuts.ContainsKey(key))
throw new ArgumentException(string.Format("A global shortcut for Key '{0}' was already registered with state '{1}'", key, _workflowStateShortcuts[key].Name));
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:7,代码来源:ShortcutResourcesLoader.cs
示例5: ConvertType
//.........这里部分代码省略.........
{
t = new Thickness(numberList[0], numberList[1]);
}
else if (numberList.Length == 4)
{
t = new Thickness(numberList[0], numberList[1], numberList[2], numberList[3]);
}
else
{
throw new ArgumentException("Invalid # of parameters");
}
result = t;
return true;
}
else if (targetType == typeof(Color))
{
Color color;
if (ColorConverter.ConvertColor(value, out color))
{
result = color;
return true;
}
}
else if (targetType == typeof(Brush) && value is string || value is Color)
{
try
{
Color color;
if (ColorConverter.ConvertColor(value, out color))
{
SolidColorBrush b = new SolidColorBrush
{
Color = color
};
result = b;
return true;
}
}
catch (Exception)
{
return false;
}
}
else if (targetType == typeof(GridLength))
{
string text = value.ToString();
if (text == "Auto")
result = new GridLength(GridUnitType.Auto, 0.0);
else if (text == "AutoStretch")
result = new GridLength(GridUnitType.AutoStretch, 1.0);
else if (text.IndexOf('*') >= 0)
{
int pos = text.IndexOf('*');
text = text.Substring(0, pos);
if (text.Length > 0)
{
object obj;
TypeConverter.Convert(text, typeof(double), out obj);
result = new GridLength(GridUnitType.Star, (double)obj);
}
else
result = new GridLength(GridUnitType.Star, 1.0);
}
else
{
double v = double.Parse(text);
result = new GridLength(GridUnitType.Pixel, v);
}
return true;
}
else if (targetType == typeof(string) && value is IResourceString)
{
result = ((IResourceString)value).Evaluate();
return true;
}
else if (targetType.IsAssignableFrom(typeof(IExecutableCommand)) && value is ICommand)
{
result = new CommandBridge((ICommand)value);
return true;
}
else if (targetType == typeof(Key) && value is string)
{
string str = (string)value;
// Try a special key
result = Key.GetSpecialKeyByName(str);
if (result == null)
if (str.Length != 1)
throw new ArgumentException(string.Format("Cannot convert '{0}' to type Key", str));
else
result = new Key(str[0]);
return true;
}
else if (targetType == typeof(string) && value is IEnumerable)
{
result = StringUtils.Join(", ", (IEnumerable)value);
return true;
}
result = value;
return false;
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:101,代码来源:MPF.cs
示例6: HandleClipboardKeys
protected void HandleClipboardKeys(ref Key key)
{
if (!HasFocus)
return;
if (key == Key.Cut)
{
if (ServiceRegistration.Get<IClipboardManager>().SetClipboardText(Text))
{
Text = string.Empty;
key = Key.None;
}
}
else if (key == Key.Copy)
{
if (ServiceRegistration.Get<IClipboardManager>().SetClipboardText(Text))
key = Key.None;
}
else if (key == Key.Paste)
{
string text;
if (ServiceRegistration.Get<IClipboardManager>().GetClipboardText(out text))
{
// If caret is placed on end, simply append the text
if (CaretIndex == Text.Length)
Text += text;
else
{
string beforeCaret = Text.Substring(0, CaretIndex);
string afterCaret = Text.Substring(CaretIndex);
Text = string.Format("{0}{1}{2}", beforeCaret, text, afterCaret);
CaretIndex = beforeCaret.Length + text.Length;
}
key = Key.None;
}
}
}
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:36,代码来源:TextControl.cs
示例7: OnKeyPressed
/// <summary>
/// Will be called when a key is pressed. Derived classes may override this method
/// to implement special key handling code.
/// </summary>
/// <param name="key">The key. Should be set to 'Key.None' if handled by child.</param>
public virtual void OnKeyPressed(ref Key key)
{
foreach (UIElement child in GetChildren())
{
if (!child.IsVisible) continue;
child.OnKeyPressed(ref key);
if (key == Key.None) return;
}
}
开发者ID:BigGranu,项目名称:MediaPortal-2,代码行数:14,代码来源:UIElement.cs
示例8: MappedKeyCode
public MappedKeyCode(Key key, string code)
{
_key = key;
_code = code;
}
开发者ID:pacificIT,项目名称:MediaPortal-2,代码行数:5,代码来源:MappedKeyCode.cs
示例9: SerializeKey
/// <summary>
/// Serializes a <see cref="Key"/> into a string. This method supports both printable and special keys.
/// </summary>
/// <param name="key">Key</param>
/// <returns>Key string.</returns>
/// <exception cref="ArgumentException">If key is neither printable nor special key.</exception>
public static string SerializeKey(Key key)
{
if (key.IsPrintableKey)
return "P:" + key.RawCode;
if (key.IsSpecialKey)
return "S:" + key.Name;
throw new ArgumentException(string.Format("Cannot serialize key '{0}', it is neither a printable nor a special key", key));
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:14,代码来源:Key.cs
示例10: KeyEventArgs
/// <summary>
/// Creates a new instance of <see cref="KeyboardEventArgs"/>.
/// </summary>
/// <param name="timestamp">Time when the input occurred.</param>
/// <param name="key">Key to associate with this event.</param>
public KeyEventArgs( /*KeyboardDevice keyboard,*/ int timestamp, Key key)
: base( /*keyboard,*/ timestamp)
{
_key = key;
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:10,代码来源:KeyEventArgs.cs
示例11: HandleInput
public abstract void HandleInput(ref Key key);
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:1,代码来源:AbstractTextInputHandler.cs
示例12: MappedKeyCode
public MappedKeyCode(Key key, int code)
{
Key = key;
Code = code;
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:5,代码来源:MappedKeyCode.cs
示例13: OnKeyPressed
public override void OnKeyPressed(ref Key key)
{
base.OnKeyPressed(ref key);
if (!IsActive || key == Key.None)
return;
ICommandStencil command = KeyPressedCommand;
if (command == null)
return;
command.Execute(new object[] {key});
}
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:10,代码来源:UserInputCapture.cs
示例14: OnKeyPressed
public override void OnKeyPressed(ref Key key)
{
base.OnKeyPressed(ref key);
if (key == Key.None)
// Key event was handeled by child
return;
int updatedStartsWithIndex = -1;
try
{
if (!CheckFocusInScope())
return;
if (key.IsPrintableKey)
{
if (_startsWithIndex == -1 || _startsWith != key.RawCode)
{
_startsWith = key.RawCode.Value;
updatedStartsWithIndex = 0;
}
else
updatedStartsWithIndex = _startsWithIndex + 1;
key = Key.None;
if (!FocusItemWhichStartsWith(_startsWith, updatedStartsWithIndex))
updatedStartsWithIndex = -1;
}
}
finally
{
// Will reset the startsWith function if no char was pressed
_startsWithIndex = updatedStartsWithIndex;
}
}
开发者ID:jgauffin,项目名称:MediaPortal-2,代码行数:33,代码来源:ItemsPresenter.cs
示例15: OnKeyPressed
public override void OnKeyPressed(ref Key key)
{
// We handle the "Default" event here, "normal" events will be handled in the KeyPreview event
base.OnKeyPressed(ref key);
if (key == Key.None) return;
if (IsDefault && key == Key.Ok)
{
Execute();
key = Key.None;
}
}
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:11,代码来源:Button.cs
示例16: OnKeyPreview
internal override void OnKeyPreview(ref Key key)
{
base.OnKeyPreview(ref key);
if (!HasFocus)
return;
if (key == Key.None) return;
IExecutableCommand cmd = ContextMenuCommand;
if (key == Key.ContextMenu && ContextMenuCommand != null)
{
if (cmd != null)
InputManager.Instance.ExecuteCommand(cmd.Execute);
key = Key.None;
}
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:14,代码来源:FrameworkElement.cs
示例17: AddKeyBinding_NeedLock
protected void AddKeyBinding_NeedLock(Key key, VoidKeyActionDlgt action)
{
_registeredKeyBindings.Add(key);
IInputManager inputManager = ServiceRegistration.Get<IInputManager>();
inputManager.AddKeyBinding(key, action);
}
开发者ID:chekiI,项目名称:MediaPortal-2,代码行数:6,代码来源:PlayerBackgroundManager.cs
示例18: OnKeyPress
public void OnKeyPress(Key key)
{
if (_bdReader == null || !IsHandlingUserInput)
return;
BluRayAPI.BDKeys translatedKey;
if (BluRayAPI.KeyMapping.TryGetValue(key, out translatedKey))
{
BluRayPlayerBuilder.LogDebug("BDPlayer: Key Press {0} -> {1}", key, translatedKey);
_bdReader.Action((int)translatedKey);
}
}
开发者ID:davinx,项目名称:MediaPortal-2,代码行数:12,代码来源:BluRayPlayer.cs
示例19: KeyAction
public KeyAction(Key key, KeyActionDlgt action)
{
_key = key;
_action = action;
}
开发者ID:HAF-Blade,项目名称:MediaPortal-2,代码行数:5,代码来源:KeyAction.cs
示例20: KeyPress
public void KeyPress(Key key)
{
_lastInputTime = DateTime.Now;
TryEvent_NoLock(new KeyEvent(key));
}
开发者ID:jgauffin,项目名称:MediaPortal-2,代码行数:5,代码来源:InputManager.cs
注:本文中的MediaPortal.UI.Control.InputManager.Key类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论