-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Feature: Added open in VS/VS Code to status bar #12645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
yaira2
merged 17 commits into
files-community:main
from
ferrariofilippo:Feature_Open_Button
Jun 19, 2023
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
2a32476
Feature: Open in VS & VS Code buttons
ferrariofilippo 0b56806
Property not updated
ferrariofilippo d7210ca
Infinite Loading Fix
ferrariofilippo 9c6369a
Requested Changes - Partial
ferrariofilippo 84a1c05
Moved buttons in stackpanel
ferrariofilippo 019d8b8
Merge branch 'main' into Feature_Open_Button
ferrariofilippo da6444d
Enable Open VS Code
ferrariofilippo 3c40663
Update src/Files.App/Strings/en-US/Resources.resw
ferrariofilippo a435a98
Update StatusBarControl.xaml
yaira2 93eecb0
Update StatusBarControl.xaml
yaira2 b069384
Update src/Files.App/Strings/en-US/Resources.resw
yaira2 57e4ec8
Update src/Files.App/Strings/en-US/Resources.resw
yaira2 a2b0368
Icons
yaira2 4290042
Update PathIcons.xaml
yaira2 4ff5164
Update Resources.resw
yaira2 8978b2c
Merge branch 'main' into Feature_Open_Button
ferrariofilippo 57b6240
Added software helper
ferrariofilippo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,45 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using Files.App.Contexts; | ||
using Files.App.Shell; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal sealed class OpenInVSAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext _context; | ||
|
||
private readonly bool _isVSInstalled; | ||
|
||
public string Label { get; } = "OpenInVS".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "OpenInVSDescription".GetLocalizedResource(); | ||
|
||
public bool IsExecutable => | ||
_isVSInstalled && | ||
!string.IsNullOrWhiteSpace(_context.SolutionFilePath); | ||
|
||
public OpenInVSAction() | ||
{ | ||
_context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
_isVSInstalled = SoftwareHelpers.IsVSInstalled(); | ||
if (_isVSInstalled ) | ||
_context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName == nameof(IContentPageContext.SolutionFilePath)) | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
Win32API.RunPowershellCommand($"start {_context.SolutionFilePath}", false); | ||
|
||
return Task.CompletedTask; | ||
} | ||
} | ||
} |
This file contains hidden or 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,45 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using Files.App.Contexts; | ||
using Files.App.Shell; | ||
|
||
namespace Files.App.Actions | ||
{ | ||
internal sealed class OpenInVSCodeAction : ObservableObject, IAction | ||
{ | ||
private readonly IContentPageContext _context; | ||
|
||
private readonly bool _isVSCodeInstalled; | ||
|
||
public string Label { get; } = "OpenInVSCode".GetLocalizedResource(); | ||
|
||
public string Description { get; } = "OpenInVSCodeDescription".GetLocalizedResource(); | ||
|
||
public bool IsExecutable => | ||
_isVSCodeInstalled && | ||
_context.Folder is not null; | ||
|
||
public OpenInVSCodeAction() | ||
{ | ||
_context = Ioc.Default.GetRequiredService<IContentPageContext>(); | ||
|
||
_isVSCodeInstalled = SoftwareHelpers.IsVSCodeInstalled(); | ||
if (_isVSCodeInstalled) | ||
_context.PropertyChanged += Context_PropertyChanged; | ||
} | ||
|
||
public Task ExecuteAsync() | ||
{ | ||
Win32API.RunPowershellCommand($"code {_context.ShellPage?.FilesystemViewModel.WorkingDirectory}", false); | ||
|
||
return Task.CompletedTask; | ||
} | ||
|
||
private void Context_PropertyChanged(object? sender, PropertyChangedEventArgs e) | ||
{ | ||
if (e.PropertyName == nameof(IContentPageContext.Folder)) | ||
OnPropertyChanged(nameof(IsExecutable)); | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,49 @@ | ||
// Copyright (c) 2023 Files Community | ||
// Licensed under the MIT License. See the LICENSE. | ||
|
||
using Microsoft.Win32; | ||
|
||
namespace Files.App.Helpers | ||
{ | ||
internal static class SoftwareHelpers | ||
{ | ||
public static bool IsVSCodeInstalled() | ||
{ | ||
string registryKey = @"Software\Microsoft\Windows\CurrentVersion\Uninstall"; | ||
|
||
var key = Registry.CurrentUser.OpenSubKey(registryKey); | ||
if (key is null) | ||
return false; | ||
|
||
string? displayName; | ||
|
||
foreach (var subKey in key.GetSubKeyNames().Select(key.OpenSubKey)) | ||
{ | ||
displayName = subKey?.GetValue("DisplayName") as string; | ||
if (!string.IsNullOrWhiteSpace(displayName) && displayName.StartsWith("Microsoft Visual Studio Code")) | ||
{ | ||
key.Close(); | ||
|
||
return true; | ||
} | ||
} | ||
|
||
key.Close(); | ||
|
||
return false; | ||
} | ||
|
||
public static bool IsVSInstalled() | ||
{ | ||
string registryKey = @"SOFTWARE\Microsoft\VisualStudio"; | ||
|
||
var key = Registry.LocalMachine.OpenSubKey(registryKey); | ||
if (key is null) | ||
return false; | ||
|
||
key.Close(); | ||
|
||
return true; | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.