Skip to content

Commit e3eed6a

Browse files
authored
Merge pull request #167 from Code52/release/2.2
Release 2.2
2 parents 82bac34 + 48a6ab5 commit e3eed6a

File tree

9 files changed

+63
-29
lines changed

9 files changed

+63
-29
lines changed

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
version: 2.1.{build}
1+
version: 2.2.{build}
22
configuration: Release
33
skip_branch_with_pr: true
44
skip_tags: true

src/Carnac.Logic/MessageProvider.cs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,22 @@ public IObservable<Message> GetMessageStream()
3737
.Where(c => c.HasCompletedValue)
3838
.SelectMany(c => c.GetMessages())
3939
.Scan(new Message(), (acc, key) => Message.MergeIfNeeded(acc, key))
40-
.Where(m => !settings.DetectShortcutsOnly || m.IsShortcut);
40+
.Where(m =>
41+
{
42+
if (settings.DetectShortcutsOnly && settings.ShowOnlyModifiers)
43+
{
44+
return m.IsShortcut && m.IsModifier;
45+
}
46+
if (settings.DetectShortcutsOnly)
47+
{
48+
return m.IsShortcut;
49+
}
50+
if (settings.ShowOnlyModifiers)
51+
{
52+
return m.IsModifier;
53+
}
54+
return true;
55+
});
4156
}
4257
}
4358
}

src/Carnac.Logic/Models/Message.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ public sealed class Message
1515
readonly string shortcutName;
1616
readonly bool canBeMerged;
1717
readonly bool isShortcut;
18+
readonly bool isModifier;
1819
readonly bool isDeleting;
1920
readonly DateTime lastMessage;
2021
readonly Message previous;
@@ -30,12 +31,13 @@ public Message(KeyPress key)
3031
processName = key.Process.ProcessName;
3132
processIcon = key.Process.ProcessIcon;
3233
canBeMerged = !key.HasModifierPressed;
34+
isModifier = key.HasModifierPressed;
3335

3436
keys = new ReadOnlyCollection<KeyPress>(new[] { key });
3537
textCollection = new ReadOnlyCollection<string>(CreateTextSequence(key).ToArray());
3638
}
3739

38-
public Message(IEnumerable<KeyPress> keys, KeyShortcut shortcut)
40+
public Message(IEnumerable<KeyPress> keys, KeyShortcut shortcut, Boolean isShortcut = false)
3941
: this()
4042
{
4143
var allKeys = keys.ToArray();
@@ -48,7 +50,8 @@ public Message(IEnumerable<KeyPress> keys, KeyShortcut shortcut)
4850
processName = distinctProcessName.Single();
4951
processIcon = allKeys.First().Process.ProcessIcon;
5052
shortcutName = shortcut.Name;
51-
isShortcut = true;
53+
this.isShortcut = isShortcut;
54+
this.isModifier = allKeys.Any(k => k.HasModifierPressed);
5255
canBeMerged = false;
5356

5457
this.keys = new ReadOnlyCollection<KeyPress>(allKeys);
@@ -91,7 +94,9 @@ private Message(Message initial, bool isDeleting)
9194
public DateTime LastMessage { get { return lastMessage; } }
9295

9396
public bool IsDeleting { get { return isDeleting; } }
94-
97+
98+
public bool IsModifier { get { return isModifier; } }
99+
95100
public Message Merge(Message other)
96101
{
97102
return new Message(this, other);

src/Carnac.Logic/Models/PopupSettings.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ public class PopupSettings : NotifyPropertyChanged
3030
[NotifyProperty(AlsoNotifyFor = new[] { "ScaleTransform", "Alignment" })]
3131
public NotificationPlacement Placement { get; set; }
3232

33+
[DefaultValue(false)]
34+
public bool AutoUpdate { get; set; }
35+
3336
//Used to determine which from it's leftmost co-ord
3437
double left;
3538
public double Left
@@ -85,5 +88,6 @@ public string SortDescription
8588
public bool DetectShortcutsOnly { get; set; }
8689
public bool ShowApplicationIcon { get; set; }
8790
public bool SettingsConfigured { get; set; }
91+
public bool ShowOnlyModifiers { get; set; }
8892
}
8993
}

src/Carnac.Logic/ShortcutAccumulator.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ void ShortcutCompleted(KeyShortcut shortcut)
8888
if (HasCompletedValue)
8989
throw new InvalidOperationException();
9090

91-
messages = new[] { new Message(Keys, shortcut) };
91+
messages = new[] { new Message(Keys, shortcut, true) };
9292
HasCompletedValue = true;
9393
}
9494

src/Carnac.Logic/Win32Methods.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ public static class Win32Methods
1616
public const int WM_SYSKEYUP = 261;
1717
public const int WM_SYSKEYDOWN = 260;
1818
public const int WS_EX_TRANSPARENT = 0x00000020;
19+
public const int WS_EX_TOOLWINDOW = 0x00000080;
1920
public const int GWL_EXSTYLE = (-20);
2021

2122
//
@@ -40,10 +41,10 @@ public static class Win32Methods
4041
[DllImport("user32.dll")]
4142
static extern int SetWindowLong(IntPtr hwnd, int index, int newStyle);
4243

43-
public static void SetWindowExTransparent(IntPtr hwnd)
44+
public static void SetWindowExTransparentAndNotInWindowList(IntPtr hwnd)
4445
{
4546
var extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
46-
SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
47+
SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW);
4748
}
4849
}
4950
}

src/Carnac/App.xaml.cs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -53,22 +53,25 @@ protected override void OnStartup(StartupEventArgs e)
5353
carnac.Start();
5454

5555
#if !DEBUG
56-
Observable
57-
.Timer(TimeSpan.FromMinutes(5))
58-
.Subscribe(async x =>
59-
{
60-
try
56+
if (settings.AutoUpdate)
57+
{
58+
Observable
59+
.Timer(TimeSpan.FromMinutes(5))
60+
.Subscribe(async x =>
6161
{
62-
using (var mgr = UpdateManager.GitHubUpdateManager(carnacUpdateUrl))
62+
try
6363
{
64-
await mgr.Result.UpdateApp();
64+
using (var mgr = UpdateManager.GitHubUpdateManager(carnacUpdateUrl))
65+
{
66+
await mgr.Result.UpdateApp();
67+
}
6568
}
66-
}
67-
catch
68-
{
69-
// Do something useful with the exception
70-
}
71-
});
69+
catch
70+
{
71+
// Do something useful with the exception
72+
}
73+
});
74+
}
7275
#endif
7376

7477
base.OnStartup(e);

src/Carnac/UI/KeyShowView.xaml.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ protected override void OnSourceInitialized(EventArgs e)
2020
base.OnSourceInitialized(e);
2121

2222
var hwnd = new WindowInteropHelper(this).Handle;
23-
Win32Methods.SetWindowExTransparent(hwnd);
24-
23+
Win32Methods.SetWindowExTransparentAndNotInWindowList(hwnd);
2524
var timer = new Timer(100);
2625
timer.Elapsed +=
2726
(s, x) =>
@@ -83,7 +82,7 @@ public static readonly int
8382

8483
private void WindowLoaded(object sender, RoutedEventArgs e)
8584
{
86-
85+
8786
}
8887

8988
void SettingsLeftChanged(object sender, EventArgs e)

src/Carnac/UI/PreferencesView.xaml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
xmlns:utilities="clr-namespace:Carnac.Utilities"
88
xmlns:carnac="clr-namespace:Carnac"
99
x:Class="Carnac.UI.PreferencesView"
10-
Width="610" Height="420" Icon="../icon.ico"
10+
Width="610" Height="420" Icon="../icon.ico"
1111
Foreground="{DynamicResource BlackBrush}"
1212
d:DataContext="{d:DesignInstance ui:PreferencesViewModel}" mc:Ignorable="d"
1313
ShowTitleBar="False" ShowMinButton="False" ShowMaxRestoreButton="False"
@@ -25,7 +25,7 @@
2525
<ResourceDictionary
2626
Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
2727
</ResourceDictionary.MergedDictionaries>
28-
28+
2929
<DataTemplate x:Key="ColourPickerTemplate">
3030
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch"
3131
d:DataContext="{d:DesignInstance ui:AvailableColor}">
@@ -56,7 +56,7 @@
5656
<StackPanel Margin="10,0,0,0" Orientation="Vertical">
5757
<carnac:PositionOnMonitorSelector />
5858
<ui:PreferencesField Header="Top Offset">
59-
<Slider Value="{Binding Settings.TopOffset}" IsSnapToTickEnabled="True"
59+
<Slider Value="{Binding Settings.TopOffset}" IsSnapToTickEnabled="True"
6060
LargeChange="10"
6161
Maximum="{Binding SelectedScreen.Height}" Minimum="0" SmallChange="1" TickFrequency="20" />
6262
<ui:PreferencesField.SecondaryControl>
@@ -84,6 +84,10 @@
8484
<TextBox Foreground="White" Text="{Binding Settings.RightOffset}" />
8585
</ui:PreferencesField.SecondaryControl>
8686
</ui:PreferencesField>
87+
<Separator Height="10" Margin="0"/>
88+
<ui:PreferencesField Header="Auto Update">
89+
<CheckBox IsChecked="{Binding Settings.AutoUpdate}" Content="auto check updates from GitHub (need to restart this program)" />
90+
</ui:PreferencesField>
8791
</StackPanel>
8892
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Grid.Row="1" Margin="5">
8993
<Button Width="150" Margin="0 0 5 0" Content="Reset to Defaults" Command="{Binding ResetToDefaultsCommand}" />
@@ -138,9 +142,12 @@
138142
</ui:PreferencesField>
139143

140144
<ui:PreferencesField Header="Shortcuts Only">
141-
<CheckBox IsChecked="{Binding Settings.DetectShortcutsOnly}" />
145+
<CheckBox IsChecked="{Binding Settings.DetectShortcutsOnly}" Content="shows only keys which are listed in keymaps folder" />
142146
</ui:PreferencesField>
143-
<ui:PreferencesField Header="Show Application Icon">
147+
<ui:PreferencesField Header="Show Only Modifiers">
148+
<CheckBox IsChecked="{Binding Settings.ShowOnlyModifiers}" Content="shows only keys which have ctrl, shift, alt or windows" />
149+
</ui:PreferencesField>
150+
<ui:PreferencesField Header="Show Application Icon">
144151
<CheckBox IsChecked="{Binding Settings.ShowApplicationIcon}" />
145152
</ui:PreferencesField>
146153
</StackPanel>

0 commit comments

Comments
 (0)