Permalink
Browse files

you are now able to change your keyboard shortcut, the default shortc…

…ut is still hardcoded to Alt+F2
  • Loading branch information...
1 parent 4d80c77 commit f39c520a4b2db88a56925950c2f3bf7ebe6bdcfc @srushti committed Aug 19, 2009
View
9 Azazel.4.5.resharper
@@ -55,15 +55,13 @@
<ExceptionName IsNull="False">
</ExceptionName>
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Locals" />
- <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="NotPublicInstanceFields" />
- <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="NotPublicStaticFields" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="Parameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypesAndNamespaces" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Interfaces" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="TypeParameters" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="MethodPropertyEvent" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="LocalConstants" />
- <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PublicFields" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="PublicFields" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AA_BB" ElementKind="Constants">
<ExtraRule Prefix="" Suffix="" Style="AaBb" />
<ExtraRule Prefix="" Suffix="" Style="aaBb" />
@@ -73,7 +71,12 @@
</PredefinedRule>
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="EnumMember" />
<PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="Other" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="aaBb" ElementKind="PrivateInstanceFields" />
+ <PredefinedRule Inspect="True" Prefix="_" Suffix="" Style="aaBb" ElementKind="PrivateStaticFields" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateConstants" />
+ <PredefinedRule Inspect="True" Prefix="" Suffix="" Style="AaBb" ElementKind="PrivateStaticReadonly" />
<Abbreviation Text="FF" />
+ <Abbreviation Text="WPF" />
</Naming2>
</CodeStyleSettings>
<SharedSolutionTemplateManager>
View
2 Azazel/App.xaml.cs
@@ -15,7 +15,7 @@ public partial class App {
return;
}
}
- var command = new MainWindowCommand(Shutdown);
+ var command = new MainWindowCommand(Shutdown, new AppSettings());
command.Execute();
command.Collapse();
DispatcherUnhandledException += (sender, args) => {
View
8 Azazel/AppFinder.cs
@@ -12,14 +12,16 @@ namespace Azazel {
public class AppFinder {
private readonly History history;
private readonly XStream xstream;
+ private readonly PersistanceHelper persistanceHelper;
private Launchables allLaunchables;
private readonly CharacterPlugins characterPlugins;
private LaunchablesDictionary dictionary;
- public AppFinder(LaunchablePlugins launchablePlugins, CharacterPlugins characterPlugins, XStream xstream) {
+ public AppFinder(LaunchablePlugins launchablePlugins, CharacterPlugins characterPlugins, XStream xstream, PersistanceHelper persistanceHelper) {
this.xstream = xstream;
+ this.persistanceHelper = persistanceHelper;
LoadFiles(launchablePlugins);
- history = new History(new File(new FileInfo(Paths.Instance.History)), this.xstream);
+ history = new History(new File(new FileInfo(Paths.Instance.History)), this.xstream, persistanceHelper);
this.characterPlugins = characterPlugins;
}
@@ -35,7 +37,7 @@ public class AppFinder {
}
private Folders LoadFoldersToParse() {
- return PersistanceHelper.LoadOrSaveAndLoad(xstream, Paths.Instance.Folders,
+ return persistanceHelper.LoadOrSaveAndLoad(Paths.Instance.Folders,
new Folders(Folders.QuickLaunch, Folders.StartMenu, Folders.AllUsersStartMenu));
}
View
21 Azazel/AppSettings.cs
@@ -2,14 +2,27 @@
namespace Azazel {
public class AppSettings {
+ private Hotkeys appHotkeys;
+ public HotkeysChangedHandler HotkeysChanged = hotkeys => { };
+
+ public Hotkeys AppHotkeys {
+ get { return appHotkeys; }
+ set {
+ appHotkeys = value;
+ HotkeysChanged(appHotkeys);
+ }
+ }
+ }
+
+ public delegate void HotkeysChangedHandler(Hotkeys hotkeys);
+
+ public class Hotkeys {
public readonly Hotkey DisplayHotKey;
- public readonly Hotkey KillHotKey;
- public AppSettings() {}
+ protected Hotkeys() {}
- public AppSettings(Hotkey displayHotKey, Hotkey killHotKey) {
+ public Hotkeys(Hotkey displayHotKey) {
DisplayHotKey = displayHotKey;
- KillHotKey = killHotKey;
}
}
}
View
459 Azazel/Azazel.csproj
@@ -1,230 +1,231 @@
-<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
- <PropertyGroup>
- <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
- <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
- <ProjectGuid>{832572F6-F3D9-46C7-B922-E7F69D35FE6A}</ProjectGuid>
- <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
- <RootNamespace>Azazel</RootNamespace>
- <AssemblyName>Azazel</AssemblyName>
- <WarningLevel>4</WarningLevel>
- <OutputType>winexe</OutputType>
- <MinFrameworkVersionRequired>3.0</MinFrameworkVersionRequired>
- <IsWebBootstrapper>false</IsWebBootstrapper>
- <ApplicationIcon>
- </ApplicationIcon>
- <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
- <FileUpgradeFlags>
- </FileUpgradeFlags>
- <UpgradeBackupLocation>
- </UpgradeBackupLocation>
- <OldToolsVersion>2.0</OldToolsVersion>
- <PublishUrl>Publish\</PublishUrl>
- <Install>true</Install>
- <InstallFrom>Web</InstallFrom>
- <UpdateEnabled>true</UpdateEnabled>
- <UpdateMode>Foreground</UpdateMode>
- <UpdateInterval>7</UpdateInterval>
- <UpdateIntervalUnits>Days</UpdateIntervalUnits>
- <UpdatePeriodically>false</UpdatePeriodically>
- <UpdateRequired>false</UpdateRequired>
- <MapFileExtensions>false</MapFileExtensions>
- <ApplicationRevision>0</ApplicationRevision>
- <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
- <UseApplicationTrust>false</UseApplicationTrust>
- <BootstrapperEnabled>true</BootstrapperEnabled>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
- <DebugSymbols>true</DebugSymbols>
- <DebugType>full</DebugType>
- <Optimize>false</Optimize>
- <OutputPath>.\bin\Debug\</OutputPath>
- <DefineConstants>DEBUG;TRACE</DefineConstants>
- <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
- </PropertyGroup>
- <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
- <DebugSymbols>false</DebugSymbols>
- <Optimize>true</Optimize>
- <OutputPath>.\bin\Release\</OutputPath>
- <DefineConstants>TRACE</DefineConstants>
- </PropertyGroup>
- <ItemGroup>
- <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\lib\log4net.dll</HintPath>
- </Reference>
- <Reference Include="mscorlib" />
- <Reference Include="System" />
- <Reference Include="System.configuration" />
- <Reference Include="System.Core">
- <RequiredTargetFramework>3.5</RequiredTargetFramework>
- </Reference>
- <Reference Include="System.Data" />
- <Reference Include="System.Drawing" />
- <Reference Include="System.Windows.Forms" />
- <Reference Include="System.Xml" />
- <Reference Include="WindowsBase">
- <RequiredTargetFramework>3.0</RequiredTargetFramework>
- </Reference>
- <Reference Include="PresentationCore">
- <RequiredTargetFramework>3.0</RequiredTargetFramework>
- </Reference>
- <Reference Include="PresentationFramework">
- <RequiredTargetFramework>3.0</RequiredTargetFramework>
- </Reference>
- <Reference Include="UIAutomationProvider">
- <RequiredTargetFramework>3.0</RequiredTargetFramework>
- </Reference>
- <Reference Include="UIAutomationTypes" />
- <Reference Include="ReachFramework" />
- <Reference Include="System.Printing" />
- <Reference Include="System.ServiceModel" />
- <Reference Include="System.Runtime.Serialization" />
- <Reference Include="System.IdentityModel" />
- <Reference Include="XStream, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
- <SpecificVersion>False</SpecificVersion>
- <HintPath>..\lib\XStream.dll</HintPath>
- </Reference>
- <Page Include="PluggingIn\KeyboardShortcut.xaml">
- <Generator>MSBuild:Compile</Generator>
- <SubType>Designer</SubType>
- </Page>
- <Page Include="Simple Styles.xaml">
- <Generator>MSBuild:Compile</Generator>
- <SubType>Designer</SubType>
- </Page>
- <Compile Include="PluggingIn\KeyboardShortcut.xaml.cs">
- <DependentUpon>KeyboardShortcut.xaml</DependentUpon>
- </Compile>
- </ItemGroup>
- <ItemGroup>
- <ApplicationDefinition Include="App.xaml">
- <Generator>MSBuild:Compile</Generator>
- <SubType>Designer</SubType>
- </ApplicationDefinition>
- <Page Include="MainWindow.xaml">
- <Generator>MSBuild:Compile</Generator>
- <SubType>Designer</SubType>
- </Page>
- <Compile Include="App.xaml.cs">
- <DependentUpon>App.xaml</DependentUpon>
- <SubType>Code</SubType>
- </Compile>
- <Compile Include="MainWindow.xaml.cs">
- <DependentUpon>MainWindow.xaml</DependentUpon>
- <SubType>Code</SubType>
- </Compile>
- </ItemGroup>
- <ItemGroup>
- <Compile Include="AppFinder.cs" />
- <Compile Include="AppSettings.cs" />
- <Compile Include="Arrays.cs" />
- <Compile Include="AzazelException.cs" />
- <Compile Include="Clipboard.cs" />
- <Compile Include="Constants.cs" />
- <Compile Include="Extensions\StaticAssembly.cs" />
- <Compile Include="Extensions\StaticDictionary.cs" />
- <Compile Include="Extensions\StaticEnumerable.cs" />
- <Compile Include="FileRank.cs" />
- <Compile Include="FileSystem\Files.cs" />
- <Compile Include="FileSystem\FileSystemElement.cs" />
- <Compile Include="FileSystem\FileSystemStalker.cs" />
- <Compile Include="FileSystem\Folder.cs" />
- <Compile Include="FileSystem\File.cs" />
- <Compile Include="FileSystem\Folders.cs" />
- <Compile Include="FileSystem\FoldersConverter.cs" />
- <Compile Include="FileSystem\FoldersToParse.cs" />
- <Compile Include="FileSystem\IconExtractor.cs" />
- <Compile Include="FileSystem\Launchable.cs" />
- <Compile Include="FileSystem\Paths.cs" />
- <Compile Include="FileSystem\PersistanceHelper.cs" />
- <Compile Include="FileSystem\Runner.cs" />
- <Compile Include="History.cs" />
- <Compile Include="KeyHookup\InterceptKeys.cs" />
- <Compile Include="KeyHelper.cs" />
- <Compile Include="LaunchablesDictionary.cs" />
- <Compile Include="Logging\LogManager.cs" />
- <Compile Include="MainWindowCommand.cs" />
- <Compile Include="MainWindowController.cs" />
- <Compile Include="MainWindow.States.cs" />
- <Compile Include="Modifiers.cs" />
- <Compile Include="KeyHookup\HotKey.cs" />
- <Compile Include="PluggingIn\CharacterPlugin.cs" />
- <Compile Include="PluggingIn\ExecutedCommand.cs" />
- <Compile Include="PluggingIn\FileHandler.cs" />
- <Compile Include="PluggingIn\LaunchableHandler.cs" />
- <Compile Include="PluggingIn\LaunchableHandlers.cs" />
- <Compile Include="PluggingIn\Plugin.cs" />
- <Compile Include="PluggingIn\Recent.cs" />
- <Compile Include="PluggingIn\SelfPlugin.cs" />
- <Compile Include="PluggingIn\LaunchablePlugin.cs" />
- <Compile Include="PluggingIn\PluginLoader.cs" />
- <Compile Include="Properties\AssemblyInfo.cs" />
- <EmbeddedResource Include="Properties\Resources.resx">
- <Generator>ResXFileCodeGenerator</Generator>
- <SubType>Designer</SubType>
- <LastGenOutput>Resources.Designer.cs</LastGenOutput>
- </EmbeddedResource>
- <None Include="Properties\Settings.settings">
- <Generator>SettingsSingleFileGenerator</Generator>
- <LastGenOutput>Settings.Designer.cs</LastGenOutput>
- </None>
- <Compile Include="Properties\Resources.Designer.cs">
- <AutoGen>True</AutoGen>
- <DesignTime>True</DesignTime>
- <DependentUpon>Resources.resx</DependentUpon>
- </Compile>
- <Compile Include="Properties\Settings.Designer.cs">
- <AutoGen>True</AutoGen>
- <DesignTimeSharedInput>True</DesignTimeSharedInput>
- <DependentUpon>Settings.settings</DependentUpon>
- </Compile>
- <Compile Include="Extensions\StaticString.cs" />
- <Compile Include="Settings.cs" />
- <Compile Include="Threading\Thread.cs" />
- <Compile Include="Threading\Timer.cs" />
- <Compile Include="Token.cs" />
- <Compile Include="TODO.cs" />
- <Compile Include="WindowHider.cs" />
- <AppDesigner Include="Properties\" />
- </ItemGroup>
- <ItemGroup>
- <COMReference Include="IWshRuntimeLibrary">
- <Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
- <VersionMajor>1</VersionMajor>
- <VersionMinor>0</VersionMinor>
- <Lcid>0</Lcid>
- <WrapperTool>tlbimp</WrapperTool>
- <Isolated>False</Isolated>
- </COMReference>
- </ItemGroup>
- <ItemGroup>
- <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
- <Visible>False</Visible>
- <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
- <Install>false</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
- <Visible>False</Visible>
- <ProductName>.NET Framework 3.5</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
- <Visible>False</Visible>
- <ProductName>Windows Installer 3.1</ProductName>
- <Install>true</Install>
- </BootstrapperPackage>
- </ItemGroup>
- <ItemGroup>
- <None Include="App.config" />
- </ItemGroup>
- <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
- <PropertyGroup>
- <PostBuildEvent>
- </PostBuildEvent>
- </PropertyGroup>
+<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProjectGuid>{832572F6-F3D9-46C7-B922-E7F69D35FE6A}</ProjectGuid>
+ <ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
+ <RootNamespace>Azazel</RootNamespace>
+ <AssemblyName>Azazel</AssemblyName>
+ <WarningLevel>4</WarningLevel>
+ <OutputType>winexe</OutputType>
+ <MinFrameworkVersionRequired>3.0</MinFrameworkVersionRequired>
+ <IsWebBootstrapper>false</IsWebBootstrapper>
+ <ApplicationIcon>
+ </ApplicationIcon>
+ <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <UpgradeBackupLocation>
+ </UpgradeBackupLocation>
+ <OldToolsVersion>2.0</OldToolsVersion>
+ <PublishUrl>Publish\</PublishUrl>
+ <Install>true</Install>
+ <InstallFrom>Web</InstallFrom>
+ <UpdateEnabled>true</UpdateEnabled>
+ <UpdateMode>Foreground</UpdateMode>
+ <UpdateInterval>7</UpdateInterval>
+ <UpdateIntervalUnits>Days</UpdateIntervalUnits>
+ <UpdatePeriodically>false</UpdatePeriodically>
+ <UpdateRequired>false</UpdateRequired>
+ <MapFileExtensions>false</MapFileExtensions>
+ <ApplicationRevision>0</ApplicationRevision>
+ <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
+ <UseApplicationTrust>false</UseApplicationTrust>
+ <BootstrapperEnabled>true</BootstrapperEnabled>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugSymbols>true</DebugSymbols>
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>.\bin\Debug\</OutputPath>
+ <DefineConstants>DEBUG;TRACE</DefineConstants>
+ <TreatWarningsAsErrors>true</TreatWarningsAsErrors>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugSymbols>false</DebugSymbols>
+ <Optimize>true</Optimize>
+ <OutputPath>.\bin\Release\</OutputPath>
+ <DefineConstants>TRACE</DefineConstants>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="log4net, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d426115821, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\lib\log4net.dll</HintPath>
+ </Reference>
+ <Reference Include="mscorlib" />
+ <Reference Include="System" />
+ <Reference Include="System.configuration" />
+ <Reference Include="System.Core">
+ <RequiredTargetFramework>3.5</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="System.Data" />
+ <Reference Include="System.Drawing" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml" />
+ <Reference Include="WindowsBase">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="PresentationCore">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="PresentationFramework">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="UIAutomationProvider">
+ <RequiredTargetFramework>3.0</RequiredTargetFramework>
+ </Reference>
+ <Reference Include="UIAutomationTypes" />
+ <Reference Include="ReachFramework" />
+ <Reference Include="System.Printing" />
+ <Reference Include="System.ServiceModel" />
+ <Reference Include="System.Runtime.Serialization" />
+ <Reference Include="System.IdentityModel" />
+ <Reference Include="XStream, Version=0.9.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>..\lib\XStream.dll</HintPath>
+ </Reference>
+ <Page Include="PluggingIn\KeyboardShortcut.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ <Page Include="Simple Styles.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ <Compile Include="PluggingIn\KeyboardShortcut.xaml.cs">
+ <DependentUpon>KeyboardShortcut.xaml</DependentUpon>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <ApplicationDefinition Include="App.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </ApplicationDefinition>
+ <Page Include="MainWindow.xaml">
+ <Generator>MSBuild:Compile</Generator>
+ <SubType>Designer</SubType>
+ </Page>
+ <Compile Include="App.xaml.cs">
+ <DependentUpon>App.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ <Compile Include="MainWindow.xaml.cs">
+ <DependentUpon>MainWindow.xaml</DependentUpon>
+ <SubType>Code</SubType>
+ </Compile>
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="AppFinder.cs" />
+ <Compile Include="AppSettings.cs" />
+ <Compile Include="Arrays.cs" />
+ <Compile Include="AzazelException.cs" />
+ <Compile Include="Clipboard.cs" />
+ <Compile Include="Constants.cs" />
+ <Compile Include="Extensions\StaticAssembly.cs" />
+ <Compile Include="Extensions\StaticDictionary.cs" />
+ <Compile Include="Extensions\StaticEnumerable.cs" />
+ <Compile Include="FileRank.cs" />
+ <Compile Include="FileSystem\Files.cs" />
+ <Compile Include="FileSystem\FileSystemElement.cs" />
+ <Compile Include="FileSystem\FileSystemStalker.cs" />
+ <Compile Include="FileSystem\Folder.cs" />
+ <Compile Include="FileSystem\File.cs" />
+ <Compile Include="FileSystem\Folders.cs" />
+ <Compile Include="FileSystem\FoldersConverter.cs" />
+ <Compile Include="FileSystem\FoldersToParse.cs" />
+ <Compile Include="FileSystem\IconExtractor.cs" />
+ <Compile Include="FileSystem\Launchable.cs" />
+ <Compile Include="FileSystem\Paths.cs" />
+ <Compile Include="FileSystem\PersistanceHelper.cs" />
+ <Compile Include="FileSystem\Runner.cs" />
+ <Compile Include="History.cs" />
+ <Compile Include="KeyHookup\InterceptKeys.cs" />
+ <Compile Include="KeyHookup\NativeMethods.cs" />
+ <Compile Include="KeyHookup\WPFHotkeyManager.cs" />
+ <Compile Include="LaunchablesDictionary.cs" />
+ <Compile Include="Logging\LogManager.cs" />
+ <Compile Include="MainWindowCommand.cs" />
+ <Compile Include="MainWindowController.cs" />
+ <Compile Include="MainWindow.States.cs" />
+ <Compile Include="Modifiers.cs" />
+ <Compile Include="KeyHookup\HotKey.cs" />
+ <Compile Include="PluggingIn\CharacterPlugin.cs" />
+ <Compile Include="PluggingIn\ExecutedCommand.cs" />
+ <Compile Include="PluggingIn\FileHandler.cs" />
+ <Compile Include="PluggingIn\LaunchableHandler.cs" />
+ <Compile Include="PluggingIn\LaunchableHandlers.cs" />
+ <Compile Include="PluggingIn\Plugin.cs" />
+ <Compile Include="PluggingIn\Recent.cs" />
+ <Compile Include="PluggingIn\SelfPlugin.cs" />
+ <Compile Include="PluggingIn\LaunchablePlugin.cs" />
+ <Compile Include="PluggingIn\PluginLoader.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <EmbeddedResource Include="Properties\Resources.resx">
+ <Generator>ResXFileCodeGenerator</Generator>
+ <SubType>Designer</SubType>
+ <LastGenOutput>Resources.Designer.cs</LastGenOutput>
+ </EmbeddedResource>
+ <None Include="Properties\Settings.settings">
+ <Generator>SettingsSingleFileGenerator</Generator>
+ <LastGenOutput>Settings.Designer.cs</LastGenOutput>
+ </None>
+ <Compile Include="Properties\Resources.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTime>True</DesignTime>
+ <DependentUpon>Resources.resx</DependentUpon>
+ </Compile>
+ <Compile Include="Properties\Settings.Designer.cs">
+ <AutoGen>True</AutoGen>
+ <DesignTimeSharedInput>True</DesignTimeSharedInput>
+ <DependentUpon>Settings.settings</DependentUpon>
+ </Compile>
+ <Compile Include="Extensions\StaticString.cs" />
+ <Compile Include="Settings.cs" />
+ <Compile Include="Threading\Thread.cs" />
+ <Compile Include="Threading\Timer.cs" />
+ <Compile Include="Token.cs" />
+ <Compile Include="TODO.cs" />
+ <Compile Include="WindowHider.cs" />
+ <AppDesigner Include="Properties\" />
+ </ItemGroup>
+ <ItemGroup>
+ <COMReference Include="IWshRuntimeLibrary">
+ <Guid>{F935DC20-1CF0-11D0-ADB9-00C04FD58A0B}</Guid>
+ <VersionMajor>1</VersionMajor>
+ <VersionMinor>0</VersionMinor>
+ <Lcid>0</Lcid>
+ <WrapperTool>tlbimp</WrapperTool>
+ <Isolated>False</Isolated>
+ </COMReference>
+ </ItemGroup>
+ <ItemGroup>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.2.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 2.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.0">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.0 %28x86%29</ProductName>
+ <Install>false</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Net.Framework.3.5">
+ <Visible>False</Visible>
+ <ProductName>.NET Framework 3.5</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ <BootstrapperPackage Include="Microsoft.Windows.Installer.3.1">
+ <Visible>False</Visible>
+ <ProductName>Windows Installer 3.1</ProductName>
+ <Install>true</Install>
+ </BootstrapperPackage>
+ </ItemGroup>
+ <ItemGroup>
+ <None Include="App.config" />
+ </ItemGroup>
+ <Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
+ <PropertyGroup>
+ <PostBuildEvent>
+ </PostBuildEvent>
+ </PropertyGroup>
</Project>
View
2 Azazel/FileSystem/File.cs
@@ -100,7 +100,7 @@ private class NullFile : File {
}
public static void WriteAllText(string path, string contents) {
- var parentFolderPath = new File(path).ParentFolder.FullName;
+ string parentFolderPath = new File(path).ParentFolder.FullName;
if (!Folder.Exists(parentFolderPath)) Folder.Create(parentFolderPath);
System.IO.File.WriteAllText(path, contents);
}
View
4 Azazel/FileSystem/Paths.cs
@@ -26,8 +26,8 @@ public class Paths {
get { return AppDataFile("exception.txt"); }
}
- public string AppSettings {
- get { return AppDataFile("AppSettings.xml"); }
+ public string AppHotkeys {
+ get { return AppDataFile("AppHotkeys.xml"); }
}
private static string AppDataFile(string fileName) {
View
25 Azazel/FileSystem/PersistanceHelper.cs
@@ -3,24 +3,33 @@
using xstream;
namespace Azazel.FileSystem {
- public static class PersistanceHelper {
- public static T LoadOrSaveAndLoad<T>(XStream xStream, string filePath, T defaultObject) {
+ public class PersistanceHelper {
+ private XStream xStream;
+
+ public PersistanceHelper(XStream xStream) {
+ this.xStream = xStream;
+ }
+
+ public T LoadOrSaveAndLoad<T>(string filePath, T defaultObject) {
if (!File.Exists(filePath))
Save(filePath, xStream, defaultObject);
try {
return (T) xStream.FromXml(((LoadFile) (() => File.Contents(filePath)))().Trim());
}
catch (Exception e) {
LogManager.WriteLog(e);
- var file = new File(filePath);
- File.WriteAllText(
- file.FullName + DateTime.Now.ToString().Replace("/", "").Replace("\\", "").Replace(" ", "").Replace(":", "") + file.Extension,
- File.Contents(filePath));
- Save(filePath, xStream, defaultObject);
- return (T) xStream.FromXml(File.Contents(filePath).Trim());
+ return SaveAndLoad(filePath, defaultObject);
}
}
+ public T SaveAndLoad<T>(string filePath, T defaultObject) {
+ var file = new File(filePath);
+ File.WriteAllText(file.FullName + DateTime.Now.ToString().Replace("/", "").Replace("\\", "").Replace(" ", "").Replace(":", "") + file.Extension,
+ File.Contents(filePath));
+ Save(filePath, xStream, defaultObject);
+ return (T) xStream.FromXml(File.Contents(filePath).Trim());
+ }
+
public static void Save<T>(string path, XStream xStream, T t) {
try {
File.WriteAllText(path, xStream.ToXml(t));
View
8 Azazel/FileSystem/Runner.cs
@@ -22,12 +22,13 @@ public class Runner {
return new Runner("explorer", folder.FullName);
}
- public void AsyncStart() {
+ public void AsyncStart(VoidDelegate callback) {
if (voidDelegate == null) {
startInfo.WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
new VoidDelegate(delegate {
try {
Process.Start(startInfo);
+ callback();
}
catch (Exception e) {
LogManager.WriteLog(e);
@@ -37,12 +38,17 @@ public class Runner {
else {
try {
voidDelegate();
+ callback();
}
catch (Exception e) {
LogManager.WriteLog(e);
}
}
}
+
+ public void AsyncStart() {
+ AsyncStart(() => { });
+ }
}
public static class StaticRunner {
View
4 Azazel/History.cs
@@ -11,10 +11,10 @@ public class History {
protected History() {}
- public History(File historyFile, XStream xstream) {
+ public History(File historyFile, XStream xstream, PersistanceHelper persistanceHelper) {
this.historyFile = historyFile;
this.xstream = xstream;
- dictionary = PersistanceHelper.LoadOrSaveAndLoad(xstream, Paths.Instance.History, dictionary);
+ dictionary = persistanceHelper.LoadOrSaveAndLoad(Paths.Instance.History, dictionary);
}
public Launchable this[string input] {
View
28 Azazel/KeyHelper.cs
@@ -1,28 +0,0 @@
-using System.Windows.Input;
-
-namespace Azazel {
- public static class KeyHelper {
- public static bool IsCharOrDigit(this Key keyToCompare, Modifiers modifiers) {
- return IsLetter(keyToCompare) || IsDigit(keyToCompare, modifiers);
- }
-
- private static bool IsDigit(this Key keyToCompare, Modifiers modifiers) {
- return (keyToCompare >= Key.NumPad0 && keyToCompare <= Key.NumPad9) || (keyToCompare >= Key.D0 && keyToCompare <= Key.D9 && !modifiers.HasShift);
- }
-
- private static bool IsLetter(this Key keyToCompare) {
- return (keyToCompare >= Key.A && keyToCompare <= Key.Z);
- }
-
- public static string ActualChar(this Key key, Modifiers modifiers) {
- string keyString = key.ToString();
- if (IsLetter(key)) return keyString;
- if (IsDigit(key, modifiers)) return keyString.Substring(keyString.Length - 1, 1);
- return "";
- }
-
- public static bool IsBackspace(this Key key) {
- return key == Key.Back;
- }
- }
-}
View
191 Azazel/KeyHookup/HotKey.cs
@@ -1,17 +1,10 @@
using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Runtime.InteropServices;
using System.Text;
-using System.Text.RegularExpressions;
-using System.Windows;
using System.Windows.Forms;
-using System.Windows.Input;
-using System.Windows.Interop;
namespace Azazel.KeyHookup {
[Serializable]
- public struct Hotkey {
+ public class Hotkey {
internal int id;
public readonly Keys key;
public readonly Modifiers modifiers;
@@ -22,28 +15,6 @@ public struct Hotkey {
id = -1;
}
- public static Hotkey Parse(string key) {
- var rx = new Regex(@"(?:(?:(?<win>win)|(?<ctrl>ctrl|control|ctl)|(?<alt>alt)|(?<shift>shift))\s*(?:[\|+-])\s*)+(?<key>.*)",
- RegexOptions.IgnoreCase);
-
- var mods = ModifierKeys.None;
-
- var m = rx.Match(key);
-
- if (!m.Success) return new Hotkey();
-
- if (m.Groups["win"].Success)
- mods |= ModifierKeys.Windows;
- if (m.Groups["ctrl"].Success)
- mods |= ModifierKeys.Control;
- if (m.Groups["alt"].Success)
- mods |= ModifierKeys.Alt;
- if (m.Groups["shift"].Success)
- mods |= ModifierKeys.Shift;
-
- return new Hotkey(new Modifiers(mods), (Keys) Enum.Parse(typeof (Keys), m.Groups["key"].Value, true));
- }
-
public override string ToString() {
var hotKeyString = new StringBuilder();
if (modifiers.HasWin)
@@ -70,164 +41,4 @@ public struct Hotkey {
return key.GetHashCode() + 29*modifiers.GetHashCode();
}
}
-
- public class WPFHotkeyManager : IDisposable {
- public delegate void HotkeyPressedEvent(Window window, Hotkey hotkey);
-
- private readonly Window actualWindow;
-
- private IntPtr handle;
- private Dictionary<int, Hotkey> Hotkeys;
- private int id;
- private ObservableCollection<Hotkey> observableHotkeys;
-
- private WindowInteropHelper window;
-
- public WPFHotkeyManager(Window TopLevelWindow) {
- actualWindow = TopLevelWindow;
-
- if (!actualWindow.IsArrangeValid)
- actualWindow.SourceInitialized += OnSourceInitialized;
- else OnSourceInitialized(actualWindow, null);
- }
-
- public ReadOnlyCollection<Hotkey> ReadOnlyHotkeys {
- get {
- var hotkeys = new Hotkey[Hotkeys.Count];
- Hotkeys.Values.CopyTo(hotkeys, 0);
- return new ReadOnlyCollection<Hotkey>(hotkeys);
- }
- }
-
- public ObservableCollection<Hotkey> ObservableHotkeys {
- get { return observableHotkeys; }
- }
-
- public int Count {
- get { return Hotkeys.Count; }
- }
-
- public bool IsReadOnly {
- get { return false; }
- }
-
- public Hotkey this[int index] {
- get { return Hotkeys[index]; }
- set { throw new Exception("The method or operation is not implemented."); }
- }
-
- public void Dispose() {
- Clear();
- handle = IntPtr.Zero;
- }
-
- public event HotkeyPressedEvent HotkeyPressed;
-
- private void OnSourceInitialized(object sender, EventArgs e) {
- window = new WindowInteropHelper(actualWindow);
- handle = window.Handle;
- HwndSource.FromHwnd(handle).AddHook(WndProc);
- Hotkeys = new Dictionary<int, Hotkey>();
- observableHotkeys = new ObservableCollection<Hotkey>();
- }
-
- public Hotkey GetKey(int Id) {
- return Hotkeys[Id];
- }
-
- public void Register(Hotkey key) {
- if (handle == IntPtr.Zero)
- throw new InvalidOperationException("You can't register hotkeys until your Window is loaded.");
- if (NativeMethods.RegisterHotKey(handle, ++id, key.modifiers.ModifierKeys, key.key)) {
- key.id = id;
- Hotkeys.Add(id, key);
- observableHotkeys.Add(key);
- }
- else Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
- }
-
- public void Unregister(Hotkey key) {
- var index = IndexOf(key);
- if (index > 0) {
- if (NativeMethods.UnregisterHotKey(handle, index)) {
- Hotkeys.Remove(index);
- observableHotkeys.Remove(key);
- }
- else Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
- }
- }
-
- private void Clear() {
- foreach (var key in Hotkeys)
- NativeMethods.UnregisterHotKey(handle, key.Key);
- Hotkeys.Clear();
- }
-
- private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) {
- if (WM.Hotkey == msg) {
- if (Hotkeys.ContainsKey(wParam.ToInt32())) {
- HotkeyPressed(actualWindow, Hotkeys[wParam.ToInt32()]);
- handled = true;
- }
- }
- return IntPtr.Zero;
- }
-
- public void Add(Hotkey item) {
- if (Hotkeys.ContainsValue(item))
- throw new ArgumentException("That Hotkey is already registered.");
- Register(item);
- }
-
- public bool Contains(Hotkey item) {
- return Hotkeys.ContainsValue(item);
- }
-
- public void CopyTo(Hotkey[] array, int arrayIndex) {
- Hotkeys.Values.CopyTo(array, arrayIndex);
- }
-
- private void Remove(Hotkey item) {
- Unregister(item);
- }
-
- public IEnumerator<Hotkey> GetEnumerator() {
- return Hotkeys.Values.GetEnumerator();
- }
-
- private int IndexOf(Hotkey item) {
- if (item.id > 0 && Hotkeys.ContainsKey(item.id))
- return item.id;
- if (Hotkeys.ContainsValue(item)) {
- foreach (var k in Hotkeys) {
- if (item.Equals(k.Value)) {
- item.id = k.Value.id;
- return item.id;
- }
- }
- }
-
- throw new ArgumentOutOfRangeException(string.Format("The hotkey \"{0}\" is not in this hotkey manager.", item));
- }
-
- public void RemoveAt(int index) {
- Remove(Hotkeys[index]);
- }
- }
-
- public struct WM {
- internal const int GetHotkey = 0x33;
- internal const int Hotkey = 0x312;
- internal const int SetHotkey = 0x0032;
- }
-
- public static class NativeMethods {
- [DllImport("User32", SetLastError = true)]
- [return : MarshalAs(UnmanagedType.Bool)]
- public static extern bool RegisterHotKey(IntPtr hWnd, int id, ModifierKeys fsModifiers, Keys uVirtKey);
-
- [DllImport("User32", SetLastError = true)]
- [return : MarshalAs(UnmanagedType.Bool)]
- public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
- }
}
View
16 Azazel/KeyHookup/NativeMethods.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Runtime.InteropServices;
+using System.Windows.Forms;
+using System.Windows.Input;
+
+namespace Azazel.KeyHookup {
+ public static class NativeMethods {
+ [DllImport("User32", SetLastError = true)]
+ [return : MarshalAs(UnmanagedType.Bool)]
+ public static extern bool RegisterHotKey(IntPtr hWnd, int id, ModifierKeys fsModifiers, Keys uVirtKey);
+
+ [DllImport("User32", SetLastError = true)]
+ [return : MarshalAs(UnmanagedType.Bool)]
+ public static extern bool UnregisterHotKey(IntPtr hWnd, int id);
+ }
+}
View
99 Azazel/KeyHookup/WPFHotkeyManager.cs
@@ -0,0 +1,99 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Runtime.InteropServices;
+using System.Windows;
+using System.Windows.Interop;
+
+namespace Azazel.KeyHookup {
+ public class WPFHotkeyManager : IDisposable {
+ public delegate void HotkeyPressedEvent(Window window, Hotkey hotkey);
+
+ private readonly Window actualWindow;
+
+ private IntPtr handle;
+ private Dictionary<int, Hotkey> hotkeys;
+ private int id;
+
+ private WindowInteropHelper window;
+
+ public WPFHotkeyManager(Window topLevelWindow) {
+ actualWindow = topLevelWindow;
+
+ if (!actualWindow.IsArrangeValid)
+ actualWindow.SourceInitialized += OnSourceInitialized;
+ else OnSourceInitialized(actualWindow, null);
+ }
+
+ private ObservableCollection<Hotkey> ObservableHotkeys { get; set; }
+
+ public void Dispose() {
+ Clear();
+ handle = IntPtr.Zero;
+ }
+
+ public event HotkeyPressedEvent HotkeyPressed;
+
+ private void OnSourceInitialized(object sender, EventArgs e) {
+ window = new WindowInteropHelper(actualWindow);
+ handle = window.Handle;
+ HwndSource.FromHwnd(handle).AddHook(WndProc);
+ hotkeys = new Dictionary<int, Hotkey>();
+ ObservableHotkeys = new ObservableCollection<Hotkey>();
+ }
+
+ public void Register(Hotkey key) {
+ if (handle == IntPtr.Zero)
+ throw new InvalidOperationException("You can't register hotkeys until your Window is loaded.");
+ if (NativeMethods.RegisterHotKey(handle, ++id, key.modifiers.ModifierKeys, key.key)) {
+ key.id = id;
+ hotkeys.Add(id, key);
+ ObservableHotkeys.Add(key);
+ }
+ else Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
+ }
+
+ public void Unregister(Hotkey key) {
+ int index = IndexOf(key);
+ if (index > 0) {
+ if (NativeMethods.UnregisterHotKey(handle, index)) {
+ hotkeys.Remove(index);
+ ObservableHotkeys.Remove(key);
+ }
+ else Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
+ }
+ }
+
+ private void Clear() {
+ foreach (var key in hotkeys)
+ NativeMethods.UnregisterHotKey(handle, key.Key);
+ hotkeys.Clear();
+ }
+
+ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled) {
+ const int hotkey = 0x312;
+ if (hotkey == msg) {
+ if (hotkeys.ContainsKey(wParam.ToInt32())) {
+ HotkeyPressed(actualWindow, hotkeys[wParam.ToInt32()]);
+ handled = true;
+ }
+ }
+ return IntPtr.Zero;
+ }
+
+ private int IndexOf(Hotkey item) {
+ if (item.id > 0 && hotkeys.ContainsKey(item.id))
+ return item.id;
+ if (hotkeys.ContainsValue(item)) {
+ foreach (var k in hotkeys) {
+ if (item.Equals(k.Value)) {
+ item.id = k.Value.id;
+ return item.id;
+ }
+ }
+ }
+
+ throw new ArgumentOutOfRangeException(string.Format("The hotkey \"{0}\" is not in this hotkey manager.", item));
+ }
+ }
+}
View
37 Azazel/MainWindowCommand.cs
@@ -7,24 +7,31 @@
namespace Azazel {
public class MainWindowCommand {
private readonly VoidDelegate killApplication;
- private readonly Hotkey displayHotkey;
- private readonly Hotkey killHotkey;
+ private Hotkey displayHotkey;
+ private readonly Hotkey killHotkey = new Hotkey(Modifiers.Alt | Modifiers.Control | Modifiers.Shift, Keys.F4);
private WPFHotkeyManager hotkeyManager;
private readonly MainWindowController controller;
private MainWindow window;
private readonly Hotkey unchangeableDisplayHotkey = new Hotkey(Modifiers.Alt | Modifiers.Control | Modifiers.Shift, Keys.Space);
- public MainWindowCommand(VoidDelegate killApplication) {
+ public MainWindowCommand(VoidDelegate killApplication, AppSettings appSettings) {
var selfPlugin = new SelfPlugin();
var loader = new PluginLoader(selfPlugin);
- AppSettings appSettings = PersistanceHelper.LoadOrSaveAndLoad(selfPlugin.XStream, Paths.Instance.AppSettings,
- new AppSettings(new Hotkey(Modifiers.Alt, Keys.F2),
- new Hotkey(Modifiers.Alt | Modifiers.Control | Modifiers.Shift,
- Keys.F4)));
- displayHotkey = appSettings.DisplayHotKey;
- killHotkey = appSettings.KillHotKey;
- controller = new MainWindowController(loader.LaunchablePlugins, loader.CharacterPlugins, loader.LaunchableHandlers, selfPlugin);
+ var persistanceHelper = new PersistanceHelper(selfPlugin.XStream);
+ appSettings.AppHotkeys = persistanceHelper.LoadOrSaveAndLoad(Paths.Instance.AppHotkeys,
+ new Hotkeys(new Hotkey(Modifiers.Alt, Keys.F2)));
+ Hotkeys hotkeys = appSettings.AppHotkeys;
+ displayHotkey = hotkeys.DisplayHotKey;
+ controller = new MainWindowController(loader.LaunchablePlugins, loader.CharacterPlugins, loader.LaunchableHandlers, selfPlugin, persistanceHelper,
+ appSettings);
this.killApplication = killApplication;
+ appSettings.HotkeysChanged += HandleHotkeysChanged;
+ }
+
+ private void HandleHotkeysChanged(Hotkeys hotkeys) {
+ UnregisterHotkeys();
+ displayHotkey = hotkeys.DisplayHotKey;
+ RegisterEvents();
}
public void Execute() {
@@ -49,14 +56,18 @@ public class MainWindowCommand {
private void HandleHotkey(Hotkey hotkey) {
if (window.Visibility != Visibility.Visible) {
window.Close();
- hotkeyManager.Unregister(displayHotkey);
- hotkeyManager.Unregister(killHotkey);
- hotkeyManager.Unregister(unchangeableDisplayHotkey);
+ UnregisterHotkeys();
if (hotkey.Equals(displayHotkey)) Execute();
else if (hotkey.Equals(killHotkey)) killApplication();
}
if (hotkey.Equals(displayHotkey) || hotkey.Equals(unchangeableDisplayHotkey)) window.Activate();
}
+
+ private void UnregisterHotkeys() {
+ hotkeyManager.Unregister(displayHotkey);
+ hotkeyManager.Unregister(killHotkey);
+ hotkeyManager.Unregister(unchangeableDisplayHotkey);
+ }
}
public delegate void VoidDelegate();
View
24 Azazel/MainWindowController.cs
@@ -4,7 +4,6 @@
using Azazel.Logging;
using Azazel.PluggingIn;
using Azazel.Threading;
-using Action=Azazel.FileSystem.Action;
namespace Azazel {
public class MainWindowController {
@@ -18,13 +17,14 @@ public class MainWindowController {
private readonly SelfPlugin selfPlugin;
public event VoidDelegate RefreshedResults = () => { };
- public MainWindowController(LaunchablePlugins launchablePlugins, CharacterPlugins characterPlugins, LaunchableHandlers launchableHandlers, SelfPlugin selfPlugin) {
+ public MainWindowController(LaunchablePlugins launchablePlugins, CharacterPlugins characterPlugins, LaunchableHandlers launchableHandlers,
+ SelfPlugin selfPlugin, PersistanceHelper persistanceHelper, AppSettings settings) {
this.launchableHandlers = launchableHandlers;
this.selfPlugin = selfPlugin;
- appFinder = new AppFinder(launchablePlugins, characterPlugins, selfPlugin.XStream);
+ appFinder = new AppFinder(launchablePlugins, characterPlugins, selfPlugin.XStream, persistanceHelper);
selfPlugin.RefreshRequested += (() => appFinder.LoadFiles(launchablePlugins));
selfPlugin.AddAFolder += (() => appFinder.AddFolder(launchablePlugins));
- selfPlugin.ChangeShortcut += (() => new KeyboardShortcutChangeCommand().Execute());
+ selfPlugin.ChangeShortcut += (() => new KeyboardShortcutChangeCommand(settings, persistanceHelper).Execute());
}
public void SetInput(string value, bool asynchronous) {
@@ -38,8 +38,8 @@ public class MainWindowController {
private void RefreshResults(object parameter) {
var value = (string) parameter;
if (input == value) return;
- var workingToken = latestToken = new Token();
- var newFiles = value.Contains(input) && !selectedFiles.IsEmpty() ? appFinder.FindFiles(selectedFiles, value) : appFinder.FindFiles(value);
+ Token workingToken = latestToken = new Token();
+ Launchables newFiles = value.Contains(input) && !selectedFiles.IsEmpty() ? appFinder.FindFiles(selectedFiles, value) : appFinder.FindFiles(value);
if (!latestToken.Equals(workingToken)) {
LogManager.WriteLog("token check failed with input {0} and value {1}", input, value);
return;
@@ -98,7 +98,7 @@ public class MainWindowController {
}
public Launchable ImmediateResult(string inputText) {
- if(inputText.IsNullOrEmpty()) return File.Null;
+ if (inputText.IsNullOrEmpty()) return File.Null;
return appFinder.ExactMatch(inputText);
}
@@ -108,8 +108,16 @@ public class MainWindowController {
}
internal class KeyboardShortcutChangeCommand {
+ private readonly AppSettings settings;
+ private readonly PersistanceHelper persistanceHelper;
+
+ public KeyboardShortcutChangeCommand(AppSettings settings, PersistanceHelper persistanceHelper) {
+ this.settings = settings;
+ this.persistanceHelper = persistanceHelper;
+ }
+
public void Execute() {
- var window = new KeyboardShortcut();
+ var window = new KeyboardShortcut(settings, persistanceHelper);
window.Show();
window.Activate();
}
View
8 Azazel/Modifiers.cs
@@ -38,10 +38,6 @@ public class Modifiers {
get { return HasModifier(ModifierKeys.Alt); }
}
- public bool IsNone {
- get { return Equals(modifierKeys, ModifierKeys.None); }
- }
-
public ModifierKeys ModifierKeys {
get { return modifierKeys; }
}
@@ -53,5 +49,9 @@ public class Modifiers {
public static Modifiers operator |(Modifiers first, Modifiers second) {
return new Modifiers(first.modifierKeys | second.modifierKeys);
}
+
+ public override string ToString() {
+ return modifierKeys.ToString();
+ }
}
}
View
2 Azazel/PluggingIn/KeyboardShortcut.xaml
@@ -8,7 +8,7 @@
<Grid x:Name="LayoutRoot">
<Rectangle Fill="{DynamicResource background}" Stroke="#FF000000" OpacityMask="{DynamicResource opacityMask}"/>
- <Label d:LayoutOverrides="Height" FontSize="22" x:Name="currentlySelected" Content="" VerticalAlignment="Top" HorizontalAlignment="Left" Width="213"/>
+ <Label FontSize="22" x:Name="currentlySelected" Content="ue" VerticalAlignment="Top" Foreground="{DynamicResource text}"/>
<CheckBox Margin="0,0,0,20.1" x:Name="useWindowsKey" Content="Use Windows Key?" d:LayoutOverrides="Width, Height" HorizontalAlignment="Left" VerticalAlignment="Bottom"/>
</Grid>
</Window>
View
15 Azazel/PluggingIn/KeyboardShortcut.xaml.cs
@@ -3,20 +3,30 @@
using System.Text;
using System.Windows.Forms;
using System.Windows.Input;
+using Azazel.FileSystem;
using Azazel.KeyHookup;
namespace Azazel.PluggingIn {
public partial class KeyboardShortcut {
+ private readonly AppSettings settings;
+ private readonly PersistanceHelper persistanceHelper;
private Hotkey newHotkey;
- public KeyboardShortcut() {
+ public KeyboardShortcut(AppSettings settings, PersistanceHelper persistanceHelper) {
+ this.settings = settings;
+ this.persistanceHelper = persistanceHelper;
InitializeComponent();
HookEvents();
}
private void HookEvents() {
Activated += delegate { new WindowHider(this).Hide(); };
KeyUp += ((sender, e) => KeyPressed(e.Key, Modifiers.Current));
+ useWindowsKey.Checked += delegate { OnUseWindowsCheckedChanged(); };
+ }
+
+ private void OnUseWindowsCheckedChanged() {
+ KeyPressed((Key) Enum.Parse(typeof (Key), newHotkey.key.ToString()), newHotkey.modifiers);
}
private void KeyPressed(Key key, Modifiers modifiers) {
@@ -40,7 +50,8 @@ public partial class KeyboardShortcut {
}
private void SaveAsKeyboardShortcut() {
-// PersistanceHelper.LoadOrSaveAndLoad<Hotkey>()
+ settings.AppHotkeys = persistanceHelper.SaveAndLoad(Paths.Instance.AppHotkeys, new Hotkeys(newHotkey));
+ Close();
}
}
}
View
3 AzazelTests/AppFinderTest.cs
@@ -1,6 +1,7 @@
using Azazel.FileSystem;
using Azazel.PluggingIn;
using NUnit.Framework;
+using Rhino.Mocks;
using xstream;
namespace Azazel {
@@ -10,7 +11,7 @@ public class AppFinderTest {
[SetUp]
public void SetUp() {
- finder = new AppFinder(new LaunchablePlugins(), new CharacterPlugins(), new XStream());
+ finder = new AppFinder(new LaunchablePlugins(), new CharacterPlugins(), new XStream(), MockRepository.GenerateMock<PersistanceHelper>());
}
[Test]
View
23 Venus/Services/ServicesPlugin.cs
@@ -12,7 +12,7 @@ public class ServicesPlugin : LaunchablePlugin {
public Launchables Launchables() {
var services = new Launchables();
foreach (var service in ServiceController.GetServices()) {
- var icon = new PluginIconLoader().Png("services");
+ ImageSource icon = new PluginIconLoader().Png("services");
services.Add(new Service(service, icon));
}
return services;
@@ -42,7 +42,10 @@ public class Service : Launchable {
get {
var actions = new Actions();
serviceController.Refresh();
- if (CanStop) actions.Add(new ServiceStopAction(serviceController));
+ if (CanStop) {
+ actions.Add(new ServiceStopAction(serviceController));
+ actions.Add(new ServiceRestartAction(serviceController));
+ }
if (CanStart) actions.Add(new ServiceStartAction(serviceController));
actions.Add(new ServiceStatusAction(serviceController));
return actions;
@@ -105,6 +108,22 @@ private class ServiceStopAction : Action {
}
}
+ private class ServiceRestartAction : Action {
+ private readonly ServiceController controller;
+
+ public ServiceRestartAction(ServiceController controller) {
+ this.controller = controller;
+ }
+
+ public void Act() {
+ new Runner(controller.Stop).AsyncStart(controller.Start);
+ }
+
+ public string Name {
+ get { return "Restart Service"; }
+ }
+ }
+
public void Launch(string arguments) {}
public bool ShouldStoreHistory {

0 comments on commit f39c520

Please sign in to comment.