forked from microsoft/PowerToys
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import the source code for Window Walker (microsoft#1177)
Import the codebase for Window Walker - Not loaded into the module list - Not added it to the installer list.
- Loading branch information
Showing
53 changed files
with
14,344 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
{ | ||
} | ||
} |
90 changes: 90 additions & 0 deletions
90
src/modules/windowwalker/app/Window Walker/Components/ApplicationUpdates.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
22
src/modules/windowwalker/app/Window Walker/Components/Command.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
104
src/modules/windowwalker/app/Window Walker/Components/Commands.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.