13 changed files with 178 additions and 36 deletions
After Width: | Height: | Size: 1.5 KiB |
@ -0,0 +1,74 @@
@@ -0,0 +1,74 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Linq; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Gui.OptionPanels; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Project.Commands |
||||
{ |
||||
public class ViewInBrowser : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
var node = ProjectBrowserPad.Instance.SelectedNode as FileNode; |
||||
if (node == null) { |
||||
return; |
||||
} |
||||
|
||||
var project = ProjectService.CurrentProject as CompilableProject; |
||||
if (project == null) { |
||||
return; |
||||
} |
||||
|
||||
if (!project.IsWebProject) { |
||||
MessageService.ShowError("${res:ProjectComponent.ContextMenu.NotAWebProject}"); |
||||
return; |
||||
} |
||||
|
||||
if (!WebProjectService.IsIISInstalled) { |
||||
MessageService.ShowError("${res:ICSharpCode.WepProjectOptionsPanel.IISNotFound}"); |
||||
return; |
||||
} |
||||
|
||||
string fileName = node.FileName; |
||||
|
||||
// set project options
|
||||
project.StartAction = StartAction.StartURL; |
||||
string directoryName = Path.GetDirectoryName(project.FileName) + "\\"; |
||||
project.StartUrl = fileName.Replace(directoryName, "/").Replace("\\", "/"); |
||||
|
||||
// set web server options
|
||||
string projectName = project.Name; |
||||
var existingOptions = WebProjectsOptions.Instance.GetWebProjectOptions(projectName); |
||||
|
||||
var options = new WebProjectOptions { |
||||
Data = new WebProjectDebugData { |
||||
WebServer = WebProjectService.IISVersion == IISVersion.IISExpress ? WebServer.IISExpress : WebServer.IIS, |
||||
Port = (existingOptions != null && existingOptions.Data != null) ? existingOptions.Data.Port : "8080", //TODO: port collision detection
|
||||
ProjectUrl = string.Format("{0}/{1}", CompilableProject.LocalHost, project.Name) |
||||
}, |
||||
ProjectName = projectName |
||||
}; |
||||
|
||||
if (options.Data.WebServer == WebServer.IISExpress) { |
||||
options.Data.ProjectUrl = string.Format( |
||||
@"{0}:{1}/{2}", CompilableProject.LocalHost, options.Data.Port, projectName); |
||||
} |
||||
|
||||
WebProjectsOptions.Instance.SetWebProjectOptions(projectName, options); |
||||
|
||||
// create virtual directory
|
||||
string error = WebProjectService.CreateVirtualDirectory( |
||||
projectName, |
||||
Path.GetDirectoryName(ProjectService.CurrentProject.FileName)); |
||||
LoggingService.Info(error ?? string.Empty); |
||||
|
||||
// RunProject
|
||||
new RunProject().Run(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,32 @@
@@ -0,0 +1,32 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Linq; |
||||
|
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
|
||||
namespace ICSharpCode.SharpDevelop |
||||
{ |
||||
public class ViewInBrowserConditionEvaluator : IConditionEvaluator |
||||
{ |
||||
public bool IsValid(object caller, Condition condition) |
||||
{ |
||||
var node = ProjectBrowserPad.Instance.SelectedNode; |
||||
if (node == null) { |
||||
return false; |
||||
} |
||||
|
||||
string fileName = Path.GetFileName(node.FullPath); |
||||
|
||||
string[] extensions = condition["extensions"].Split(','); |
||||
if (!extensions.Any(e => fileName.EndsWith(e))) { |
||||
return false; |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
} |
||||
} |
Binary file not shown.
Loading…
Reference in new issue