mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 03:07:04 +02:00
UI staff
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<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" />
|
||||
<layout type="log4net.Layout.PatternLayout">
|
||||
<conversionPattern value="Date:%date Level:%-5level Msg:%message%newline" />
|
||||
</layout>
|
||||
</appender>
|
||||
<root>
|
||||
<appender-ref ref="LogFileAppender" />
|
||||
</root>
|
||||
</log4net>
|
||||
</configuration>
|
||||
32
WinAlfred/App.xaml
Normal file
32
WinAlfred/App.xaml
Normal file
@@ -0,0 +1,32 @@
|
||||
<Application x:Class="WinAlfred.App"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
StartupUri="MainWindow.xaml">
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<Style x:Key="windowShow" TargetType="Window">
|
||||
<Setter Property="Border.RenderTransform">
|
||||
<Setter.Value>
|
||||
<ScaleTransform CenterX="50" CenterY="50" ScaleX="1" ScaleY="1" />
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
<Style.Triggers>
|
||||
<EventTrigger RoutedEvent="Window.Loaded">
|
||||
<EventTrigger.Actions>
|
||||
<BeginStoryboard >
|
||||
<Storyboard>
|
||||
<DoubleAnimation Duration="0:0:0.5" Storyboard.TargetProperty="RenderTransform.ScaleX"
|
||||
From="1.0" To="1.1"
|
||||
AutoReverse="True"/>
|
||||
<DoubleAnimation Duration="0:0:0.5" Storyboard.TargetProperty="RenderTransform.ScaleY"
|
||||
From="1.0" To="1.1"
|
||||
AutoReverse="True"/>
|
||||
</Storyboard>
|
||||
</BeginStoryboard>
|
||||
</EventTrigger.Actions>
|
||||
</EventTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
11
WinAlfred/App.xaml.cs
Normal file
11
WinAlfred/App.xaml.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
using System.Windows;
|
||||
|
||||
namespace WinAlfred
|
||||
{
|
||||
/// <summary>
|
||||
/// App.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
}
|
||||
}
|
||||
128
WinAlfred/CustomControls/ResultItemControl.Designer.cs
generated
128
WinAlfred/CustomControls/ResultItemControl.Designer.cs
generated
@@ -1,128 +0,0 @@
|
||||
namespace WinAlfreds.CustomControls
|
||||
{
|
||||
partial class ResultItemControl
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region 组件设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.pictureBox1 = new System.Windows.Forms.PictureBox();
|
||||
this.lblTitle = new System.Windows.Forms.Label();
|
||||
this.lblSubTitle = new System.Windows.Forms.Label();
|
||||
this.panel1 = new System.Windows.Forms.Panel();
|
||||
this.button1 = new System.Windows.Forms.Button();
|
||||
this.panel2 = new System.Windows.Forms.Panel();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
this.panel1.SuspendLayout();
|
||||
this.panel2.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
this.pictureBox1.Dock = System.Windows.Forms.DockStyle.Left;
|
||||
this.pictureBox1.Location = new System.Drawing.Point(0, 0);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(44, 54);
|
||||
this.pictureBox1.TabIndex = 0;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
// lblTitle
|
||||
//
|
||||
this.lblTitle.AutoSize = true;
|
||||
this.lblTitle.Dock = System.Windows.Forms.DockStyle.Top;
|
||||
this.lblTitle.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
|
||||
this.lblTitle.ForeColor = System.Drawing.Color.FromArgb(((int)(((byte)(34)))), ((int)(((byte)(34)))), ((int)(((byte)(34)))));
|
||||
this.lblTitle.Location = new System.Drawing.Point(0, 0);
|
||||
this.lblTitle.Name = "lblTitle";
|
||||
this.lblTitle.Size = new System.Drawing.Size(80, 16);
|
||||
this.lblTitle.TabIndex = 1;
|
||||
this.lblTitle.Text = "lblTitle";
|
||||
//
|
||||
// lblSubTitle
|
||||
//
|
||||
this.lblSubTitle.AutoSize = true;
|
||||
this.lblSubTitle.Dock = System.Windows.Forms.DockStyle.Bottom;
|
||||
this.lblSubTitle.Location = new System.Drawing.Point(0, 42);
|
||||
this.lblSubTitle.Name = "lblSubTitle";
|
||||
this.lblSubTitle.Size = new System.Drawing.Size(71, 12);
|
||||
this.lblSubTitle.TabIndex = 2;
|
||||
this.lblSubTitle.Text = "lblSubTitle";
|
||||
//
|
||||
// panel1
|
||||
//
|
||||
this.panel1.Controls.Add(this.button1);
|
||||
this.panel1.Dock = System.Windows.Forms.DockStyle.Right;
|
||||
this.panel1.Location = new System.Drawing.Point(341, 0);
|
||||
this.panel1.Name = "panel1";
|
||||
this.panel1.Size = new System.Drawing.Size(62, 54);
|
||||
this.panel1.TabIndex = 4;
|
||||
//
|
||||
// button1
|
||||
//
|
||||
this.button1.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.button1.Location = new System.Drawing.Point(0, 0);
|
||||
this.button1.Name = "button1";
|
||||
this.button1.Size = new System.Drawing.Size(62, 54);
|
||||
this.button1.TabIndex = 0;
|
||||
this.button1.Text = "button1";
|
||||
this.button1.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// panel2
|
||||
//
|
||||
this.panel2.Controls.Add(this.lblTitle);
|
||||
this.panel2.Controls.Add(this.lblSubTitle);
|
||||
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.panel2.Location = new System.Drawing.Point(44, 0);
|
||||
this.panel2.Name = "panel2";
|
||||
this.panel2.Size = new System.Drawing.Size(297, 54);
|
||||
this.panel2.TabIndex = 5;
|
||||
//
|
||||
// ResultItemControl
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.Controls.Add(this.panel2);
|
||||
this.Controls.Add(this.panel1);
|
||||
this.Controls.Add(this.pictureBox1);
|
||||
this.Name = "ResultItemControl";
|
||||
this.Size = new System.Drawing.Size(403, 54);
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit();
|
||||
this.panel1.ResumeLayout(false);
|
||||
this.panel2.ResumeLayout(false);
|
||||
this.panel2.PerformLayout();
|
||||
this.ResumeLayout(false);
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.PictureBox pictureBox1;
|
||||
private System.Windows.Forms.Label lblTitle;
|
||||
private System.Windows.Forms.Label lblSubTitle;
|
||||
private System.Windows.Forms.Panel panel1;
|
||||
private System.Windows.Forms.Button button1;
|
||||
private System.Windows.Forms.Panel panel2;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using WinAlfred.Plugin;
|
||||
|
||||
namespace WinAlfreds.CustomControls
|
||||
{
|
||||
public partial class ResultItemControl : UserControl
|
||||
{
|
||||
public ResultItemControl(Result result)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
lblTitle.Text = result.Title;
|
||||
lblSubTitle.Text = result.SubTitle;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
84
WinAlfred/FrmMain.Designer.cs
generated
84
WinAlfred/FrmMain.Designer.cs
generated
@@ -1,84 +0,0 @@
|
||||
namespace WinAlfred
|
||||
{
|
||||
partial class FrmMain
|
||||
{
|
||||
/// <summary>
|
||||
/// 必需的设计器变量。
|
||||
/// </summary>
|
||||
private System.ComponentModel.IContainer components = null;
|
||||
|
||||
/// <summary>
|
||||
/// 清理所有正在使用的资源。
|
||||
/// </summary>
|
||||
/// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
if (disposing && (components != null))
|
||||
{
|
||||
components.Dispose();
|
||||
}
|
||||
base.Dispose(disposing);
|
||||
}
|
||||
|
||||
#region Windows 窗体设计器生成的代码
|
||||
|
||||
/// <summary>
|
||||
/// 设计器支持所需的方法 - 不要
|
||||
/// 使用代码编辑器修改此方法的内容。
|
||||
/// </summary>
|
||||
private void InitializeComponent()
|
||||
{
|
||||
this.tbQuery = new System.Windows.Forms.TextBox();
|
||||
this.pnlResults = new System.Windows.Forms.Panel();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
// tbQuery
|
||||
//
|
||||
this.tbQuery.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
|
||||
this.tbQuery.Location = new System.Drawing.Point(12, 12);
|
||||
this.tbQuery.Name = "tbQuery";
|
||||
this.tbQuery.Size = new System.Drawing.Size(471, 21);
|
||||
this.tbQuery.TabIndex = 0;
|
||||
this.tbQuery.TextChanged += new System.EventHandler(this.TbQuery_TextChanged);
|
||||
this.tbQuery.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbQuery_KeyDown);
|
||||
//
|
||||
// pnlResults
|
||||
//
|
||||
this.pnlResults.AutoSize = true;
|
||||
this.pnlResults.Location = new System.Drawing.Point(12, 39);
|
||||
this.pnlResults.Name = "pnlResults";
|
||||
this.pnlResults.Size = new System.Drawing.Size(471, 22);
|
||||
this.pnlResults.TabIndex = 1;
|
||||
//
|
||||
// FrmMain
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.AutoSize = true;
|
||||
this.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.ClientSize = new System.Drawing.Size(495, 72);
|
||||
this.Controls.Add(this.pnlResults);
|
||||
this.Controls.Add(this.tbQuery);
|
||||
this.DoubleBuffered = true;
|
||||
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
|
||||
this.MaximizeBox = false;
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "FrmMain";
|
||||
this.ShowIcon = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
|
||||
this.Text = "WinAlfred";
|
||||
this.Load += new System.EventHandler(this.FrmMain_Load);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private System.Windows.Forms.TextBox tbQuery;
|
||||
private System.Windows.Forms.Panel pnlResults;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,89 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Data;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Windows.Forms;
|
||||
using WinAlfred.Helper;
|
||||
using WinAlfred.Plugin;
|
||||
using WinAlfred.PluginLoader;
|
||||
using WinAlfreds.CustomControls;
|
||||
using WinAlfreds.Helper;
|
||||
|
||||
namespace WinAlfred
|
||||
{
|
||||
public partial class FrmMain : Form
|
||||
{
|
||||
public List<PluginPair> plugins = new List<PluginPair>();
|
||||
private List<Result> results = new List<Result>();
|
||||
KeyboardHook hook = new KeyboardHook();
|
||||
|
||||
public FrmMain()
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
hook.KeyPressed += OnHotKey;
|
||||
hook.RegisterHotKey(XModifierKeys.Alt, Keys.Space);
|
||||
}
|
||||
|
||||
private void OnHotKey(object sender, KeyPressedEventArgs e)
|
||||
{
|
||||
if (!Visible)
|
||||
{
|
||||
tbQuery.SelectAll();
|
||||
}
|
||||
Visible = !Visible;
|
||||
}
|
||||
|
||||
private void FrmMain_Load(object sender, EventArgs e)
|
||||
{
|
||||
plugins.AddRange(new PythonPluginLoader().LoadPlugin());
|
||||
plugins.AddRange(new CSharpPluginLoader().LoadPlugin());
|
||||
}
|
||||
|
||||
private void TbQuery_TextChanged(object sender, EventArgs e)
|
||||
{
|
||||
results.Clear();
|
||||
foreach (PluginPair pair in plugins)
|
||||
{
|
||||
Query q = new Query(tbQuery.Text);
|
||||
if (pair.Metadata.ActionKeyword == q.ActionName)
|
||||
{
|
||||
try
|
||||
{
|
||||
results.AddRange(pair.Plugin.Query(q));
|
||||
}
|
||||
catch (Exception queryException)
|
||||
{
|
||||
Log.Error(string.Format("Plugin {0} query failed: {1}", pair.Metadata.Name, queryException.Message));
|
||||
#if (DEBUG)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
var s = results.OrderByDescending(o => o.Score);
|
||||
|
||||
pnlResults.Controls.Clear();
|
||||
foreach (Result result in results)
|
||||
{
|
||||
ResultItemControl control = new ResultItemControl(result);
|
||||
pnlResults.Controls.Add(control);
|
||||
}
|
||||
}
|
||||
|
||||
private void tbQuery_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Escape)
|
||||
{
|
||||
e.Handled = true;
|
||||
e.SuppressKeyPress = true;
|
||||
Hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,120 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<root>
|
||||
<!--
|
||||
Microsoft ResX Schema
|
||||
|
||||
Version 2.0
|
||||
|
||||
The primary goals of this format is to allow a simple XML format
|
||||
that is mostly human readable. The generation and parsing of the
|
||||
various data types are done through the TypeConverter classes
|
||||
associated with the data types.
|
||||
|
||||
Example:
|
||||
|
||||
... ado.net/XML headers & schema ...
|
||||
<resheader name="resmimetype">text/microsoft-resx</resheader>
|
||||
<resheader name="version">2.0</resheader>
|
||||
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
|
||||
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
|
||||
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
|
||||
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
|
||||
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
|
||||
<value>[base64 mime encoded serialized .NET Framework object]</value>
|
||||
</data>
|
||||
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
|
||||
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
|
||||
<comment>This is a comment</comment>
|
||||
</data>
|
||||
|
||||
There are any number of "resheader" rows that contain simple
|
||||
name/value pairs.
|
||||
|
||||
Each data row contains a name, and value. The row also contains a
|
||||
type or mimetype. Type corresponds to a .NET class that support
|
||||
text/value conversion through the TypeConverter architecture.
|
||||
Classes that don't support this are serialized and stored with the
|
||||
mimetype set.
|
||||
|
||||
The mimetype is used for serialized objects, and tells the
|
||||
ResXResourceReader how to depersist the object. This is currently not
|
||||
extensible. For a given mimetype the value must be set accordingly:
|
||||
|
||||
Note - application/x-microsoft.net.object.binary.base64 is the format
|
||||
that the ResXResourceWriter will generate, however the reader can
|
||||
read any of the formats listed below.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.binary.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.soap.base64
|
||||
value : The object must be serialized with
|
||||
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
|
||||
: and then encoded with base64 encoding.
|
||||
|
||||
mimetype: application/x-microsoft.net.object.bytearray.base64
|
||||
value : The object must be serialized into a byte array
|
||||
: using a System.ComponentModel.TypeConverter
|
||||
: and then encoded with base64 encoding.
|
||||
-->
|
||||
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
|
||||
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
|
||||
<xsd:element name="root" msdata:IsDataSet="true">
|
||||
<xsd:complexType>
|
||||
<xsd:choice maxOccurs="unbounded">
|
||||
<xsd:element name="metadata">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" use="required" type="xsd:string" />
|
||||
<xsd:attribute name="type" type="xsd:string" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="assembly">
|
||||
<xsd:complexType>
|
||||
<xsd:attribute name="alias" type="xsd:string" />
|
||||
<xsd:attribute name="name" type="xsd:string" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="data">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
|
||||
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
|
||||
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
|
||||
<xsd:attribute ref="xml:space" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
<xsd:element name="resheader">
|
||||
<xsd:complexType>
|
||||
<xsd:sequence>
|
||||
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
|
||||
</xsd:sequence>
|
||||
<xsd:attribute name="name" type="xsd:string" use="required" />
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:choice>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
</xsd:schema>
|
||||
<resheader name="resmimetype">
|
||||
<value>text/microsoft-resx</value>
|
||||
</resheader>
|
||||
<resheader name="version">
|
||||
<value>2.0</value>
|
||||
</resheader>
|
||||
<resheader name="reader">
|
||||
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
<resheader name="writer">
|
||||
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
|
||||
</resheader>
|
||||
</root>
|
||||
@@ -1,9 +1,8 @@
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows.Forms;
|
||||
using WinAlfred.Helper;
|
||||
|
||||
namespace WinAlfreds.Helper
|
||||
namespace WinAlfred.Helper
|
||||
{
|
||||
public sealed class KeyboardHook : IDisposable
|
||||
{
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Reflection;
|
||||
using log4net;
|
||||
|
||||
namespace WinAlfred.Helper
|
||||
|
||||
19
WinAlfred/MainWindow.xaml
Normal file
19
WinAlfred/MainWindow.xaml
Normal file
@@ -0,0 +1,19 @@
|
||||
<Window x:Class="WinAlfred.MainWindow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:winAlfred="clr-namespace:WinAlfred"
|
||||
Title="WinAlfred" Height="80" Width="525"
|
||||
Background="Cornsilk"
|
||||
Loaded="MainWindow_OnLoaded"
|
||||
SizeToContent="Height"
|
||||
ResizeMode="NoResize"
|
||||
WindowStyle="None"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ShowInTaskbar="False"
|
||||
>
|
||||
<DockPanel>
|
||||
<TextBox DockPanel.Dock="Top" Margin="10" VerticalContentAlignment="Center" x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" Height="26.965" />
|
||||
<winAlfred:ResultPanel x:Name="resultCtrl" />
|
||||
</DockPanel>
|
||||
</Window>
|
||||
|
||||
123
WinAlfred/MainWindow.xaml.cs
Normal file
123
WinAlfred/MainWindow.xaml.cs
Normal file
@@ -0,0 +1,123 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Forms;
|
||||
using System.Windows.Input;
|
||||
using WinAlfred.Helper;
|
||||
using WinAlfred.Plugin;
|
||||
using WinAlfred.PluginLoader;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
|
||||
namespace WinAlfred
|
||||
{
|
||||
public partial class MainWindow : Window
|
||||
{
|
||||
private KeyboardHook hook = new KeyboardHook();
|
||||
public List<PluginPair> plugins = new List<PluginPair>();
|
||||
private List<Result> results = new List<Result>();
|
||||
|
||||
public MainWindow()
|
||||
{
|
||||
InitializeComponent();
|
||||
hook.KeyPressed += OnHotKey;
|
||||
hook.RegisterHotKey(XModifierKeys.Alt, Keys.Space);
|
||||
resultCtrl.resultItemChangedEvent += resultCtrl_resultItemChangedEvent;
|
||||
}
|
||||
|
||||
private void resultCtrl_resultItemChangedEvent()
|
||||
{
|
||||
Height = resultCtrl.pnlContainer.ActualHeight + tbQuery.Height + tbQuery.Margin.Top + tbQuery.Margin.Bottom;
|
||||
}
|
||||
|
||||
private void OnHotKey(object sender, KeyPressedEventArgs e)
|
||||
{
|
||||
if (!IsVisible)
|
||||
{
|
||||
ShowWinAlfred();
|
||||
}
|
||||
else
|
||||
{
|
||||
HideWinAlfred();
|
||||
}
|
||||
}
|
||||
|
||||
private void TextBoxBase_OnTextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
results.Clear();
|
||||
foreach (PluginPair pair in plugins)
|
||||
{
|
||||
var q = new Query(tbQuery.Text);
|
||||
if (pair.Metadata.ActionKeyword == q.ActionName)
|
||||
{
|
||||
try
|
||||
{
|
||||
results.AddRange(pair.Plugin.Query(q));
|
||||
results.ForEach(o => o.PluginDirectory = pair.Metadata.PluginDirecotry);
|
||||
}
|
||||
catch (Exception queryException)
|
||||
{
|
||||
Log.Error(string.Format("Plugin {0} query failed: {1}", pair.Metadata.Name,
|
||||
queryException.Message));
|
||||
#if (DEBUG)
|
||||
{
|
||||
throw;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
resultCtrl.AddResults(results.OrderByDescending(o => o.Score).ToList());
|
||||
resultCtrl.SelectFirst();
|
||||
}
|
||||
|
||||
public void HideWinAlfred()
|
||||
{
|
||||
Hide();
|
||||
}
|
||||
|
||||
public void ShowWinAlfred()
|
||||
{
|
||||
tbQuery.SelectAll();
|
||||
Focus();
|
||||
tbQuery.Focus();
|
||||
Show();
|
||||
}
|
||||
|
||||
private void MainWindow_OnLoaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
plugins.AddRange(new PythonPluginLoader().LoadPlugin());
|
||||
plugins.AddRange(new CSharpPluginLoader().LoadPlugin());
|
||||
|
||||
ShowWinAlfred();
|
||||
}
|
||||
|
||||
private void TbQuery_OnPreviewKeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
switch (e.Key)
|
||||
{
|
||||
case Key.Escape:
|
||||
HideWinAlfred();
|
||||
e.Handled = true;
|
||||
break;
|
||||
|
||||
case Key.Down:
|
||||
resultCtrl.SelectNext();
|
||||
e.Handled = true;
|
||||
break;
|
||||
|
||||
case Key.Up:
|
||||
resultCtrl.SelectPrev();
|
||||
e.Handled = true;
|
||||
break;
|
||||
|
||||
case Key.Enter:
|
||||
resultCtrl.AcceptSelect();
|
||||
e.Handled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,7 @@ namespace WinAlfred.PluginLoader
|
||||
metadata.Version = ini.GetSetting("plugin", "Version");
|
||||
metadata.ActionKeyword = ini.GetSetting("plugin", "ActionKeyword");
|
||||
metadata.ExecuteFile = AppDomain.CurrentDomain.BaseDirectory + directory + "\\" + ini.GetSetting("plugin", "ExecuteFile");
|
||||
metadata.PluginDirecotry = AppDomain.CurrentDomain.BaseDirectory + directory + "\\";
|
||||
|
||||
if (!AllowedLanguage.IsAllowed(metadata.Language))
|
||||
{
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using WinAlfred.Helper;
|
||||
using WinAlfred.Plugin;
|
||||
|
||||
@@ -55,7 +55,16 @@ namespace WinAlfred.PluginLoader
|
||||
|
||||
}
|
||||
|
||||
InitPlugin(plugins);
|
||||
return plugins;
|
||||
}
|
||||
|
||||
private void InitPlugin(List<PluginPair> plugins)
|
||||
{
|
||||
foreach (IPlugin plugin in plugins.Select(pluginPair => pluginPair.Plugin))
|
||||
{
|
||||
new Thread(plugin.Init).Start();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using IronPython.Hosting;
|
||||
using Microsoft.Scripting.Hosting;
|
||||
using WinAlfred.Helper;
|
||||
using WinAlfred.Plugin;
|
||||
|
||||
namespace WinAlfred.PluginLoader
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using IronPython.Hosting;
|
||||
using Microsoft.Scripting.Hosting;
|
||||
using WinAlfred.Plugin;
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace WinAlfred
|
||||
{
|
||||
static class Program
|
||||
{
|
||||
/// <summary>
|
||||
/// 应用程序的主入口点。
|
||||
/// </summary>
|
||||
[STAThread]
|
||||
static void Main()
|
||||
{
|
||||
Application.EnableVisualStyles();
|
||||
Application.SetCompatibleTextRenderingDefault(false);
|
||||
Application.Run(new FrmMain());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,17 @@
|
||||
using System.Reflection;
|
||||
using System.Resources;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Windows;
|
||||
|
||||
// 有关程序集的常规信息通过以下
|
||||
// 特性集控制。更改这些特性值可修改
|
||||
// 与程序集关联的信息。
|
||||
[assembly: AssemblyTitle("WinAlfreds")]
|
||||
[assembly: AssemblyTitle("WinAlfredWPF")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("Microsoft")]
|
||||
[assembly: AssemblyProduct("WinAlfreds")]
|
||||
[assembly: AssemblyProduct("WinAlfredWPF")]
|
||||
[assembly: AssemblyCopyright("Copyright © Microsoft 2013")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
@@ -19,8 +21,25 @@ using System.Runtime.InteropServices;
|
||||
// 则将该类型上的 ComVisible 特性设置为 true。
|
||||
[assembly: ComVisible(false)]
|
||||
|
||||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
|
||||
[assembly: Guid("58cdcef9-2715-45be-a57d-1c03c6cb4f90")]
|
||||
//若要开始生成可本地化的应用程序,请在
|
||||
//<PropertyGroup> 中的 .csproj 文件中
|
||||
//设置 <UICulture>CultureYouAreCodingWith</UICulture>。例如,如果您在源文件中
|
||||
//使用的是美国英语,请将 <UICulture> 设置为 en-US。然后取消
|
||||
//对以下 NeutralResourceLanguage 特性的注释。更新
|
||||
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
|
||||
|
||||
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
|
||||
|
||||
|
||||
[assembly: ThemeInfo(
|
||||
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
|
||||
//(在页面或应用程序资源词典中
|
||||
// 未找到某个资源的情况下使用)
|
||||
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
|
||||
//(在页面、应用程序或任何主题特定资源词典中
|
||||
// 未找到某个资源的情况下使用)
|
||||
)]
|
||||
|
||||
|
||||
// 程序集的版本信息由下面四个值组成:
|
||||
//
|
||||
@@ -34,4 +53,3 @@ using System.Runtime.InteropServices;
|
||||
// [assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.0.0")]
|
||||
[assembly: AssemblyFileVersion("1.0.0.0")]
|
||||
[assembly: log4net.Config.XmlConfigurator(ConfigFileExtension = "config", Watch = true)]
|
||||
54
WinAlfred/Properties/Resources.Designer.cs
generated
54
WinAlfred/Properties/Resources.Designer.cs
generated
@@ -1,17 +1,17 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本: 4.0.30319.18052
|
||||
// 运行时版本:4.0.30319.18052
|
||||
//
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将丢失。
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WinAlfreds.Properties
|
||||
{
|
||||
|
||||
|
||||
namespace WinAlfred.Properties {
|
||||
using System;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 一个强类型的资源类,用于查找本地化的字符串等。
|
||||
/// </summary>
|
||||
@@ -22,48 +22,40 @@ namespace WinAlfreds.Properties
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
internal class Resources
|
||||
{
|
||||
|
||||
internal class Resources {
|
||||
|
||||
private static global::System.Resources.ResourceManager resourceMan;
|
||||
|
||||
|
||||
private static global::System.Globalization.CultureInfo resourceCulture;
|
||||
|
||||
|
||||
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
|
||||
internal Resources()
|
||||
{
|
||||
internal Resources() {
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 返回此类使用的、缓存的 ResourceManager 实例。
|
||||
/// 返回此类使用的缓存的 ResourceManager 实例。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Resources.ResourceManager ResourceManager
|
||||
{
|
||||
get
|
||||
{
|
||||
if ((resourceMan == null))
|
||||
{
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinAlfreds.Properties.Resources", typeof(Resources).Assembly);
|
||||
internal static global::System.Resources.ResourceManager ResourceManager {
|
||||
get {
|
||||
if (object.ReferenceEquals(resourceMan, null)) {
|
||||
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("WinAlfred.Properties.Resources", typeof(Resources).Assembly);
|
||||
resourceMan = temp;
|
||||
}
|
||||
return resourceMan;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 为所有资源查找重写当前线程的 CurrentUICulture 属性,
|
||||
/// 方法是使用此强类型资源类。
|
||||
/// 使用此强类型资源类,为所有资源查找
|
||||
/// 重写当前线程的 CurrentUICulture 属性。
|
||||
/// </summary>
|
||||
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
|
||||
internal static global::System.Globalization.CultureInfo Culture
|
||||
{
|
||||
get
|
||||
{
|
||||
internal static global::System.Globalization.CultureInfo Culture {
|
||||
get {
|
||||
return resourceCulture;
|
||||
}
|
||||
set
|
||||
{
|
||||
set {
|
||||
resourceCulture = value;
|
||||
}
|
||||
}
|
||||
|
||||
28
WinAlfred/Properties/Settings.Designer.cs
generated
28
WinAlfred/Properties/Settings.Designer.cs
generated
@@ -1,28 +1,24 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.18052
|
||||
// 此代码由工具生成。
|
||||
// 运行时版本:4.0.30319.18052
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// 对此文件的更改可能会导致不正确的行为,并且如果
|
||||
// 重新生成代码,这些更改将会丢失。
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace WinAlfreds.Properties
|
||||
{
|
||||
|
||||
|
||||
namespace WinAlfred.Properties {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
|
||||
{
|
||||
|
||||
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
|
||||
|
||||
public static Settings Default
|
||||
{
|
||||
get
|
||||
{
|
||||
|
||||
public static Settings Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)">
|
||||
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
|
||||
<Profiles>
|
||||
<Profile Name="(Default)" />
|
||||
</Profiles>
|
||||
<Settings />
|
||||
</SettingsFile>
|
||||
</SettingsFile>
|
||||
25
WinAlfred/ResultItem.xaml
Normal file
25
WinAlfred/ResultItem.xaml
Normal file
@@ -0,0 +1,25 @@
|
||||
<UserControl x:Class="WinAlfred.ResultItem"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="60.233" d:DesignWidth="436.064">
|
||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="10">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="66"></ColumnDefinition>
|
||||
<ColumnDefinition/>
|
||||
<ColumnDefinition Width="73.064"></ColumnDefinition>
|
||||
</Grid.ColumnDefinitions>
|
||||
<Image x:Name="imgIco" Width="32" Height="32" ></Image>
|
||||
<Grid HorizontalAlignment="Stretch" Grid.Column="1" VerticalAlignment="Stretch">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="33"></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock x:Name="tbTitle">Title</TextBlock>
|
||||
<TextBlock Grid.Row="1" x:Name="tbSubTitle">sdfdsf</TextBlock>
|
||||
</Grid>
|
||||
<Button Grid.Column="2" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
42
WinAlfred/ResultItem.xaml.cs
Normal file
42
WinAlfred/ResultItem.xaml.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using WinAlfred.Plugin;
|
||||
|
||||
namespace WinAlfred
|
||||
{
|
||||
public partial class ResultItem : UserControl
|
||||
{
|
||||
private bool selected;
|
||||
|
||||
public Result Result { get; private set; }
|
||||
|
||||
public bool Selected
|
||||
{
|
||||
get
|
||||
{
|
||||
return selected;
|
||||
}
|
||||
set
|
||||
{
|
||||
selected = value;
|
||||
Background = selected ? Brushes.Gray : Brushes.White;
|
||||
}
|
||||
}
|
||||
|
||||
public ResultItem(Result result)
|
||||
{
|
||||
|
||||
InitializeComponent();
|
||||
Result = result;
|
||||
|
||||
tbTitle.Text = result.Title;
|
||||
tbSubTitle.Text = result.SubTitle;
|
||||
if (!string.IsNullOrEmpty(result.IcoPath))
|
||||
{
|
||||
imgIco.Source = new BitmapImage(new Uri(result.PluginDirectory + result.IcoPath));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
11
WinAlfred/ResultPanel.xaml
Normal file
11
WinAlfred/ResultPanel.xaml
Normal file
@@ -0,0 +1,11 @@
|
||||
<UserControl x:Class="WinAlfred.ResultPanel"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="300" d:DesignWidth="300">
|
||||
<StackPanel x:Name="pnlContainer">
|
||||
|
||||
</StackPanel>
|
||||
</UserControl>
|
||||
118
WinAlfred/ResultPanel.xaml.cs
Normal file
118
WinAlfred/ResultPanel.xaml.cs
Normal file
@@ -0,0 +1,118 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows.Controls;
|
||||
using WinAlfred.Plugin;
|
||||
|
||||
namespace WinAlfred
|
||||
{
|
||||
/// <summary>
|
||||
/// Result.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ResultPanel : UserControl
|
||||
{
|
||||
public delegate void ResultItemsChanged();
|
||||
|
||||
public event ResultItemsChanged resultItemChangedEvent;
|
||||
|
||||
protected virtual void OnResultItemChangedEvent()
|
||||
{
|
||||
ResultItemsChanged handler = resultItemChangedEvent;
|
||||
if (handler != null) handler();
|
||||
}
|
||||
|
||||
public void AddResults(List<Result> results)
|
||||
{
|
||||
pnlContainer.Children.Clear();
|
||||
foreach (Result result in results)
|
||||
{
|
||||
ResultItem control = new ResultItem(result);
|
||||
pnlContainer.Children.Add(control);
|
||||
}
|
||||
pnlContainer.UpdateLayout();
|
||||
|
||||
double resultItemHeight = 0;
|
||||
if (pnlContainer.Children.Count > 0)
|
||||
{
|
||||
var resultItem = pnlContainer.Children[0] as ResultItem;
|
||||
if (resultItem != null)
|
||||
resultItemHeight = resultItem.ActualHeight;
|
||||
}
|
||||
Height = pnlContainer.Height = results.Count * resultItemHeight;
|
||||
OnResultItemChangedEvent();
|
||||
}
|
||||
|
||||
private int GetCurrentSelectedResultIndex()
|
||||
{
|
||||
for (int i = 0; i < pnlContainer.Children.Count; i++)
|
||||
{
|
||||
var resultItemControl = pnlContainer.Children[i] as ResultItem;
|
||||
if (resultItemControl != null && resultItemControl.Selected)
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void UnSelectAll()
|
||||
{
|
||||
for (int i = 0; i < pnlContainer.Children.Count; i++)
|
||||
{
|
||||
var resultItemControl = pnlContainer.Children[i] as ResultItem;
|
||||
if (resultItemControl != null && resultItemControl.Selected)
|
||||
{
|
||||
resultItemControl.Selected = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectNext()
|
||||
{
|
||||
int index = GetCurrentSelectedResultIndex();
|
||||
if (index == pnlContainer.Children.Count - 1)
|
||||
{
|
||||
index = -1;
|
||||
}
|
||||
Select(index + 1);
|
||||
}
|
||||
|
||||
public void SelectPrev()
|
||||
{
|
||||
int index = GetCurrentSelectedResultIndex();
|
||||
if (index == 0)
|
||||
{
|
||||
index = pnlContainer.Children.Count;
|
||||
}
|
||||
Select(index - 1);
|
||||
}
|
||||
|
||||
private void Select(int index)
|
||||
{
|
||||
if (pnlContainer.Children.Count > 0)
|
||||
{
|
||||
UnSelectAll();
|
||||
var resultItemControl = pnlContainer.Children[index] as ResultItem;
|
||||
if (resultItemControl != null) resultItemControl.Selected = true;
|
||||
}
|
||||
}
|
||||
|
||||
public void SelectFirst()
|
||||
{
|
||||
Select(0);
|
||||
}
|
||||
|
||||
public void AcceptSelect()
|
||||
{
|
||||
int index = GetCurrentSelectedResultIndex();
|
||||
var resultItemControl = pnlContainer.Children[index] as ResultItem;
|
||||
if (resultItemControl != null)
|
||||
{
|
||||
resultItemControl.Result.Action();
|
||||
}
|
||||
}
|
||||
|
||||
public ResultPanel()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,13 +4,15 @@
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
||||
<ProjectGuid>{498C79C7-F29E-414B-A53D-0B09EEB67EF2}</ProjectGuid>
|
||||
<ProjectGuid>{DB90F671-D861-46BB-93A3-F1304F5BA1C5}</ProjectGuid>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<AppDesignerFolder>Properties</AppDesignerFolder>
|
||||
<RootNamespace>WinAlfreds</RootNamespace>
|
||||
<AssemblyName>WinAlfreds</AssemblyName>
|
||||
<RootNamespace>WinAlfred</RootNamespace>
|
||||
<AssemblyName>WinAlfred</AssemblyName>
|
||||
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
|
||||
<FileAlignment>512</FileAlignment>
|
||||
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\</SolutionDir>
|
||||
<RestorePackages>true</RestorePackages>
|
||||
</PropertyGroup>
|
||||
@@ -33,24 +35,6 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="IronPython">
|
||||
<HintPath>..\packages\IronPython.2.7.4\lib\Net35\IronPython.dll</HintPath>
|
||||
@@ -80,28 +64,21 @@
|
||||
<HintPath>..\packages\IronPython.2.7.4\lib\Net35\Microsoft.Scripting.Metadata.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
<Reference Include="System.Data.DataSetExtensions" />
|
||||
<Reference Include="System.Data" />
|
||||
<Reference Include="System.Deployment" />
|
||||
<Reference Include="System.Drawing" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<Reference Include="System.Xml" />
|
||||
<Reference Include="WindowsBase" />
|
||||
<Reference Include="PresentationCore" />
|
||||
<Reference Include="PresentationFramework" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="CustomControls\ResultItemControl.cs">
|
||||
<SubType>UserControl</SubType>
|
||||
</Compile>
|
||||
<Compile Include="CustomControls\ResultItemControl.Designer.cs">
|
||||
<DependentUpon>ResultItemControl.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="FrmMain.cs">
|
||||
<SubType>Form</SubType>
|
||||
</Compile>
|
||||
<Compile Include="FrmMain.Designer.cs">
|
||||
<DependentUpon>FrmMain.cs</DependentUpon>
|
||||
</Compile>
|
||||
<ApplicationDefinition Include="App.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</ApplicationDefinition>
|
||||
<Compile Include="Helper\IniParser.cs" />
|
||||
<Compile Include="Helper\KeyboardHook.cs" />
|
||||
<Compile Include="Helper\Log.cs" />
|
||||
@@ -109,34 +86,57 @@
|
||||
<Compile Include="PluginLoader\CSharpPluginLoader.cs" />
|
||||
<Compile Include="PluginLoader\PythonPluginLoader.cs" />
|
||||
<Compile Include="PluginLoader\PythonPluginWrapper.cs" />
|
||||
<Compile Include="Program.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<EmbeddedResource Include="CustomControls\ResultItemControl.resx">
|
||||
<DependentUpon>ResultItemControl.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="FrmMain.resx">
|
||||
<DependentUpon>FrmMain.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
<Compile Include="ResultPanel.xaml.cs">
|
||||
<DependentUpon>ResultPanel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="ResultItem.xaml.cs">
|
||||
<DependentUpon>ResultItem.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</EmbeddedResource>
|
||||
</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>
|
||||
<Page Include="ResultPanel.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="ResultItem.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
<SubType>Code</SubType>
|
||||
</Compile>
|
||||
<Compile Include="Properties\Resources.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>Resources.resx</DependentUpon>
|
||||
</Compile>
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<Compile Include="Properties\Settings.Designer.cs">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DependentUpon>Settings.settings</DependentUpon>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<EmbeddedResource Include="Properties\Resources.resx">
|
||||
<Generator>ResXFileCodeGenerator</Generator>
|
||||
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
|
||||
</EmbeddedResource>
|
||||
<None Include="packages.config" />
|
||||
<None Include="Properties\Settings.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<AppDesigner Include="Properties\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\WinAlfred.Plugin\WinAlfred.Plugin.csproj">
|
||||
@@ -145,7 +145,7 @@
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\nuget.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.
|
||||
Other similar extension points exist, see Microsoft.Common.targets.
|
||||
<Target Name="BeforeBuild">
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
<Configurations active="默认"><Configuration name="默认"><GuestCommandRemote val="project command through a shared folder"></GuestCommandRemote><ShareFoldersRemote val=""></ShareFoldersRemote><RemoteDebugMonitor val=""></RemoteDebugMonitor><MonitorName val="VMDebug"></MonitorName><RemoteVM val=""></RemoteVM><StartMode val="No"></StartMode><TerminationModeRemote val="No operation"></TerminationModeRemote><CopyFilesRemote val=""></CopyFilesRemote><PreRemoteCommandLine val=""></PreRemoteCommandLine><PostRemoteCommandLine val=""></PostRemoteCommandLine><RecordingToReplay val=""></RecordingToReplay><ReplayVM val=""></ReplayVM><BaseSnapshotForRecording val=""></BaseSnapshotForRecording><CopyFilesRecord val=""></CopyFilesRecord><PreRecordCommandLine val=""></PreRecordCommandLine><PostRecordCommandLine val=""></PostRecordCommandLine><TerminationModeRecord val="No operation"></TerminationModeRecord><InstanceToDebug val=""></InstanceToDebug><GuestCommandReplay val="project command through a shared folder"></GuestCommandReplay><ShareFoldersRecord val=""></ShareFoldersRecord><RemoteReplayFlag val=""></RemoteReplayFlag><RemoteMachine val=""></RemoteMachine><RemoteReplayVM val=""></RemoteReplayVM><RemoteRecordingToReplay val=""></RemoteRecordingToReplay><RemoteReplayPasscode val=""></RemoteReplayPasscode><HostSearchPath val=""></HostSearchPath></Configuration></Configurations>
|
||||
Reference in New Issue
Block a user