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. 6
      samples/CustomView/MyCustomView.cs
  4. 18
      samples/DisplayBindings/AlternateEditor/AlternateEditorDisplayBinding.cs
  5. 30
      samples/DisplayBindings/AlternateEditor/Editor.cs
  6. 4
      samples/DisplayBindings/HtmlPreview/Src/PreviewDisplayBinding.cs
  7. 24
      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 @@ -94,8 +94,6 @@ namespace CSharpEditor
NRefactoryResolver resolver = new NRefactoryResolver(mainForm.myProjectContent.Language);
Dom.ResolveResult rr = resolver.Resolve(FindExpression(textArea),
textArea.Caret.Line + 1,
textArea.Caret.Column + 1,
mainForm.parseInformation,
textArea.MotherTextEditorControl.Text);
List<ICompletionData> resultList = new List<ICompletionData>();

2
samples/CSharpCodeCompletion/ToolTipProvider.cs

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

6
samples/CustomView/MyCustomView.cs

@ -25,9 +25,11 @@ @@ -25,9 +25,11 @@
// 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 ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace CustomView
@ -63,11 +65,11 @@ 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; @@ -29,31 +29,21 @@ using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using System;
using System.IO;
namespace AlternateEditor
{
public class AlternateEditorDisplayBinding : IDisplayBinding
{
public bool CanCreateContentForFile(string fileName)
{
return true;
}
public bool CanCreateContentForLanguage(string language)
public bool CanCreateContentForFile(string fileName)
{
return true;
}
public IViewContent CreateContentForFile(string fileName)
{
Editor editor = new Editor();
editor.Load(fileName);
return editor;
}
public IViewContent CreateContentForLanguage(string language, string content)
public IViewContent CreateContentForFile(OpenedFile file)
{
return new Editor();
return new Editor(file);
}
}
}

30
samples/DisplayBindings/AlternateEditor/Editor.cs

@ -25,8 +25,10 @@ @@ -25,8 +25,10 @@
// 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 ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
using System;
using System.IO;
using System.Windows.Forms;
namespace AlternateEditor
@ -47,9 +49,14 @@ 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.TextChanged += TextChanged;
}
public override void RedrawContent()
@ -62,18 +69,23 @@ namespace AlternateEditor @@ -62,18 +69,23 @@ namespace AlternateEditor
rtb.Dispose();
}
public override void Save(string fileName)
public override void Save(OpenedFile file, Stream stream)
{
rtb.SaveFile(fileName, RichTextBoxStreamType.PlainText);
TitleName = fileName;
IsDirty = false;
rtb.SaveFile(stream, RichTextBoxStreamType.PlainText);
TitleName = file.FileName;
}
public override void Load(string fileName)
public override void Load(OpenedFile file, Stream stream)
{
rtb.LoadFile(fileName, RichTextBoxStreamType.PlainText);
TitleName = fileName;
IsDirty = false;
rtb.LoadFile(stream, RichTextBoxStreamType.PlainText);
TitleName = file.FileName;
}
void TextChanged(object source, EventArgs e)
{
if (PrimaryFile != null) {
PrimaryFile.MakeDirty();
}
}
}
}

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

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

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

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

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

@ -26,9 +26,12 @@ @@ -26,9 +26,12 @@
// OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
using System;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.Core;
using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Gui;
namespace ImageViewer
@ -36,36 +39,54 @@ namespace ImageViewer @@ -36,36 +39,54 @@ namespace ImageViewer
public class ImageViewContent : AbstractViewContent
{
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 {
get {
return box;
}
}
public override string TabPageText {
public override bool IsReadOnly {
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;
this.FileName = fileName;
this.TitleName = Path.GetFileName(fileName);
box.SizeMode = PictureBoxSizeMode.Zoom;
box.Load(fileName);
}
public override void Save(string fileName) {
this.IsDirty = false;
this.FileName = fileName;
this.TitleName = Path.GetFileName(fileName);
box.Image.Save(fileName);
}
/// <summary>
/// The load method takes a copy of the image and saves the
/// 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;
public override bool IsReadOnly {
get {
return (File.GetAttributes(this.FileName)
& FileAttributes.ReadOnly) != 0;
box.SizeMode = PictureBoxSizeMode.Zoom;
box.Image = new Bitmap(image.Width, image.Height);
using (Graphics graphics = Graphics.FromImage(box.Image)) {
graphics.DrawImage(image, 0, 0);
}
}
public override void Save(OpenedFile file, Stream stream)
{
box.Image.Save(stream, format);
}
}
}

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

@ -37,16 +37,10 @@ namespace ImageViewer @@ -37,16 +37,10 @@ namespace ImageViewer
public bool CanCreateContentForFile(string fileName) {
return true;
}
public IViewContent CreateContentForFile(string fileName) {
ImageViewContent vc = new ImageViewContent();
vc.Load(fileName);
public IViewContent CreateContentForFile(OpenedFile file) {
ImageViewContent vc = new ImageViewContent(file);
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 @@ @@ -5,7 +5,7 @@
<Manifest>
<Identity name="Grunwald.LineCounter"/>
<Dependency addin="SharpDevelop" version="2.1"/>
<Dependency addin="SharpDevelop" version="3.0"/>
</Manifest>
<Runtime>

4
samples/NRefactoryExample/WrapperGeneratorVisitor.cs

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

11
samples/SdaUser/SdaAddIns/SdaBase.addin

@ -235,4 +235,15 @@ @@ -235,4 +235,15 @@
class = "ICSharpCode.SharpDevelop.Commands.OptionsCommand"/>
</MenuItem>
</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>

6
samples/SdaUser/SdaUser.sln

@ -1,5 +1,7 @@ @@ -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}"
EndProject
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 @@ @@ -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>
<OutputType>Library</OutputType>
<RootNamespace>SharpDevelopInteraction</RootNamespace>
@ -15,6 +15,7 @@ @@ -15,6 +15,7 @@
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<BaseIntermediateOutputPath>obj\</BaseIntermediateOutputPath>
@ -38,6 +39,12 @@ @@ -38,6 +39,12 @@
</PropertyGroup>
<ItemGroup>
<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="ICSharpCode.Core">
<HintPath>..\..\..\bin\ICSharpCode.Core.dll</HintPath>
@ -55,6 +62,9 @@ @@ -55,6 +62,9 @@
<SpecificVersion>False</SpecificVersion>
<Private>False</Private>
</Reference>
<Reference Include="System.Xml.Linq">
<RequiredTargetFramework>3.5</RequiredTargetFramework>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="InteractionClass.cs" />

Loading…
Cancel
Save