Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

bug fixes, added right click to open cmd to tree

  • Loading branch information...
commit 251131cefcedc66cf205fa15976f2fb8940d22d5 1 parent bbc81c3
@JustinBeckwith JustinBeckwith authored
View
10 NodePowerTools.sln
@@ -1,8 +1,14 @@

-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 11
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NodePowerTools", "NodePowerTools\NodePowerTools.csproj", "{0AD95D26-46AE-416F-8C3F-B0C18E437C48}"
EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{801D5147-DDE0-4558-BCBD-66A5243E1823}"
+ ProjectSection(SolutionItems) = preProject
+ license.md = license.md
+ readme.md = readme.md
+ EndProjectSection
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
View
BIN  NodePowerTools.v11.suo
Binary file not shown
View
1  NodePowerTools/NodePowerTools.csproj
@@ -56,6 +56,7 @@
<Compile Include="OutputWindow.xaml.cs">
<DependentUpon>OutputWindow.xaml</DependentUpon>
</Compile>
+ <Compile Include="ThemeHelper.cs" />
<Compile Include="WebMatrixExtension.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
View
38 NodePowerTools/OutputWindow.xaml.cs
@@ -1,11 +1,10 @@
using System;
+using System.ComponentModel.Composition;
using System.IO;
using System.Text;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Windows;
using System.Windows.Controls;
using Microsoft.WebMatrix.Extensibility;
+using Microsoft.WebMatrix.Extensibility.Editor;
namespace NodePowerTools
{
@@ -25,6 +24,10 @@ public partial class OutputWindow : UserControl
private string _filePath;
private StreamReader _fileStreamReader;
private ISiteFileWatcherService _siteFileWatcherService;
+ private long _logLength;
+
+
+
#endregion
@@ -41,8 +44,7 @@ public partial class OutputWindow : UserControl
/// </summary>
public OutputWindow()
{
- InitializeComponent();
-
+ InitializeComponent();
}
#endregion
@@ -54,11 +56,11 @@ public OutputWindow()
#region Initialize
/// <summary>
- ///
+ /// monitor the log file for changes, set up the initial read
/// </summary>
/// <param name="filePath"></param>
/// <param name="siteFileWatcherService"></param>
- public void Initialize(string filePath, ISiteFileWatcherService siteFileWatcherService)
+ public void Initialize(string filePath, ISiteFileWatcherService siteFileWatcherService, ITheme theme)
{
_filePath = Path.GetFullPath(filePath);
_siteFileWatcherService = siteFileWatcherService;
@@ -67,6 +69,9 @@ public void Initialize(string filePath, ISiteFileWatcherService siteFileWatcherS
this.PerformInitialRead();
_siteFileWatcherService.RegisterForSiteNotifications(WatcherChangeTypes.All, new FileSystemEventHandler(FileSystemEvent), null);
+
+ outy.Foreground = theme.DefaultFormat.ForeColor;
+ outy.Background = theme.DefaultFormat.BackColor;
}
#endregion
@@ -77,6 +82,7 @@ public void Initialize(string filePath, ISiteFileWatcherService siteFileWatcherS
private void PerformInitialRead()
{
_fileStreamReader = new StreamReader(new FileStream(_filePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);
+ _logLength = _fileStreamReader.BaseStream.Length;
this.WriteToLog(_fileStreamReader.ReadToEnd());
}
#endregion
@@ -119,11 +125,21 @@ private void FileSystemEvent(object sender, FileSystemEventArgs e)
}
else if (e.ChangeType == WatcherChangeTypes.Changed)
{
- var line = "";
- while ((line = _fileStreamReader.ReadLine()) != null)
+ if (_fileStreamReader.BaseStream.Length < _logLength)
+ {
+ // if the log has decreased in size, it got reset.
+ this.PerformInitialRead();
+ }
+ else
{
- this.WriteToLog(line);
- }
+ // there was an additive change to the log
+ _logLength = _fileStreamReader.BaseStream.Length;
+ var line = "";
+ while ((line = _fileStreamReader.ReadLine()) != null)
+ {
+ this.WriteToLog(line);
+ }
+ }
}
}
}
View
12 NodePowerTools/ThemeHelper.cs
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+
+namespace NodePowerTools
+{
+ public class ThemeHelper
+ {
+
+ }
+}
View
88 NodePowerTools/WebMatrixExtension.cs
@@ -9,6 +9,7 @@
using System.Windows.Media;
using System.Windows;
using Microsoft.WebMatrix.Extensibility.Editor;
+using System.Collections.Generic;
namespace NodePowerTools
{
@@ -17,7 +18,7 @@ namespace NodePowerTools
/// </summary>
[Export(typeof(Extension))]
public class WebMatrixExtension : Extension
- {
+ {
//--------------------------------------------------------------------------
//
@@ -63,6 +64,9 @@ public class WebMatrixExtension : Extension
private ISiteFileWatcherService _siteFileWatcher;
private OutputWindow _outputWindow;
private string _mainScriptPath;
+
+ [Import(ThemeKeys.DefaultTheme, typeof(ITheme))]
+ private ITheme DefaultTheme { get; set; }
@@ -75,7 +79,7 @@ private IEditorTaskPanelService EditorTaskPanelService
}
set
{
- _editorTaskPanel = value;
+ _editorTaskPanel = value;
}
}
@@ -101,7 +105,7 @@ private ISiteFileWatcherService SiteFileWatcherService
//--------------------------------------------------------------------------
#region Constructors
-
+
/// <summary>
/// Initializes a new instance of the NodePowerTools class.
/// </summary>
@@ -119,14 +123,14 @@ public WebMatrixExtension()
{
_mainScriptPath = this.GetMainFileName();
var nodeInspectorUrl = string.Format("{0}/{1}/debug", _host.WebSite.Uri.ToString(), _mainScriptPath);
- Process.Start("chrome", nodeInspectorUrl);
+ Process.Start("chrome", nodeInspectorUrl);
//Process.Start("chrome", _host.WebSite.Uri.ToString());
}
});
}
#endregion
-
+
//--------------------------------------------------------------------------
//
@@ -142,11 +146,11 @@ public WebMatrixExtension()
protected override void Initialize(IWebMatrixHost host, ExtensionInitData data)
{
// Get new values
- _host = host;
+ _host = host;
if (host != null)
{
host.WorkspaceChanged += new EventHandler<WorkspaceChangedEventArgs>(WebMatrixHost_WorkspaceChanged);
- host.WebSiteChanged += new EventHandler<EventArgs>(WebMatrixHost_WebSiteChanged);
+ host.WebSiteChanged += new EventHandler<EventArgs>(WebMatrixHost_WebSiteChanged);
// Add a simple button to the Ribbon
_ribbonGroup = new RibbonGroup(
@@ -163,15 +167,17 @@ protected override void Initialize(IWebMatrixHost host, ExtensionInitData data)
data.RibbonItems.Add(_ribbonGroup);
_editorTaskPanel.PageChanged += InitializeLogTab;
+ // handle the right click event the tree
+ host.ContextMenuOpening += new EventHandler<ContextMenuOpeningEventArgs>(host_ContextMenuOpening);
// if this is the first time the extension is installed, this method will be called
- if (_host != null && _host.WebSite != null && !String.IsNullOrEmpty(_host.WebSite.Path))
+ if (_host.WebSite != null && !String.IsNullOrEmpty(_host.WebSite.Path))
{
_isNodeSite = IsNodeProject();
_ribbonGroup.IsVisible = _host.Workspace is IEditorWorkspace && _isNodeSite;
InitializeLogTab(this, EventArgs.Empty);
}
- }
+ }
}
#endregion
@@ -183,12 +189,12 @@ protected override void Initialize(IWebMatrixHost host, ExtensionInitData data)
/// <param name="e"></param>
private void InitializeLogTab(object sender, EventArgs e)
{
- if (_isNodeSite && _host.WebSite != null && !String.IsNullOrEmpty(_host.WebSite.Path)
+ if (_isNodeSite && _host.WebSite != null && !String.IsNullOrEmpty(_host.WebSite.Path)
&& !_editorTaskPanel.TaskTabExists(_outputTaskPanelId))
{
_mainScriptPath = this.GetMainFileName();
_outputWindow = new OutputWindow();
- _outputWindow.Initialize(Path.Combine(_host.WebSite.Path, _mainScriptPath + ".logs", "0.txt"), _siteFileWatcher);
+ _outputWindow.Initialize(Path.Combine(_host.WebSite.Path, _mainScriptPath + ".logs", "0.txt"), _siteFileWatcher, DefaultTheme);
_editorTaskPanel.AddTaskTab(_outputTaskPanelId, new TaskTabItemDescriptor(null, "Output", _outputWindow, Brushes.DarkOliveGreen));
}
else
@@ -197,7 +203,7 @@ private void InitializeLogTab(object sender, EventArgs e)
{
_editorTaskPanel.RemoveTaskTab(_outputTaskPanelId);
}
- }
+ }
}
#endregion
@@ -209,7 +215,7 @@ private void InitializeLogTab(object sender, EventArgs e)
/// <param name="sender">Event source.</param>
/// <param name="e">Event arguments.</param>
private void WebMatrixHost_WorkspaceChanged(object sender, WorkspaceChangedEventArgs e)
- {
+ {
_ribbonGroup.IsVisible = e.NewWorkspace is IEditorWorkspace && _isNodeSite;
}
#endregion
@@ -226,6 +232,40 @@ private void WebMatrixHost_WebSiteChanged(object sender, EventArgs e)
}
#endregion
+ #region host_ContextMenuOpening
+ /// <summary>
+ /// add an option to open a console here if it's a directory
+ /// </summary>
+ /// <param name="sender"></param>
+ /// <param name="e"></param>
+ protected void host_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
+ {
+ // we only show the context menu if every item selected in the tree is valid to be compiled
+ IList<string> paths = new List<string>();
+ var showContextMenu = e.Items.Count > 0;
+ foreach (ISiteItem item in e.Items)
+ {
+ if (item == null || !(item is ISiteFolder))
+ {
+ showContextMenu = false;
+ break;
+ }
+ else
+ {
+ paths.Add((item as ISiteFolder).Path);
+ }
+ }
+
+ // if all of the files in the list are valid, show the command window option
+ if (showContextMenu)
+ {
+ var menuItem = new ContextMenuItem("Open Command Window", null, new DelegateCommand(new Action<object>(OpenCMD)), paths);
+ e.AddMenuItem(menuItem);
+ }
+ }
+
+ #endregion
+
//--------------------------------------------------------------------------
//
// Methods
@@ -243,7 +283,7 @@ protected bool IsChromeInstalled()
// older installs don't have the clients reg, so check uninstall
var key = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Uninstall");
foreach (string name in key.GetSubKeyNames())
- if (name == "Google Chrome") return true;
+ if (name == "Google Chrome") return true;
// try it this way
key = Registry.CurrentUser.OpenSubKey(@"Software\Google\Update\Clients");
@@ -322,7 +362,25 @@ protected string GetMainFileName()
}
#endregion
-
+ #region OpenCMD
+ /// <summary>
+ /// opens a cmd window at the current directory
+ /// </summary>
+ /// <param name="e"></param>
+ protected void OpenCMD(object e)
+ {
+ IList<string> paths = (IList<string>)e;
+ foreach (var path in paths)
+ {
+ ProcessStartInfo info = new ProcessStartInfo()
+ {
+ FileName = "cmd.exe",
+ WorkingDirectory = path
+ };
+ Process.Start(info);
+ }
+ }
+ #endregion
}
}
View
BIN  NodePowerTools/bin/Debug/Microsoft.WebMatrix.Extensibility.dll
Binary file not shown
View
12 NodePowerTools/bin/Debug/Microsoft.WebMatrix.Extensibility.xml
@@ -2583,18 +2583,6 @@
<param name="id">HierarchyId instance.</param>
<returns>ISiteItem instance.</returns>
</member>
- <member name="M:Microsoft.WebMatrix.Extensibility.IWebMatrixHost.AddRibbonItems(System.Collections.Generic.IEnumerable{Microsoft.WebMatrix.Extensibility.RibbonItem})">
- <summary>
- Adds a sequence of Ribbon items to the Ribbon.
- </summary>
- <param name="ribbonItems">Sequence of RibbonItems.</param>
- </member>
- <member name="M:Microsoft.WebMatrix.Extensibility.IWebMatrixHost.AddDashboardItems(System.Collections.Generic.IEnumerable{Microsoft.WebMatrix.Extensibility.DashboardItem})">
- <summary>
- Adds a sequence of dashboard items to the dashboard.
- </summary>
- <param name="dashboardItems">Sequence of IDashboardItems.</param>
- </member>
<member name="M:Microsoft.WebMatrix.Extensibility.IWebMatrixHost.ApplyPathProtection(System.Collections.Generic.IEnumerable{Microsoft.WebMatrix.Extensibility.IProtectPathInfo})">
<summary>
Applies a set of IProtectPathInfo rules to the site's files.
View
BIN  NodePowerTools/bin/Debug/NodePowerTools.dll
Binary file not shown
View
BIN  NodePowerTools/bin/Debug/NodePowerTools.pdb
Binary file not shown
View
1  NodePowerTools/obj/Debug/NodePowerTools.csproj.FileListAbsolute.txt
@@ -11,3 +11,4 @@ C:\Users\justbe\Dropbox\Code\NodePowerTools\NodePowerTools\obj\Debug\NodePowerTo
C:\Users\justbe\Dropbox\Code\NodePowerTools\NodePowerTools\obj\Debug\NodePowerTools.g.resources
C:\Users\justbe\Dropbox\Code\NodePowerTools\NodePowerTools\obj\Debug\NodePowerTools.dll
C:\Users\justbe\Dropbox\Code\NodePowerTools\NodePowerTools\obj\Debug\NodePowerTools.pdb
+C:\Users\justbe\Dropbox\Code\NodePowerTools\NodePowerTools\obj\Debug\NodePowerTools.csprojResolveAssemblyReference.cache
View
BIN  NodePowerTools/obj/Debug/NodePowerTools.dll
Binary file not shown
View
BIN  NodePowerTools/obj/Debug/NodePowerTools.pdb
Binary file not shown
View
2  NodePowerTools/obj/Debug/NodePowerTools_MarkupCompile.cache
@@ -12,7 +12,7 @@ DEBUG;TRACE
11220583743
-4-954173909
+5-678810663
16-311245677
OutputWindow.xaml;
View
2  NodePowerTools/obj/Debug/NodePowerTools_MarkupCompile.i.cache
@@ -12,7 +12,7 @@ DEBUG;TRACE
11220583743
-574230856
+6349594102
16-311245677
OutputWindow.xaml;
Please sign in to comment.
Something went wrong with that request. Please try again.