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 @@ -31,7 +31,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
}
public bool CanCreateContentForFile(string fileName)
public bool CanCreateContentForFile(FileName fileName)
{
return true;
}
@ -41,7 +41,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -41,7 +41,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
return new AvalonEditViewContent(file);
}
public bool IsPreferredBindingForFile(string fileName)
public bool IsPreferredBindingForFile(FileName fileName)
{
string extension = Path.GetExtension(fileName);
var fileFilter = ProjectService.GetFileFilters().FirstOrDefault(ff => ff.ContainsExtension(extension));
@ -49,7 +49,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -49,7 +49,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
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;
}
@ -57,7 +57,7 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -57,7 +57,7 @@ namespace ICSharpCode.AvalonEdit.AddIn
public class ChooseEncodingDisplayBinding : IDisplayBinding
{
public bool CanCreateContentForFile(string fileName)
public bool CanCreateContentForFile(FileName fileName)
{
return true;
}
@ -79,12 +79,12 @@ namespace ICSharpCode.AvalonEdit.AddIn @@ -79,12 +79,12 @@ namespace ICSharpCode.AvalonEdit.AddIn
}
}
public bool IsPreferredBindingForFile(string fileName)
public bool IsPreferredBindingForFile(FileName fileName)
{
return false;
}
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType)
public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{
return double.NegativeInfinity;
}

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

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

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

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

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

@ -1,13 +1,15 @@ @@ -1,13 +1,15 @@
// 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 ICSharpCode.SharpDevelop.Editor;
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Editor;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
using ICSharpCode.XmlEditor;
namespace ICSharpCode.XmlEditor

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

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

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

@ -37,7 +37,7 @@ @@ -37,7 +37,7 @@
<Doozer name="CustomTool" class="ICSharpCode.SharpDevelop.Project.CustomToolDoozer"/>
<Doozer name="CustomProperty" class="ICSharpCode.SharpDevelop.Project.CustomPropertyDoozer"/>
<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="ProjectBinding" class="ICSharpCode.SharpDevelop.ProjectBindingDoozer"/>
<Doozer name="LanguageBinding" class="ICSharpCode.SharpDevelop.LanguageBindingDoozer"/>
@ -64,6 +64,8 @@ @@ -64,6 +64,8 @@
class="ICSharpCode.SharpDevelop.Workbench.FileService"/>
<Service id="ICSharpCode.SharpDevelop.Workbench.IShutdownService"
class="ICSharpCode.SharpDevelop.Workbench.ShutdownService"/>
<Service id="ICSharpCode.SharpDevelop.Workbench.IDisplayBindingService"
class="ICSharpCode.SharpDevelop.Workbench.DisplayBindingService"/>
<Service id="ICSharpCode.SharpDevelop.Dom.ITreeNodeFactory"
class="ICSharpCode.SharpDevelop.Dom.TreeNodeFactoryService"/>
<Service id="ICSharpCode.SharpDevelop.Dom.IModelFactory"
@ -92,7 +94,10 @@ @@ -92,7 +94,10 @@
class = "ICSharpCode.SharpDevelop.BrowserDisplayBinding.BrowserDisplayBinding"/>
<DisplayBinding id = "AutoDetect"
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 name = "/SharpDevelop/Workbench/FileFilter">
@ -1940,12 +1945,6 @@ @@ -1940,12 +1945,6 @@
<!-- 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">
<MenuItem id = "FindReferences"
label = "${res:SharpDevelop.Refactoring.FindReferencesCommand}"

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

@ -214,10 +214,6 @@ @@ -214,10 +214,6 @@
<SubType>Code</SubType>
</Compile>
<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.Designer.cs">
<DependentUpon>AsynchronousWaitDialog.cs</DependentUpon>
@ -267,6 +263,11 @@ @@ -267,6 +263,11 @@
<Compile Include="Workbench\AbstractViewContent.cs" />
<Compile Include="Workbench\AbstractViewContentHandlingLoadErrors.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\File\FileService.cs" />
<Compile Include="Workbench\File\IRecentOpen.cs" />
@ -291,10 +292,6 @@ @@ -291,10 +292,6 @@
<Compile Include="Src\Gui\Dialogs\NewProjectDialog.Designer.cs">
<DependentUpon>NewProjectDialog.cs</DependentUpon>
</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">
<DependentUpon>CodeGenerationPanel.xaml</DependentUpon>
<SubType>Code</SubType>
@ -484,10 +481,6 @@ @@ -484,10 +481,6 @@
<Compile Include="Src\Services\Debugger\BreakpointBookmark.cs" />
<Compile Include="Src\Services\Debugger\BreakpointBookmarkEventArgs.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\OpenedFile.cs" />
<Compile Include="Src\Services\LanguageBinding\AggregatedLanguageBinding.cs" />
@ -510,16 +503,13 @@ @@ -510,16 +503,13 @@
<Compile Include="Src\Services\Tasks\TagComment.cs" />
<Compile Include="Src\Services\Tasks\Task.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\Services\ProjectBinding\IProjectBinding.cs" />
<Compile Include="Src\Internal\Templates\Project\ProjectCreateInformation.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\Services\ProjectBinding\ProjectBindingDoozer.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\Services\AmbienceService\AmbienceService.cs" />
<Compile Include="Src\Internal\ConditionEvaluators\WindowOpenEvaluator.cs" />
@ -666,7 +656,6 @@ @@ -666,7 +656,6 @@
<Compile Include="Src\Gui\Dialogs\ProjectOptionsView.cs" />
<Compile Include="Src\Gui\Pads\ProjectBrowser\Commands\ToolbarCommands.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\IStringValueFilter.cs" />
<Compile Include="Src\Gui\XmlForms\Lib\StringWrapper.cs" />
@ -822,6 +811,7 @@ @@ -822,6 +811,7 @@
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Folder Include="Workbench\DisplayBinding" />
<Page Include="Editor\Bookmarks\BookmarkPadContent.xaml" />
<Page Include="Src\Gui\Components\StringListEditorDialog.xaml" />
<Page Include="Src\Gui\Components\StringListEditorXaml.xaml" />

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

@ -200,5 +200,10 @@ namespace ICSharpCode.SharpDevelop @@ -200,5 +200,10 @@ namespace ICSharpCode.SharpDevelop
public static IBookmarkManager BookmarkManager {
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 @@ -266,35 +266,7 @@ namespace ICSharpCode.SharpDevelop.Commands
{
protected override void OpenFiles(FileName[] fileNames)
{
OpenFilesWith(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);
}
}
}
SD.FileService.ShowOpenWithDialog(fileNames);
}
}

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

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

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

@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -69,7 +69,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
/// </summary>
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; @@ -5,7 +5,7 @@ using System;
using System.Text.RegularExpressions;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop
namespace ICSharpCode.SharpDevelop.Workbench
{
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; @@ -7,9 +7,8 @@ using System.Diagnostics;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.SharpDevelop
namespace ICSharpCode.SharpDevelop.Workbench
{
/// <summary>
/// Display binding for opening a file in an external process.
@ -22,7 +21,7 @@ namespace ICSharpCode.SharpDevelop @@ -22,7 +21,7 @@ namespace ICSharpCode.SharpDevelop
public string Title { 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);
}
@ -64,12 +63,12 @@ namespace ICSharpCode.SharpDevelop @@ -64,12 +63,12 @@ namespace ICSharpCode.SharpDevelop
Process.Start(info);
}
public bool IsPreferredBindingForFile(string fileName)
public bool IsPreferredBindingForFile(FileName fileName)
{
return false;
}
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType)
public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{
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 @@ @@ -4,12 +4,10 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop
namespace ICSharpCode.SharpDevelop.Workbench
{
/// <summary>
/// This class defines the SharpDevelop display binding interface, it is a factory
@ -17,7 +15,7 @@ namespace ICSharpCode.SharpDevelop @@ -17,7 +15,7 @@ namespace ICSharpCode.SharpDevelop
/// </summary>
public interface IDisplayBinding
{
bool IsPreferredBindingForFile(string fileName);
bool IsPreferredBindingForFile(FileName fileName);
/// <remarks>
/// This function determines, if this display binding is able to create
@ -28,9 +26,9 @@ namespace ICSharpCode.SharpDevelop @@ -28,9 +26,9 @@ namespace ICSharpCode.SharpDevelop
/// an IViewContent for the file given by fileName.
/// false otherwise
/// </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>
/// Creates a new IViewContent object for the file fileName
@ -40,6 +38,4 @@ namespace ICSharpCode.SharpDevelop @@ -40,6 +38,4 @@ namespace ICSharpCode.SharpDevelop
/// </returns>
IViewContent CreateContentForFile(OpenedFile file);
}
}

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

@ -0,0 +1,46 @@ @@ -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 @@ @@ -2,9 +2,8 @@
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
using System;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop
namespace ICSharpCode.SharpDevelop.Workbench
{
/// <summary>
/// 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 @@ -162,6 +162,11 @@ namespace ICSharpCode.SharpDevelop.Workbench
/// <returns>The existing or opened <see cref="IViewContent"/> for the specified file.</returns>
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>
/// Opens a new unsaved file.
/// </summary>

13
src/Main/SharpDevelop/SharpDevelop.csproj

@ -114,6 +114,18 @@ @@ -114,6 +114,18 @@
<Compile Include="Workbench\AvalonPadContent.cs" />
<Compile Include="Workbench\AvalonWorkbenchWindow.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\FileServiceOpenedFile.cs" />
<Compile Include="Workbench\FullScreenEnabledWindow.cs" />
@ -237,6 +249,7 @@ @@ -237,6 +249,7 @@
<Folder Include="Logging" />
<Folder Include="Parser" />
<Folder Include="Sda" />
<Folder Include="Workbench\DisplayBinding" />
</ItemGroup>
<ItemGroup>
<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 @@ @@ -1,7 +1,7 @@
// 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)
namespace ICSharpCode.SharpDevelop.Gui
namespace ICSharpCode.SharpDevelop.Workbench
{
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; @@ -7,12 +7,12 @@ using System.Windows.Forms;
using System.IO;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui
namespace ICSharpCode.SharpDevelop.Workbench
{
/// <summary>
/// This dialog is used to add a new program to the open with dialog.
/// </summary>
public partial class AddOpenWithEntryDialog : Form
partial class AddOpenWithEntryDialog : Form
{
public AddOpenWithEntryDialog()
{
@ -42,7 +42,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -42,7 +42,7 @@ namespace ICSharpCode.SharpDevelop.Gui
void BrowseForProgramButtonClick(object sender, EventArgs e)
{
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) {
programNameTextBox.Text = "\"" + dlg.FileName + "\"";
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; @@ -5,35 +5,33 @@ using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.SharpDevelop
namespace ICSharpCode.SharpDevelop.Workbench
{
/// <summary>
/// Implements content auto detection and opens the appropriate IViewContent.
/// </summary>
public sealed class AutoDetectDisplayBinding : IDisplayBinding
sealed class AutoDetectDisplayBinding : IDisplayBinding
{
public bool IsPreferredBindingForFile(string fileName)
public bool IsPreferredBindingForFile(FileName fileName)
{
return false;
}
public bool CanCreateContentForFile(string fileName)
public bool CanCreateContentForFile(FileName fileName)
{
return true;
}
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType)
public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{
return double.NegativeInfinity;
}
public IViewContent CreateContentForFile(OpenedFile file)
{
var codons = DisplayBindingService.GetCodonsPerFileName(file.FileName);
var codons = SD.DisplayBindingService.GetCodonsPerFileName(file.FileName);
DisplayBindingDescriptor bestMatch = null;
double max = double.NegativeInfinity;
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; @@ -5,7 +5,7 @@ using System;
using System.Collections;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop
namespace ICSharpCode.SharpDevelop.Workbench
{
/// <summary>
/// Creates DisplayBindingDescriptor objects.
@ -49,7 +49,7 @@ namespace ICSharpCode.SharpDevelop @@ -49,7 +49,7 @@ namespace ICSharpCode.SharpDevelop
/// fileNamePattern = "\.(cs|vb)$" /&gt;
/// &lt;/Path&gt;
/// </example>
public class DisplayBindingDoozer : IDoozer
sealed class DisplayBindingDoozer : IDoozer
{
/// <summary>
/// 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; @@ -5,24 +5,23 @@ using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.SharpDevelop
namespace ICSharpCode.SharpDevelop.Workbench
{
/// <summary>
/// This class handles the installed display bindings
/// and provides a simple access point to these bindings.
/// </summary>
public static class DisplayBindingService
sealed class DisplayBindingService : IDisplayBindingService
{
const string displayBindingPath = "/SharpDevelop/Workbench/DisplayBindings";
static Properties displayBindingServiceProperties;
Properties displayBindingServiceProperties;
static List<DisplayBindingDescriptor> bindings;
static List<ExternalProcessDisplayBinding> externalProcessDisplayBindings = new List<ExternalProcessDisplayBinding>();
List<DisplayBindingDescriptor> bindings;
List<ExternalProcessDisplayBinding> externalProcessDisplayBindings = new List<ExternalProcessDisplayBinding>();
internal static void InitializeService()
public DisplayBindingService()
{
bindings = AddInTree.BuildItems<DisplayBindingDescriptor>(displayBindingPath, null, true);
displayBindingServiceProperties = PropertyService.NestedProperties("DisplayBindingService");
@ -33,7 +32,7 @@ namespace ICSharpCode.SharpDevelop @@ -33,7 +32,7 @@ namespace ICSharpCode.SharpDevelop
}
}
public static DisplayBindingDescriptor AddExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding)
public DisplayBindingDescriptor AddExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding)
{
SD.MainThread.VerifyAccess();
if (binding == null)
@ -43,12 +42,12 @@ namespace ICSharpCode.SharpDevelop @@ -43,12 +42,12 @@ namespace ICSharpCode.SharpDevelop
return descriptor;
}
static void SaveExternalProcessDisplayBindings()
void SaveExternalProcessDisplayBindings()
{
displayBindingServiceProperties.SetList("ExternalProcesses", externalProcessDisplayBindings);
}
static DisplayBindingDescriptor AddExternalProcessDisplayBindingInternal(ExternalProcessDisplayBinding binding)
DisplayBindingDescriptor AddExternalProcessDisplayBindingInternal(ExternalProcessDisplayBinding binding)
{
externalProcessDisplayBindings.Add(binding);
DisplayBindingDescriptor descriptor = new DisplayBindingDescriptor(binding) {
@ -59,7 +58,7 @@ namespace ICSharpCode.SharpDevelop @@ -59,7 +58,7 @@ namespace ICSharpCode.SharpDevelop
return descriptor;
}
public static void RemoveExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding)
public void RemoveExternalProcessDisplayBinding(ExternalProcessDisplayBinding binding)
{
SD.MainThread.VerifyAccess();
if (binding == null)
@ -79,7 +78,7 @@ namespace ICSharpCode.SharpDevelop @@ -79,7 +78,7 @@ namespace ICSharpCode.SharpDevelop
/// <summary>
/// Gets the primary display binding for the specified file name.
/// </summary>
public static IDisplayBinding GetBindingPerFileName(string filename)
public IDisplayBinding GetBindingPerFileName(FileName filename)
{
SD.MainThread.VerifyAccess();
if (FileUtility.IsUrl(filename)) {
@ -94,7 +93,7 @@ namespace ICSharpCode.SharpDevelop @@ -94,7 +93,7 @@ namespace ICSharpCode.SharpDevelop
/// <summary>
/// Gets the default primary display binding for the specified file name.
/// </summary>
public static DisplayBindingDescriptor GetDefaultCodonPerFileName(string filename)
public DisplayBindingDescriptor GetDefaultCodonPerFileName(FileName filename)
{
SD.MainThread.VerifyAccess();
@ -120,7 +119,7 @@ namespace ICSharpCode.SharpDevelop @@ -120,7 +119,7 @@ namespace ICSharpCode.SharpDevelop
return autoDetectDescriptor;
}
public static void SetDefaultCodon(string extension, DisplayBindingDescriptor bindingDescriptor)
public void SetDefaultCodon(string extension, DisplayBindingDescriptor bindingDescriptor)
{
SD.MainThread.VerifyAccess();
if (bindingDescriptor == null)
@ -136,7 +135,7 @@ namespace ICSharpCode.SharpDevelop @@ -136,7 +135,7 @@ namespace ICSharpCode.SharpDevelop
/// <summary>
/// Gets list of possible primary display bindings for the specified file name.
/// </summary>
public static IList<DisplayBindingDescriptor> GetCodonsPerFileName(string filename)
public IReadOnlyList<DisplayBindingDescriptor> GetCodonsPerFileName(FileName filename)
{
SD.MainThread.VerifyAccess();
@ -149,7 +148,7 @@ namespace ICSharpCode.SharpDevelop @@ -149,7 +148,7 @@ namespace ICSharpCode.SharpDevelop
return list;
}
static bool IsPrimaryBindingValidForFileName(DisplayBindingDescriptor binding, string filename)
static bool IsPrimaryBindingValidForFileName(DisplayBindingDescriptor binding, FileName filename)
{
if (!binding.IsSecondary && binding.CanOpenFile(filename)) {
if (binding.Binding != null && binding.Binding.CanCreateContentForFile(filename)) {
@ -164,7 +163,7 @@ namespace ICSharpCode.SharpDevelop @@ -164,7 +163,7 @@ namespace ICSharpCode.SharpDevelop
/// </summary>
/// <param name="viewContent">The view content to attach to</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();
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 @@ @@ -1,7 +1,7 @@
// 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)
namespace ICSharpCode.SharpDevelop.Gui
namespace ICSharpCode.SharpDevelop.Workbench
{
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; @@ -5,14 +5,15 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace ICSharpCode.SharpDevelop.Gui
namespace ICSharpCode.SharpDevelop.Workbench
{
/// <summary>
/// Dialog to choose the display binding to use to open a file.
/// </summary>
public sealed partial class OpenWithDialog : Form
sealed partial class OpenWithDialog : Form
{
sealed class ListEntry
{
@ -87,7 +88,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -87,7 +88,7 @@ namespace ICSharpCode.SharpDevelop.Gui
Title = dlg.DisplayName,
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 @@ -108,7 +109,7 @@ namespace ICSharpCode.SharpDevelop.Gui
void RemoveButtonClick(object sender, EventArgs e)
{
DisplayBindingService.RemoveExternalProcessDisplayBinding((ExternalProcessDisplayBinding)SelectedBinding.GetLoadedBinding());
SD.DisplayBindingService.RemoveExternalProcessDisplayBinding((ExternalProcessDisplayBinding)SelectedBinding.GetLoadedBinding());
if (defaultBindingIndex == programListBox.SelectedIndex)
defaultBindingIndex = -1;
programListBox.Items.RemoveAt(programListBox.SelectedIndex);
@ -125,7 +126,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -125,7 +126,7 @@ namespace ICSharpCode.SharpDevelop.Gui
programListBox.Items[defaultBindingIndex] = new ListEntry(
((ListEntry)programListBox.Items[defaultBindingIndex]).desc,
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; @@ -6,16 +6,15 @@ using System.Diagnostics;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop.Workbench;
namespace ICSharpCode.SharpDevelop
namespace ICSharpCode.SharpDevelop.Workbench
{
/// <summary>
/// Opens files with the default Windows application for them.
/// </summary>
public class ShellExecuteDisplayBinding : IDisplayBinding
sealed class ShellExecuteDisplayBinding : IDisplayBinding
{
public bool CanCreateContentForFile(string fileName)
public bool CanCreateContentForFile(FileName fileName)
{
return true;
}
@ -35,12 +34,12 @@ namespace ICSharpCode.SharpDevelop @@ -35,12 +34,12 @@ namespace ICSharpCode.SharpDevelop
return null;
}
public bool IsPreferredBindingForFile(string fileName)
public bool IsPreferredBindingForFile(FileName fileName)
{
return false;
}
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType)
public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{
return double.NegativeInfinity;
}

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

@ -26,8 +26,9 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -26,8 +26,9 @@ namespace ICSharpCode.SharpDevelop.Workbench
void ParserServiceLoadSolutionProjectsThreadEnded(object sender, EventArgs e)
{
var displayBindingService = SD.DisplayBindingService;
foreach (IViewContent content in SD.Workbench.ViewContentCollection.ToArray()) {
DisplayBindingService.AttachSubWindows(content, true);
displayBindingService.AttachSubWindows(content, true);
}
}
@ -297,7 +298,7 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -297,7 +298,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
return viewContent;
}
IDisplayBinding binding = DisplayBindingService.GetBindingPerFileName(fileName);
IDisplayBinding binding = SD.DisplayBindingService.GetBindingPerFileName(fileName);
if (binding == null) {
binding = new ErrorFallbackBinding("Could not find any display binding for " + Path.GetFileName(fileName));
@ -336,7 +337,7 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -336,7 +337,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
try {
IViewContent newContent = binding.CreateContentForFile(file);
if (newContent != null) {
DisplayBindingService.AttachSubWindows(newContent, false);
SD.DisplayBindingService.AttachSubWindows(newContent, false);
SD.Workbench.ShowView(newContent, switchToOpenedView);
}
} finally {
@ -359,7 +360,8 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -359,7 +360,8 @@ namespace ICSharpCode.SharpDevelop.Workbench
if (content == null)
throw new ArgumentNullException("content");
IDisplayBinding binding = DisplayBindingService.GetBindingPerFileName(defaultName);
var displayBindingService = SD.DisplayBindingService;
IDisplayBinding binding = displayBindingService.GetBindingPerFileName(FileName.Create(defaultName));
if (binding == null) {
binding = new ErrorFallbackBinding("Can't create display binding for file " + defaultName);
@ -373,7 +375,7 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -373,7 +375,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
return null;
}
DisplayBindingService.AttachSubWindows(newContent, false);
displayBindingService.AttachSubWindows(newContent, false);
SD.Workbench.ShowView(newContent);
return newContent;
@ -416,7 +418,7 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -416,7 +418,7 @@ namespace ICSharpCode.SharpDevelop.Workbench
this.errorMessage = errorMessage;
}
public bool CanCreateContentForFile(string fileName)
public bool CanCreateContentForFile(FileName fileName)
{
return true;
}
@ -426,12 +428,12 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -426,12 +428,12 @@ namespace ICSharpCode.SharpDevelop.Workbench
return new SimpleViewContent(errorMessage) { TitleName = Path.GetFileName(file.FileName) };
}
public bool IsPreferredBindingForFile(string fileName)
public bool IsPreferredBindingForFile(FileName fileName)
{
return false;
}
public double AutoDetectFileContent(string fileName, Stream fileContent, string detectedMimeType)
public double AutoDetectFileContent(FileName fileName, Stream fileContent, string detectedMimeType)
{
return double.NegativeInfinity;
}
@ -473,6 +475,38 @@ namespace ICSharpCode.SharpDevelop.Workbench @@ -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
#region Remove/Rename/Copy

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

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

Loading…
Cancel
Save