mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-06 11:16:51 +02:00
add theme function. And provide two themes default.
This commit is contained in:
@@ -4,56 +4,9 @@
|
||||
>
|
||||
<Application.Resources>
|
||||
<ResourceDictionary>
|
||||
<Style x:Key="defaultQueryBoxStyle" BasedOn="{x:Null}" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="FontSize" Value="22"/>
|
||||
<Setter Property="FontWeight" Value="Medium"/>
|
||||
<Setter Property="AllowDrop" Value="true"/>
|
||||
<Setter Property="Background" Value="Transparent"/>
|
||||
<Setter Property="Margin" Value="10 10 10 5"/>
|
||||
<Setter Property="Height" Value="36"/>
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="FocusVisualStyle" Value="{x:Null}"/>
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
||||
<Setter Property="Template">
|
||||
<Setter.Value>
|
||||
<ControlTemplate TargetType="{x:Type TextBox}">
|
||||
<Border x:Name="border" Background="Transparent" BorderBrush="Transparent" CornerRadius="3" BorderThickness="0">
|
||||
<ScrollViewer x:Name="PART_ContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
|
||||
</Border>
|
||||
<ControlTemplate.Triggers>
|
||||
<Trigger Property="IsFocused" Value="True">
|
||||
<Setter Property="BorderBrush" TargetName="border" Value="Silver"/>
|
||||
</Trigger>
|
||||
</ControlTemplate.Triggers>
|
||||
</ControlTemplate>
|
||||
</Setter.Value>
|
||||
</Setter>
|
||||
</Style>
|
||||
<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.MergedDictionaries>
|
||||
<ResourceDictionary Source="Themes/Default.xaml"></ResourceDictionary>
|
||||
</ResourceDictionary.MergedDictionaries>
|
||||
</ResourceDictionary>
|
||||
</Application.Resources>
|
||||
</Application>
|
||||
|
||||
44
WinAlfred/Helper/Settings.cs
Normal file
44
WinAlfred/Helper/Settings.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace WinAlfred.Helper
|
||||
{
|
||||
public class Settings
|
||||
{
|
||||
private string configPath = Directory.GetCurrentDirectory() + "\\config.ini";
|
||||
private static readonly Settings settings = new Settings();
|
||||
IniParser parser = new IniParser("config.ini");
|
||||
|
||||
public string Theme { get; set; }
|
||||
|
||||
private Settings()
|
||||
{
|
||||
LoadSettings();
|
||||
}
|
||||
|
||||
private void LoadSettings()
|
||||
{
|
||||
if (!File.Exists(configPath)) File.Create(configPath);
|
||||
Theme = parser.GetSetting("ui", "theme");
|
||||
}
|
||||
|
||||
public void SaveSettings()
|
||||
{
|
||||
parser.AddSetting("ui", "theme", Theme);
|
||||
parser.SaveSettings();
|
||||
}
|
||||
|
||||
public static Settings Instance
|
||||
{
|
||||
get
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
BIN
WinAlfred/Images/app.png
Normal file
BIN
WinAlfred/Images/app.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.7 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 4.8 KiB |
@@ -1,8 +1,7 @@
|
||||
<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="#ebebeb"
|
||||
Title="WinAlfred"
|
||||
Topmost="True"
|
||||
Loaded="MainWindow_OnLoaded"
|
||||
SizeToContent="Height"
|
||||
@@ -10,17 +9,17 @@
|
||||
WindowStyle="None"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
ShowInTaskbar="False"
|
||||
Icon="Images\ico.png"
|
||||
Style="{DynamicResource WindowStyle}"
|
||||
Icon="Images\app.png"
|
||||
>
|
||||
<Grid>
|
||||
<Grid Style="{DynamicResource GridStyle}">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition ></RowDefinition>
|
||||
<RowDefinition Height="2"></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBox AllowDrop="True" Style="{DynamicResource defaultQueryBoxStyle}" Grid.Row="0" x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" />
|
||||
<Line Stroke="Blue" x:Name="progressBar" Y1="0" Y2="0" X2="100" Grid.Row="1" Height="2" StrokeThickness="1"></Line>
|
||||
<winAlfred:ResultPanel x:Name="resultCtrl" Grid.Row="2" Margin="10 0 10 0" />
|
||||
<TextBox AllowDrop="True" Style="{DynamicResource QueryBoxStyle}" Grid.Row="0" x:Name="tbQuery" PreviewKeyDown="TbQuery_OnPreviewKeyDown" TextChanged="TextBoxBase_OnTextChanged" />
|
||||
<Line Style="{DynamicResource PendingLineStyle}" x:Name="progressBar" Y1="0" Y2="0" X2="100" Grid.Row="1" Height="2" StrokeThickness="1"></Line>
|
||||
<winAlfred:ResultPanel x:Name="resultCtrl" Grid.Row="2"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
|
||||
</Window>
|
||||
@@ -11,6 +11,7 @@ using WinAlfred.Commands;
|
||||
using WinAlfred.Helper;
|
||||
using WinAlfred.Plugin;
|
||||
using WinAlfred.PluginLoader;
|
||||
using Application = System.Windows.Application;
|
||||
using KeyEventArgs = System.Windows.Input.KeyEventArgs;
|
||||
using MessageBox = System.Windows.MessageBox;
|
||||
|
||||
@@ -34,6 +35,8 @@ namespace WinAlfred
|
||||
resultCtrl.resultItemChangedEvent += resultCtrl_resultItemChangedEvent;
|
||||
ThreadPool.SetMaxThreads(30, 10);
|
||||
InitProgressbarAnimation();
|
||||
|
||||
ChangeStyles(Settings.Instance.Theme);
|
||||
}
|
||||
|
||||
private void WakeupApp()
|
||||
@@ -50,7 +53,7 @@ namespace WinAlfred
|
||||
double oldLeft = Left;
|
||||
Left = 20000;
|
||||
ShowWinAlfred();
|
||||
cmdDispatcher.DispatchCommand(new Query("qq"),false);
|
||||
cmdDispatcher.DispatchCommand(new Query("qq"), false);
|
||||
HideWinAlfred();
|
||||
Left = oldLeft;
|
||||
}
|
||||
@@ -84,8 +87,8 @@ namespace WinAlfred
|
||||
|
||||
private void resultCtrl_resultItemChangedEvent()
|
||||
{
|
||||
Height = resultCtrl.pnlContainer.ActualHeight + tbQuery.Height + tbQuery.Margin.Top + tbQuery.Margin.Bottom;
|
||||
resultCtrl.Margin = resultCtrl.GetCurrentResultCount() > 0 ? new Thickness { Bottom = 10, Left = 10, Right = 10 } : new Thickness { Bottom = 0, Left = 10, Right = 10 };
|
||||
//Height = resultCtrl.pnlContainer.ActualHeight + tbQuery.Height + tbQuery.Margin.Top + tbQuery.Margin.Bottom;
|
||||
resultCtrl.Margin = resultCtrl.GetCurrentResultCount() > 0 ? new Thickness { Top = 10 } : new Thickness { Top = 0 };
|
||||
}
|
||||
|
||||
private void OnHotKey(object sender, KeyPressedEventArgs e)
|
||||
@@ -250,7 +253,7 @@ namespace WinAlfred
|
||||
//todo:this used be opened to users, it's they choise use it or not in thier workflows
|
||||
list.ForEach(o =>
|
||||
{
|
||||
if(o.AutoAjustScore) o.Score += selectedRecords.GetSelectedCount(o);
|
||||
if (o.AutoAjustScore) o.Score += selectedRecords.GetSelectedCount(o);
|
||||
});
|
||||
resultCtrl.Dispatcher.Invoke(new Action(() =>
|
||||
{
|
||||
@@ -260,6 +263,17 @@ namespace WinAlfred
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeStyles(string themeName)
|
||||
{
|
||||
ResourceDictionary dict = new ResourceDictionary
|
||||
{
|
||||
Source = new Uri("pack://application:,,,/Themes/" + themeName + ".xaml")
|
||||
};
|
||||
|
||||
Application.Current.Resources.MergedDictionaries.Clear();
|
||||
Application.Current.Resources.MergedDictionaries.Add(dict);
|
||||
}
|
||||
|
||||
#region Public API
|
||||
|
||||
//Those method can be invoked by plugins
|
||||
@@ -292,7 +306,14 @@ namespace WinAlfred
|
||||
m.Show(title, subTitle, iconPath);
|
||||
}
|
||||
|
||||
public void OpenSettingDialog()
|
||||
{
|
||||
SettingWidow s = new SettingWidow(this);
|
||||
s.Show();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,8 @@ namespace WinAlfred.PluginLoader
|
||||
CloseApp = window.CloseApp,
|
||||
HideApp = window.HideApp,
|
||||
ShowApp = () => window.ShowApp(),
|
||||
ShowMsg = (title, subTitle, iconPath) => window.ShowMsg(title, subTitle, iconPath)
|
||||
ShowMsg = (title, subTitle, iconPath) => window.ShowMsg(title, subTitle, iconPath),
|
||||
OpenSettingDialog = ()=> window.OpenSettingDialog()
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
577
WinAlfred/Properties/Annotations.cs
Normal file
577
WinAlfred/Properties/Annotations.cs
Normal file
@@ -0,0 +1,577 @@
|
||||
using System;
|
||||
|
||||
#pragma warning disable 1591
|
||||
// ReSharper disable UnusedMember.Global
|
||||
// ReSharper disable MemberCanBePrivate.Global
|
||||
// ReSharper disable UnusedAutoPropertyAccessor.Global
|
||||
// ReSharper disable IntroduceOptionalParameters.Global
|
||||
// ReSharper disable MemberCanBeProtected.Global
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
namespace WinAlfred.Annotations
|
||||
{
|
||||
/// <summary>
|
||||
/// Indicates that the value of the marked element could be <c>null</c> sometimes,
|
||||
/// so the check for <c>null</c> is necessary before its usage
|
||||
/// </summary>
|
||||
/// <example><code>
|
||||
/// [CanBeNull] public object Test() { return null; }
|
||||
/// public void UseTest() {
|
||||
/// var p = Test();
|
||||
/// var s = p.ToString(); // Warning: Possible 'System.NullReferenceException'
|
||||
/// }
|
||||
/// </code></example>
|
||||
[AttributeUsage(
|
||||
AttributeTargets.Method | AttributeTargets.Parameter |
|
||||
AttributeTargets.Property | AttributeTargets.Delegate |
|
||||
AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public sealed class CanBeNullAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the value of the marked element could never be <c>null</c>
|
||||
/// </summary>
|
||||
/// <example><code>
|
||||
/// [NotNull] public object Foo() {
|
||||
/// return null; // Warning: Possible 'null' assignment
|
||||
/// }
|
||||
/// </code></example>
|
||||
[AttributeUsage(
|
||||
AttributeTargets.Method | AttributeTargets.Parameter |
|
||||
AttributeTargets.Property | AttributeTargets.Delegate |
|
||||
AttributeTargets.Field, AllowMultiple = false, Inherited = true)]
|
||||
public sealed class NotNullAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the marked method builds string by format pattern and (optional) arguments.
|
||||
/// Parameter, which contains format string, should be given in constructor. The format string
|
||||
/// should be in <see cref="string.Format(IFormatProvider,string,object[])"/>-like form
|
||||
/// </summary>
|
||||
/// <example><code>
|
||||
/// [StringFormatMethod("message")]
|
||||
/// public void ShowError(string message, params object[] args) { /* do something */ }
|
||||
/// public void Foo() {
|
||||
/// ShowError("Failed: {0}"); // Warning: Non-existing argument in format string
|
||||
/// }
|
||||
/// </code></example>
|
||||
[AttributeUsage(
|
||||
AttributeTargets.Constructor | AttributeTargets.Method,
|
||||
AllowMultiple = false, Inherited = true)]
|
||||
public sealed class StringFormatMethodAttribute : Attribute
|
||||
{
|
||||
/// <param name="formatParameterName">
|
||||
/// Specifies which parameter of an annotated method should be treated as format-string
|
||||
/// </param>
|
||||
public StringFormatMethodAttribute(string formatParameterName)
|
||||
{
|
||||
FormatParameterName = formatParameterName;
|
||||
}
|
||||
|
||||
public string FormatParameterName { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the function argument should be string literal and match one
|
||||
/// of the parameters of the caller function. For example, ReSharper annotates
|
||||
/// the parameter of <see cref="System.ArgumentNullException"/>
|
||||
/// </summary>
|
||||
/// <example><code>
|
||||
/// public void Foo(string param) {
|
||||
/// if (param == null)
|
||||
/// throw new ArgumentNullException("par"); // Warning: Cannot resolve symbol
|
||||
/// }
|
||||
/// </code></example>
|
||||
[AttributeUsage(AttributeTargets.Parameter, AllowMultiple = false, Inherited = true)]
|
||||
public sealed class InvokerParameterNameAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the method is contained in a type that implements
|
||||
/// <see cref="System.ComponentModel.INotifyPropertyChanged"/> interface
|
||||
/// and this method is used to notify that some property value changed
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// The method should be non-static and conform to one of the supported signatures:
|
||||
/// <list>
|
||||
/// <item><c>NotifyChanged(string)</c></item>
|
||||
/// <item><c>NotifyChanged(params string[])</c></item>
|
||||
/// <item><c>NotifyChanged{T}(Expression{Func{T}})</c></item>
|
||||
/// <item><c>NotifyChanged{T,U}(Expression{Func{T,U}})</c></item>
|
||||
/// <item><c>SetProperty{T}(ref T, T, string)</c></item>
|
||||
/// </list>
|
||||
/// </remarks>
|
||||
/// <example><code>
|
||||
/// public class Foo : INotifyPropertyChanged {
|
||||
/// public event PropertyChangedEventHandler PropertyChanged;
|
||||
/// [NotifyPropertyChangedInvocator]
|
||||
/// protected virtual void NotifyChanged(string propertyName) { ... }
|
||||
///
|
||||
/// private string _name;
|
||||
/// public string Name {
|
||||
/// get { return _name; }
|
||||
/// set { _name = value; NotifyChanged("LastName"); /* Warning */ }
|
||||
/// }
|
||||
/// }
|
||||
/// </code>
|
||||
/// Examples of generated notifications:
|
||||
/// <list>
|
||||
/// <item><c>NotifyChanged("Property")</c></item>
|
||||
/// <item><c>NotifyChanged(() => Property)</c></item>
|
||||
/// <item><c>NotifyChanged((VM x) => x.Property)</c></item>
|
||||
/// <item><c>SetProperty(ref myField, value, "Property")</c></item>
|
||||
/// </list>
|
||||
/// </example>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = true)]
|
||||
public sealed class NotifyPropertyChangedInvocatorAttribute : Attribute
|
||||
{
|
||||
public NotifyPropertyChangedInvocatorAttribute() { }
|
||||
public NotifyPropertyChangedInvocatorAttribute(string parameterName)
|
||||
{
|
||||
ParameterName = parameterName;
|
||||
}
|
||||
|
||||
public string ParameterName { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Describes dependency between method input and output
|
||||
/// </summary>
|
||||
/// <syntax>
|
||||
/// <p>Function Definition Table syntax:</p>
|
||||
/// <list>
|
||||
/// <item>FDT ::= FDTRow [;FDTRow]*</item>
|
||||
/// <item>FDTRow ::= Input => Output | Output <= Input</item>
|
||||
/// <item>Input ::= ParameterName: Value [, Input]*</item>
|
||||
/// <item>Output ::= [ParameterName: Value]* {halt|stop|void|nothing|Value}</item>
|
||||
/// <item>Value ::= true | false | null | notnull | canbenull</item>
|
||||
/// </list>
|
||||
/// If method has single input parameter, it's name could be omitted.<br/>
|
||||
/// Using <c>halt</c> (or <c>void</c>/<c>nothing</c>, which is the same)
|
||||
/// for method output means that the methos doesn't return normally.<br/>
|
||||
/// <c>canbenull</c> annotation is only applicable for output parameters.<br/>
|
||||
/// You can use multiple <c>[ContractAnnotation]</c> for each FDT row,
|
||||
/// or use single attribute with rows separated by semicolon.<br/>
|
||||
/// </syntax>
|
||||
/// <examples><list>
|
||||
/// <item><code>
|
||||
/// [ContractAnnotation("=> halt")]
|
||||
/// public void TerminationMethod()
|
||||
/// </code></item>
|
||||
/// <item><code>
|
||||
/// [ContractAnnotation("halt <= condition: false")]
|
||||
/// public void Assert(bool condition, string text) // regular assertion method
|
||||
/// </code></item>
|
||||
/// <item><code>
|
||||
/// [ContractAnnotation("s:null => true")]
|
||||
/// public bool IsNullOrEmpty(string s) // string.IsNullOrEmpty()
|
||||
/// </code></item>
|
||||
/// <item><code>
|
||||
/// // A method that returns null if the parameter is null, and not null if the parameter is not null
|
||||
/// [ContractAnnotation("null => null; notnull => notnull")]
|
||||
/// public object Transform(object data)
|
||||
/// </code></item>
|
||||
/// <item><code>
|
||||
/// [ContractAnnotation("s:null=>false; =>true,result:notnull; =>false, result:null")]
|
||||
/// public bool TryParse(string s, out Person result)
|
||||
/// </code></item>
|
||||
/// </list></examples>
|
||||
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true, Inherited = true)]
|
||||
public sealed class ContractAnnotationAttribute : Attribute
|
||||
{
|
||||
public ContractAnnotationAttribute([NotNull] string contract)
|
||||
: this(contract, false) { }
|
||||
|
||||
public ContractAnnotationAttribute([NotNull] string contract, bool forceFullStates)
|
||||
{
|
||||
Contract = contract;
|
||||
ForceFullStates = forceFullStates;
|
||||
}
|
||||
|
||||
public string Contract { get; private set; }
|
||||
public bool ForceFullStates { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that marked element should be localized or not
|
||||
/// </summary>
|
||||
/// <example><code>
|
||||
/// [LocalizationRequiredAttribute(true)]
|
||||
/// public class Foo {
|
||||
/// private string str = "my string"; // Warning: Localizable string
|
||||
/// }
|
||||
/// </code></example>
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
public sealed class LocalizationRequiredAttribute : Attribute
|
||||
{
|
||||
public LocalizationRequiredAttribute() : this(true) { }
|
||||
public LocalizationRequiredAttribute(bool required)
|
||||
{
|
||||
Required = required;
|
||||
}
|
||||
|
||||
public bool Required { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the value of the marked type (or its derivatives)
|
||||
/// cannot be compared using '==' or '!=' operators and <c>Equals()</c>
|
||||
/// should be used instead. However, using '==' or '!=' for comparison
|
||||
/// with <c>null</c> is always permitted.
|
||||
/// </summary>
|
||||
/// <example><code>
|
||||
/// [CannotApplyEqualityOperator]
|
||||
/// class NoEquality { }
|
||||
/// class UsesNoEquality {
|
||||
/// public void Test() {
|
||||
/// var ca1 = new NoEquality();
|
||||
/// var ca2 = new NoEquality();
|
||||
/// if (ca1 != null) { // OK
|
||||
/// bool condition = ca1 == ca2; // Warning
|
||||
/// }
|
||||
/// }
|
||||
/// }
|
||||
/// </code></example>
|
||||
[AttributeUsage(
|
||||
AttributeTargets.Interface | AttributeTargets.Class |
|
||||
AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
|
||||
public sealed class CannotApplyEqualityOperatorAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// When applied to a target attribute, specifies a requirement for any type marked
|
||||
/// with the target attribute to implement or inherit specific type or types.
|
||||
/// </summary>
|
||||
/// <example><code>
|
||||
/// [BaseTypeRequired(typeof(IComponent)] // Specify requirement
|
||||
/// public class ComponentAttribute : Attribute { }
|
||||
/// [Component] // ComponentAttribute requires implementing IComponent interface
|
||||
/// public class MyComponent : IComponent { }
|
||||
/// </code></example>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = true)]
|
||||
[BaseTypeRequired(typeof(Attribute))]
|
||||
public sealed class BaseTypeRequiredAttribute : Attribute
|
||||
{
|
||||
public BaseTypeRequiredAttribute([NotNull] Type baseType)
|
||||
{
|
||||
BaseType = baseType;
|
||||
}
|
||||
|
||||
[NotNull] public Type BaseType { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that the marked symbol is used implicitly
|
||||
/// (e.g. via reflection, in external library), so this symbol
|
||||
/// will not be marked as unused (as well as by other usage inspections)
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.All, AllowMultiple = false, Inherited = true)]
|
||||
public sealed class UsedImplicitlyAttribute : Attribute
|
||||
{
|
||||
public UsedImplicitlyAttribute()
|
||||
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }
|
||||
|
||||
public UsedImplicitlyAttribute(ImplicitUseKindFlags useKindFlags)
|
||||
: this(useKindFlags, ImplicitUseTargetFlags.Default) { }
|
||||
|
||||
public UsedImplicitlyAttribute(ImplicitUseTargetFlags targetFlags)
|
||||
: this(ImplicitUseKindFlags.Default, targetFlags) { }
|
||||
|
||||
public UsedImplicitlyAttribute(
|
||||
ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
|
||||
{
|
||||
UseKindFlags = useKindFlags;
|
||||
TargetFlags = targetFlags;
|
||||
}
|
||||
|
||||
public ImplicitUseKindFlags UseKindFlags { get; private set; }
|
||||
public ImplicitUseTargetFlags TargetFlags { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Should be used on attributes and causes ReSharper
|
||||
/// to not mark symbols marked with such attributes as unused
|
||||
/// (as well as by other usage inspections)
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
|
||||
public sealed class MeansImplicitUseAttribute : Attribute
|
||||
{
|
||||
public MeansImplicitUseAttribute()
|
||||
: this(ImplicitUseKindFlags.Default, ImplicitUseTargetFlags.Default) { }
|
||||
|
||||
public MeansImplicitUseAttribute(ImplicitUseKindFlags useKindFlags)
|
||||
: this(useKindFlags, ImplicitUseTargetFlags.Default) { }
|
||||
|
||||
public MeansImplicitUseAttribute(ImplicitUseTargetFlags targetFlags)
|
||||
: this(ImplicitUseKindFlags.Default, targetFlags) { }
|
||||
|
||||
public MeansImplicitUseAttribute(
|
||||
ImplicitUseKindFlags useKindFlags, ImplicitUseTargetFlags targetFlags)
|
||||
{
|
||||
UseKindFlags = useKindFlags;
|
||||
TargetFlags = targetFlags;
|
||||
}
|
||||
|
||||
[UsedImplicitly] public ImplicitUseKindFlags UseKindFlags { get; private set; }
|
||||
[UsedImplicitly] public ImplicitUseTargetFlags TargetFlags { get; private set; }
|
||||
}
|
||||
|
||||
[Flags]
|
||||
public enum ImplicitUseKindFlags
|
||||
{
|
||||
Default = Access | Assign | InstantiatedWithFixedConstructorSignature,
|
||||
/// <summary>Only entity marked with attribute considered used</summary>
|
||||
Access = 1,
|
||||
/// <summary>Indicates implicit assignment to a member</summary>
|
||||
Assign = 2,
|
||||
/// <summary>
|
||||
/// Indicates implicit instantiation of a type with fixed constructor signature.
|
||||
/// That means any unused constructor parameters won't be reported as such.
|
||||
/// </summary>
|
||||
InstantiatedWithFixedConstructorSignature = 4,
|
||||
/// <summary>Indicates implicit instantiation of a type</summary>
|
||||
InstantiatedNoFixedConstructorSignature = 8,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Specify what is considered used implicitly
|
||||
/// when marked with <see cref="MeansImplicitUseAttribute"/>
|
||||
/// or <see cref="UsedImplicitlyAttribute"/>
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum ImplicitUseTargetFlags
|
||||
{
|
||||
Default = Itself,
|
||||
Itself = 1,
|
||||
/// <summary>Members of entity marked with attribute are considered used</summary>
|
||||
Members = 2,
|
||||
/// <summary>Entity marked with attribute and all its members considered used</summary>
|
||||
WithMembers = Itself | Members
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This attribute is intended to mark publicly available API
|
||||
/// which should not be removed and so is treated as used
|
||||
/// </summary>
|
||||
[MeansImplicitUse]
|
||||
public sealed class PublicAPIAttribute : Attribute
|
||||
{
|
||||
public PublicAPIAttribute() { }
|
||||
public PublicAPIAttribute([NotNull] string comment)
|
||||
{
|
||||
Comment = comment;
|
||||
}
|
||||
|
||||
[NotNull] public string Comment { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Tells code analysis engine if the parameter is completely handled
|
||||
/// when the invoked method is on stack. If the parameter is a delegate,
|
||||
/// indicates that delegate is executed while the method is executed.
|
||||
/// If the parameter is an enumerable, indicates that it is enumerated
|
||||
/// while the method is executed
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter, Inherited = true)]
|
||||
public sealed class InstantHandleAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that a method does not make any observable state changes.
|
||||
/// The same as <c>System.Diagnostics.Contracts.PureAttribute</c>
|
||||
/// </summary>
|
||||
/// <example><code>
|
||||
/// [Pure] private int Multiply(int x, int y) { return x * y; }
|
||||
/// public void Foo() {
|
||||
/// const int a = 2, b = 2;
|
||||
/// Multiply(a, b); // Waring: Return value of pure method is not used
|
||||
/// }
|
||||
/// </code></example>
|
||||
[AttributeUsage(AttributeTargets.Method, Inherited = true)]
|
||||
public sealed class PureAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// Indicates that a parameter is a path to a file or a folder
|
||||
/// within a web project. Path can be relative or absolute,
|
||||
/// starting from web root (~)
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public class PathReferenceAttribute : Attribute
|
||||
{
|
||||
public PathReferenceAttribute() { }
|
||||
public PathReferenceAttribute([PathReference] string basePath)
|
||||
{
|
||||
BasePath = basePath;
|
||||
}
|
||||
|
||||
[NotNull] public string BasePath { get; private set; }
|
||||
}
|
||||
|
||||
// ASP.NET MVC attributes
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
|
||||
/// is an MVC action. If applied to a method, the MVC action name is calculated
|
||||
/// implicitly from the context. Use this attribute for custom wrappers similar to
|
||||
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
|
||||
public sealed class AspMvcActionAttribute : Attribute
|
||||
{
|
||||
public AspMvcActionAttribute() { }
|
||||
public AspMvcActionAttribute([NotNull] string anonymousProperty)
|
||||
{
|
||||
AnonymousProperty = anonymousProperty;
|
||||
}
|
||||
|
||||
[NotNull] public string AnonymousProperty { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC area.
|
||||
/// Use this attribute for custom wrappers similar to
|
||||
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String)</c>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public sealed class AspMvcAreaAttribute : PathReferenceAttribute
|
||||
{
|
||||
public AspMvcAreaAttribute() { }
|
||||
public AspMvcAreaAttribute([NotNull] string anonymousProperty)
|
||||
{
|
||||
AnonymousProperty = anonymousProperty;
|
||||
}
|
||||
|
||||
[NotNull] public string AnonymousProperty { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. If applied to a parameter, indicates that
|
||||
/// the parameter is an MVC controller. If applied to a method,
|
||||
/// the MVC controller name is calculated implicitly from the context.
|
||||
/// Use this attribute for custom wrappers similar to
|
||||
/// <c>System.Web.Mvc.Html.ChildActionExtensions.RenderAction(HtmlHelper, String, String)</c>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
|
||||
public sealed class AspMvcControllerAttribute : Attribute
|
||||
{
|
||||
public AspMvcControllerAttribute() { }
|
||||
public AspMvcControllerAttribute([NotNull] string anonymousProperty)
|
||||
{
|
||||
AnonymousProperty = anonymousProperty;
|
||||
}
|
||||
|
||||
[NotNull] public string AnonymousProperty { get; private set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC Master.
|
||||
/// Use this attribute for custom wrappers similar to
|
||||
/// <c>System.Web.Mvc.Controller.View(String, String)</c>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public sealed class AspMvcMasterAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC model type.
|
||||
/// Use this attribute for custom wrappers similar to
|
||||
/// <c>System.Web.Mvc.Controller.View(String, Object)</c>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public sealed class AspMvcModelTypeAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. If applied to a parameter, indicates that
|
||||
/// the parameter is an MVC partial view. If applied to a method,
|
||||
/// the MVC partial view name is calculated implicitly from the context.
|
||||
/// Use this attribute for custom wrappers similar to
|
||||
/// <c>System.Web.Mvc.Html.RenderPartialExtensions.RenderPartial(HtmlHelper, String)</c>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
|
||||
public sealed class AspMvcPartialViewAttribute : PathReferenceAttribute { }
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. Allows disabling all inspections
|
||||
/// for MVC views within a class or a method.
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
|
||||
public sealed class AspMvcSupressViewErrorAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC display template.
|
||||
/// Use this attribute for custom wrappers similar to
|
||||
/// <c>System.Web.Mvc.Html.DisplayExtensions.DisplayForModel(HtmlHelper, String)</c>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public sealed class AspMvcDisplayTemplateAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC editor template.
|
||||
/// Use this attribute for custom wrappers similar to
|
||||
/// <c>System.Web.Mvc.Html.EditorExtensions.EditorForModel(HtmlHelper, String)</c>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public sealed class AspMvcEditorTemplateAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. Indicates that a parameter is an MVC template.
|
||||
/// Use this attribute for custom wrappers similar to
|
||||
/// <c>System.ComponentModel.DataAnnotations.UIHintAttribute(System.String)</c>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter)]
|
||||
public sealed class AspMvcTemplateAttribute : Attribute { }
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. If applied to a parameter, indicates that the parameter
|
||||
/// is an MVC view. If applied to a method, the MVC view name is calculated implicitly
|
||||
/// from the context. Use this attribute for custom wrappers similar to
|
||||
/// <c>System.Web.Mvc.Controller.View(Object)</c>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method)]
|
||||
public sealed class AspMvcViewAttribute : PathReferenceAttribute { }
|
||||
|
||||
/// <summary>
|
||||
/// ASP.NET MVC attribute. When applied to a parameter of an attribute,
|
||||
/// indicates that this parameter is an MVC action name
|
||||
/// </summary>
|
||||
/// <example><code>
|
||||
/// [ActionName("Foo")]
|
||||
/// public ActionResult Login(string returnUrl) {
|
||||
/// ViewBag.ReturnUrl = Url.Action("Foo"); // OK
|
||||
/// return RedirectToAction("Bar"); // Error: Cannot resolve action
|
||||
/// }
|
||||
/// </code></example>
|
||||
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Property)]
|
||||
public sealed class AspMvcActionSelectorAttribute : Attribute { }
|
||||
|
||||
[AttributeUsage(
|
||||
AttributeTargets.Parameter | AttributeTargets.Property |
|
||||
AttributeTargets.Field, Inherited = true)]
|
||||
public sealed class HtmlElementAttributesAttribute : Attribute
|
||||
{
|
||||
public HtmlElementAttributesAttribute() { }
|
||||
public HtmlElementAttributesAttribute([NotNull] string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
[NotNull] public string Name { get; private set; }
|
||||
}
|
||||
|
||||
[AttributeUsage(
|
||||
AttributeTargets.Parameter | AttributeTargets.Field |
|
||||
AttributeTargets.Property, Inherited = true)]
|
||||
public sealed class HtmlAttributeValueAttribute : Attribute
|
||||
{
|
||||
public HtmlAttributeValueAttribute([NotNull] string name)
|
||||
{
|
||||
Name = name;
|
||||
}
|
||||
|
||||
[NotNull] public string Name { get; private set; }
|
||||
}
|
||||
|
||||
// Razor attributes
|
||||
|
||||
/// <summary>
|
||||
/// Razor attribute. Indicates that a parameter or a method is a Razor section.
|
||||
/// Use this attribute for custom wrappers similar to
|
||||
/// <c>System.Web.WebPages.WebPageBase.RenderSection(String)</c>
|
||||
/// </summary>
|
||||
[AttributeUsage(AttributeTargets.Parameter | AttributeTargets.Method, Inherited = true)]
|
||||
public sealed class RazorSectionAttribute : Attribute { }
|
||||
}
|
||||
@@ -5,8 +5,9 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
mc:Ignorable="d"
|
||||
d:DesignWidth="400"
|
||||
Style="{DynamicResource ItemStyle}"
|
||||
Height="50">
|
||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5">
|
||||
<Grid HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Margin="5" >
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="32"></ColumnDefinition>
|
||||
<ColumnDefinition/>
|
||||
@@ -18,8 +19,8 @@
|
||||
<RowDefinition Height="23"></RowDefinition>
|
||||
<RowDefinition></RowDefinition>
|
||||
</Grid.RowDefinitions>
|
||||
<TextBlock x:Name="tbTitle" FontSize="16" Foreground="#37392c" FontWeight="Medium">Title</TextBlock>
|
||||
<TextBlock Grid.Row="1" Foreground="#8e94a4" x:Name="tbSubTitle">sdfdsf</TextBlock>
|
||||
<TextBlock Style="{DynamicResource ItemTitleStyle}" x:Name="tbTitle">Title</TextBlock>
|
||||
<TextBlock Style="{DynamicResource ItemSubTitleStyle}" Grid.Row="1" x:Name="tbSubTitle">sub title</TextBlock>
|
||||
</Grid>
|
||||
<DockPanel Grid.Column="2" Visibility="Hidden">
|
||||
<Image x:Name="img" Source="Images\ctrl.png" VerticalAlignment="Center"/>
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using System.Windows.Media;
|
||||
using System.Windows.Media.Imaging;
|
||||
using WinAlfred.Annotations;
|
||||
using WinAlfred.Plugin;
|
||||
using Brush = System.Windows.Media.Brush;
|
||||
|
||||
namespace WinAlfred
|
||||
{
|
||||
public partial class ResultItem : UserControl
|
||||
public partial class ResultItem : UserControl, INotifyPropertyChanged
|
||||
{
|
||||
private bool selected;
|
||||
|
||||
@@ -25,17 +27,16 @@ namespace WinAlfred
|
||||
set
|
||||
{
|
||||
selected = value;
|
||||
BrushConverter bc = new BrushConverter();
|
||||
Background = selected ? (Brush)(bc.ConvertFrom("#d1d1d1")) : (Brush)(bc.ConvertFrom("#ebebeb"));
|
||||
if (selected)
|
||||
{
|
||||
img.Visibility = Visibility.Visible;
|
||||
img.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory()+"\\Images\\enter.png"));
|
||||
img.Source = new BitmapImage(new Uri(Directory.GetCurrentDirectory() + "\\Images\\enter.png"));
|
||||
}
|
||||
else
|
||||
{
|
||||
img.Visibility = Visibility.Hidden;
|
||||
}
|
||||
OnPropertyChanged("Selected");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,7 +76,7 @@ namespace WinAlfred
|
||||
}
|
||||
}
|
||||
|
||||
public static ImageSource GetIcon(string fileName)
|
||||
private static ImageSource GetIcon(string fileName)
|
||||
{
|
||||
Icon icon = Icon.ExtractAssociatedIcon(fileName);
|
||||
return System.Windows.Interop.Imaging.CreateBitmapSourceFromHIcon(
|
||||
@@ -83,5 +84,14 @@ namespace WinAlfred
|
||||
new Int32Rect(0, 0, icon.Width, icon.Height),
|
||||
BitmapSizeOptions.FromEmptyOptions());
|
||||
}
|
||||
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
|
||||
[NotifyPropertyChangedInvocator]
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
PropertyChangedEventHandler handler = PropertyChanged;
|
||||
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,6 +153,7 @@ namespace WinAlfred
|
||||
|
||||
double scrollPosition = 0;
|
||||
Point newItemBottomPoint = resultItemControl.TranslatePoint(new Point(0, resultItemControl.ActualHeight), pnlContainer);
|
||||
scrollPosition = newItemBottomPoint.Y;
|
||||
if (index == 0)
|
||||
{
|
||||
sv.ScrollToTop();
|
||||
@@ -167,7 +168,9 @@ namespace WinAlfred
|
||||
if (index < oldIndex)
|
||||
{
|
||||
//move up and old item is at the top of the scroll view
|
||||
if (newItemBottomPoint.Y - sv.VerticalOffset == 0)
|
||||
var scrollPostionY = sv.VerticalOffset - sv.VerticalOffset%resultItemControl.ActualHeight +
|
||||
resultItemControl.ActualHeight;
|
||||
if (newItemBottomPoint.Y - scrollPostionY == 0)
|
||||
{
|
||||
scrollPosition = sv.VerticalOffset - resultItemControl.ActualHeight;
|
||||
}
|
||||
@@ -179,7 +182,8 @@ namespace WinAlfred
|
||||
else
|
||||
{
|
||||
//move down and old item is at the bottom of scroll view
|
||||
if (sv.ActualHeight + sv.VerticalOffset == newItemBottomPoint.Y - resultItemControl.ActualHeight)
|
||||
double scrollPostionY = (sv.ActualHeight + sv.VerticalOffset) - (sv.ActualHeight + sv.VerticalOffset)%resultItemControl.ActualHeight;
|
||||
if (scrollPostionY == newItemBottomPoint.Y - resultItemControl.ActualHeight)
|
||||
{
|
||||
scrollPosition = newItemBottomPoint.Y - sv.ActualHeight;
|
||||
}
|
||||
|
||||
13
WinAlfred/SettingWindow.xaml
Normal file
13
WinAlfred/SettingWindow.xaml
Normal file
@@ -0,0 +1,13 @@
|
||||
<Window x:Class="WinAlfred.SettingWidow"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
Icon="Images\app.png"
|
||||
Title="WinAlfred Setting"
|
||||
ResizeMode="NoResize"
|
||||
WindowStartupLocation="CenterScreen"
|
||||
Height="407.447" Width="843.989">
|
||||
<Grid>
|
||||
<TextBlock Text="Theme:"/>
|
||||
<ComboBox x:Name="themeComboBox" SelectionChanged="ThemeComboBox_OnSelectionChanged" HorizontalAlignment="Left" Margin="59.83,0,0,0" VerticalAlignment="Top" Width="120"/>
|
||||
</Grid>
|
||||
</Window>
|
||||
46
WinAlfred/SettingWindow.xaml.cs
Normal file
46
WinAlfred/SettingWindow.xaml.cs
Normal file
@@ -0,0 +1,46 @@
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
using WinAlfred.Helper;
|
||||
|
||||
namespace WinAlfred
|
||||
{
|
||||
public partial class SettingWidow : Window
|
||||
{
|
||||
private MainWindow mainWindow;
|
||||
|
||||
public SettingWidow(MainWindow mainWindow)
|
||||
{
|
||||
this.mainWindow = mainWindow;
|
||||
InitializeComponent();
|
||||
Loaded += Setting_Loaded;
|
||||
}
|
||||
|
||||
private void Setting_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
foreach (string theme in LoadAvailableThemes())
|
||||
{
|
||||
string themeName = theme.Substring(theme.LastIndexOf('\\') + 1).Replace(".xaml", "");
|
||||
themeComboBox.Items.Add(themeName);
|
||||
}
|
||||
|
||||
themeComboBox.SelectedItem = Settings.Instance.Theme;
|
||||
}
|
||||
|
||||
private List<string> LoadAvailableThemes()
|
||||
{
|
||||
string themePath = Directory.GetCurrentDirectory() + "\\Themes\\";
|
||||
return Directory.GetFiles(themePath).Where(filePath => filePath.EndsWith(".xaml")).ToList();
|
||||
}
|
||||
|
||||
private void ThemeComboBox_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
string themeName = themeComboBox.SelectedItem.ToString();
|
||||
mainWindow.ChangeStyles(themeName);
|
||||
Settings.Instance.Theme = themeName;
|
||||
Settings.Instance.SaveSettings();
|
||||
}
|
||||
}
|
||||
}
|
||||
43
WinAlfred/Themes/Default.xaml
Normal file
43
WinAlfred/Themes/Default.xaml
Normal file
@@ -0,0 +1,43 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style x:Key="QueryBoxStyle" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="FontSize" Value="22"/>
|
||||
<Setter Property="FontWeight" Value="Medium"/>
|
||||
<Setter Property="AllowDrop" Value="true"/>
|
||||
<Setter Property="Height" Value="46"/>
|
||||
<Setter Property="Background" Value="#616161"/>
|
||||
<Setter Property="Foreground" Value="#E3E0E3" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
||||
</Style>
|
||||
<Style x:Key="WindowStyle" TargetType="{x:Type Window}" >
|
||||
<Setter Property="Height" Value="80"></Setter>
|
||||
<Setter Property="Width" Value="500"></Setter>
|
||||
<Setter Property="Background" Value="#424242"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="GridStyle" TargetType="{x:Type Grid}" >
|
||||
<Setter Property="Margin" Value="8 10 8 8"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="PendingLineStyle" TargetType="{x:Type Line}" >
|
||||
<Setter Property="Stroke" Value="Blue"></Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Item Style -->
|
||||
<Style x:Key="ItemTitleStyle" TargetType="{x:Type TextBlock}" >
|
||||
<Setter Property="Foreground" Value="#FFFFF8"></Setter>
|
||||
<Setter Property="FontSize" Value="16"></Setter>
|
||||
<Setter Property="FontWeight" Value="Medium"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="ItemSubTitleStyle" TargetType="{x:Type TextBlock}" >
|
||||
<Setter Property="Foreground" Value="#D9D9D4"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="ItemStyle" TargetType="{x:Type UserControl}" >
|
||||
<Setter Property="Background" Value="Transparent"></Setter>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Selected}" Value="true">
|
||||
<Setter Property="Background" Value="#4F6180"></Setter>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
43
WinAlfred/Themes/Light.xaml
Normal file
43
WinAlfred/Themes/Light.xaml
Normal file
@@ -0,0 +1,43 @@
|
||||
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
|
||||
<Style x:Key="QueryBoxStyle" TargetType="{x:Type TextBox}">
|
||||
<Setter Property="BorderThickness" Value="0"/>
|
||||
<Setter Property="FontSize" Value="22"/>
|
||||
<Setter Property="FontWeight" Value="Medium"/>
|
||||
<Setter Property="AllowDrop" Value="true"/>
|
||||
<Setter Property="Height" Value="46"/>
|
||||
<Setter Property="Background" Value="#D1D1D1"/>
|
||||
<Setter Property="Foreground" Value="#000000" />
|
||||
<Setter Property="VerticalContentAlignment" Value="Center"/>
|
||||
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
|
||||
</Style>
|
||||
<Style x:Key="WindowStyle" TargetType="{x:Type Window}" >
|
||||
<Setter Property="Background" Value="#EBEBEB"></Setter>
|
||||
<Setter Property="Width" Value="520"></Setter>
|
||||
<Setter Property="Height" Value="80"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="GridStyle" TargetType="{x:Type Grid}" >
|
||||
<Setter Property="Margin" Value="8 10 8 8"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="PendingLineStyle" TargetType="{x:Type Line}" >
|
||||
<Setter Property="Stroke" Value="Blue"></Setter>
|
||||
</Style>
|
||||
|
||||
<!-- Item Style -->
|
||||
<Style x:Key="ItemTitleStyle" TargetType="{x:Type TextBlock}" >
|
||||
<Setter Property="Foreground" Value="#1A191A"></Setter>
|
||||
<Setter Property="FontSize" Value="16"></Setter>
|
||||
<Setter Property="FontWeight" Value="Medium"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="ItemSubTitleStyle" TargetType="{x:Type TextBlock}" >
|
||||
<Setter Property="Foreground" Value="#807F80"></Setter>
|
||||
</Style>
|
||||
<Style x:Key="ItemStyle" TargetType="{x:Type UserControl}" >
|
||||
<Setter Property="Background" Value="Transparent"></Setter>
|
||||
<Style.Triggers>
|
||||
<DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Selected}" Value="true">
|
||||
<Setter Property="Background" Value="#D1D1D1"></Setter>
|
||||
</DataTrigger>
|
||||
</Style.Triggers>
|
||||
</Style>
|
||||
</ResourceDictionary>
|
||||
@@ -116,6 +116,7 @@
|
||||
<Compile Include="Helper\DwmDropShadow.cs" />
|
||||
<Compile Include="Helper\KeyboardHook.cs" />
|
||||
<Compile Include="Helper\Log.cs" />
|
||||
<Compile Include="Helper\Settings.cs" />
|
||||
<Compile Include="Helper\WinAlfredException.cs" />
|
||||
<Compile Include="Msg.xaml.cs">
|
||||
<DependentUpon>Msg.xaml</DependentUpon>
|
||||
@@ -126,6 +127,7 @@
|
||||
<Compile Include="PluginLoader\Plugins.cs" />
|
||||
<Compile Include="PluginLoader\PythonPluginLoader.cs" />
|
||||
<Compile Include="PluginLoader\PythonPluginWrapper.cs" />
|
||||
<Compile Include="Properties\Annotations.cs" />
|
||||
<Compile Include="ResultPanel.xaml.cs">
|
||||
<DependentUpon>ResultPanel.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@@ -133,6 +135,9 @@
|
||||
<DependentUpon>ResultItem.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Helper\SelectedRecords.cs" />
|
||||
<Compile Include="SettingWindow.xaml.cs">
|
||||
<DependentUpon>SettingWindow.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Page Include="MainWindow.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -157,6 +162,18 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="SettingWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Themes\Light.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Themes\Default.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Properties\AssemblyInfo.cs">
|
||||
@@ -200,9 +217,6 @@
|
||||
<Name>WinAlfred.Plugin</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\ico.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Resources\app.ico" />
|
||||
</ItemGroup>
|
||||
@@ -235,11 +249,24 @@
|
||||
<Install>true</Install>
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Resource Include="Images\app.png" />
|
||||
<Resource Include="Images\bookmark.png" />
|
||||
<Resource Include="Images\close.png" />
|
||||
<Resource Include="Images\cmd.png" />
|
||||
<Resource Include="Images\enter.png" />
|
||||
<Resource Include="Images\exit.png" />
|
||||
<Resource Include="Images\folder.png" />
|
||||
<Resource Include="Images\lock.png" />
|
||||
<Resource Include="Images\logoff.png" />
|
||||
<Resource Include="Images\work.png" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
|
||||
<PropertyGroup>
|
||||
<PostBuildEvent>xcopy /Y $(ProjectDir)Images\*.* $(SolutionDir)WinAlfred\bin\Debug\Images\
|
||||
xcopy /Y $(ProjectDir)app.ico $(SolutionDir)WinAlfred\bin\Debug\</PostBuildEvent>
|
||||
<PostBuildEvent>xcopy /Y $(ProjectDir)Images\*.* $(TargetDir)Images\
|
||||
xcopy /Y $(ProjectDir)app.ico $(TargetDir)
|
||||
xcopy /Y $(ProjectDir)Themes\*.* $(TargetDir)Themes\</PostBuildEvent>
|
||||
</PropertyGroup>
|
||||
<!-- 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.
|
||||
|
||||
Reference in New Issue
Block a user