Browse Source

Move IDisplayBinding and 'Open with' dialog to new folder structure.

newNRvisualizers
Daniel Grunwald 13 years ago
parent
commit
ad1dc15050
  1. 12
      src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditDisplayBinding.cs
  2. 6
      src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditDisplayBinding.cs
  3. 7
      src/AddIns/DisplayBindings/IconEditor/IconDisplayBinding.cs
  4. 4
      src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlDisplayBinding.cs
  5. 7
      src/AddIns/Misc/AddInManager/Project/Src/AddInInstallBinding.cs
  6. 15
      src/Main/Base/Project/ICSharpCode.SharpDevelop.addin
  7. 22
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  8. 5
      src/Main/Base/Project/Services/SD.cs
  9. 30
      src/Main/Base/Project/Src/Commands/FileCommands.cs
  10. 18
      src/Main/Base/Project/Src/Gui/BrowserDisplayBinding/BrowserDisplayBinding.cs
  11. 2
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/DefaultFileNodeCommands.cs
  12. 2
      src/Main/Base/Project/Workbench/DisplayBinding/DisplayBindingDescriptor.cs
  13. 9
      src/Main/Base/Project/Workbench/DisplayBinding/ExternalProcessDisplayBinding.cs
  14. 14
      src/Main/Base/Project/Workbench/DisplayBinding/IDisplayBinding.cs
  15. 46
      src/Main/Base/Project/Workbench/DisplayBinding/IDisplayBindingService.cs
  16. 3
      src/Main/Base/Project/Workbench/DisplayBinding/ISecondaryDisplayBinding.cs
  17. 5
      src/Main/Base/Project/Workbench/File/IFileService.cs
  18. 13
      src/Main/SharpDevelop/SharpDevelop.csproj
  19. 2
      src/Main/SharpDevelop/Workbench/DisplayBinding/AddOpenWithEntryDialog.Designer.cs
  20. 6
      src/Main/SharpDevelop/Workbench/DisplayBinding/AddOpenWithEntryDialog.cs
  21. 16
      src/Main/SharpDevelop/Workbench/DisplayBinding/AutoDetectDisplayBinding.cs
  22. 4
      src/Main/SharpDevelop/Workbench/DisplayBinding/DisplayBindingDoozer.cs
  23. 33
      src/Main/SharpDevelop/Workbench/DisplayBinding/DisplayBindingService.cs
  24. 2
      src/Main/SharpDevelop/Workbench/DisplayBinding/OpenWithDialog.Designer.cs
  25. 11
      src/Main/SharpDevelop/Workbench/DisplayBinding/OpenWithDialog.cs
  26. 11
      src/Main/SharpDevelop/Workbench/DisplayBinding/ShellExecuteDisplayBinding.cs
  27. 50
      src/Main/SharpDevelop/Workbench/FileService.cs
  28. 1
      src/Main/SharpDevelop/Workbench/WorkbenchStartup.cs

12
src/AddIns/DisplayBindings/AvalonEdit.AddIn/Src/AvalonEditDisplayBinding.cs

@ -31,7 +31,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
} }
public bool CanCreateContentForFile(string fileName) public bool CanCreateContentForFile(FileName fileName)
{ {
return true; return true;
} }
@ -41,7 +41,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
return new AvalonEditViewContent(file); return new AvalonEditViewContent(file);
} }
public bool IsPreferredBindingForFile(string fileName) public bool IsPreferredBindingForFile(FileName fileName)
{ {
string extension = Path.GetExtension(fileName); string extension = Path.GetExtension(fileName);
var fileFilter = ProjectService.GetFileFilters().FirstOrDefault(ff => ff.ContainsExtension(extension)); var fileFilter = ProjectService.GetFileFilters().FirstOrDefault(ff => ff.ContainsExtension(extension));
@ -49,7 +49,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
return fileFilter != null && fileFilter.MimeType.StartsWith("text/", StringComparison.OrdinalIgnoreCase); return fileFilter != null && fileFilter.MimeType.StartsWith("text/", StringComparison.OrdinalIgnoreCase);
} }
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType) public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{ {
return detectedMimeType.StartsWith("text/") ? 0.5 : 0; return detectedMimeType.StartsWith("text/") ? 0.5 : 0;
} }
@ -57,7 +57,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
public class ChooseEncodingDisplayBinding : IDisplayBinding public class ChooseEncodingDisplayBinding : IDisplayBinding
{ {
public bool CanCreateContentForFile(string fileName) public bool CanCreateContentForFile(FileName fileName)
{ {
return true; return true;
} }
@ -79,12 +79,12 @@ namespace ICSharpCode.AvalonEdit.AddIn
} }
} }
public bool IsPreferredBindingForFile(string fileName) public bool IsPreferredBindingForFile(FileName fileName)
{ {
return false; return false;
} }
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType) public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{ {
return double.NegativeInfinity; return double.NegativeInfinity;
} }

6
src/AddIns/DisplayBindings/HexEditor/Project/Src/View/HexEditDisplayBinding.cs

@ -13,17 +13,17 @@ namespace HexEditor.View
{ {
public class HexEditDisplayBinding : IDisplayBinding public class HexEditDisplayBinding : IDisplayBinding
{ {
public bool CanCreateContentForFile(string fileName) public bool CanCreateContentForFile(FileName fileName)
{ {
return true; return true;
} }
public bool IsPreferredBindingForFile(string fileName) public bool IsPreferredBindingForFile(FileName fileName)
{ {
return false; return false;
} }
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType) public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{ {
return 0.1; return 0.1;
} }

7
src/AddIns/DisplayBindings/IconEditor/IconDisplayBinding.cs

@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench; using ICSharpCode.SharpDevelop.Workbench;
@ -10,7 +11,7 @@ namespace ICSharpCode.IconEditor
{ {
public class IconDisplayBinding : IDisplayBinding public class IconDisplayBinding : IDisplayBinding
{ {
public bool CanCreateContentForFile(string fileName) public bool CanCreateContentForFile(FileName fileName)
{ {
return true; // definition in .addin does extension-based filtering return true; // definition in .addin does extension-based filtering
} }
@ -20,12 +21,12 @@ namespace ICSharpCode.IconEditor
return new IconViewContent(file); return new IconViewContent(file);
} }
public bool IsPreferredBindingForFile(string fileName) public bool IsPreferredBindingForFile(FileName fileName)
{ {
return true; return true;
} }
public double AutoDetectFileContent(string fileName, System.IO.Stream fileContent, string detectedMimeType) public double AutoDetectFileContent(FileName fileName, System.IO.Stream fileContent, string detectedMimeType)
{ {
return 1; return 1;
} }

4
src/AddIns/DisplayBindings/XmlEditor/Project/Src/XmlDisplayBinding.cs

@ -1,13 +1,15 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using ICSharpCode.SharpDevelop.Editor;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
using ICSharpCode.XmlEditor; using ICSharpCode.XmlEditor;
namespace ICSharpCode.XmlEditor namespace ICSharpCode.XmlEditor

7
src/AddIns/Misc/AddInManager/Project/Src/AddInInstallBinding.cs

@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Workbench; using ICSharpCode.SharpDevelop.Workbench;
@ -10,7 +11,7 @@ namespace ICSharpCode.AddInManager
#if !STANDALONE #if !STANDALONE
public class AddInInstallBinding : IDisplayBinding public class AddInInstallBinding : IDisplayBinding
{ {
public bool CanCreateContentForFile(string fileName) public bool CanCreateContentForFile(FileName fileName)
{ {
return true; return true;
} }
@ -22,12 +23,12 @@ namespace ICSharpCode.AddInManager
return null; return null;
} }
public bool IsPreferredBindingForFile(string fileName) public bool IsPreferredBindingForFile(FileName fileName)
{ {
return true; return true;
} }
public double AutoDetectFileContent(string fileName, System.IO.Stream fileContent, string detectedMimeType) public double AutoDetectFileContent(FileName fileName, System.IO.Stream fileContent, string detectedMimeType)
{ {
return 1; return 1;
} }

15
src/Main/Base/Project/ICSharpCode.SharpDevelop.addin

@ -37,7 +37,7 @@
<Doozer name="CustomTool" class="ICSharpCode.SharpDevelop.Project.CustomToolDoozer"/> <Doozer name="CustomTool" class="ICSharpCode.SharpDevelop.Project.CustomToolDoozer"/>
<Doozer name="CustomProperty" class="ICSharpCode.SharpDevelop.Project.CustomPropertyDoozer"/> <Doozer name="CustomProperty" class="ICSharpCode.SharpDevelop.Project.CustomPropertyDoozer"/>
<Doozer name="OptionPanel" class="ICSharpCode.SharpDevelop.OptionPanelDoozer"/> <Doozer name="OptionPanel" class="ICSharpCode.SharpDevelop.OptionPanelDoozer"/>
<Doozer name="DisplayBinding" class="ICSharpCode.SharpDevelop.DisplayBindingDoozer"/> <Doozer name="DisplayBinding" class="ICSharpCode.SharpDevelop.Workbench.DisplayBindingDoozer"/>
<Doozer name="Pad" class="ICSharpCode.SharpDevelop.PadDoozer"/> <Doozer name="Pad" class="ICSharpCode.SharpDevelop.PadDoozer"/>
<Doozer name="ProjectBinding" class="ICSharpCode.SharpDevelop.ProjectBindingDoozer"/> <Doozer name="ProjectBinding" class="ICSharpCode.SharpDevelop.ProjectBindingDoozer"/>
<Doozer name="LanguageBinding" class="ICSharpCode.SharpDevelop.LanguageBindingDoozer"/> <Doozer name="LanguageBinding" class="ICSharpCode.SharpDevelop.LanguageBindingDoozer"/>
@ -64,6 +64,8 @@
class="ICSharpCode.SharpDevelop.Workbench.FileService"/> class="ICSharpCode.SharpDevelop.Workbench.FileService"/>
<Service id="ICSharpCode.SharpDevelop.Workbench.IShutdownService" <Service id="ICSharpCode.SharpDevelop.Workbench.IShutdownService"
class="ICSharpCode.SharpDevelop.Workbench.ShutdownService"/> class="ICSharpCode.SharpDevelop.Workbench.ShutdownService"/>
<Service id="ICSharpCode.SharpDevelop.Workbench.IDisplayBindingService"
class="ICSharpCode.SharpDevelop.Workbench.DisplayBindingService"/>
<Service id="ICSharpCode.SharpDevelop.Dom.ITreeNodeFactory" <Service id="ICSharpCode.SharpDevelop.Dom.ITreeNodeFactory"
class="ICSharpCode.SharpDevelop.Dom.TreeNodeFactoryService"/> class="ICSharpCode.SharpDevelop.Dom.TreeNodeFactoryService"/>
<Service id="ICSharpCode.SharpDevelop.Dom.IModelFactory" <Service id="ICSharpCode.SharpDevelop.Dom.IModelFactory"
@ -92,7 +94,10 @@
class = "ICSharpCode.SharpDevelop.BrowserDisplayBinding.BrowserDisplayBinding"/> class = "ICSharpCode.SharpDevelop.BrowserDisplayBinding.BrowserDisplayBinding"/>
<DisplayBinding id = "AutoDetect" <DisplayBinding id = "AutoDetect"
title = "Auto-detect file type" title = "Auto-detect file type"
class = "ICSharpCode.SharpDevelop.AutoDetectDisplayBinding"/> class = "ICSharpCode.SharpDevelop.Workbench.AutoDetectDisplayBinding"/>
<DisplayBinding id = "ShellExecute"
title = "${res:Gui.ProjectBrowser.OpenWith.Bindings.DefaultWindowsApplication}"
class = "ICSharpCode.SharpDevelop.Workbench.ShellExecuteDisplayBinding" />
</Path> </Path>
<Path name = "/SharpDevelop/Workbench/FileFilter"> <Path name = "/SharpDevelop/Workbench/FileFilter">
@ -1940,12 +1945,6 @@
<!-- TEXT EDITOR --> <!-- TEXT EDITOR -->
<Path name = "/SharpDevelop/Workbench/DisplayBindings">
<DisplayBinding id = "ShellExecute"
title = "${res:Gui.ProjectBrowser.OpenWith.Bindings.DefaultWindowsApplication}"
class = "ICSharpCode.SharpDevelop.ShellExecuteDisplayBinding" />
</Path>
<Path name = "/SharpDevelop/ViewContent/TextEditor/EntityContextMenu"> <Path name = "/SharpDevelop/ViewContent/TextEditor/EntityContextMenu">
<MenuItem id = "FindReferences" <MenuItem id = "FindReferences"
label = "${res:SharpDevelop.Refactoring.FindReferencesCommand}" label = "${res:SharpDevelop.Refactoring.FindReferencesCommand}"

22
src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj

@ -214,10 +214,6 @@
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Src\Gui\CustomFocusManager.cs" /> <Compile Include="Src\Gui\CustomFocusManager.cs" />
<Compile Include="Src\Gui\Dialogs\AddOpenWithEntryDialog.cs" />
<Compile Include="Src\Gui\Dialogs\AddOpenWithEntryDialog.Designer.cs">
<DependentUpon>AddOpenWithEntryDialog.cs</DependentUpon>
</Compile>
<Compile Include="Src\Gui\Dialogs\AsynchronousWaitDialog.cs" /> <Compile Include="Src\Gui\Dialogs\AsynchronousWaitDialog.cs" />
<Compile Include="Src\Gui\Dialogs\AsynchronousWaitDialog.Designer.cs"> <Compile Include="Src\Gui\Dialogs\AsynchronousWaitDialog.Designer.cs">
<DependentUpon>AsynchronousWaitDialog.cs</DependentUpon> <DependentUpon>AsynchronousWaitDialog.cs</DependentUpon>
@ -267,6 +263,11 @@
<Compile Include="Workbench\AbstractViewContent.cs" /> <Compile Include="Workbench\AbstractViewContent.cs" />
<Compile Include="Workbench\AbstractViewContentHandlingLoadErrors.cs" /> <Compile Include="Workbench\AbstractViewContentHandlingLoadErrors.cs" />
<Compile Include="Workbench\AbstractViewContentWithoutFile.cs" /> <Compile Include="Workbench\AbstractViewContentWithoutFile.cs" />
<Compile Include="Workbench\DisplayBinding\DisplayBindingDescriptor.cs" />
<Compile Include="Workbench\DisplayBinding\ExternalProcessDisplayBinding.cs" />
<Compile Include="Workbench\DisplayBinding\IDisplayBinding.cs" />
<Compile Include="Workbench\DisplayBinding\IDisplayBindingService.cs" />
<Compile Include="Workbench\DisplayBinding\ISecondaryDisplayBinding.cs" />
<Compile Include="Workbench\FakeXmlViewContent.cs" /> <Compile Include="Workbench\FakeXmlViewContent.cs" />
<Compile Include="Workbench\File\FileService.cs" /> <Compile Include="Workbench\File\FileService.cs" />
<Compile Include="Workbench\File\IRecentOpen.cs" /> <Compile Include="Workbench\File\IRecentOpen.cs" />
@ -291,10 +292,6 @@
<Compile Include="Src\Gui\Dialogs\NewProjectDialog.Designer.cs"> <Compile Include="Src\Gui\Dialogs\NewProjectDialog.Designer.cs">
<DependentUpon>NewProjectDialog.cs</DependentUpon> <DependentUpon>NewProjectDialog.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Src\Gui\Dialogs\OpenWithDialog.cs" />
<Compile Include="Src\Gui\Dialogs\OpenWithDialog.Designer.cs">
<DependentUpon>OpenWithDialog.cs</DependentUpon>
</Compile>
<Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\CodeGenerationPanel.xaml.cs"> <Compile Include="Src\Gui\Dialogs\OptionPanels\IDEOptions\CodeGenerationPanel.xaml.cs">
<DependentUpon>CodeGenerationPanel.xaml</DependentUpon> <DependentUpon>CodeGenerationPanel.xaml</DependentUpon>
<SubType>Code</SubType> <SubType>Code</SubType>
@ -484,10 +481,6 @@
<Compile Include="Src\Services\Debugger\BreakpointBookmark.cs" /> <Compile Include="Src\Services\Debugger\BreakpointBookmark.cs" />
<Compile Include="Src\Services\Debugger\BreakpointBookmarkEventArgs.cs" /> <Compile Include="Src\Services\Debugger\BreakpointBookmarkEventArgs.cs" />
<Compile Include="Src\Services\Debugger\DecompiledBreakpointBookmark.cs" /> <Compile Include="Src\Services\Debugger\DecompiledBreakpointBookmark.cs" />
<Compile Include="Src\Services\DisplayBinding\AutoDetectDisplayBinding.cs" />
<Compile Include="Src\Services\DisplayBinding\ExternalProcessDisplayBinding.cs" />
<Compile Include="Src\Services\DisplayBinding\ISecondaryDisplayBinding.cs" />
<Compile Include="Src\Services\DisplayBinding\ShellExecuteDisplayBinding.cs" />
<Compile Include="Workbench\File\IFileService.cs" /> <Compile Include="Workbench\File\IFileService.cs" />
<Compile Include="Workbench\File\OpenedFile.cs" /> <Compile Include="Workbench\File\OpenedFile.cs" />
<Compile Include="Src\Services\LanguageBinding\AggregatedLanguageBinding.cs" /> <Compile Include="Src\Services\LanguageBinding\AggregatedLanguageBinding.cs" />
@ -510,16 +503,13 @@
<Compile Include="Src\Services\Tasks\TagComment.cs" /> <Compile Include="Src\Services\Tasks\TagComment.cs" />
<Compile Include="Src\Services\Tasks\Task.cs" /> <Compile Include="Src\Services\Tasks\Task.cs" />
<Compile Include="Src\Services\Tasks\TaskService.cs" /> <Compile Include="Src\Services\Tasks\TaskService.cs" />
<Compile Include="Src\Services\DisplayBinding\IDisplayBinding.cs" />
<Compile Include="Src\Internal\ExternalTool\ToolLoader.cs" /> <Compile Include="Src\Internal\ExternalTool\ToolLoader.cs" />
<Compile Include="Src\Services\ProjectBinding\IProjectBinding.cs" /> <Compile Include="Src\Services\ProjectBinding\IProjectBinding.cs" />
<Compile Include="Src\Internal\Templates\Project\ProjectCreateInformation.cs" /> <Compile Include="Src\Internal\Templates\Project\ProjectCreateInformation.cs" />
<Compile Include="Src\Services\ProjectBinding\ProjectBindingService.cs" /> <Compile Include="Src\Services\ProjectBinding\ProjectBindingService.cs" />
<Compile Include="Src\Services\DisplayBinding\DisplayBindingDoozer.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\CombineOpenEvaluator.cs" /> <Compile Include="Src\Internal\ConditionEvaluators\CombineOpenEvaluator.cs" />
<Compile Include="Src\Services\ProjectBinding\ProjectBindingDoozer.cs" /> <Compile Include="Src\Services\ProjectBinding\ProjectBindingDoozer.cs" />
<Compile Include="Src\Services\Language\Language.cs" /> <Compile Include="Src\Services\Language\Language.cs" />
<Compile Include="Src\Services\DisplayBinding\DisplayBindingService.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\ProjectActiveEvaluator.cs" /> <Compile Include="Src\Internal\ConditionEvaluators\ProjectActiveEvaluator.cs" />
<Compile Include="Src\Services\AmbienceService\AmbienceService.cs" /> <Compile Include="Src\Services\AmbienceService\AmbienceService.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\WindowOpenEvaluator.cs" /> <Compile Include="Src\Internal\ConditionEvaluators\WindowOpenEvaluator.cs" />
@ -666,7 +656,6 @@
<Compile Include="Src\Gui\Dialogs\ProjectOptionsView.cs" /> <Compile Include="Src\Gui\Dialogs\ProjectOptionsView.cs" />
<Compile Include="Src\Gui\Pads\ProjectBrowser\Commands\ToolbarCommands.cs" /> <Compile Include="Src\Gui\Pads\ProjectBrowser\Commands\ToolbarCommands.cs" />
<Compile Include="Src\Services\ProjectBinding\ProjectBindingDescriptor.cs" /> <Compile Include="Src\Services\ProjectBinding\ProjectBindingDescriptor.cs" />
<Compile Include="Src\Services\DisplayBinding\DisplayBindingDescriptor.cs" />
<Compile Include="Src\Gui\XmlForms\Lib\IPropertyValueCreator.cs" /> <Compile Include="Src\Gui\XmlForms\Lib\IPropertyValueCreator.cs" />
<Compile Include="Src\Gui\XmlForms\Lib\IStringValueFilter.cs" /> <Compile Include="Src\Gui\XmlForms\Lib\IStringValueFilter.cs" />
<Compile Include="Src\Gui\XmlForms\Lib\StringWrapper.cs" /> <Compile Include="Src\Gui\XmlForms\Lib\StringWrapper.cs" />
@ -822,6 +811,7 @@
</EmbeddedResource> </EmbeddedResource>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Folder Include="Workbench\DisplayBinding" />
<Page Include="Editor\Bookmarks\BookmarkPadContent.xaml" /> <Page Include="Editor\Bookmarks\BookmarkPadContent.xaml" />
<Page Include="Src\Gui\Components\StringListEditorDialog.xaml" /> <Page Include="Src\Gui\Components\StringListEditorDialog.xaml" />
<Page Include="Src\Gui\Components\StringListEditorXaml.xaml" /> <Page Include="Src\Gui\Components\StringListEditorXaml.xaml" />

5
src/Main/Base/Project/Services/SD.cs

@ -200,5 +200,10 @@ namespace ICSharpCode.SharpDevelop
public static IBookmarkManager BookmarkManager { public static IBookmarkManager BookmarkManager {
get { return GetRequiredService<IBookmarkManager>(); } get { return GetRequiredService<IBookmarkManager>(); }
} }
/// <inheritdoc see="IDisplayBindingService"/>
public static IDisplayBindingService DisplayBindingService {
get { return GetRequiredService<IDisplayBindingService>(); }
}
} }
} }

30
src/Main/Base/Project/Src/Commands/FileCommands.cs

@ -266,35 +266,7 @@ namespace ICSharpCode.SharpDevelop.Commands
{ {
protected override void OpenFiles(FileName[] fileNames) protected override void OpenFiles(FileName[] fileNames)
{ {
OpenFilesWith(fileNames); SD.FileService.ShowOpenWithDialog(fileNames);
}
/// <summary>
/// Shows the OpenWith dialog for the specified files.
/// </summary>
public static void OpenFilesWith(FileName[] fileNames)
{
if (fileNames.Length == 0)
return;
List<DisplayBindingDescriptor> codons = DisplayBindingService.GetCodonsPerFileName(fileNames[0]).ToList();
for (int i = 1; i < fileNames.Length; i++) {
var codonsForThisFile = DisplayBindingService.GetCodonsPerFileName(fileNames[i]);
codons.RemoveAll(c => !codonsForThisFile.Contains(c));
}
if (codons.Count == 0)
return;
int defaultCodonIndex = codons.IndexOf(DisplayBindingService.GetDefaultCodonPerFileName(fileNames[0]));
if (defaultCodonIndex < 0)
defaultCodonIndex = 0;
using (OpenWithDialog dlg = new OpenWithDialog(codons, defaultCodonIndex, Path.GetExtension(fileNames[0]))) {
if (dlg.ShowDialog(SD.WinForms.MainWin32Window) == DialogResult.OK) {
foreach (var fileName in fileNames) {
SD.FileService.OpenFileWith(fileName, dlg.SelectedBinding.Binding, true);
}
}
}
} }
} }

18
src/Main/Base/Project/Src/Gui/BrowserDisplayBinding/BrowserDisplayBinding.cs

@ -2,6 +2,7 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench; using ICSharpCode.SharpDevelop.Workbench;
@ -9,12 +10,13 @@ namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding
{ {
public class BrowserDisplayBinding : IDisplayBinding public class BrowserDisplayBinding : IDisplayBinding
{ {
public bool CanCreateContentForFile(string fileName) public bool CanCreateContentForFile(FileName fileName)
{ {
return fileName.StartsWith("http:") string fileNameStr = fileName;
|| fileName.StartsWith("https:") return fileNameStr.StartsWith("http:", StringComparison.OrdinalIgnoreCase)
|| fileName.StartsWith("ftp:") || fileNameStr.StartsWith("https:", StringComparison.OrdinalIgnoreCase)
|| fileName.StartsWith("browser:"); || fileNameStr.StartsWith("ftp:", StringComparison.OrdinalIgnoreCase)
|| fileNameStr.StartsWith("browser:", StringComparison.OrdinalIgnoreCase);
} }
public IViewContent CreateContentForFile(OpenedFile file) public IViewContent CreateContentForFile(OpenedFile file)
@ -22,7 +24,7 @@ namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding
string fileName = file.FileName; string fileName = file.FileName;
BrowserPane browserPane = new BrowserPane(); BrowserPane browserPane = new BrowserPane();
if (fileName.StartsWith("browser://")) { if (fileName.StartsWith("browser://", StringComparison.OrdinalIgnoreCase)) {
browserPane.Navigate(fileName.Substring("browser://".Length)); browserPane.Navigate(fileName.Substring("browser://".Length));
} else { } else {
browserPane.Navigate(fileName); browserPane.Navigate(fileName);
@ -30,12 +32,12 @@ namespace ICSharpCode.SharpDevelop.BrowserDisplayBinding
return browserPane; return browserPane;
} }
public bool IsPreferredBindingForFile(string fileName) public bool IsPreferredBindingForFile(FileName fileName)
{ {
return CanCreateContentForFile(fileName); return CanCreateContentForFile(fileName);
} }
public double AutoDetectFileContent(string fileName, System.IO.Stream fileContent, string detectedMimeType) public double AutoDetectFileContent(FileName fileName, System.IO.Stream fileContent, string detectedMimeType)
{ {
return 1; return 1;
} }

2
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/DefaultFileNodeCommands.cs

@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
/// </summary> /// </summary>
static void OpenWith(string fileName) static void OpenWith(string fileName)
{ {
ICSharpCode.SharpDevelop.Commands.OpenFileWith.OpenFilesWith(new [] { FileName.Create(fileName) }); SD.FileService.ShowOpenWithDialog(new [] { FileName.Create(fileName) });
} }
} }

2
src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingDescriptor.cs → src/Main/Base/Project/Workbench/DisplayBinding/DisplayBindingDescriptor.cs

@ -5,7 +5,7 @@ using System;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using ICSharpCode.Core; using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Workbench
{ {
public class DisplayBindingDescriptor public class DisplayBindingDescriptor
{ {

9
src/Main/Base/Project/Src/Services/DisplayBinding/ExternalProcessDisplayBinding.cs → src/Main/Base/Project/Workbench/DisplayBinding/ExternalProcessDisplayBinding.cs

@ -7,9 +7,8 @@ using System.Diagnostics;
using System.IO; using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Workbench
{ {
/// <summary> /// <summary>
/// Display binding for opening a file in an external process. /// Display binding for opening a file in an external process.
@ -22,7 +21,7 @@ namespace ICSharpCode.SharpDevelop
public string Title { get; set; } public string Title { get; set; }
public string Id { get; set; } public string Id { get; set; }
public bool CanCreateContentForFile(string fileName) public bool CanCreateContentForFile(FileName fileName)
{ {
return string.Equals(Path.GetExtension(fileName), FileExtension, StringComparison.OrdinalIgnoreCase); return string.Equals(Path.GetExtension(fileName), FileExtension, StringComparison.OrdinalIgnoreCase);
} }
@ -64,12 +63,12 @@ namespace ICSharpCode.SharpDevelop
Process.Start(info); Process.Start(info);
} }
public bool IsPreferredBindingForFile(string fileName) public bool IsPreferredBindingForFile(FileName fileName)
{ {
return false; return false;
} }
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType) public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{ {
return double.NegativeInfinity; return double.NegativeInfinity;
} }

14
src/Main/Base/Project/Src/Services/DisplayBinding/IDisplayBinding.cs → src/Main/Base/Project/Workbench/DisplayBinding/IDisplayBinding.cs

@ -4,12 +4,10 @@
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Workbench
{ {
/// <summary> /// <summary>
/// This class defines the SharpDevelop display binding interface, it is a factory /// This class defines the SharpDevelop display binding interface, it is a factory
@ -17,7 +15,7 @@ namespace ICSharpCode.SharpDevelop
/// </summary> /// </summary>
public interface IDisplayBinding public interface IDisplayBinding
{ {
bool IsPreferredBindingForFile(string fileName); bool IsPreferredBindingForFile(FileName fileName);
/// <remarks> /// <remarks>
/// This function determines, if this display binding is able to create /// This function determines, if this display binding is able to create
@ -28,9 +26,9 @@ namespace ICSharpCode.SharpDevelop
/// an IViewContent for the file given by fileName. /// an IViewContent for the file given by fileName.
/// false otherwise /// false otherwise
/// </returns> /// </returns>
bool CanCreateContentForFile(string fileName); bool CanCreateContentForFile(FileName fileName);
double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType); double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType);
/// <remarks> /// <remarks>
/// Creates a new IViewContent object for the file fileName /// Creates a new IViewContent object for the file fileName
@ -40,6 +38,4 @@ namespace ICSharpCode.SharpDevelop
/// </returns> /// </returns>
IViewContent CreateContentForFile(OpenedFile file); IViewContent CreateContentForFile(OpenedFile file);
} }
} }

46
src/Main/Base/Project/Workbench/DisplayBinding/IDisplayBindingService.cs

@ -0,0 +1,46 @@
// 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.Collections.Generic;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Workbench
{
/// <summary>
/// Manages the list of display bindings, and the user's default settings (for Open With dialog)
/// </summary>
[SDService]
public interface IDisplayBindingService
{
/// <summary>
/// Attach secondary view contents to the view content.
/// </summary>
/// <param name="viewContent">The view content to attach to</param>
/// <param name="isReattaching">This is a reattaching pass</param>
void AttachSubWindows(IViewContent viewContent, bool isReattaching);
/// <summary>
/// Gets the primary display binding for the specified file name.
/// </summary>
IDisplayBinding GetBindingPerFileName(FileName filename);
/// <summary>
/// Gets the default primary display binding for the specified file name.
/// </summary>
DisplayBindingDescriptor GetDefaultCodonPerFileName(FileName filename);
/// <summary>
/// Sets the default display binding for the specified file extension.
/// </summary>
void SetDefaultCodon(string extension, DisplayBindingDescriptor bindingDescriptor);
/// <summary>
/// Gets list of possible primary display bindings for the specified file name.
/// </summary>
IReadOnlyList<DisplayBindingDescriptor> GetCodonsPerFileName(FileName filename);
DisplayBindingDescriptor AddExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding);
void RemoveExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding);
}
}

3
src/Main/Base/Project/Src/Services/DisplayBinding/ISecondaryDisplayBinding.cs → src/Main/Base/Project/Workbench/DisplayBinding/ISecondaryDisplayBinding.cs

@ -2,9 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System; using System;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Workbench
{ {
/// <summary> /// <summary>
/// This class defines the SharpDevelop display binding interface, it is a factory /// This class defines the SharpDevelop display binding interface, it is a factory

5
src/Main/Base/Project/Workbench/File/IFileService.cs

@ -162,6 +162,11 @@ namespace ICSharpCode.SharpDevelop.Workbench
/// <returns>The existing or opened <see cref="IViewContent"/> for the specified file.</returns> /// <returns>The existing or opened <see cref="IViewContent"/> for the specified file.</returns>
IViewContent OpenFileWith(FileName fileName, IDisplayBinding displayBinding, bool switchToOpenedView = true); IViewContent OpenFileWith(FileName fileName, IDisplayBinding displayBinding, bool switchToOpenedView = true);
/// <summary>
/// Shows the 'Open With' dialog, allowing the user to pick a display binding for opening the specified files.
/// </summary>
IEnumerable<IViewContent> ShowOpenWithDialog(IEnumerable<FileName> fileNames, bool switchToOpenedView = true);
/// <summary> /// <summary>
/// Opens a new unsaved file. /// Opens a new unsaved file.
/// </summary> /// </summary>

13
src/Main/SharpDevelop/SharpDevelop.csproj

@ -114,6 +114,18 @@
<Compile Include="Workbench\AvalonPadContent.cs" /> <Compile Include="Workbench\AvalonPadContent.cs" />
<Compile Include="Workbench\AvalonWorkbenchWindow.cs" /> <Compile Include="Workbench\AvalonWorkbenchWindow.cs" />
<Compile Include="Workbench\ChooseLayoutComboBox.cs" /> <Compile Include="Workbench\ChooseLayoutComboBox.cs" />
<Compile Include="Workbench\DisplayBinding\AddOpenWithEntryDialog.cs" />
<Compile Include="Workbench\DisplayBinding\AddOpenWithEntryDialog.Designer.cs">
<DependentUpon>AddOpenWithEntryDialog.cs</DependentUpon>
</Compile>
<Compile Include="Workbench\DisplayBinding\AutoDetectDisplayBinding.cs" />
<Compile Include="Workbench\DisplayBinding\DisplayBindingDoozer.cs" />
<Compile Include="Workbench\DisplayBinding\DisplayBindingService.cs" />
<Compile Include="Workbench\DisplayBinding\OpenWithDialog.cs" />
<Compile Include="Workbench\DisplayBinding\OpenWithDialog.Designer.cs">
<DependentUpon>OpenWithDialog.cs</DependentUpon>
</Compile>
<Compile Include="Workbench\DisplayBinding\ShellExecuteDisplayBinding.cs" />
<Compile Include="Workbench\FileService.cs" /> <Compile Include="Workbench\FileService.cs" />
<Compile Include="Workbench\FileServiceOpenedFile.cs" /> <Compile Include="Workbench\FileServiceOpenedFile.cs" />
<Compile Include="Workbench\FullScreenEnabledWindow.cs" /> <Compile Include="Workbench\FullScreenEnabledWindow.cs" />
@ -237,6 +249,7 @@
<Folder Include="Logging" /> <Folder Include="Logging" />
<Folder Include="Parser" /> <Folder Include="Parser" />
<Folder Include="Sda" /> <Folder Include="Sda" />
<Folder Include="Workbench\DisplayBinding" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Page Include="OptionPanels\LoadSaveOptions.xaml" /> <Page Include="OptionPanels\LoadSaveOptions.xaml" />

2
src/Main/Base/Project/Src/Gui/Dialogs/AddOpenWithEntryDialog.Designer.cs → src/Main/SharpDevelop/Workbench/DisplayBinding/AddOpenWithEntryDialog.Designer.cs generated

@ -1,7 +1,7 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Workbench
{ {
partial class AddOpenWithEntryDialog partial class AddOpenWithEntryDialog
{ {

6
src/Main/Base/Project/Src/Gui/Dialogs/AddOpenWithEntryDialog.cs → src/Main/SharpDevelop/Workbench/DisplayBinding/AddOpenWithEntryDialog.cs

@ -7,12 +7,12 @@ using System.Windows.Forms;
using System.IO; using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Workbench
{ {
/// <summary> /// <summary>
/// This dialog is used to add a new program to the open with dialog. /// This dialog is used to add a new program to the open with dialog.
/// </summary> /// </summary>
public partial class AddOpenWithEntryDialog : Form partial class AddOpenWithEntryDialog : Form
{ {
public AddOpenWithEntryDialog() public AddOpenWithEntryDialog()
{ {
@ -42,7 +42,7 @@ namespace ICSharpCode.SharpDevelop.Gui
void BrowseForProgramButtonClick(object sender, EventArgs e) void BrowseForProgramButtonClick(object sender, EventArgs e)
{ {
using (OpenFileDialog dlg = new OpenFileDialog()) { using (OpenFileDialog dlg = new OpenFileDialog()) {
dlg.Filter = StringParser.Parse(OptionPanels.ExternalToolPane.ExecutableFilesFilter); dlg.Filter = StringParser.Parse(Gui.OptionPanels.ExternalToolPane.ExecutableFilesFilter);
if (dlg.ShowDialog(this) == DialogResult.OK) { if (dlg.ShowDialog(this) == DialogResult.OK) {
programNameTextBox.Text = "\"" + dlg.FileName + "\""; programNameTextBox.Text = "\"" + dlg.FileName + "\"";
if (!userEditedDisplayName) { if (!userEditedDisplayName) {

16
src/Main/Base/Project/Src/Services/DisplayBinding/AutoDetectDisplayBinding.cs → src/Main/SharpDevelop/Workbench/DisplayBinding/AutoDetectDisplayBinding.cs

@ -5,35 +5,33 @@ using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui; namespace ICSharpCode.SharpDevelop.Workbench
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.SharpDevelop
{ {
/// <summary> /// <summary>
/// Implements content auto detection and opens the appropriate IViewContent. /// Implements content auto detection and opens the appropriate IViewContent.
/// </summary> /// </summary>
public sealed class AutoDetectDisplayBinding : IDisplayBinding sealed class AutoDetectDisplayBinding : IDisplayBinding
{ {
public bool IsPreferredBindingForFile(string fileName) public bool IsPreferredBindingForFile(FileName fileName)
{ {
return false; return false;
} }
public bool CanCreateContentForFile(string fileName) public bool CanCreateContentForFile(FileName fileName)
{ {
return true; return true;
} }
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType) public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{ {
return double.NegativeInfinity; return double.NegativeInfinity;
} }
public IViewContent CreateContentForFile(OpenedFile file) public IViewContent CreateContentForFile(OpenedFile file)
{ {
var codons = DisplayBindingService.GetCodonsPerFileName(file.FileName); var codons = SD.DisplayBindingService.GetCodonsPerFileName(file.FileName);
DisplayBindingDescriptor bestMatch = null; DisplayBindingDescriptor bestMatch = null;
double max = double.NegativeInfinity; double max = double.NegativeInfinity;
const int BUFFER_LENGTH = 4 * 1024; const int BUFFER_LENGTH = 4 * 1024;

4
src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingDoozer.cs → src/Main/SharpDevelop/Workbench/DisplayBinding/DisplayBindingDoozer.cs

@ -5,7 +5,7 @@ using System;
using System.Collections; using System.Collections;
using ICSharpCode.Core; using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Workbench
{ {
/// <summary> /// <summary>
/// Creates DisplayBindingDescriptor objects. /// Creates DisplayBindingDescriptor objects.
@ -49,7 +49,7 @@ namespace ICSharpCode.SharpDevelop
/// fileNamePattern = "\.(cs|vb)$" /&gt; /// fileNamePattern = "\.(cs|vb)$" /&gt;
/// &lt;/Path&gt; /// &lt;/Path&gt;
/// </example> /// </example>
public class DisplayBindingDoozer : IDoozer sealed class DisplayBindingDoozer : IDoozer
{ {
/// <summary> /// <summary>
/// Gets if the doozer handles codon conditions on its own. /// Gets if the doozer handles codon conditions on its own.

33
src/Main/Base/Project/Src/Services/DisplayBinding/DisplayBindingService.cs → src/Main/SharpDevelop/Workbench/DisplayBinding/DisplayBindingService.cs

@ -5,24 +5,23 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Workbench
{ {
/// <summary> /// <summary>
/// This class handles the installed display bindings /// This class handles the installed display bindings
/// and provides a simple access point to these bindings. /// and provides a simple access point to these bindings.
/// </summary> /// </summary>
public static class DisplayBindingService sealed class DisplayBindingService : IDisplayBindingService
{ {
const string displayBindingPath = "/SharpDevelop/Workbench/DisplayBindings"; const string displayBindingPath = "/SharpDevelop/Workbench/DisplayBindings";
static Properties displayBindingServiceProperties; Properties displayBindingServiceProperties;
static List<DisplayBindingDescriptor> bindings; List<DisplayBindingDescriptor> bindings;
static List<ExternalProcessDisplayBinding> externalProcessDisplayBindings = new List<ExternalProcessDisplayBinding>(); List<ExternalProcessDisplayBinding> externalProcessDisplayBindings = new List<ExternalProcessDisplayBinding>();
internal static void InitializeService() public DisplayBindingService()
{ {
bindings = AddInTree.BuildItems<DisplayBindingDescriptor>(displayBindingPath, null, true); bindings = AddInTree.BuildItems<DisplayBindingDescriptor>(displayBindingPath, null, true);
displayBindingServiceProperties = PropertyService.NestedProperties("DisplayBindingService"); displayBindingServiceProperties = PropertyService.NestedProperties("DisplayBindingService");
@ -33,7 +32,7 @@ namespace ICSharpCode.SharpDevelop
} }
} }
public static DisplayBindingDescriptor AddExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding) public DisplayBindingDescriptor AddExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding)
{ {
SD.MainThread.VerifyAccess(); SD.MainThread.VerifyAccess();
if (binding == null) if (binding == null)
@ -43,12 +42,12 @@ namespace ICSharpCode.SharpDevelop
return descriptor; return descriptor;
} }
static void SaveExternalProcessDisplayBindings() void SaveExternalProcessDisplayBindings()
{ {
displayBindingServiceProperties.SetList("ExternalProcesses", externalProcessDisplayBindings); displayBindingServiceProperties.SetList("ExternalProcesses", externalProcessDisplayBindings);
} }
static DisplayBindingDescriptor AddExternalProcessDisplayBindingInternal(ExternalProcessDisplayBinding binding) DisplayBindingDescriptor AddExternalProcessDisplayBindingInternal(ExternalProcessDisplayBinding binding)
{ {
externalProcessDisplayBindings.Add(binding); externalProcessDisplayBindings.Add(binding);
DisplayBindingDescriptor descriptor = new DisplayBindingDescriptor(binding) { DisplayBindingDescriptor descriptor = new DisplayBindingDescriptor(binding) {
@ -59,7 +58,7 @@ namespace ICSharpCode.SharpDevelop
return descriptor; return descriptor;
} }
public static void RemoveExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding) public void RemoveExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding)
{ {
SD.MainThread.VerifyAccess(); SD.MainThread.VerifyAccess();
if (binding == null) if (binding == null)
@ -79,7 +78,7 @@ namespace ICSharpCode.SharpDevelop
/// <summary> /// <summary>
/// Gets the primary display binding for the specified file name. /// Gets the primary display binding for the specified file name.
/// </summary> /// </summary>
public static IDisplayBinding GetBindingPerFileName(string filename) public IDisplayBinding GetBindingPerFileName(FileName filename)
{ {
SD.MainThread.VerifyAccess(); SD.MainThread.VerifyAccess();
if (FileUtility.IsUrl(filename)) { if (FileUtility.IsUrl(filename)) {
@ -94,7 +93,7 @@ namespace ICSharpCode.SharpDevelop
/// <summary> /// <summary>
/// Gets the default primary display binding for the specified file name. /// Gets the default primary display binding for the specified file name.
/// </summary> /// </summary>
public static DisplayBindingDescriptor GetDefaultCodonPerFileName(string filename) public DisplayBindingDescriptor GetDefaultCodonPerFileName(FileName filename)
{ {
SD.MainThread.VerifyAccess(); SD.MainThread.VerifyAccess();
@ -120,7 +119,7 @@ namespace ICSharpCode.SharpDevelop
return autoDetectDescriptor; return autoDetectDescriptor;
} }
public static void SetDefaultCodon(string extension, DisplayBindingDescriptor bindingDescriptor) public void SetDefaultCodon(string extension, DisplayBindingDescriptor bindingDescriptor)
{ {
SD.MainThread.VerifyAccess(); SD.MainThread.VerifyAccess();
if (bindingDescriptor == null) if (bindingDescriptor == null)
@ -136,7 +135,7 @@ namespace ICSharpCode.SharpDevelop
/// <summary> /// <summary>
/// Gets list of possible primary display bindings for the specified file name. /// Gets list of possible primary display bindings for the specified file name.
/// </summary> /// </summary>
public static IList<DisplayBindingDescriptor> GetCodonsPerFileName(string filename) public IReadOnlyList<DisplayBindingDescriptor> GetCodonsPerFileName(FileName filename)
{ {
SD.MainThread.VerifyAccess(); SD.MainThread.VerifyAccess();
@ -149,7 +148,7 @@ namespace ICSharpCode.SharpDevelop
return list; return list;
} }
static bool IsPrimaryBindingValidForFileName(DisplayBindingDescriptor binding, string filename) static bool IsPrimaryBindingValidForFileName(DisplayBindingDescriptor binding, FileName filename)
{ {
if (!binding.IsSecondary && binding.CanOpenFile(filename)) { if (!binding.IsSecondary && binding.CanOpenFile(filename)) {
if (binding.Binding != null && binding.Binding.CanCreateContentForFile(filename)) { if (binding.Binding != null && binding.Binding.CanCreateContentForFile(filename)) {
@ -164,7 +163,7 @@ namespace ICSharpCode.SharpDevelop
/// </summary> /// </summary>
/// <param name="viewContent">The view content to attach to</param> /// <param name="viewContent">The view content to attach to</param>
/// <param name="isReattaching">This is a reattaching pass</param> /// <param name="isReattaching">This is a reattaching pass</param>
public static void AttachSubWindows(IViewContent viewContent, bool isReattaching) public void AttachSubWindows(IViewContent viewContent, bool isReattaching)
{ {
SD.MainThread.VerifyAccess(); SD.MainThread.VerifyAccess();
if (viewContent == null) if (viewContent == null)

2
src/Main/Base/Project/Src/Gui/Dialogs/OpenWithDialog.Designer.cs → src/Main/SharpDevelop/Workbench/DisplayBinding/OpenWithDialog.Designer.cs generated

@ -1,7 +1,7 @@
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) // 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) // This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Workbench
{ {
partial class OpenWithDialog partial class OpenWithDialog
{ {

11
src/Main/Base/Project/Src/Gui/Dialogs/OpenWithDialog.cs → src/Main/SharpDevelop/Workbench/DisplayBinding/OpenWithDialog.cs

@ -5,14 +5,15 @@ using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Drawing; using System.Drawing;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui namespace ICSharpCode.SharpDevelop.Workbench
{ {
/// <summary> /// <summary>
/// Dialog to choose the display binding to use to open a file. /// Dialog to choose the display binding to use to open a file.
/// </summary> /// </summary>
public sealed partial class OpenWithDialog : Form sealed partial class OpenWithDialog : Form
{ {
sealed class ListEntry sealed class ListEntry
{ {
@ -87,7 +88,7 @@ namespace ICSharpCode.SharpDevelop.Gui
Title = dlg.DisplayName, Title = dlg.DisplayName,
Id = Guid.NewGuid().ToString() Id = Guid.NewGuid().ToString()
}; };
programListBox.Items.Add(new ListEntry(DisplayBindingService.AddExternalProcessDisplayBinding(binding), false)); programListBox.Items.Add(new ListEntry(SD.DisplayBindingService.AddExternalProcessDisplayBinding(binding), false));
} }
} }
} }
@ -108,7 +109,7 @@ namespace ICSharpCode.SharpDevelop.Gui
void RemoveButtonClick(object sender, EventArgs e) void RemoveButtonClick(object sender, EventArgs e)
{ {
DisplayBindingService.RemoveExternalProcessDisplayBinding((ExternalProcessDisplayBinding)SelectedBinding.GetLoadedBinding()); SD.DisplayBindingService.RemoveExternalProcessDisplayBinding((ExternalProcessDisplayBinding)SelectedBinding.GetLoadedBinding());
if (defaultBindingIndex == programListBox.SelectedIndex) if (defaultBindingIndex == programListBox.SelectedIndex)
defaultBindingIndex = -1; defaultBindingIndex = -1;
programListBox.Items.RemoveAt(programListBox.SelectedIndex); programListBox.Items.RemoveAt(programListBox.SelectedIndex);
@ -125,7 +126,7 @@ namespace ICSharpCode.SharpDevelop.Gui
programListBox.Items[defaultBindingIndex] = new ListEntry( programListBox.Items[defaultBindingIndex] = new ListEntry(
((ListEntry)programListBox.Items[defaultBindingIndex]).desc, ((ListEntry)programListBox.Items[defaultBindingIndex]).desc,
true); true);
DisplayBindingService.SetDefaultCodon(fileExtension, SelectedBinding); SD.DisplayBindingService.SetDefaultCodon(fileExtension, SelectedBinding);
} }
} }
} }

11
src/Main/Base/Project/Src/Services/DisplayBinding/ShellExecuteDisplayBinding.cs → src/Main/SharpDevelop/Workbench/DisplayBinding/ShellExecuteDisplayBinding.cs

@ -6,16 +6,15 @@ using System.Diagnostics;
using System.IO; using System.IO;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.SharpDevelop namespace ICSharpCode.SharpDevelop.Workbench
{ {
/// <summary> /// <summary>
/// Opens files with the default Windows application for them. /// Opens files with the default Windows application for them.
/// </summary> /// </summary>
public class ShellExecuteDisplayBinding : IDisplayBinding sealed class ShellExecuteDisplayBinding : IDisplayBinding
{ {
public bool CanCreateContentForFile(string fileName) public bool CanCreateContentForFile(FileName fileName)
{ {
return true; return true;
} }
@ -35,12 +34,12 @@ namespace ICSharpCode.SharpDevelop
return null; return null;
} }
public bool IsPreferredBindingForFile(string fileName) public bool IsPreferredBindingForFile(FileName fileName)
{ {
return false; return false;
} }
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType) public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{ {
return double.NegativeInfinity; return double.NegativeInfinity;
} }

50
src/Main/SharpDevelop/Workbench/FileService.cs

@ -26,8 +26,9 @@ namespace ICSharpCode.SharpDevelop.Workbench
void ParserServiceLoadSolutionProjectsThreadEnded(object sender, EventArgs e) void ParserServiceLoadSolutionProjectsThreadEnded(object sender, EventArgs e)
{ {
var displayBindingService = SD.DisplayBindingService;
foreach (IViewContent content in SD.Workbench.ViewContentCollection.ToArray()) { foreach (IViewContent content in SD.Workbench.ViewContentCollection.ToArray()) {
DisplayBindingService.AttachSubWindows(content, true); displayBindingService.AttachSubWindows(content, true);
} }
} }
@ -297,7 +298,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
return viewContent; return viewContent;
} }
IDisplayBinding binding = DisplayBindingService.GetBindingPerFileName(fileName); IDisplayBinding binding = SD.DisplayBindingService.GetBindingPerFileName(fileName);
if (binding == null) { if (binding == null) {
binding = new ErrorFallbackBinding("Could not find any display binding for " + Path.GetFileName(fileName)); binding = new ErrorFallbackBinding("Could not find any display binding for " + Path.GetFileName(fileName));
@ -336,7 +337,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
try { try {
IViewContent newContent = binding.CreateContentForFile(file); IViewContent newContent = binding.CreateContentForFile(file);
if (newContent != null) { if (newContent != null) {
DisplayBindingService.AttachSubWindows(newContent, false); SD.DisplayBindingService.AttachSubWindows(newContent, false);
SD.Workbench.ShowView(newContent, switchToOpenedView); SD.Workbench.ShowView(newContent, switchToOpenedView);
} }
} finally { } finally {
@ -359,7 +360,8 @@ namespace ICSharpCode.SharpDevelop.Workbench
if (content == null) if (content == null)
throw new ArgumentNullException("content"); throw new ArgumentNullException("content");
IDisplayBinding binding = DisplayBindingService.GetBindingPerFileName(defaultName); var displayBindingService = SD.DisplayBindingService;
IDisplayBinding binding = displayBindingService.GetBindingPerFileName(FileName.Create(defaultName));
if (binding == null) { if (binding == null) {
binding = new ErrorFallbackBinding("Can't create display binding for file " + defaultName); binding = new ErrorFallbackBinding("Can't create display binding for file " + defaultName);
@ -373,7 +375,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
return null; return null;
} }
DisplayBindingService.AttachSubWindows(newContent, false); displayBindingService.AttachSubWindows(newContent, false);
SD.Workbench.ShowView(newContent); SD.Workbench.ShowView(newContent);
return newContent; return newContent;
@ -416,7 +418,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
} }
public bool CanCreateContentForFile(string fileName) public bool CanCreateContentForFile(FileName fileName)
{ {
return true; return true;
} }
@ -426,12 +428,12 @@ namespace ICSharpCode.SharpDevelop.Workbench
return new SimpleViewContent(errorMessage) { TitleName = Path.GetFileName(file.FileName) }; return new SimpleViewContent(errorMessage) { TitleName = Path.GetFileName(file.FileName) };
} }
public bool IsPreferredBindingForFile(string fileName) public bool IsPreferredBindingForFile(FileName fileName)
{ {
return false; return false;
} }
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType) public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{ {
return double.NegativeInfinity; return double.NegativeInfinity;
} }
@ -473,6 +475,38 @@ namespace ICSharpCode.SharpDevelop.Workbench
} }
} }
} }
public IEnumerable<IViewContent> ShowOpenWithDialog(IEnumerable<FileName> fileNames, bool switchToOpenedView = true)
{
var fileNamesList = fileNames.ToList();
if (fileNamesList.Count == 0)
return Enumerable.Empty<IViewContent>();
var displayBindingService = SD.DisplayBindingService;
List<DisplayBindingDescriptor> codons = displayBindingService.GetCodonsPerFileName(fileNamesList[0]).ToList();
for (int i = 1; i < fileNamesList.Count; i++) {
var codonsForThisFile = displayBindingService.GetCodonsPerFileName(fileNamesList[i]);
codons.RemoveAll(c => !codonsForThisFile.Contains(c));
}
if (codons.Count == 0)
return Enumerable.Empty<IViewContent>();
int defaultCodonIndex = codons.IndexOf(displayBindingService.GetDefaultCodonPerFileName(fileNamesList[0]));
if (defaultCodonIndex < 0)
defaultCodonIndex = 0;
using (OpenWithDialog dlg = new OpenWithDialog(codons, defaultCodonIndex, Path.GetExtension(fileNamesList[0]))) {
if (dlg.ShowDialog(SD.WinForms.MainWin32Window) == DialogResult.OK) {
var result = new List<IViewContent>();
foreach (var fileName in fileNamesList) {
IViewContent vc = OpenFileWith(fileName, dlg.SelectedBinding.Binding, switchToOpenedView);
if (vc != null)
result.Add(vc);
}
return result;
}
}
return Enumerable.Empty<IViewContent>();
}
#endregion #endregion
#region Remove/Rename/Copy #region Remove/Rename/Copy

1
src/Main/SharpDevelop/Workbench/WorkbenchStartup.cs

@ -45,7 +45,6 @@ namespace ICSharpCode.SharpDevelop.Workbench
LanguageService.ValidateLanguage(); LanguageService.ValidateLanguage();
DisplayBindingService.InitializeService();
TaskService.Initialize(); TaskService.Initialize();
Project.CustomToolsService.Initialize(); Project.CustomToolsService.Initialize();

Loading…
Cancel
Save