Skip to content

Commit

Permalink
Import the source code for Window Walker (microsoft#1177)
Browse files Browse the repository at this point in the history
Import the codebase for Window Walker 

- Not loaded into the module list 
- Not added it to the installer list.
  • Loading branch information
betsegaw authored and udit3333 committed Feb 20, 2020
1 parent afc39e5 commit 267f5ed
Show file tree
Hide file tree
Showing 53 changed files with 14,344 additions and 0 deletions.
18 changes: 18 additions & 0 deletions PowerToys.sln
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "runner", "src\runner\runner.vcxproj", "{9412D5C6-2CF2-4FC2-A601-B55508EA9B27}"
ProjectSection(ProjectDependencies) = postProject
{48804216-2A0E-4168-A6D8-9CD068D14227} = {48804216-2A0E-4168-A6D8-9CD068D14227}
{51D3BD1F-07A8-48EB-B2A0-0A249CD4E1A6} = {51D3BD1F-07A8-48EB-B2A0-0A249CD4E1A6}
{74485049-C722-400F-ABE5-86AC52D929B3} = {74485049-C722-400F-ABE5-86AC52D929B3}
{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB} = {B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}
{A46629C4-1A6C-40FA-A8B6-10E5102BB0BA} = {A46629C4-1A6C-40FA-A8B6-10E5102BB0BA}
{07C389E3-6BC8-41CF-923E-307B1265FA2D} = {07C389E3-6BC8-41CF-923E-307B1265FA2D}
EndProjectSection
Expand Down Expand Up @@ -103,6 +105,11 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "powerpreview", "src\modules\previewpane\powerpreview\powerpreview.vcxproj", "{217DF501-135C-4E38-BFC8-99D4821032EA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "powerpreviewTest", "src\modules\previewpane\powerpreviewTest\powerpreviewTest.vcxproj", "{47310AB4-9034-4BD1-8D8B-E88AD21A171B}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "windowwalker", "windowwalker", "{8DC78AF7-DC3E-4C57-A8FB-7E347DE74A03}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Window Walker", "src\modules\windowwalker\app\Window Walker\Window Walker.csproj", "{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WindowWalker", "src\modules\windowwalker\dll\WindowWalker.vcxproj", "{51D3BD1F-07A8-48EB-B2A0-0A249CD4E1A6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down Expand Up @@ -210,6 +217,14 @@ Global
{47310AB4-9034-4BD1-8D8B-E88AD21A171B}.Debug|x64.Build.0 = Debug|x64
{47310AB4-9034-4BD1-8D8B-E88AD21A171B}.Release|x64.ActiveCfg = Release|x64
{47310AB4-9034-4BD1-8D8B-E88AD21A171B}.Release|x64.Build.0 = Release|x64
{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}.Debug|x64.ActiveCfg = Debug|x64
{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}.Debug|x64.Build.0 = Debug|x64
{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}.Release|x64.ActiveCfg = Release|x64
{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}.Release|x64.Build.0 = Release|x64
{51D3BD1F-07A8-48EB-B2A0-0A249CD4E1A6}.Debug|x64.ActiveCfg = Debug|x64
{51D3BD1F-07A8-48EB-B2A0-0A249CD4E1A6}.Debug|x64.Build.0 = Debug|x64
{51D3BD1F-07A8-48EB-B2A0-0A249CD4E1A6}.Release|x64.ActiveCfg = Release|x64
{51D3BD1F-07A8-48EB-B2A0-0A249CD4E1A6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -242,6 +257,9 @@ Global
{748417CA-F17E-487F-9411-CAFB6D3F4877} = {2F305555-C296-497E-AC20-5FA1B237996A}
{217DF501-135C-4E38-BFC8-99D4821032EA} = {2F305555-C296-497E-AC20-5FA1B237996A}
{47310AB4-9034-4BD1-8D8B-E88AD21A171B} = {2F305555-C296-497E-AC20-5FA1B237996A}
{8DC78AF7-DC3E-4C57-A8FB-7E347DE74A03} = {4574FDD0-F61D-4376-98BF-E5A1262C11EC}
{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB} = {8DC78AF7-DC3E-4C57-A8FB-7E347DE74A03}
{51D3BD1F-07A8-48EB-B2A0-0A249CD4E1A6} = {8DC78AF7-DC3E-4C57-A8FB-7E347DE74A03}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {C3A2F9D1-7930-4EF4-A6FC-7EE0A99821D0}
Expand Down
25 changes: 25 additions & 0 deletions src/modules/windowwalker/app/Window Walker.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26430.6
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Window Walker", "Window Walker\Window Walker.csproj", "{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}"
EndProject
Global
GlobalSection(Performance) = preSolution
HasPerformanceSessions = true
EndGlobalSection
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{B9BDF8BE-FED7-49B5-A7AE-DD4D1CA2D9EB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
6 changes: 6 additions & 0 deletions src/modules/windowwalker/app/Window Walker/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2"/>
</startup>
</configuration>
16 changes: 16 additions & 0 deletions src/modules/windowwalker/app/Window Walker/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<Application x:Class="WindowWalker.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>
<BooleanToVisibilityConverter x:Key="BoolToVis" />
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Dark.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.Indigo.xaml" />
<ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Indigo.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
15 changes: 15 additions & 0 deletions src/modules/windowwalker/app/Window Walker/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Betsegaw Tadele's https://github.com/betsegaw/windowwalker/

using System.Windows;

namespace WindowWalker
{
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Betsegaw Tadele's https://github.com/betsegaw/windowwalker/

using System;
using System.Deployment.Application;

namespace WindowWalker.Components
{
public class ApplicationUpdates
{
private static DateTime _lastUpdateCheck = DateTime.Now;
private static bool alreadyCheckingForUpdate = false;

private static bool updateAvailable = false;

public static void InstallUpdateSyncWithInfo()
{
if (alreadyCheckingForUpdate)
{
return;
}
else
{
alreadyCheckingForUpdate = true;
}

var daysSinceLastUpdate = (DateTime.Now - _lastUpdateCheck).Days;

if (ApplicationDeployment.IsNetworkDeployed)
{
if (updateAvailable)
{
UpdateCheckInfo info = null;
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

try
{
info = ad.CheckForDetailedUpdate();
}
catch
{
return;
}
finally
{
_lastUpdateCheck = DateTime.Now;
}

if (info.UpdateAvailable || true)
{
try
{
ad.Update();
System.Windows.Application.Current.Shutdown();
System.Windows.Forms.Application.Restart();
}
catch
{
return;
}
}
}
else
{
ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

ad.CheckForUpdateCompleted += new CheckForUpdateCompletedEventHandler(CheckForUpdateCompleted);
ad.CheckForUpdateAsync();

_lastUpdateCheck = DateTime.Now;
}
}
}

private static void CheckForUpdateCompleted(object sender, CheckForUpdateCompletedEventArgs e)
{
if (e.Error != null || !e.UpdateAvailable)
{
alreadyCheckingForUpdate = false;
return;
}
else
{
updateAvailable = true;
alreadyCheckingForUpdate = false;
}
}
}
}
22 changes: 22 additions & 0 deletions src/modules/windowwalker/app/Window Walker/Components/Command.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Betsegaw Tadele's https://github.com/betsegaw/windowwalker/

namespace WindowWalker.Components
{
/// <summary>
/// Command class representing a single command
/// </summary>
public class Command
{
/// <summary>
/// Gets or sets the set of substrings to search for in the search text to figure out if the user wants this command
/// </summary>
public string[] SearchTexts { get; set; }

/// <summary>
/// Gets or sets the help tip to get displayed in the cycling display
/// </summary>
public string Tip { get; set; }
}
}
104 changes: 104 additions & 0 deletions src/modules/windowwalker/app/Window Walker/Components/Commands.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
// Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. Code forked from Betsegaw Tadele's https://github.com/betsegaw/windowwalker/

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace WindowWalker.Components
{
/// <summary>
/// A class to handle the commands entered by the user, different
/// form the user being able to search through their windows
/// </summary>
internal class Commands
{
/// <summary>
/// Initializes static members of the <see cref="Commands"/> class.
/// Constructor primarily used to enforce the creation of tips
/// and populate the enabled commands list
/// </summary>
static Commands()
{
_enabledCommands = new Dictionary<string, Command>
{
{
"quit",
new Command()
{
SearchTexts = new string[]
{
":quit",
":q",
},
Tip = "type \":quit\" to exit",
}
},
{
"launchTerminal",
new Command()
{
SearchTexts = new string[]
{
":lterminal",
":lcmd",
":lterm",
":lt",
},
Tip = "type \":lt\" or \":lcmd\"to launch a new terminal window",
}
},
{
"launchVSCode",
new Command()
{
SearchTexts = new string[]
{
":lvscode",
":lcode",
},
Tip = "type \":lvscode\" or \":lcode\"to launch a new instance of VSCode",
}
},
};
}

/// <summary>
/// Dictionary containing all the enabled commands
/// </summary>
private static readonly Dictionary<string, Command> _enabledCommands;

/// <summary>
/// Primary method which executes on the commands that are passed to it
/// </summary>
/// <param name="commandText">The search text the user has entered</param>
public static void ProcessCommand(string commandText)
{
LivePreview.DeactivateLivePreview();

if (_enabledCommands["quit"].SearchTexts.Contains(commandText))
{
System.Windows.Application.Current.Shutdown();
}
else if (_enabledCommands["launchTerminal"].SearchTexts.Contains(commandText))
{
Process.Start(new ProcessStartInfo("cmd.exe")
{ WorkingDirectory = Environment.GetFolderPath(Environment.SpecialFolder.UserProfile) });
}
else if (_enabledCommands["launchVSCode"].SearchTexts.Contains(commandText))
{
Process.Start("code");
}
}

/// <summary>
/// Gets the tips for all the enabled commands
/// </summary>
public static IEnumerable<string> GetTips()
{
return _enabledCommands.Select(x => x.Value.Tip);
}
}
}
Loading

0 comments on commit 267f5ed

Please sign in to comment.