Browse Source
Add ShellExecuteDisplayBinding: allows to launch files using the default program associated with them in SharpDevelop's "Open With" menu. git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2649 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
5 changed files with 49 additions and 6 deletions
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt"/>
|
||||
// <license see="prj:///doc/license.txt"/>
|
||||
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
|
||||
// <version>$Revision$</version>
|
||||
// </file>
|
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
using System.Diagnostics; |
||||
|
||||
namespace ICSharpCode.SharpDevelop |
||||
{ |
||||
/// <summary>
|
||||
/// Opens files with the default Windows application for them.
|
||||
/// </summary>
|
||||
public class ShellExecuteDisplayBinding : IDisplayBinding |
||||
{ |
||||
public bool CanCreateContentForFile(string fileName) |
||||
{ |
||||
return !FileUtility.IsUrl(fileName); |
||||
} |
||||
|
||||
public ICSharpCode.SharpDevelop.Gui.IViewContent CreateContentForFile(OpenedFile file) |
||||
{ |
||||
if (file.IsDirty) { |
||||
// TODO: warn user that the file must be saved
|
||||
} |
||||
try { |
||||
Process.Start(file.FileName); |
||||
} catch (Exception ex) { |
||||
MessageService.ShowError(ex.Message); |
||||
} |
||||
return null; |
||||
} |
||||
} |
||||
} |
||||
Loading…
Reference in new issue