Browse Source

Updated samples so they work with SharpDevelop 3.0

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@2755 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Matt Ward 18 years ago
parent
commit
4f8f2dc7db
  1. 2
      samples/CSharpCodeCompletion/CodeCompletionProvider.cs
  2. 2
      samples/CSharpCodeCompletion/ToolTipProvider.cs
  3. 8
      samples/CustomView/MyCustomView.cs
  4. 18
      samples/DisplayBindings/AlternateEditor/AlternateEditorDisplayBinding.cs
  5. 32
      samples/DisplayBindings/AlternateEditor/Editor.cs
  6. 4
      samples/DisplayBindings/HtmlPreview/Src/PreviewDisplayBinding.cs
  7. 28
      samples/DisplayBindings/HtmlPreview/Src/PreviewViewContent.cs
  8. 59
      samples/DisplayBindings/ImageViewer/Src/ImageViewContent.cs
  9. 12
      samples/DisplayBindings/ImageViewer/Src/ImageViewerDisplayBinding.cs
  10. 2
      samples/LineCounter/LineCounter.addin
  11. 4
      samples/NRefactoryExample/WrapperGeneratorVisitor.cs
  12. 11
      samples/SdaUser/SdaAddIns/SdaBase.addin
  13. 6
      samples/SdaUser/SdaUser.sln
  14. 12
      samples/SdaUser/SharpDevelopInteraction/SharpDevelopInteraction.csproj

2
samples/CSharpCodeCompletion/CodeCompletionProvider.cs

@ -94,8 +94,6 @@ namespace CSharpEditor
NRefactoryResolver resolver = new NRefactoryResolver(mainForm.myProjectContent.Language); NRefactoryResolver resolver = new NRefactoryResolver(mainForm.myProjectContent.Language);
Dom.ResolveResult rr = resolver.Resolve(FindExpression(textArea), Dom.ResolveResult rr = resolver.Resolve(FindExpression(textArea),
textArea.Caret.Line + 1,
textArea.Caret.Column + 1,
mainForm.parseInformation, mainForm.parseInformation,
textArea.MotherTextEditorControl.Text); textArea.MotherTextEditorControl.Text);
List<ICompletionData> resultList = new List<ICompletionData>(); List<ICompletionData> resultList = new List<ICompletionData>();

2
samples/CSharpCodeCompletion/ToolTipProvider.cs

@ -62,8 +62,6 @@ namespace CSharpEditor
TextEditor.TextArea textArea = editor.ActiveTextAreaControl.TextArea; TextEditor.TextArea textArea = editor.ActiveTextAreaControl.TextArea;
NRefactoryResolver resolver = new NRefactoryResolver(mainForm.myProjectContent.Language); NRefactoryResolver resolver = new NRefactoryResolver(mainForm.myProjectContent.Language);
ResolveResult rr = resolver.Resolve(expression, ResolveResult rr = resolver.Resolve(expression,
e.LogicalPosition.Y + 1,
e.LogicalPosition.X + 1,
mainForm.parseInformation, mainForm.parseInformation,
textArea.MotherTextEditorControl.Text); textArea.MotherTextEditorControl.Text);
string toolTipText = GetText(rr); string toolTipText = GetText(rr);

8
samples/CustomView/MyCustomView.cs

@ -25,9 +25,11 @@
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT // 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. // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using System; using System;
using System.Drawing; using System.Drawing;
using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
namespace CustomView namespace CustomView
@ -63,11 +65,11 @@ namespace CustomView
} }
} }
public override void Save(string fileName) public override void Load(OpenedFile file, Stream stream)
{ {
} }
public override void Load(string fileName) public override void Save(OpenedFile file, Stream stream)
{ {
} }

18
samples/DisplayBindings/AlternateEditor/AlternateEditorDisplayBinding.cs

@ -29,31 +29,21 @@ using ICSharpCode.Core;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using System; using System;
using System.IO;
namespace AlternateEditor namespace AlternateEditor
{ {
public class AlternateEditorDisplayBinding : IDisplayBinding public class AlternateEditorDisplayBinding : IDisplayBinding
{ {
public bool CanCreateContentForFile(string fileName)
{
return true;
}
public bool CanCreateContentForLanguage(string language) public bool CanCreateContentForFile(string fileName)
{ {
return true; return true;
} }
public IViewContent CreateContentForFile(string fileName) public IViewContent CreateContentForFile(OpenedFile file)
{
Editor editor = new Editor();
editor.Load(fileName);
return editor;
}
public IViewContent CreateContentForLanguage(string language, string content)
{ {
return new Editor(); return new Editor(file);
} }
} }
} }

32
samples/DisplayBindings/AlternateEditor/Editor.cs

@ -25,8 +25,10 @@
// IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT // 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. // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
using System; using System;
using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
namespace AlternateEditor namespace AlternateEditor
@ -47,9 +49,14 @@ namespace AlternateEditor
} }
} }
public Editor() public Editor(OpenedFile file)
{ {
Files.Add(file);
OnFileNameChanged(file);
file.ForceInitializeView(this);
rtb.Dock = DockStyle.Fill; rtb.Dock = DockStyle.Fill;
rtb.TextChanged += TextChanged;
} }
public override void RedrawContent() public override void RedrawContent()
@ -61,19 +68,24 @@ namespace AlternateEditor
{ {
rtb.Dispose(); rtb.Dispose();
} }
public override void Save(OpenedFile file, Stream stream)
{
rtb.SaveFile(stream, RichTextBoxStreamType.PlainText);
TitleName = file.FileName;
}
public override void Save(string fileName) public override void Load(OpenedFile file, Stream stream)
{ {
rtb.SaveFile(fileName, RichTextBoxStreamType.PlainText); rtb.LoadFile(stream, RichTextBoxStreamType.PlainText);
TitleName = fileName; TitleName = file.FileName;
IsDirty = false;
} }
public override void Load(string fileName) void TextChanged(object source, EventArgs e)
{ {
rtb.LoadFile(fileName, RichTextBoxStreamType.PlainText); if (PrimaryFile != null) {
TitleName = fileName; PrimaryFile.MakeDirty();
IsDirty = false; }
} }
} }
} }

4
samples/DisplayBindings/HtmlPreview/Src/PreviewDisplayBinding.cs

@ -47,8 +47,8 @@ namespace HtmlPreview
return true; return true;
} }
public ISecondaryViewContent[] CreateSecondaryViewContent(IViewContent viewContent) { public IViewContent[] CreateSecondaryViewContent(IViewContent viewContent) {
return new ISecondaryViewContent[] { new PreviewViewContent() }; return new IViewContent[] { new PreviewViewContent(viewContent) };
} }
} }
} }

28
samples/DisplayBindings/HtmlPreview/Src/PreviewViewContent.cs

@ -37,8 +37,12 @@ namespace HtmlPreview
/// </summary> /// </summary>
public class PreviewViewContent : AbstractSecondaryViewContent public class PreviewViewContent : AbstractSecondaryViewContent
{ {
public PreviewViewContent() IEditable editable;
public PreviewViewContent(IViewContent viewContent) : base(viewContent)
{ {
TabPageText = "Preview";
editable = viewContent as IEditable;
} }
WebBrowser browser = new WebBrowser(); WebBrowser browser = new WebBrowser();
@ -48,24 +52,18 @@ namespace HtmlPreview
get { get {
return browser; return browser;
} }
} }
public override string TabPageText { protected override void LoadFromPrimary()
get { {
return "Preview"; if (editable != null) {
browser.DocumentText = editable.Text;
} }
} }
public override void Deselected() { protected override void SaveToPrimary()
browser.DocumentText = ""; {
base.Deselected(); }
}
public override void Selected() {
IViewContent viewContent = this.WorkbenchWindow.ViewContent;
IEditable editable = (IEditable)viewContent;
browser.DocumentText = editable.Text;
base.Selected();
}
#endregion #endregion

59
samples/DisplayBindings/ImageViewer/Src/ImageViewContent.cs

@ -26,9 +26,12 @@
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System; using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO; using System.IO;
using System.Windows.Forms; using System.Windows.Forms;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui; using ICSharpCode.SharpDevelop.Gui;
namespace ImageViewer namespace ImageViewer
@ -36,36 +39,54 @@ namespace ImageViewer
public class ImageViewContent : AbstractViewContent public class ImageViewContent : AbstractViewContent
{ {
PictureBox box = new PictureBox(); PictureBox box = new PictureBox();
ImageFormat format;
public ImageViewContent(OpenedFile file)
{
this.TabPageText = "Image Viewer";
this.Files.Add(file);
file.ForceInitializeView(this);
}
public override Control Control { public override Control Control {
get { get {
return box; return box;
} }
} }
public override string TabPageText {
public override bool IsReadOnly {
get { get {
return "Image Viewer"; if (File.Exists(PrimaryFile.FileName)) {
return (File.GetAttributes(PrimaryFile.FileName)
& FileAttributes.ReadOnly) != 0;
}
return false;
} }
} }
public override void Load(string fileName) {
this.IsDirty = false; /// <summary>
this.FileName = fileName; /// The load method takes a copy of the image and saves the
this.TitleName = Path.GetFileName(fileName); /// image format so the image can be saved later without throwing
/// a GDI+ exception. This is because the stream is disposed during
/// the lifetime of the image:
///
/// http://support.microsoft.com/?id=814675
/// </summary>
public override void Load(OpenedFile file, Stream stream)
{
Image image = Image.FromStream(stream);
format = image.RawFormat;
box.SizeMode = PictureBoxSizeMode.Zoom; box.SizeMode = PictureBoxSizeMode.Zoom;
box.Load(fileName); box.Image = new Bitmap(image.Width, image.Height);
} using (Graphics graphics = Graphics.FromImage(box.Image)) {
graphics.DrawImage(image, 0, 0);
public override void Save(string fileName) { }
this.IsDirty = false;
this.FileName = fileName;
this.TitleName = Path.GetFileName(fileName);
box.Image.Save(fileName);
} }
public override bool IsReadOnly { public override void Save(OpenedFile file, Stream stream)
get { {
return (File.GetAttributes(this.FileName) box.Image.Save(stream, format);
& FileAttributes.ReadOnly) != 0;
}
} }
} }
} }

12
samples/DisplayBindings/ImageViewer/Src/ImageViewerDisplayBinding.cs

@ -37,16 +37,10 @@ namespace ImageViewer
public bool CanCreateContentForFile(string fileName) { public bool CanCreateContentForFile(string fileName) {
return true; return true;
} }
public IViewContent CreateContentForFile(string fileName) {
ImageViewContent vc = new ImageViewContent(); public IViewContent CreateContentForFile(OpenedFile file) {
vc.Load(fileName); ImageViewContent vc = new ImageViewContent(file);
return vc; return vc;
} }
public bool CanCreateContentForLanguage(string languageName) {
return false;
}
public IViewContent CreateContentForLanguage(string languageName, string content) {
throw new NotImplementedException();
}
} }
} }

2
samples/LineCounter/LineCounter.addin

@ -5,7 +5,7 @@
<Manifest> <Manifest>
<Identity name="Grunwald.LineCounter"/> <Identity name="Grunwald.LineCounter"/>
<Dependency addin="SharpDevelop" version="2.1"/> <Dependency addin="SharpDevelop" version="3.0"/>
</Manifest> </Manifest>
<Runtime> <Runtime>

4
samples/NRefactoryExample/WrapperGeneratorVisitor.cs

@ -59,7 +59,7 @@ namespace NRefactoryExample
cd.Parameters.Add(new ParameterDeclarationExpression(fd.TypeReference, cd.Parameters.Add(new ParameterDeclarationExpression(fd.TypeReference,
"wrappedObject")); "wrappedObject"));
// this.wrappedObject = wrappedObject; // this.wrappedObject = wrappedObject;
Expression fieldReference = new FieldReferenceExpression(new ThisReferenceExpression(), Expression fieldReference = new MemberReferenceExpression(new ThisReferenceExpression(),
"wrappedObject"); "wrappedObject");
Expression assignment = new AssignmentExpression(fieldReference, Expression assignment = new AssignmentExpression(fieldReference,
AssignmentOperatorType.Assign, AssignmentOperatorType.Assign,
@ -122,7 +122,7 @@ namespace NRefactoryExample
static InvocationExpression CreateMethodCall(MethodDeclaration method) static InvocationExpression CreateMethodCall(MethodDeclaration method)
{ {
IdentifierExpression wrappedObject = new IdentifierExpression("wrappedObject"); IdentifierExpression wrappedObject = new IdentifierExpression("wrappedObject");
FieldReferenceExpression methodName = new FieldReferenceExpression(wrappedObject, method.Name); MemberReferenceExpression methodName = new MemberReferenceExpression(wrappedObject, method.Name);
InvocationExpression ie = new InvocationExpression(methodName, null); InvocationExpression ie = new InvocationExpression(methodName, null);
foreach (ParameterDeclarationExpression param in method.Parameters) { foreach (ParameterDeclarationExpression param in method.Parameters) {
Expression expr = new IdentifierExpression(param.ParameterName); Expression expr = new IdentifierExpression(param.ParameterName);

11
samples/SdaUser/SdaAddIns/SdaBase.addin

@ -235,4 +235,15 @@
class = "ICSharpCode.SharpDevelop.Commands.OptionsCommand"/> class = "ICSharpCode.SharpDevelop.Commands.OptionsCommand"/>
</MenuItem> </MenuItem>
</Path> </Path>
<Path name="/SharpDevelop/Workbench/ToolBar">
<ToolbarItem id = "New"
icon = "Icons.16x16.NewDocumentIcon"
tooltip = "${res:XML.MainMenu.FileMenu.New.File.Description}"
class = "ICSharpCode.SharpDevelop.Commands.CreateNewFile"/>
<ToolbarItem id = "Open"
icon = "Icons.16x16.OpenFileIcon"
tooltip = "${res:XML.MainMenu.FileMenu.Open.File.Description}"
class = "ICSharpCode.SharpDevelop.Commands.OpenFile"/>
</Path>
</AddIn> </AddIn>

6
samples/SdaUser/SdaUser.sln

@ -1,5 +1,7 @@
Microsoft Visual Studio Solution File, Format Version 9.00 
# SharpDevelop 2.1.0.1602 Microsoft Visual Studio Solution File, Format Version 10.00
# Visual Studio 2008
# SharpDevelop 3.0.0.2745
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SdaUser", "SdaUser.csproj", "{3FF48818-69D2-4884-8F4F-62EC72F0D5F0}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SdaUser", "SdaUser.csproj", "{3FF48818-69D2-4884-8F4F-62EC72F0D5F0}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDevelopInteraction", "SharpDevelopInteraction\SharpDevelopInteraction.csproj", "{84054D5E-0B81-4C4B-AABB-DCC43030830B}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDevelopInteraction", "SharpDevelopInteraction\SharpDevelopInteraction.csproj", "{84054D5E-0B81-4C4B-AABB-DCC43030830B}"

12
samples/SdaUser/SharpDevelopInteraction/SharpDevelopInteraction.csproj

@ -1,4 +1,4 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="3.5">
<PropertyGroup> <PropertyGroup>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<RootNamespace>SharpDevelopInteraction</RootNamespace> <RootNamespace>SharpDevelopInteraction</RootNamespace>
@ -15,6 +15,7 @@
<FileAlignment>4096</FileAlignment> <FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors> <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' "> <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath> <BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
@ -38,6 +39,12 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Core">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
<Reference Include="ICSharpCode.Core"> <Reference Include="ICSharpCode.Core">
<HintPath>..\..\..\bin\ICSharpCode.Core.dll</HintPath> <HintPath>..\..\..\bin\ICSharpCode.Core.dll</HintPath>
@ -55,6 +62,9 @@
<SpecificVersion>False</SpecificVersion> <SpecificVersion>False</SpecificVersion>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="InteractionClass.cs" /> <Compile Include="InteractionClass.cs" />

Loading…
Cancel
Save