-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow opening windows explorer when the search query is a path that e…
…xists
- Loading branch information
Christian Rondeau
committed
Sep 1, 2014
1 parent
8533212
commit 873c1fb
Showing
6 changed files
with
89 additions
and
3 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
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
62 changes: 62 additions & 0 deletions
62
GoToWindow.Plugins.ExplorerExtensions/ViewModel/OpenExplorerCommandResult.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,62 @@ | ||
using System; | ||
using System.ComponentModel; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using GoToWindow.Extensibility.Controls; | ||
using GoToWindow.Extensibility.ViewModel; | ||
using log4net; | ||
|
||
namespace GoToWindow.Plugins.ExplorerExtensions.ViewModel | ||
{ | ||
public class OpenExplorerCommandResult : SearchResultBase, IBasicCommandResult, INotifyPropertyChanged | ||
{ | ||
private static readonly ILog Log = LogManager.GetLogger(typeof(OpenExplorerCommandResult).Assembly, "GoToWindow"); | ||
|
||
private string _text; | ||
private string _query; | ||
|
||
public event PropertyChangedEventHandler PropertyChanged; | ||
|
||
public string BeforeText { get { return "Open Windows Explorer with path '"; } } | ||
public string AfterText { get { return "'"; } } | ||
|
||
public string Text | ||
{ | ||
get { return _text; } | ||
set | ||
{ | ||
_text = value; | ||
OnPropertyChanged("Text"); | ||
} | ||
} | ||
|
||
public OpenExplorerCommandResult() | ||
: base(() => new BasicCommandEntry()) | ||
{ | ||
|
||
} | ||
|
||
protected void OnPropertyChanged(string name) | ||
{ | ||
if (PropertyChanged != null) | ||
PropertyChanged(this, new PropertyChangedEventArgs(name)); | ||
} | ||
|
||
public void Select() | ||
{ | ||
Log.DebugFormat("Launching Explorer with '{0}'.", _query); | ||
Process.Start(_query); | ||
} | ||
|
||
public bool IsShown(string searchQuery) | ||
{ | ||
_query = searchQuery; | ||
Text = _query; | ||
var isPathQuery = !String.IsNullOrWhiteSpace(searchQuery) && searchQuery.Length >= 2 && searchQuery[1] == ':'; | ||
|
||
if (!isPathQuery) return false; | ||
|
||
return Directory.Exists(searchQuery); | ||
} | ||
} | ||
} |
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