提交 e0ffb2b3 编写于 作者: N Nicke Manarin

Fixes for the key strokes.

上级 f005a83d
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Runtime.Serialization;
using System.Windows.Input;
......@@ -63,8 +64,13 @@ namespace ScreenToGif.Util
/// <paramref name="modifiers" /> is not a valid <see cref="T:System.Windows.Input.ModifierKeys" />-or-<paramref name="key" /> is not a valid <see cref="T:System.Windows.Input.Key" />.</exception>
/// <exception cref="T:System.NotSupportedException">
/// <paramref name="key" /> and <paramref name="modifiers" /> do not form a valid <see cref="T:System.Windows.Input.KeyGesture" />.</exception>
public SimpleKeyGesture(Key key, ModifierKeys modifiers, bool isUppercase = false) : this(key, modifiers, string.Empty, isUppercase)
{ }
public SimpleKeyGesture(Key key, ModifierKeys modifiers, bool isUppercase = false) : this(key, modifiers,
string.Empty, isUppercase)
{
//Remove the modifier key, if it's the same as the detected pressend key.
if (key == Key.LeftCtrl || key == Key.LeftShift || key == Key.LeftAlt || key == Key.LWin || key == Key.RightCtrl || key == Key.RightShift || key == Key.RightAlt || key == Key.RWin)
Modifiers = ModifierKeys.None;
}
/// <summary>Initializes a new instance of the <see cref="T:System.Windows.Input.KeyGesture" /> class with the specified <see cref="T:System.Windows.Input.Key" />, <see cref="T:System.Windows.Input.ModifierKeys" />, and display string.</summary>
/// <param name="key">The key associated with the gesture.</param>
......
......@@ -5193,17 +5193,22 @@ namespace ScreenToGif.Windows
var render = Dispatcher.Invoke(() =>
{
#region Text
//Removes any duplicated modifier key.
var keyList = new List<SimpleKeyGesture>();
for (var i = 0; i < frame.KeyList.Count; i++)
{
if (i + 1 > frame.KeyList.Count - 1 || !frame.KeyList[i + 1].Modifiers.ToString().Contains(frame.KeyList[i].Key.ToString().Remove("Left", "Right").TrimStart('L').TrimStart('R')))
//If this frame being added will be repeated next, ignore.
if (frame.KeyList.Count > i + 1 && frame.KeyList[i + 1].Key == frame.KeyList[i].Key && frame.KeyList[i + 1].Modifiers == frame.KeyList[i].Modifiers)
continue;
//Removes the previous modifier key, if a combination is next to it: "LeftCtrl Control + A" will be "Control + A".
if (i + 1 > frame.KeyList.Count - 1 || !frame.KeyList[i + 1].Modifiers.ToString().Contains(frame.KeyList[i].Key.ToString().Remove("Left", "Right").Replace("Ctrl", "Control").TrimStart('L').TrimStart('R')))
keyList.Add(frame.KeyList[i]);
}
//Update text with key strokes.
KeyStrokesLabel.Text = keyList.GroupBy(g => g.Key).Select(s => s.First()).Select(x => "" + Native.GetSelectKeyText(x.Key, x.Modifiers, x.IsUppercase)).Aggregate((p, n) => p + UserSettings.All.KeyStrokesSeparator + n);
KeyStrokesLabel.Text = keyList.Select(x => "" + Native.GetSelectKeyText(x.Key, x.Modifiers, x.IsUppercase)).Aggregate((p, n) => p + UserSettings.All.KeyStrokesSeparator + n);
KeyStrokesLabel.UpdateLayout();
//Renders the current Visual.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册