Browse Source

Updated SharpSnippetCompiler sample to be able to re-open a closed file when clicking an item in the errors list.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@5510 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
pull/1/head
Matt Ward 16 years ago
parent
commit
37c63c645c
  1. 6
      samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/Workbench.cs
  2. 17
      samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.cs
  3. 1
      samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj
  4. 52
      samples/SharpSnippetCompiler/SharpSnippetCompiler/TextEditorDisplayBinding.cs

6
samples/SharpSnippetCompiler/SharpSnippetCompiler.Core/Workbench.cs

@ -121,7 +121,11 @@ namespace ICSharpCode.SharpSnippetCompiler.Core @@ -121,7 +121,11 @@ namespace ICSharpCode.SharpSnippetCompiler.Core
public void CloseContent(IViewContent content)
{
throw new NotImplementedException();
if (views.Contains(content)) {
views.Remove(content);
}
content.Dispose();
}
public void CloseAllViews()

17
samples/SharpSnippetCompiler/SharpSnippetCompiler/MainForm.cs

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
// SharpDevelop samples
// Copyright (c) 2008, AlphaSierraPapa
// Copyright (c) 2010, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
@ -31,6 +31,8 @@ using System.Collections.Generic; @@ -31,6 +31,8 @@ using System.Collections.Generic;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Commands;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpDevelop.Project;
@ -91,7 +93,7 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -91,7 +93,7 @@ namespace ICSharpCode.SharpSnippetCompiler
get { return fileTabControl.SelectedTab as SnippetTabPage; }
}
public void LoadFile(string fileName)
public IViewContent LoadFile(string fileName)
{
// Create a new tab page.
SharpSnippetCompilerControl snippetControl = new SharpSnippetCompilerControl();
@ -110,6 +112,8 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -110,6 +112,8 @@ namespace ICSharpCode.SharpSnippetCompiler
WorkbenchSingleton.Workbench.ViewContentCollection.Add(view);
UpdateActiveView(view);
return view;
}
public void ActivateErrorList()
@ -357,7 +361,14 @@ namespace ICSharpCode.SharpSnippetCompiler @@ -357,7 +361,14 @@ namespace ICSharpCode.SharpSnippetCompiler
if (item != null) {
ProjectService.RemoveProjectItem(project, item);
project.Save();
foreach (IViewContent view in WorkbenchSingleton.Workbench.ViewContentCollection) {
if (view.Control == snippetControl) {
WorkbenchSingleton.Workbench.CloseContent(view);
break;
}
}
fileTabControl.TabPages.Remove(activeTabPage);
activeTabPage.Dispose();
}

1
samples/SharpSnippetCompiler/SharpSnippetCompiler/SharpSnippetCompiler.csproj

@ -68,6 +68,7 @@ @@ -68,6 +68,7 @@
</Compile>
<Compile Include="Program.cs" />
<Compile Include="SnippetTabPage.cs" />
<Compile Include="TextEditorDisplayBinding.cs" />
<Compile Include="WorkbenchLayout.cs" />
<Compile Include="WorkbenchWindow.cs" />
<EmbeddedResource Include="MainForm.resx">

52
samples/SharpSnippetCompiler/SharpSnippetCompiler/TextEditorDisplayBinding.cs

@ -0,0 +1,52 @@ @@ -0,0 +1,52 @@
// SharpDevelop samples
// Copyright (c) 2010, AlphaSierraPapa
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without modification, are
// permitted provided that the following conditions are met:
//
// - Redistributions of source code must retain the above copyright notice, this list
// of conditions and the following disclaimer.
//
// - Redistributions in binary form must reproduce the above copyright notice, this list
// of conditions and the following disclaimer in the documentation and/or other materials
// provided with the distribution.
//
// - Neither the name of the SharpDevelop team nor the names of its contributors may be used to
// endorse or promote products derived from this software without specific prior written
// permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS &AS IS& AND ANY EXPRESS
// OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
// AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using ICSharpCode.SharpSnippetCompiler.Core;
namespace ICSharpCode.SharpSnippetCompiler
{
public class TextEditorDisplayBinding : IDisplayBinding
{
public TextEditorDisplayBinding()
{
}
public bool CanCreateContentForFile(string fileName)
{
return true;
}
public IViewContent CreateContentForFile(OpenedFile file)
{
MainForm form = WorkbenchSingleton.MainForm as MainForm;
return form.LoadFile(file.FileName);
}
}
}
Loading…
Cancel
Save