Browse Source

Add WpfDesigner addin.

Add AbstractViewContentHandlingLoadErrors for easy handling of invalid files.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2572 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 18 years ago
parent
commit
bc1d6f3211
  1. 14
      src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/AddNewFileCommand.cs
  2. 2
      src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/AddStringEntryCommand.cs
  3. 2
      src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/CopyResourceNameCommand.cs
  4. 2
      src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/RenameEntryCommand.cs
  5. 2
      src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/SaveEntryAsCommand.cs
  6. 13
      src/AddIns/DisplayBindings/ResourceEditor/Project/Src/DisplayDefinition.cs
  7. 16
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Configuration/AssemblyInfo.cs
  8. 46
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfDisplayBinding.cs
  9. 53
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs
  10. 80
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj
  11. 21
      src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin
  12. 2
      src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj
  13. 138
      src/Main/Base/Project/Src/Gui/AbstractViewContentHandlingLoadErrors.cs
  14. 9
      src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs
  15. 9
      src/Main/Base/Project/Src/Gui/Pads/ToolsPad.cs
  16. 1
      src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs
  17. 13
      src/Main/Base/Project/Src/Util/Linq.cs
  18. 117
      src/Main/Base/Project/Src/Util/UnclosableStream.cs
  19. 33
      src/SharpDevelop.sln

14
src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/AddNewFileCommand.cs

@ -20,7 +20,7 @@ namespace ResourceEditor @@ -20,7 +20,7 @@ namespace ResourceEditor
{
public override void Run()
{
ResourceEditorControl editor = (ResourceEditorControl)WorkbenchSingleton.Workbench.ActiveViewContent.Control;
ResourceEditorControl editor = ((ResourceEditWrapper)WorkbenchSingleton.Workbench.ActiveViewContent).ResourceEditor;
if(editor.ResourceList.WriteProtected) {
return;
@ -28,10 +28,10 @@ namespace ResourceEditor @@ -28,10 +28,10 @@ namespace ResourceEditor
using (OpenFileDialog fdiag = new OpenFileDialog()) {
fdiag.AddExtension = true;
fdiag.Filter = "All files (*.*)|*.*";
fdiag.Filter = StringParser.Parse("${res:SharpDevelop.FileFilter.AllFiles}|*.*");
fdiag.Multiselect = true;
fdiag.CheckFileExists = true;
if (fdiag.ShowDialog(ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm) == DialogResult.OK) {
foreach (string filename in fdiag.FileNames) {
string oresname = Path.ChangeExtension(Path.GetFileName(filename), null);
@ -40,7 +40,7 @@ namespace ResourceEditor @@ -40,7 +40,7 @@ namespace ResourceEditor
string resname = oresname;
int i = 0;
TestName:
TestName:
if (editor.ResourceList.Resources.ContainsKey(resname)) {
if (i == 10) {
continue;
@ -80,8 +80,8 @@ namespace ResourceEditor @@ -80,8 +80,8 @@ namespace ResourceEditor
}
default:
// try to read a bitmap
try {
return new Bitmap(name);
try {
return new Bitmap(name);
} catch {}
// try to read a serialized object
@ -109,7 +109,7 @@ namespace ResourceEditor @@ -109,7 +109,7 @@ namespace ResourceEditor
string message = ResourceService.GetString("ResourceEditor.Messages.CantLoadResource");
MessageService.ShowWarning(message + " " + name + ".");
}
break;
break;
}
return null;
}

2
src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/AddStringEntryCommand.cs

@ -16,7 +16,7 @@ namespace ResourceEditor @@ -16,7 +16,7 @@ namespace ResourceEditor
{
public override void Run()
{
ResourceEditorControl editor = (ResourceEditorControl)WorkbenchSingleton.Workbench.ActiveViewContent.Control;
ResourceEditorControl editor = ((ResourceEditWrapper)WorkbenchSingleton.Workbench.ActiveViewContent).ResourceEditor;
if(editor.ResourceList.WriteProtected) {
return;

2
src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/CopyResourceNameCommand.cs

@ -15,7 +15,7 @@ namespace ResourceEditor @@ -15,7 +15,7 @@ namespace ResourceEditor
{
public override void Run()
{
ResourceEditorControl editor = (ResourceEditorControl)WorkbenchSingleton.Workbench.ActiveViewContent.Control;
ResourceEditorControl editor = ((ResourceEditWrapper)WorkbenchSingleton.Workbench.ActiveViewContent).ResourceEditor;
if(editor.ResourceList.SelectedItems.Count > 0) {
ClipboardWrapper.SetText(editor.ResourceList.SelectedItems[0].Text);

2
src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/RenameEntryCommand.cs

@ -15,7 +15,7 @@ namespace ResourceEditor @@ -15,7 +15,7 @@ namespace ResourceEditor
{
public override void Run()
{
ResourceEditorControl editor = (ResourceEditorControl)WorkbenchSingleton.Workbench.ActiveViewContent.Control;
ResourceEditorControl editor = ((ResourceEditWrapper)WorkbenchSingleton.Workbench.ActiveViewContent).ResourceEditor;
if(editor.ResourceList.SelectedItems.Count != 0) {
editor.ResourceList.SelectedItems[0].BeginEdit();

2
src/AddIns/DisplayBindings/ResourceEditor/Project/Src/Commands/SaveEntryAsCommand.cs

@ -19,7 +19,7 @@ namespace ResourceEditor @@ -19,7 +19,7 @@ namespace ResourceEditor
{
public override void Run()
{
ResourceEditorControl editor = (ResourceEditorControl)WorkbenchSingleton.Workbench.ActiveViewContent.Control;
ResourceEditorControl editor = ((ResourceEditWrapper)WorkbenchSingleton.Workbench.ActiveViewContent).ResourceEditor;
ResourceList list = editor.ResourceList;
if(list.SelectedItems.Count != 1) {

13
src/AddIns/DisplayBindings/ResourceEditor/Project/Src/DisplayDefinition.cs

@ -34,14 +34,12 @@ namespace ResourceEditor @@ -34,14 +34,12 @@ namespace ResourceEditor
/// <summary>
/// This class describes the main functionality of a language codon
/// </summary>
public class ResourceEditWrapper : AbstractViewContent, IClipboardHandler
public class ResourceEditWrapper : AbstractViewContentHandlingLoadErrors, IClipboardHandler
{
ResourceEditorControl resourceEditor = new ResourceEditorControl();
public override Control Control {
get {
return resourceEditor;
}
public ResourceEditorControl ResourceEditor {
get { return resourceEditor; }
}
public override bool IsReadOnly {
@ -57,6 +55,7 @@ namespace ResourceEditor @@ -57,6 +55,7 @@ namespace ResourceEditor
public ResourceEditWrapper(OpenedFile file)
{
base.UserControl = resourceEditor;
resourceEditor.ResourceList.Changed += new EventHandler(SetDirty);
this.Files.Add(file);
}
@ -71,12 +70,12 @@ namespace ResourceEditor @@ -71,12 +70,12 @@ namespace ResourceEditor
resourceEditor.Dispose();
}
public override void Load(OpenedFile file, Stream stream)
protected override void LoadInternal(OpenedFile file, Stream stream)
{
resourceEditor.ResourceList.LoadFile(file.FileName, stream);
}
public override void Save(OpenedFile file, Stream stream)
protected override void SaveInternal(OpenedFile file, Stream stream)
{
resourceEditor.ResourceList.SaveFile(file.FileName, stream);
}

16
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Configuration/AssemblyInfo.cs

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
#region Using directives
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
#endregion
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("WpfDesign.AddIn")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

46
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfDisplayBinding.cs

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.IO;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
namespace ICSharpCode.WpfDesign.AddIn
{
public class WpfPrimaryDisplayBinding : IDisplayBinding
{
public bool CanCreateContentForFile(string fileName)
{
return Path.GetExtension(fileName).Equals(".xaml", StringComparison.OrdinalIgnoreCase);
}
public IViewContent CreateContentForFile(OpenedFile file)
{
return new WpfViewContent(file);
}
}
public class WpfSecondaryDisplayBinding : ISecondaryDisplayBinding
{
public bool ReattachWhenParserServiceIsReady {
get {
return false;
}
}
public bool CanAttachTo(IViewContent content)
{
return Path.GetExtension(content.PrimaryFileName).Equals(".xaml", StringComparison.OrdinalIgnoreCase);
}
public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent)
{
return new IViewContent[] { new WpfViewContent(viewContent.PrimaryFile) };
}
}
}

53
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/Src/WpfViewContent.cs

@ -0,0 +1,53 @@ @@ -0,0 +1,53 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Text;
using System.Xml;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using System.Windows.Forms;
using System.Windows.Forms.Integration;
using ICSharpCode.WpfDesign.Designer;
namespace ICSharpCode.WpfDesign.AddIn
{
/// <summary>
/// Description of WpfViewContent.
/// </summary>
public class WpfViewContent : AbstractViewContentHandlingLoadErrors
{
ElementHost wpfHost;
DesignSurface designer;
public WpfViewContent(OpenedFile file) : base(file)
{
}
protected override void LoadInternal(OpenedFile file, System.IO.Stream stream)
{
if (designer == null) {
// initialize designer on first load
wpfHost = new ElementHost();
designer = new DesignSurface();
wpfHost.Child = designer;
this.UserControl = wpfHost;
}
using (XmlTextReader r = new XmlTextReader(stream)) {
designer.LoadDesigner(r);
}
}
protected override void SaveInternal(OpenedFile file, System.IO.Stream stream)
{
using (XmlTextWriter xmlWriter = new XmlTextWriter(stream, Encoding.UTF8)) {
xmlWriter.Formatting = Formatting.Indented;
designer.SaveDesigner(xmlWriter);
}
}
}
}

80
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.AddIn.csproj

@ -0,0 +1,80 @@ @@ -0,0 +1,80 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectGuid>{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}</ProjectGuid>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.WpfDesign.AddIn</RootNamespace>
<AssemblyName>ICSharpCode.WpfDesign.AddIn</AssemblyName>
<OutputPath>..\..\..\..\..\AddIns\AddIns\DisplayBindings\WpfDesign\</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<Optimize>False</Optimize>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
<DefineConstants>TRACE</DefineConstants>
</PropertyGroup>
<PropertyGroup Condition=" '$(Platform)' == 'AnyCPU' ">
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
</PropertyGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
<ItemGroup>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
<Reference Include="WindowsFormsIntegration" />
</ItemGroup>
<ItemGroup>
<None Include="WpfDesign.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Compile Include="..\..\..\..\Main\GlobalAssemblyInfo.cs">
<Link>Configuration\GlobalAssemblyInfo.cs</Link>
</Compile>
<Compile Include="Configuration\AssemblyInfo.cs" />
<Compile Include="Src\WpfDisplayBinding.cs" />
<Compile Include="Src\WpfViewContent.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj">
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project>
<Name>ICSharpCode.SharpDevelop</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\WpfDesign.Designer\Project\WpfDesign.Designer.csproj">
<Project>{78CC29AC-CC79-4355-B1F2-97936DF198AC}</Project>
<Name>WpfDesign.Designer</Name>
<Private>False</Private>
</ProjectReference>
<ProjectReference Include="..\WpfDesign\Project\WpfDesign.csproj">
<Project>{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}</Project>
<Name>WpfDesign</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
</Project>

21
src/AddIns/DisplayBindings/WpfDesign/WpfDesign.AddIn/WpfDesign.addin

@ -0,0 +1,21 @@ @@ -0,0 +1,21 @@
<AddIn name = "WPF Designer AddIn"
author = "Daniel Grunwald"
copyright = "prj:///doc/copyright.txt"
description = "WPF Designer">
<Runtime>
<Import assembly = "ICSharpCode.WpfDesign.AddIn.dll"/>
</Runtime>
<Path name = "/SharpDevelop/Workbench/DisplayBindings">
<!--<DisplayBinding id = "WPFDesigner"
class = "ICSharpCode.WpfDesign.AddIn.WpfPrimaryDisplayBinding"
insertbefore = "Text"
fileNamePattern = "\.xaml$"
title = "WPF designer"/>-->
<DisplayBinding id = "WPFDesigner"
type = "Secondary"
class = "ICSharpCode.WpfDesign.AddIn.WpfSecondaryDisplayBinding"
fileNamePattern = "\.xaml$"/>
</Path>
</AddIn>

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

@ -55,6 +55,7 @@ @@ -55,6 +55,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="Src\Gui\AbstractSecondaryViewContent.cs" />
<Compile Include="Src\Gui\AbstractViewContentHandlingLoadErrors.cs" />
<Compile Include="Src\Gui\AbstractViewContentWithoutFile.cs" />
<Compile Include="Src\Gui\BrowserDisplayBinding\BrowserDisplayBinding.cs" />
<Compile Include="Src\Gui\Components\SideBar\TextEditorSideBar.cs" />
@ -718,6 +719,7 @@ @@ -718,6 +719,7 @@
<Compile Include="Src\Project\BuildTarget.cs" />
<Compile Include="Src\Util\GenericConverter.cs" />
<Compile Include="Src\Internal\Templates\TemplateLoadException.cs" />
<Compile Include="Src\Util\UnclosableStream.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\Libraries\DockPanel_Src\WinFormsUI\WinFormsUI.csproj">

138
src/Main/Base/Project/Src/Gui/AbstractViewContentHandlingLoadErrors.cs

@ -0,0 +1,138 @@ @@ -0,0 +1,138 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace ICSharpCode.SharpDevelop.Gui
{
/// <summary>
/// This class handles errors in the Load method and prevents destroying invalid files.
/// Scenario:
/// open a .resx file both with the resource editor and the text editor. Add a string entry using the
/// resource editor. Modify it using the text editor, and introduce invalid XML syntax (e.g. use a
/// &lt; in the edited value. Close the text editor without saving the changes. The resource editor
/// will show the load error. Close the resource editor, this time saving the changes.
/// The resource editor is now expected to write the invalid file to disk.
/// This class handles this scenario by displaying an error message for invalid files, and
/// holding the invalid data that got copied from the text editor to the resource editor in memory.
/// So saving during a load error works as expected.
/// </summary>
public abstract class AbstractViewContentHandlingLoadErrors : AbstractViewContent
{
Panel panel = new Panel();
Control userControl;
protected AbstractViewContentHandlingLoadErrors()
{
}
protected AbstractViewContentHandlingLoadErrors(OpenedFile file) : base(file)
{
}
public sealed override Control Control {
get { return panel; }
}
protected Control UserControl {
get { return userControl; }
set {
if (userControl != value) {
if (errorList.Count == 0 && userControl != null) {
panel.Controls.Remove(userControl);
}
userControl = value;
userControl.Dock = DockStyle.Fill;
if (errorList.Count == 0 && userControl != null) {
panel.Controls.Add(userControl);
}
}
}
}
public bool HasLoadError {
get {
return errorList.Count > 0;
}
}
class LoadError
{
internal Exception exception;
internal byte[] fileData;
public LoadError(Exception exception, Stream stream)
{
this.exception = exception;
stream.Position = 0;
this.fileData = new byte[(int)stream.Length];
int pos = 0;
while (pos < fileData.Length) {
int c = stream.Read(fileData, pos, fileData.Length - pos);
if (c == 0) break;
pos += c;
}
}
}
TextBox errorTextBox;
void ShowError(Exception ex)
{
if (errorTextBox == null) {
errorTextBox = new TextBox();
errorTextBox.Multiline = true;
errorTextBox.ReadOnly = true;
errorTextBox.BackColor = SystemColors.Window;
errorTextBox.Dock = DockStyle.Fill;
}
errorTextBox.Text = ex.ToString();
panel.Controls.Clear();
panel.Controls.Add(errorTextBox);
}
Dictionary<OpenedFile, LoadError> errorList = new Dictionary<OpenedFile, LoadError>();
public override sealed void Load(OpenedFile file, Stream stream)
{
try {
LoadInternal(file, new UnclosableStream(stream));
if (errorList.Count > 0) {
errorList.Remove(file);
if (errorList.Count == 0) {
panel.Controls.Clear();
if (userControl != null) {
panel.Controls.Add(userControl);
}
} else {
ShowError(Linq.First(errorList.Values).exception);
}
}
} catch (Exception ex) {
errorList[file] = new LoadError(ex, stream);
ShowError(ex);
}
}
public override sealed void Save(OpenedFile file, Stream stream)
{
if (errorList.ContainsKey(file)) {
byte[] data = errorList[file].fileData;
stream.Write(data, 0, data.Length);
} else {
SaveInternal(file, stream);
}
}
protected abstract void LoadInternal(OpenedFile file, Stream stream);
protected abstract void SaveInternal(OpenedFile file, Stream stream);
}
}

9
src/Main/Base/Project/Src/Gui/Pads/PropertyPad/PropertyPad.cs

@ -101,10 +101,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -101,10 +101,7 @@ namespace ICSharpCode.SharpDevelop.Gui
{
IHasPropertyContainer c = WorkbenchSingleton.Workbench.ActiveContent as IHasPropertyContainer;
if (c == null) {
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window != null) {
c = window.ActiveViewContent as IHasPropertyContainer;
}
c = WorkbenchSingleton.Workbench.ActiveViewContent as IHasPropertyContainer;
}
if (c != null) {
SetActiveContainer(c.PropertyContainer);
@ -149,6 +146,10 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -149,6 +146,10 @@ namespace ICSharpCode.SharpDevelop.Gui
LoggingService.Debug("PropertyPad created");
WorkbenchSingleton.Workbench.ActiveContentChanged += WorkbenchActiveContentChanged;
// it is possible that ActiveContent changes fires before ActiveViewContent.
// if we listen the new content is not a IHasPropertyContainer and we listen only to ActiveContentChanged,
// we might display the ToolsControl of a no longer active view content
WorkbenchSingleton.Workbench.ActiveViewContentChanged += WorkbenchActiveContentChanged;
WorkbenchActiveContentChanged(null, null);
}

9
src/Main/Base/Project/Src/Gui/Pads/ToolsPad.cs

@ -45,6 +45,10 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -45,6 +45,10 @@ namespace ICSharpCode.SharpDevelop.Gui
child = noToolsAvailable;
WorkbenchSingleton.Workbench.ActiveContentChanged += WorkbenchActiveContentChanged;
// it is possible that ActiveContent changes fires before ActiveViewContent.
// if we listen the new content is not a IToolsHost and we listen only to ActiveContentChanged,
// we might display the ToolsControl of a no longer active view content
WorkbenchSingleton.Workbench.ActiveViewContentChanged += WorkbenchActiveContentChanged;
WorkbenchActiveContentChanged(null, null);
}
@ -62,10 +66,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -62,10 +66,7 @@ namespace ICSharpCode.SharpDevelop.Gui
{
IToolsHost th = WorkbenchSingleton.Workbench.ActiveContent as IToolsHost;
if (th == null) {
IWorkbenchWindow window = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow;
if (window != null) {
th = window.ActiveViewContent as IToolsHost;
}
th = WorkbenchSingleton.Workbench.ActiveViewContent as IToolsHost;
}
if (th != null) {
SetChild(th.ToolsControl ?? noToolsAvailable);

1
src/Main/Base/Project/Src/Gui/Workbench/DefaultWorkbench.cs

@ -218,6 +218,7 @@ namespace ICSharpCode.SharpDevelop.Gui @@ -218,6 +218,7 @@ namespace ICSharpCode.SharpDevelop.Gui
if (activeContent != value) {
activeContent = value;
if (ActiveContentChanged != null) {
Console.WriteLine(Environment.StackTrace);
ActiveContentChanged(this, EventArgs.Empty);
}
}

13
src/Main/Base/Project/Src/Util/Linq.cs

@ -97,6 +97,19 @@ namespace ICSharpCode.SharpDevelop @@ -97,6 +97,19 @@ namespace ICSharpCode.SharpDevelop
return false;
}
/// <summary>
/// Returns the first element from <paramref name="input"/>.
/// </summary>
public static T First<T>(IEnumerable<T> input)
{
if (input == null)
throw new ArgumentNullException("input");
foreach (T item in input) {
return item;
}
throw new ArgumentException("input must not be an empty collection", "input");
}
public static List<T> ToList<T>(IEnumerable<T> input)
{
return new List<T>(input);

117
src/Main/Base/Project/Src/Util/UnclosableStream.cs

@ -0,0 +1,117 @@ @@ -0,0 +1,117 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <author name="Daniel Grunwald"/>
// <version>$Revision$</version>
// </file>
using System;
using System.IO;
namespace ICSharpCode.SharpDevelop
{
/// <summary>
/// Wraps another stream. Closing this stream does not close the base stream.
/// </summary>
public class UnclosableStream : Stream
{
Stream baseStream;
public UnclosableStream(Stream baseStream)
{
if (baseStream == null)
throw new ArgumentNullException("baseStream");
this.baseStream = baseStream;
}
public override bool CanRead {
get { return baseStream.CanRead; }
}
public override bool CanSeek {
get { return baseStream.CanSeek; }
}
public override bool CanWrite {
get { return baseStream.CanWrite; }
}
public override long Length {
get { return baseStream.Length; }
}
public override long Position {
get { return baseStream.Position; }
set { baseStream.Position = value; }
}
public override void Flush()
{
baseStream.Flush();
}
public override long Seek(long offset, SeekOrigin origin)
{
return baseStream.Seek(offset, origin);
}
public override void SetLength(long value)
{
baseStream.SetLength(value);
}
public override int Read(byte[] buffer, int offset, int count)
{
return baseStream.Read(buffer, offset, count);
}
public override void Write(byte[] buffer, int offset, int count)
{
baseStream.Write(buffer, offset, count);
}
public override IAsyncResult BeginRead(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
return baseStream.BeginRead(buffer, offset, count, callback, state);
}
public override IAsyncResult BeginWrite(byte[] buffer, int offset, int count, AsyncCallback callback, object state)
{
return baseStream.BeginWrite(buffer, offset, count, callback, state);
}
public override bool CanTimeout {
get { return baseStream.CanTimeout; }
}
public override int EndRead(IAsyncResult asyncResult)
{
return baseStream.EndRead(asyncResult);
}
public override void EndWrite(IAsyncResult asyncResult)
{
baseStream.EndWrite(asyncResult);
}
public override int ReadByte()
{
return baseStream.ReadByte();
}
public override int ReadTimeout {
get { return baseStream.ReadTimeout; }
set { baseStream.ReadTimeout = value; }
}
public override void WriteByte(byte value)
{
baseStream.WriteByte(value);
}
public override int WriteTimeout {
get { return baseStream.WriteTimeout; }
set { baseStream.WriteTimeout = value; }
}
}
}

33
src/SharpDevelop.sln

@ -10,6 +10,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display @@ -10,6 +10,18 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Display Bindings", "Display
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "WpfDesign", "WpfDesign", "{388C3979-2621-4839-A955-7E5C03BA0B63}"
ProjectSection(SolutionItems) = postProject
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.AddIn", "AddIns\DisplayBindings\WpfDesign\WpfDesign.AddIn\WpfDesign.AddIn.csproj", "{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.XamlDom", "AddIns\DisplayBindings\WpfDesign\WpfDesign.XamlDom\Project\WpfDesign.XamlDom.csproj", "{88DA149F-21B2-48AB-82C4-28FB6BDFD783}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign.Designer", "AddIns\DisplayBindings\WpfDesign\WpfDesign.Designer\Project\WpfDesign.Designer.csproj", "{78CC29AC-CC79-4355-B1F2-97936DF198AC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WpfDesign", "AddIns\DisplayBindings\WpfDesign\WpfDesign\Project\WpfDesign.csproj", "{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WorkflowDesigner", "AddIns\DisplayBindings\WorkflowDesigner\Project\WorkflowDesigner.csproj", "{533F4684-DBA6-4518-B005-C84F22A2DD57}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ClassDiagram", "ClassDiagram", "{DB137F0B-9B62-4232-AE92-F7BE0280B8D3}"
@ -468,6 +480,22 @@ Global @@ -468,6 +480,22 @@ Global
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|Any CPU.Build.0 = Release|Any CPU
{7C96B65D-28A5-4F28-A35B-8D83CE831EE8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.Build.0 = Release|Any CPU
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.Build.0 = Release|Any CPU
{78CC29AC-CC79-4355-B1F2-97936DF198AC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.Build.0 = Release|Any CPU
{88DA149F-21B2-48AB-82C4-28FB6BDFD783}.Release|Any CPU.ActiveCfg = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.Build.0 = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.Build.0 = Release|Any CPU
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{CE5B42B7-6E8C-4385-9E97-F4023FC16BF2} = {14A277EE-7DF1-4529-B639-7D1EF334C1C5}
@ -480,6 +508,11 @@ Global @@ -480,6 +508,11 @@ Global
{85226AFB-CE71-4851-9A75-7EEC663A8E8A} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
{DB137F0B-9B62-4232-AE92-F7BE0280B8D3} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
{533F4684-DBA6-4518-B005-C84F22A2DD57} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
{388C3979-2621-4839-A955-7E5C03BA0B63} = {4EA396ED-64AD-4AD0-A67A-AB363F3E0C79}
{66A378A1-E9F4-4AD5-8946-D0EC06C2902F} = {388C3979-2621-4839-A955-7E5C03BA0B63}
{78CC29AC-CC79-4355-B1F2-97936DF198AC} = {388C3979-2621-4839-A955-7E5C03BA0B63}
{88DA149F-21B2-48AB-82C4-28FB6BDFD783} = {388C3979-2621-4839-A955-7E5C03BA0B63}
{9A9D6FD4-6A2E-455D-ACC3-DDA775FE9865} = {388C3979-2621-4839-A955-7E5C03BA0B63}
{08F772A1-F0BE-433E-8B37-F6522953DB05} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3}
{F5E059BB-96C2-4398-BED0-8598CD434173} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3}
{5A1354DF-4989-4BB4-BC6B-D627C2E9FA13} = {DB137F0B-9B62-4232-AE92-F7BE0280B8D3}

Loading…
Cancel
Save