Copy from Jeremy's fork PR

This commit is contained in:
bkudiess
2020-03-20 09:43:42 -07:00
parent 855f092682
commit 0f78f1b333
60 changed files with 898 additions and 2082 deletions

View File

@@ -1,152 +0,0 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
using Wox.Infrastructure.Storage.UserSettings;
namespace Wox.Plugin.SystemPlugins.Program.ProgramSources {
//TODO: Consider Removing
/// <summary>
///
/// </summary>
public class FileSystemFolderSourceShallow : FileSystemProgramSource {
//private static Dictionary<string, DirectoryInfo[]> parentDirectories = new Dictionary<string, DirectoryInfo[]>();
public FileSystemFolderSourceShallow(string baseDirectory)
: base(baseDirectory) { }
public FileSystemFolderSourceShallow(ProgramSource source)
: base(source) { }
public override List<Program> LoadPrograms() {
List<Program> list = new List<Program>();
foreach (var Folder in Directory.GetDirectories(BaseDirectory)) {
list.Add(CreateEntry(Folder));
}
foreach (string file in Directory.GetFiles(base.BaseDirectory)) {
if (Suffixes.Any(o => file.EndsWith("." + o))) {
list.Add(CreateEntry(file));
}
}
return list;
}
public override string ToString() {
return typeof(UserStartMenuProgramSource).Name;
}
/*
public class FolderSource : IProgramSource {
private PluginInitContext context;
public string Location { get; set; }
public int BonusPoints { get; set; }
public FolderSource(string Location) {
this.Location = Location;
}
public List<Program> LoadPrograms() {
List<Result> results = new List<Result>();
if (Directory.Exists(Location)) {
// show all child directory
if (Location.EndsWith("\\") || Location.EndsWith("/")) {
var dirInfo = new DirectoryInfo(Location);
var dirs = dirInfo.GetDirectories();
var parentDirKey = Location.TrimEnd('\\', '/');
if (!parentDirectories.ContainsKey(parentDirKey))
parentDirectories.Add(parentDirKey, dirs);
foreach (var dir in dirs) {
if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
continue;
var dirPath = dir.FullName;
Result result = new Result {
Title = dir.Name,
IcoPath = "Images/folder.png",
Action = (c) => {
context.ChangeQuery(dirPath);
return false;
}
};
results.Add(result);
}
if (results.Count == 0) {
Result result = new Result {
Title = "Open this directory",
SubTitle = "No files in this directory",
IcoPath = "Images/folder.png",
Action = (c) => {
Process.Start(Location);
return true;
}
};
results.Add(result);
}
}
else {
Result result = new Result {
Title = "Open this directory",
SubTitle = string.Format("path: {0}", Location),
Score = 50,
IcoPath = "Images/folder.png",
Action = (c) => {
Process.Start(Location);
return true;
}
};
results.Add(result);
}
}
// change to search in current directory
var parentDir = Path.GetDirectoryName(Location);
if (!string.IsNullOrEmpty(parentDir) && results.Count == 0) {
parentDir = parentDir.TrimEnd('\\', '/');
if (parentDirectories.ContainsKey(parentDir)) {
var dirs = parentDirectories[parentDir];
var queryFileName = Path.GetFileName(Location).ToLower();
var fuzzy = FuzzyMatcher.Create(queryFileName);
foreach (var dir in dirs) {
if ((dir.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
continue;
var matchResult = fuzzy.Evaluate(dir.Name);
if (!matchResult.Success)
continue;
var dirPath = dir.FullName;
Result result = new Result {
Title = dir.Name,
IcoPath = "Images/folder.png",
Score = matchResult.Score,
Action = (c) => {
context.ChangeQuery(dirPath);
return false;
}
};
results.Add(result);
}
}
}
throw new Exception("Debug this!");
}
}
*/
}
}

View File

@@ -62,7 +62,8 @@ namespace Wox.Plugin.Program.Programs
var info = new ProcessStartInfo
{
FileName = FullPath,
WorkingDirectory = ParentDirectory
WorkingDirectory = ParentDirectory,
UseShellExecute = true
};
Main.StartProcess(Process.Start, info);
@@ -102,7 +103,12 @@ namespace Wox.Plugin.Program.Programs
Title = api.GetTranslation("wox_plugin_program_run_as_different_user"),
Action = _ =>
{
var info = FullPath.SetProcessStartInfo(ParentDirectory);
var info = new ProcessStartInfo
{
FileName = FullPath,
WorkingDirectory = ParentDirectory,
UseShellExecute = true
};
Task.Run(() => Main.StartProcess(ShellCommand.RunAsDifferentUser, info));
@@ -119,7 +125,8 @@ namespace Wox.Plugin.Program.Programs
{
FileName = FullPath,
WorkingDirectory = ParentDirectory,
Verb = "runas"
Verb = "runas",
UseShellExecute = true
};
Task.Run(() => Main.StartProcess(Process.Start, info));
@@ -133,7 +140,9 @@ namespace Wox.Plugin.Program.Programs
Title = api.GetTranslation("wox_plugin_program_open_containing_folder"),
Action = _ =>
{
Main.StartProcess(Process.Start, new ProcessStartInfo(ParentDirectory));
Main.StartProcess(Process.Start, new ProcessStartInfo("explorer", ParentDirectory));
return true;
},

View File

@@ -1,5 +0,0 @@
using System.Reflection;
using System.Runtime.InteropServices;
[assembly: AssemblyTitle("Wox.Plugin.Program")]
[assembly: Guid("82f60d9a-9280-4b6a-8b21-f3c694cb7e1d")]

View File

@@ -1,92 +1,55 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<TargetFramework>netcoreapp3.1</TargetFramework>
<ProjectGuid>{FDB3555B-58EF-4AE6-B5F1-904719637AB4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Wox.Plugin.Program</RootNamespace>
<AssemblyName>Wox.Plugin.Program</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
<TargetFrameworkProfile />
<NuGetPackageImportStamp>
</NuGetPackageImportStamp>
<UseWpf>true</UseWpf>
<UseWindowsForms>true</UseWindowsForms>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<AppendRuntimeIdentifierToOutputPath>false</AppendRuntimeIdentifierToOutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>..\..\..\..\..\x64\Debug\modules\launcher\Plugins\Wox.Plugin.Program\</OutputPath>
<OutputPath>..\..\Output\Debug\Plugins\Wox.Plugin.Program\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>..\..\..\..\..\x64\Release\modules\launcher\Plugins\Wox.Plugin.Program\</OutputPath>
<OutputPath>..\..\Output\Release\Plugins\Wox.Plugin.Program\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<Prefer32Bit>false</Prefer32Bit>
</PropertyGroup>
<ItemGroup>
<Reference Include="AppxPackagingTlb">
<HintPath>.\AppxPackagingTlb.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="ShObjIdlTlb">
<HintPath>.\ShObjIdlTlb.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Page Include="AddProgramSource.xaml" />
<Compile Include="..\..\SolutionAssemblyInfo.cs">
<Link>Properties\SolutionAssemblyInfo.cs</Link>
</Compile>
<Compile Include="AddProgramSource.xaml.cs">
<DependentUpon>AddProgramSource.xaml</DependentUpon>
</Compile>
<Compile Include="Logger\ProgramLogger.cs" />
<Compile Include="Views\Commands\ProgramSettingDisplay.cs" />
<Compile Include="FileChangeWatcher.cs" />
<Compile Include="Views\Models\ProgramSource.cs" />
<Compile Include="Programs\IProgram.cs" />
<Compile Include="Programs\UWP.cs" />
<Compile Include="Programs\Win32.cs" />
<Compile Include="SuffixesConverter.cs" />
<Compile Include="Main.cs" />
<Compile Include="Views\ProgramSetting.xaml.cs">
<DependentUpon>ProgramSetting.xaml</DependentUpon>
</Compile>
<Compile Include="Settings.cs" />
<Compile Include="ProgramSuffixes.xaml.cs">
<DependentUpon>ProgramSuffixes.xaml</DependentUpon>
</Compile>
<Compile Include="LocationConverter.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="plugin.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Reference Include="AppxPackagingTlb">
<HintPath>.\AppxPackagingTlb.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
<Reference Include="ShObjIdlTlb">
<HintPath>.\ShObjIdlTlb.dll</HintPath>
<EmbedInteropTypes>True</EmbedInteropTypes>
</Reference>
</ItemGroup>
<ItemGroup>
<None Include="Images\program.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
@@ -109,6 +72,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<Content Include="Languages\zh-cn.xaml">
<Generator>MSBuild:Compile</Generator>
@@ -135,48 +99,22 @@
<SubType>Designer</SubType>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Page Include="Views\ProgramSetting.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="ProgramSuffixes.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj">
<Project>{4fd29318-a8ab-4d8f-aa47-60bc241b8da3}</Project>
<Name>Wox.Infrastructure</Name>
</ProjectReference>
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj">
<Project>{8451ecdd-2ea4-4966-bb0a-7bbc40138e80}</Project>
<Name>Wox.Plugin</Name>
</ProjectReference>
<ProjectReference Include="..\..\Wox.Infrastructure\Wox.Infrastructure.csproj" />
<ProjectReference Include="..\..\Wox.Plugin\Wox.Plugin.csproj" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="JetBrains.Annotations">
<Version>10.3.0</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json">
<Version>9.0.1</Version>
</PackageReference>
<PackageReference Include="NLog">
<Version>4.2.0</Version>
</PackageReference>
<PackageReference Include="System.Runtime">
<Version>4.0.0</Version>
</PackageReference>
<PackageReference Include="UwpDesktop">
<Version>10.0.14393.3</Version>
</PackageReference>
<PackageReference Include="JetBrains.Annotations" Version="2019.1.3" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
<PackageReference Include="NLog" Version="4.7.0-rc1" />
<PackageReference Include="System.Runtime" Version="4.3.1" />
<PackageReference Include="UwpDesktop" Version="10.0.14393.3" />
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.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">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>