Skip to content

Commit

Permalink
Merge pull request #167 from Code52/release/2.2
Browse files Browse the repository at this point in the history
Release 2.2
  • Loading branch information
hnrkndrssn authored Jul 26, 2017
2 parents 82bac34 + 48a6ab5 commit e3eed6a
Show file tree
Hide file tree
Showing 9 changed files with 63 additions and 29 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 2.1.{build}
version: 2.2.{build}
configuration: Release
skip_branch_with_pr: true
skip_tags: true
Expand Down
17 changes: 16 additions & 1 deletion src/Carnac.Logic/MessageProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,22 @@ public IObservable<Message> GetMessageStream()
.Where(c => c.HasCompletedValue)
.SelectMany(c => c.GetMessages())
.Scan(new Message(), (acc, key) => Message.MergeIfNeeded(acc, key))
.Where(m => !settings.DetectShortcutsOnly || m.IsShortcut);
.Where(m =>
{
if (settings.DetectShortcutsOnly && settings.ShowOnlyModifiers)
{
return m.IsShortcut && m.IsModifier;
}
if (settings.DetectShortcutsOnly)
{
return m.IsShortcut;
}
if (settings.ShowOnlyModifiers)
{
return m.IsModifier;
}
return true;
});
}
}
}
11 changes: 8 additions & 3 deletions src/Carnac.Logic/Models/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public sealed class Message
readonly string shortcutName;
readonly bool canBeMerged;
readonly bool isShortcut;
readonly bool isModifier;
readonly bool isDeleting;
readonly DateTime lastMessage;
readonly Message previous;
Expand All @@ -30,12 +31,13 @@ public Message(KeyPress key)
processName = key.Process.ProcessName;
processIcon = key.Process.ProcessIcon;
canBeMerged = !key.HasModifierPressed;
isModifier = key.HasModifierPressed;

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

public Message(IEnumerable<KeyPress> keys, KeyShortcut shortcut)
public Message(IEnumerable<KeyPress> keys, KeyShortcut shortcut, Boolean isShortcut = false)
: this()
{
var allKeys = keys.ToArray();
Expand All @@ -48,7 +50,8 @@ public Message(IEnumerable<KeyPress> keys, KeyShortcut shortcut)
processName = distinctProcessName.Single();
processIcon = allKeys.First().Process.ProcessIcon;
shortcutName = shortcut.Name;
isShortcut = true;
this.isShortcut = isShortcut;
this.isModifier = allKeys.Any(k => k.HasModifierPressed);
canBeMerged = false;

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

public bool IsDeleting { get { return isDeleting; } }


public bool IsModifier { get { return isModifier; } }

public Message Merge(Message other)
{
return new Message(this, other);
Expand Down
4 changes: 4 additions & 0 deletions src/Carnac.Logic/Models/PopupSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ public class PopupSettings : NotifyPropertyChanged
[NotifyProperty(AlsoNotifyFor = new[] { "ScaleTransform", "Alignment" })]
public NotificationPlacement Placement { get; set; }

[DefaultValue(false)]
public bool AutoUpdate { get; set; }

//Used to determine which from it's leftmost co-ord
double left;
public double Left
Expand Down Expand Up @@ -85,5 +88,6 @@ public string SortDescription
public bool DetectShortcutsOnly { get; set; }
public bool ShowApplicationIcon { get; set; }
public bool SettingsConfigured { get; set; }
public bool ShowOnlyModifiers { get; set; }
}
}
2 changes: 1 addition & 1 deletion src/Carnac.Logic/ShortcutAccumulator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ void ShortcutCompleted(KeyShortcut shortcut)
if (HasCompletedValue)
throw new InvalidOperationException();

messages = new[] { new Message(Keys, shortcut) };
messages = new[] { new Message(Keys, shortcut, true) };
HasCompletedValue = true;
}

Expand Down
5 changes: 3 additions & 2 deletions src/Carnac.Logic/Win32Methods.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public static class Win32Methods
public const int WM_SYSKEYUP = 261;
public const int WM_SYSKEYDOWN = 260;
public const int WS_EX_TRANSPARENT = 0x00000020;
public const int WS_EX_TOOLWINDOW = 0x00000080;
public const int GWL_EXSTYLE = (-20);

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

public static void SetWindowExTransparent(IntPtr hwnd)
public static void SetWindowExTransparentAndNotInWindowList(IntPtr hwnd)
{
var extendedStyle = GetWindowLong(hwnd, GWL_EXSTYLE);
SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT);
SetWindowLong(hwnd, GWL_EXSTYLE, extendedStyle | WS_EX_TRANSPARENT | WS_EX_TOOLWINDOW);
}
}
}
29 changes: 16 additions & 13 deletions src/Carnac/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,25 @@ protected override void OnStartup(StartupEventArgs e)
carnac.Start();

#if !DEBUG
Observable
.Timer(TimeSpan.FromMinutes(5))
.Subscribe(async x =>
{
try
if (settings.AutoUpdate)
{
Observable
.Timer(TimeSpan.FromMinutes(5))
.Subscribe(async x =>
{
using (var mgr = UpdateManager.GitHubUpdateManager(carnacUpdateUrl))
try
{
await mgr.Result.UpdateApp();
using (var mgr = UpdateManager.GitHubUpdateManager(carnacUpdateUrl))
{
await mgr.Result.UpdateApp();
}
}
}
catch
{
// Do something useful with the exception
}
});
catch
{
// Do something useful with the exception
}
});
}
#endif

base.OnStartup(e);
Expand Down
5 changes: 2 additions & 3 deletions src/Carnac/UI/KeyShowView.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ protected override void OnSourceInitialized(EventArgs e)
base.OnSourceInitialized(e);

var hwnd = new WindowInteropHelper(this).Handle;
Win32Methods.SetWindowExTransparent(hwnd);

Win32Methods.SetWindowExTransparentAndNotInWindowList(hwnd);
var timer = new Timer(100);
timer.Elapsed +=
(s, x) =>
Expand Down Expand Up @@ -83,7 +82,7 @@ public static readonly int

private void WindowLoaded(object sender, RoutedEventArgs e)
{

}

void SettingsLeftChanged(object sender, EventArgs e)
Expand Down
17 changes: 12 additions & 5 deletions src/Carnac/UI/PreferencesView.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xmlns:utilities="clr-namespace:Carnac.Utilities"
xmlns:carnac="clr-namespace:Carnac"
x:Class="Carnac.UI.PreferencesView"
Width="610" Height="420" Icon="../icon.ico"
Width="610" Height="420" Icon="../icon.ico"
Foreground="{DynamicResource BlackBrush}"
d:DataContext="{d:DesignInstance ui:PreferencesViewModel}" mc:Ignorable="d"
ShowTitleBar="False" ShowMinButton="False" ShowMaxRestoreButton="False"
Expand All @@ -25,7 +25,7 @@
<ResourceDictionary
Source="pack://application:,,,/MahApps.Metro;component/Styles/Accents/BaseDark.xaml" />
</ResourceDictionary.MergedDictionaries>

<DataTemplate x:Key="ColourPickerTemplate">
<StackPanel Orientation="Horizontal" VerticalAlignment="Stretch"
d:DataContext="{d:DesignInstance ui:AvailableColor}">
Expand Down Expand Up @@ -56,7 +56,7 @@
<StackPanel Margin="10,0,0,0" Orientation="Vertical">
<carnac:PositionOnMonitorSelector />
<ui:PreferencesField Header="Top Offset">
<Slider Value="{Binding Settings.TopOffset}" IsSnapToTickEnabled="True"
<Slider Value="{Binding Settings.TopOffset}" IsSnapToTickEnabled="True"
LargeChange="10"
Maximum="{Binding SelectedScreen.Height}" Minimum="0" SmallChange="1" TickFrequency="20" />
<ui:PreferencesField.SecondaryControl>
Expand Down Expand Up @@ -84,6 +84,10 @@
<TextBox Foreground="White" Text="{Binding Settings.RightOffset}" />
</ui:PreferencesField.SecondaryControl>
</ui:PreferencesField>
<Separator Height="10" Margin="0"/>
<ui:PreferencesField Header="Auto Update">
<CheckBox IsChecked="{Binding Settings.AutoUpdate}" Content="auto check updates from GitHub (need to restart this program)" />
</ui:PreferencesField>
</StackPanel>
<StackPanel HorizontalAlignment="Right" Orientation="Horizontal" Grid.Row="1" Margin="5">
<Button Width="150" Margin="0 0 5 0" Content="Reset to Defaults" Command="{Binding ResetToDefaultsCommand}" />
Expand Down Expand Up @@ -138,9 +142,12 @@
</ui:PreferencesField>

<ui:PreferencesField Header="Shortcuts Only">
<CheckBox IsChecked="{Binding Settings.DetectShortcutsOnly}" />
<CheckBox IsChecked="{Binding Settings.DetectShortcutsOnly}" Content="shows only keys which are listed in keymaps folder" />
</ui:PreferencesField>
<ui:PreferencesField Header="Show Application Icon">
<ui:PreferencesField Header="Show Only Modifiers">
<CheckBox IsChecked="{Binding Settings.ShowOnlyModifiers}" Content="shows only keys which have ctrl, shift, alt or windows" />
</ui:PreferencesField>
<ui:PreferencesField Header="Show Application Icon">
<CheckBox IsChecked="{Binding Settings.ShowApplicationIcon}" />
</ui:PreferencesField>
</StackPanel>
Expand Down

0 comments on commit e3eed6a

Please sign in to comment.