regular update

This commit is contained in:
qianlifeng
2013-12-23 23:53:38 +08:00
parent fffb97ea8d
commit 87225e64fa
15 changed files with 136 additions and 42 deletions

View File

@@ -1,20 +1,20 @@
<?xml version="1.0" encoding="utf-8" ?>
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler"/>
</configSections>
<log4net>
<appender name="LogFileAppender" type="log4net.Appender.FileAppender">
<file value="log.txt" />
<appendToFile value="true" />
<rollingStyle value="Date" />
<datePattern value="yyyyMMdd-HH:mm:ss" />
<file value="log.txt"/>
<appendToFile value="true"/>
<rollingStyle value="Date"/>
<datePattern value="yyyyMMdd-HH:mm:ss"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="Date%date Level%-5level Msg%message%newline" />
<conversionPattern value="Date%date Level%-5level Msg%message%newline"/>
</layout>
</appender>
<root>
<appender-ref ref="LogFileAppender" />
<appender-ref ref="LogFileAppender"/>
</root>
</log4net>
</configuration>
<startup><supportedRuntime version="v2.0.50727"/></startup></configuration>

View File

@@ -91,12 +91,12 @@ namespace WinAlfred
resultCtrl.SelectFirst();
}
public void HideWinAlfred()
private void HideWinAlfred()
{
Hide();
}
public void ShowWinAlfred()
private void ShowWinAlfred()
{
tbQuery.SelectAll();
Focus();

View File

@@ -61,8 +61,9 @@ namespace WinAlfred.PluginLoader
metadata.Language = ini.GetSetting("plugin", "Language");
metadata.Version = ini.GetSetting("plugin", "Version");
metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword");
metadata.ExecuteFile = AppDomain.CurrentDomain.BaseDirectory + directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
metadata.ExecuteFilePath = AppDomain.CurrentDomain.BaseDirectory + directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
metadata.PluginDirecotry = AppDomain.CurrentDomain.BaseDirectory + directory + "\\";
metadata.ExecuteFileName = ini.GetSetting("plugin", "ExecuteFile");
if (!AllowedLanguage.IsAllowed(metadata.Language))
{
@@ -76,10 +77,10 @@ namespace WinAlfred.PluginLoader
#endif
return null;
}
if (!File.Exists(metadata.ExecuteFile))
if (!File.Exists(metadata.ExecuteFilePath))
{
string error = string.Format("Parse ini {0} failed: ExecuteFile didn't exist {1}", iniPath,
metadata.ExecuteFile);
string error = string.Format("Parse ini {0} failed: ExecuteFilePath didn't exist {1}", iniPath,
metadata.ExecuteFilePath);
Log.Error(error);
#if (DEBUG)
{

View File

@@ -19,7 +19,7 @@ namespace WinAlfred.PluginLoader
{
try
{
Assembly asm = Assembly.LoadFile(metadata.ExecuteFile);
Assembly asm = Assembly.LoadFile(metadata.ExecuteFilePath);
List<Type> types = asm.GetTypes().Where(o => o.GetInterfaces().Contains(typeof (IPlugin))).ToList();
if (types.Count == 0)
{

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
using WinAlfred.Plugin;
namespace WinAlfred.PluginLoader
@@ -10,27 +11,18 @@ namespace WinAlfred.PluginLoader
private PluginMetadata metadata;
[DllImport("PyWinAlfred.dll", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public extern static void ExecPython(string directory, string file, string query);
static PythonPluginWrapper()
{
}
private extern static IntPtr ExecPython(string directory, string file, string query);
public PythonPluginWrapper(PluginMetadata metadata)
{
this.metadata = metadata;
}
public List<Result> Query(Query query)
{
List<Result> results = new List<Result>();
ExecPython(metadata.PluginDirecotry, metadata.ExecuteFile.Replace(".py", ""), query.RawQuery);
results.Add(new Result()
{
});
return results;
string s = Marshal.PtrToStringAnsi(ExecPython(metadata.PluginDirecotry, metadata.ExecuteFileName.Replace(".py", ""), query.RawQuery));
List<Result> o = JsonConvert.DeserializeObject<List<Result>>(s);
return o;
}
public void Init()

View File

@@ -5,7 +5,9 @@
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<StackPanel x:Name="pnlContainer">
<ScrollViewer MaxHeight="300" VerticalScrollBarVisibility="Auto">
<StackPanel x:Name="pnlContainer">
</StackPanel>
</StackPanel>
</ScrollViewer>
</UserControl>

View File

@@ -4,9 +4,6 @@ using WinAlfred.Plugin;
namespace WinAlfred
{
/// <summary>
/// Result.xaml 的交互逻辑
/// </summary>
public partial class ResultPanel : UserControl
{
public delegate void ResultItemsChanged();
@@ -26,7 +23,7 @@ namespace WinAlfred
{
Result result = results[i];
ResultItem control = new ResultItem(result);
control.SetIndex(i+1);
control.SetIndex(i + 1);
pnlContainer.Children.Add(control);
}
@@ -39,7 +36,7 @@ namespace WinAlfred
if (resultItem != null)
resultItemHeight = resultItem.ActualHeight;
}
Height = pnlContainer.Height = results.Count * resultItemHeight;
pnlContainer.Height = results.Count * resultItemHeight;
OnResultItemChangedEvent();
}
@@ -118,4 +115,4 @@ namespace WinAlfred
InitializeComponent();
}
}
}
}

View File

@@ -15,6 +15,7 @@
<WarningLevel>4</WarningLevel>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
<RestorePackages>true</RestorePackages>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
@@ -35,14 +36,21 @@
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>app.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="log4net">
<HintPath>..\packages\log4net.2.0.3\lib\net35-full\log4net.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json">
<HintPath>..\packages\Newtonsoft.Json.5.0.8\lib\net35\Newtonsoft.Json.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
@@ -110,7 +118,9 @@
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="App.config" />
<None Include="packages.config" />
<None Include="packages.config">
<SubType>Designer</SubType>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
@@ -135,6 +145,9 @@
<ItemGroup>
<Resource Include="Images\ctrl.png" />
</ItemGroup>
<ItemGroup>
<Resource Include="app.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.

BIN
WinAlfred/app.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

View File

@@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="log4net" version="2.0.3" targetFramework="net35" />
<package id="Newtonsoft.Json" version="5.0.8" targetFramework="net35" />
</packages>