Skip to content

Commit

Permalink
Ability to single-click on items in windows list (default)
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Rondeau committed Aug 30, 2014
1 parent 01148c8 commit f9190fd
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 72 deletions.
9 changes: 3 additions & 6 deletions GoToWindow.FakeApp/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,12 @@ public MainWindow()

private void Window_Initialized(object sender, EventArgs e)
{
var args = Environment.GetCommandLineArgs();
var args = Environment.GetCommandLineArgs();

if (args.Length < 2)
throw new ApplicationException("Fake App requires a title as the command line argument");

Title = args[1];
Title = args.Length <= 2 ? "Go To Window - Fake Application (For Testing)" : args[1];
}

private void Window_KeyDown(object sender, KeyEventArgs e)
private void Window_KeyDown(object sender, KeyEventArgs e)
{
InsertKeyMessage("Down: " + GetKeyEventString(e));
}
Expand Down
3 changes: 3 additions & 0 deletions GoToWindow/App.config
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
<setting name="ShortcutPressesBeforeOpen" serializeAs="String">
<value>2</value>
</setting>
<setting name="WindowListSingleClick" serializeAs="String">
<value>True</value>
</setting>
</GoToWindow.Properties.Settings>
</userSettings>
</configuration>
12 changes: 12 additions & 0 deletions GoToWindow/Properties/Settings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions GoToWindow/Properties/Settings.settings
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@
<Setting Name="ShortcutPressesBeforeOpen" Type="System.Int32" Scope="User">
<Value Profile="(Default)">2</Value>
</Setting>
<Setting Name="WindowListSingleClick" Type="System.Boolean" Scope="User">
<Value Profile="(Default)">True</Value>
</Setting>
</Settings>
</SettingsFile>
14 changes: 9 additions & 5 deletions GoToWindow/ViewModels/SettingsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ public SettingsViewModel(IGoToWindowContext context)

public bool HookAltTab { get; set; }
public bool StartWithWindows { get; set; }
public int ShortcutPressesBeforeOpen { get; set; }
public int ShortcutPressesBeforeOpen { get; set; }
public bool WindowListSingleClick { get; set; }
public Visibility NoElevatedPrivilegesWarning { get; set; }
public string Version { get; set; }
public List<SettingsPluginViewModel> Plugins { get; private set; }
Expand All @@ -37,6 +38,7 @@ public void Load()
HookAltTab = _originalHookAltTab = Properties.Settings.Default.HookAltTab;
StartWithWindows = _originalStartWithWindows = GetStartWithWindows();
ShortcutPressesBeforeOpen = _originalShortcutPressesBeforeOpen = Properties.Settings.Default.ShortcutPressesBeforeOpen;
WindowListSingleClick = Properties.Settings.Default.WindowListSingleClick;

NoElevatedPrivilegesWarning = GetHasElevatedPrivileges()
? Visibility.Hidden
Expand Down Expand Up @@ -85,12 +87,14 @@ public void Apply()
if (_originalStartWithWindows != StartWithWindows)
{
UpdateStartWithWindows(StartWithWindows);
}
}

Properties.Settings.Default.HookAltTab = HookAltTab;
Properties.Settings.Default.ShortcutPressesBeforeOpen = ShortcutPressesBeforeOpen;
Properties.Settings.Default.WindowListSingleClick = WindowListSingleClick;

if(_originalHookAltTab != HookAltTab || _originalShortcutPressesBeforeOpen != ShortcutPressesBeforeOpen)
if(_originalHookAltTab != HookAltTab)
{
Properties.Settings.Default.HookAltTab = HookAltTab;
Properties.Settings.Default.ShortcutPressesBeforeOpen = ShortcutPressesBeforeOpen;
_context.EnableAltTabHook(HookAltTab, ShortcutPressesBeforeOpen);
}

Expand Down
1 change: 1 addition & 0 deletions GoToWindow/Windows/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@
</Border.Effect>
<ListView Name="WindowsListView"
ScrollViewer.HorizontalScrollBarVisibility="Disabled"
MouseUp="WindowsListView_MouseClick"
MouseDoubleClick="WindowsListView_MouseDoubleClick"
PreviewKeyDown="WindowsListView_PreviewKeyDown"
BorderBrush="Transparent"
Expand Down
9 changes: 8 additions & 1 deletion GoToWindow/Windows/MainWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,14 @@ public void SetFocus()

private void WindowsListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
FocusSelectedWindowItem();
if (!Properties.Settings.Default.WindowListSingleClick)
FocusSelectedWindowItem();
}

private void WindowsListView_MouseClick(object sender, MouseButtonEventArgs e)
{
if (Properties.Settings.Default.WindowListSingleClick)
FocusSelectedWindowItem();
}

private void FocusSelectedWindowItem()
Expand Down
121 changes: 61 additions & 60 deletions GoToWindow/Windows/SettingsWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,64 +15,65 @@
MinWidth="500" MinHeight="250"
d:DesignWidth="600" d:DesignHeight="250"
d:DataContext="{d:DesignInstance viewModels:SettingsViewModel}">
<Window.Resources>
<converters:IncrementIntConverter x:Key="IncrementIntConverter" />
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Name="TabsRow" Height="*" />
<RowDefinition Name="ButtonsRow" Height="Auto" />
</Grid.RowDefinitions>
<TabControl Grid.Row="0" Margin="8" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TabItem Header="_General">
<Grid>
<StackPanel Margin="10,10,0,0" Orientation="Horizontal">
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" FontWeight="Bold" Text="GoToWindow v" />
<TextBlock x:Name="VersionTextBlock" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" FontWeight="Bold" Text="{Binding Version}" />
</StackPanel>
<CheckBox x:Name="HookAltTabCheckbox" Content="_Hook Alt+Tab" IsChecked="{Binding HookAltTab}" HorizontalAlignment="Left" Margin="10,41,0,0" VerticalAlignment="Top" />
<Label Content="Shortcut Handling" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="27,61,0,0" />
<ComboBox x:Name="ShortcutPressesBeforeOpenComboBox" IsEnabled="{Binding HookAltTab}" SelectedIndex="{Binding ShortcutPressesBeforeOpen, Converter={StaticResource IncrementIntConverter}, ConverterParameter=-1}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="138,65,0,0">
<ComboBoxItem Tag="1">Single (Alt + Tab)</ComboBoxItem>
<ComboBoxItem Tag="2">Twice (Alt + Tab + Tab)</ComboBoxItem>
</ComboBox>
<CheckBox x:Name="StartWithWindowsCheckbox" Content="_Start with Windows" IsChecked="{Binding StartWithWindows}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,92,0,0"/>
<TextBlock x:Name="NoElevatedPrivilegesWarning" Visibility="{Binding NoElevatedPrivilegesWarning}" Foreground="Red" HorizontalAlignment="Left" Margin="10,112,0,0" VerticalAlignment="Top" TextWrapping="Wrap" FontWeight="Bold"><Run Text="Alt + Tab will not work in applications with elevated privileges (Run as Administrator). Restart GoToWindow as Administrator to solve."/></TextBlock>
</Grid>
</TabItem>
<TabItem Header="_Plugins">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Vertical" Margin="8">
<TextBlock FontWeight="Bold">Uncheck a plug-in to disable it.</TextBlock>
<TextBlock>You can uninstall a plug-in completely by removing it from the Plugins directory.</TextBlock>
</StackPanel>
<ListView Grid.Row="1" ItemsSource="{Binding Plugins}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" d:DataContext="{d:DesignInstance viewModels:SettingsPluginViewModel}">
<CheckBox IsChecked="{Binding Enabled}" Content="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</TabItem>
</TabControl>
<Grid Grid.Row="1" Margin="8,0,8,8" HorizontalAlignment="Stretch">
<Label Content="© Christian Rondeau 2014" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Center" FontStyle="Italic" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<StackPanel.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Margin" Value="8,0,0,0"/>
</Style>
</StackPanel.Resources>
<Button x:Name="OkButton" IsDefault="True" Content="Apply" HorizontalAlignment="Left" VerticalAlignment="Center" Width="75" Click="OkButton_Click"/>
<Button x:Name="CancelButton" IsCancel="True" Content="Close" HorizontalAlignment="Left" VerticalAlignment="Center" Width="75" Click="CancelButton_Click"/>
</StackPanel>
</Grid>
</Grid>
<Window.Resources>
<converters:IncrementIntConverter x:Key="IncrementIntConverter" />
</Window.Resources>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Name="TabsRow" Height="*" />
<RowDefinition Name="ButtonsRow" Height="Auto" />
</Grid.RowDefinitions>
<TabControl Grid.Row="0" Margin="8" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
<TabItem Header="_General">
<Grid>
<StackPanel Margin="10,10,0,0" Orientation="Horizontal">
<TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" FontWeight="Bold" Text="GoToWindow v" />
<TextBlock x:Name="VersionTextBlock" HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" FontWeight="Bold" Text="{Binding Version}" />
</StackPanel>
<CheckBox x:Name="HookAltTabCheckbox" Content="_Enabled" IsChecked="{Binding HookAltTab}" HorizontalAlignment="Left" Margin="255,37,0,0" VerticalAlignment="Top" />
<Label Content="Shortcut" Width="Auto" Height="Auto" HorizontalAlignment="Left" Margin="10,30,0,0" VerticalAlignment="Top"/>
<ComboBox Width="180" x:Name="ShortcutPressesBeforeOpenComboBox" IsEnabled="{Binding HookAltTab}" SelectedIndex="{Binding ShortcutPressesBeforeOpen, Converter={StaticResource IncrementIntConverter}, ConverterParameter=-1}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="70,34,0,0">
<ComboBoxItem Tag="1">Single (Alt + Tab)</ComboBoxItem>
<ComboBoxItem Tag="2">Twice (Alt + Tab + Tab)</ComboBoxItem>
</ComboBox>
<CheckBox x:Name="StartWithWindowsCheckbox" Content="_Start with Windows" IsChecked="{Binding StartWithWindows}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,61,0,0"/>
<CheckBox x:Name="WindowListSingleClick" Content="Click once to select an item in the list" IsChecked="{Binding WindowListSingleClick}" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,81,0,0"/>
<TextBlock x:Name="NoElevatedPrivilegesWarning" Visibility="{Binding NoElevatedPrivilegesWarning}" Foreground="Red" HorizontalAlignment="Left" Margin="10,101,0,0" VerticalAlignment="Top" TextWrapping="Wrap" FontWeight="Bold"><Run Text="Alt + Tab will not work in applications with elevated privileges (Run as Administrator). Restart GoToWindow as Administrator to solve."/></TextBlock>
</Grid>
</TabItem>
<TabItem Header="_Plugins">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Orientation="Vertical" Margin="8">
<TextBlock FontWeight="Bold">Uncheck a plug-in to disable it.</TextBlock>
<TextBlock>You can uninstall a plug-in completely by removing it from the Plugins directory.</TextBlock>
</StackPanel>
<ListView Grid.Row="1" ItemsSource="{Binding Plugins}">
<ListView.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" d:DataContext="{d:DesignInstance viewModels:SettingsPluginViewModel}">
<CheckBox IsChecked="{Binding Enabled}" Content="{Binding Name}" />
</StackPanel>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</Grid>
</TabItem>
</TabControl>
<Grid Grid.Row="1" Margin="8,0,8,8" HorizontalAlignment="Stretch">
<Label Content="© Christian Rondeau 2014" HorizontalAlignment="Left" Margin="0" VerticalAlignment="Center" FontStyle="Italic" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
<StackPanel.Resources>
<Style TargetType="{x:Type Button}">
<Setter Property="Margin" Value="8,0,0,0"/>
</Style>
</StackPanel.Resources>
<Button x:Name="OkButton" IsDefault="True" Content="Apply" HorizontalAlignment="Left" VerticalAlignment="Center" Width="75" Click="OkButton_Click"/>
<Button x:Name="CancelButton" IsCancel="True" Content="Close" HorizontalAlignment="Left" VerticalAlignment="Center" Width="75" Click="CancelButton_Click"/>
</StackPanel>
</Grid>
</Grid>
</Window>

0 comments on commit f9190fd

Please sign in to comment.