Skip to content

Commit 36f196d

Browse files
Implemented working prototype.
0 parents  commit 36f196d

File tree

13 files changed

+375
-0
lines changed

13 files changed

+375
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
.DS_Store
2+
lib
3+
obj
4+
bin
5+
packages
6+
*.suo

AxLauncher.cs

Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Diagnostics;
6+
using System.Management;
7+
using System.IO;
8+
using Newtonsoft.Json;
9+
10+
namespace Wox.Plugin.AxLauncher
11+
{
12+
/// <summary>
13+
/// Launcher class for axc files.
14+
/// </summary>
15+
public class AxLauncher : IPlugin, ISettingProvider
16+
{
17+
/// <summary>
18+
/// Settings store object.
19+
/// </summary>
20+
public static Settings settings;
21+
22+
/// <summary>
23+
/// Process the query.
24+
/// </summary>
25+
/// <param name="query"></param>
26+
/// <returns></returns>
27+
public List<Result> Query(Query query)
28+
{
29+
string[] axcFiles;
30+
string searchPattern;
31+
List<Result> results = new List<Result>();
32+
33+
// check if search parameter is given
34+
if (query.ActionParameters.Count == 0)
35+
{
36+
// no search parameter
37+
// show all .axc files
38+
searchPattern = "*.axc";
39+
}
40+
else
41+
{
42+
// search for files *parameter*.axc
43+
searchPattern = "*" + query.ActionParameters[0].ToLower() + "*.axc";
44+
}
45+
46+
if (String.Empty.Equals(settings.axcPath.Trim()))
47+
{
48+
axcFiles = new string[] { "Define the axc path in settings" };
49+
}
50+
else
51+
{
52+
axcFiles = Directory.GetFiles(settings.axcPath, searchPattern, SearchOption.AllDirectories);
53+
}
54+
55+
foreach (string axcFile in axcFiles)
56+
{
57+
results.Add(new Result()
58+
{
59+
Title = axcFile.Substring(axcFile.LastIndexOf("\\") + 1),
60+
SubTitle = axcFile,
61+
IcoPath = "Images\\app.png",
62+
Action = e =>
63+
{
64+
try
65+
{
66+
ProcessStartInfo startInfo = new ProcessStartInfo();
67+
startInfo.FileName = axcFile;
68+
Process.Start(startInfo);
69+
}
70+
catch
71+
{
72+
return false;
73+
}
74+
75+
return true;
76+
}
77+
});
78+
}
79+
return results;
80+
}
81+
82+
/// <summary>
83+
/// Init method. Loads the settings from the settings.json file.
84+
/// </summary>
85+
/// <param name="context"></param>
86+
public void Init(PluginInitContext context)
87+
{
88+
string settingsPath = System.IO.Path.Combine(context.CurrentPluginMetadata.PluginDirectory, "settings.json");
89+
try
90+
{
91+
settings = JsonConvert.DeserializeObject<Settings>(System.IO.File.ReadAllText(settingsPath));
92+
}
93+
catch
94+
{
95+
settings = new Settings();
96+
settings.settingsPath = settingsPath;
97+
}
98+
}
99+
100+
/// <summary>
101+
/// Create the settings panel for ax launcher.
102+
/// </summary>
103+
public System.Windows.Controls.Control CreateSettingPanel()
104+
{
105+
return new Setting();
106+
}
107+
108+
/// <summary>
109+
/// Save the settings object into the settings.json file.
110+
/// </summary>
111+
public static void saveSettings()
112+
{
113+
settings.saveSettings();
114+
}
115+
}
116+
}

LICENSE.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015 David Trautmann
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

Properties/AssemblyInfo.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
[assembly: AssemblyTitle("Wox.Plugin.AxLauncher")]
6+
[assembly: AssemblyDescription("Dynamics Ax Launcher Plugin for Wox")]
7+
[assembly: AssemblyConfiguration("")]
8+
[assembly: AssemblyCompany("Microsoft")]
9+
[assembly: AssemblyProduct("Wox.Plugin.AxLauncher")]
10+
[assembly: AssemblyCopyright("The MIT License (MIT)")]
11+
[assembly: AssemblyTrademark("")]
12+
[assembly: AssemblyCulture("")]
13+
14+
[assembly: ComVisible(false)]
15+
16+
[assembly: Guid("44359cc2-2c41-4e3d-b770-5e3efac78ca4")]
17+
18+
[assembly: AssemblyVersion("1.0.0.0")]
19+
[assembly: AssemblyFileVersion("1.0.0.0")]

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Wox Plugin AxLauncher
2+
A [Wox](https://github.com/qianlifeng/Wox) plugin to launch dynamics ax clients for the selected `*.axc` configuration files.
3+
4+
### Usage
5+
1. Type `ax` in Wox followed by a space.
6+
2. Press `Enter` key to launch dynamics ax with the selected configuration file.
7+
8+
### Licencse
9+
[License](LICENSE.md)

Setting.xaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<UserControl x:Class="Wox.Plugin.AxLauncher.Setting"
2+
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3+
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4+
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
5+
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6+
mc:Ignorable="d"
7+
d:DesignHeight="300" d:DesignWidth="300">
8+
<Grid>
9+
<Label Content="Axc Path" Height="28" HorizontalAlignment="Left" Name="BaseLabel" VerticalAlignment="Top" />
10+
<TextBox x:Name="tbAxcPath" Height="23" Margin="5,26,5,0" VerticalAlignment="Top" />
11+
</Grid>
12+
</UserControl>

Setting.xaml.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using System.Windows;
6+
using System.Windows.Controls;
7+
8+
namespace Wox.Plugin.AxLauncher
9+
{
10+
/// <summary>
11+
/// Interactive logic for Setting.xaml
12+
/// </summary>
13+
public partial class Setting : UserControl
14+
{
15+
public Setting()
16+
{
17+
InitializeComponent();
18+
19+
Loaded += Setting_Loaded;
20+
}
21+
22+
void Setting_Loaded(object sender, System.Windows.RoutedEventArgs e)
23+
{
24+
tbAxcPath.Text = AxLauncher.settings.axcPath;
25+
tbAxcPath.TextChanged += (o, ex) =>
26+
{
27+
AxLauncher.settings.axcPath = tbAxcPath.Text;
28+
AxLauncher.saveSettings();
29+
};
30+
}
31+
}
32+
}

Settings.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
5+
using Newtonsoft.Json;
6+
7+
namespace Wox.Plugin.AxLauncher
8+
{
9+
/// <summary>
10+
/// Store object for the settings.
11+
/// </summary>
12+
public class Settings
13+
{
14+
public string axcPath { get; set; }
15+
public string settingsPath { get; set; }
16+
17+
/// <summary>
18+
/// Save this settings to the settings.json file.
19+
/// </summary>
20+
public void saveSettings()
21+
{
22+
try
23+
{
24+
System.IO.File.WriteAllText(this.settingsPath, JsonConvert.SerializeObject(this, Formatting.Indented));
25+
}
26+
catch
27+
{
28+
throw new Exception("Saving settings.json failed.");
29+
}
30+
}
31+
}
32+
}

Wox.Plugin.AxLauncher.csproj

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>8.0.30703</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{86BE9D87-3289-4D7F-BC9D-EC19418A1E2A}</ProjectGuid>
9+
<OutputType>Library</OutputType>
10+
<AppDesignerFolder>Properties</AppDesignerFolder>
11+
<RootNamespace>Wox.Plugin.AxLauncher</RootNamespace>
12+
<AssemblyName>Wox.Plugin.AxLauncher</AssemblyName>
13+
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
14+
<FileAlignment>512</FileAlignment>
15+
<TargetFrameworkProfile />
16+
</PropertyGroup>
17+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
18+
<DebugSymbols>true</DebugSymbols>
19+
<DebugType>full</DebugType>
20+
<Optimize>false</Optimize>
21+
<OutputPath>bin\debug\</OutputPath>
22+
<DefineConstants>DEBUG;TRACE</DefineConstants>
23+
<ErrorReport>prompt</ErrorReport>
24+
<WarningLevel>4</WarningLevel>
25+
<Prefer32Bit>false</Prefer32Bit>
26+
</PropertyGroup>
27+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
28+
<DebugType>pdbonly</DebugType>
29+
<Optimize>true</Optimize>
30+
<OutputPath>bin\release\</OutputPath>
31+
<DefineConstants>TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>4</WarningLevel>
34+
<Prefer32Bit>false</Prefer32Bit>
35+
</PropertyGroup>
36+
<ItemGroup>
37+
<Reference Include="Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
38+
<SpecificVersion>False</SpecificVersion>
39+
<HintPath>packages\Newtonsoft.Json.6.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
40+
</Reference>
41+
<Reference Include="PresentationCore" />
42+
<Reference Include="PresentationFramework" />
43+
<Reference Include="System" />
44+
<Reference Include="System.Core" />
45+
<Reference Include="System.Drawing" />
46+
<Reference Include="System.Windows.Forms" />
47+
<Reference Include="System.Xml.Linq" />
48+
<Reference Include="System.Data.DataSetExtensions" />
49+
<Reference Include="System.Data" />
50+
<Reference Include="System.Xml" />
51+
<Reference Include="WindowsBase" />
52+
<Reference Include="Wox.Plugin">
53+
<HintPath>packages\Wox.Plugin.1.1.1.382\lib\net35\Wox.Plugin.dll</HintPath>
54+
</Reference>
55+
</ItemGroup>
56+
<ItemGroup>
57+
<Compile Include="AxLauncher.cs" />
58+
<Compile Include="Properties\AssemblyInfo.cs" />
59+
<Compile Include="Setting.xaml.cs">
60+
<DependentUpon>Setting.xaml</DependentUpon>
61+
</Compile>
62+
<Compile Include="Settings.cs" />
63+
</ItemGroup>
64+
<ItemGroup>
65+
<None Include="packages.config" />
66+
<None Include="plugin.json">
67+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
68+
</None>
69+
</ItemGroup>
70+
<ItemGroup>
71+
<Content Include="Images\app.png">
72+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
73+
</Content>
74+
</ItemGroup>
75+
<ItemGroup>
76+
<Page Include="Setting.xaml">
77+
<SubType>Designer</SubType>
78+
<Generator>MSBuild:Compile</Generator>
79+
</Page>
80+
</ItemGroup>
81+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
82+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
83+
Other similar extension points exist, see Microsoft.Common.targets.
84+
<Target Name="BeforeBuild">
85+
</Target>
86+
<Target Name="AfterBuild">
87+
</Target>
88+
-->
89+
</Project>

Wox.Plugin.AxLauncher.sln

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio 2013
4+
VisualStudioVersion = 12.0.21005.1
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Wox.Plugin.AxLauncher", "Wox.Plugin.AxLauncher.csproj", "{86BE9D87-3289-4D7F-BC9D-EC19418A1E2A}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{86BE9D87-3289-4D7F-BC9D-EC19418A1E2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{86BE9D87-3289-4D7F-BC9D-EC19418A1E2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{86BE9D87-3289-4D7F-BC9D-EC19418A1E2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{86BE9D87-3289-4D7F-BC9D-EC19418A1E2A}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
EndGlobal

0 commit comments

Comments
 (0)