diff --git a/samples/CSharpCodeCompletion/CodeCompletionProvider.cs b/samples/CSharpCodeCompletion/CodeCompletionProvider.cs index 8982a7ee8e..23c697d5cb 100644 --- a/samples/CSharpCodeCompletion/CodeCompletionProvider.cs +++ b/samples/CSharpCodeCompletion/CodeCompletionProvider.cs @@ -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 resultList = new List(); diff --git a/samples/CSharpCodeCompletion/ToolTipProvider.cs b/samples/CSharpCodeCompletion/ToolTipProvider.cs index 4ffed3b7cc..86b88dc20e 100644 --- a/samples/CSharpCodeCompletion/ToolTipProvider.cs +++ b/samples/CSharpCodeCompletion/ToolTipProvider.cs @@ -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); diff --git a/samples/CustomView/MyCustomView.cs b/samples/CustomView/MyCustomView.cs index 04d32ade73..94c465cc99 100644 --- a/samples/CustomView/MyCustomView.cs +++ b/samples/CustomView/MyCustomView.cs @@ -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 } } - 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) { } diff --git a/samples/DisplayBindings/AlternateEditor/AlternateEditorDisplayBinding.cs b/samples/DisplayBindings/AlternateEditor/AlternateEditorDisplayBinding.cs index 9a1603d4b5..0014add6cc 100644 --- a/samples/DisplayBindings/AlternateEditor/AlternateEditorDisplayBinding.cs +++ b/samples/DisplayBindings/AlternateEditor/AlternateEditorDisplayBinding.cs @@ -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); } } } diff --git a/samples/DisplayBindings/AlternateEditor/Editor.cs b/samples/DisplayBindings/AlternateEditor/Editor.cs index 4bce1ec7df..1235d575fb 100644 --- a/samples/DisplayBindings/AlternateEditor/Editor.cs +++ b/samples/DisplayBindings/AlternateEditor/Editor.cs @@ -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 } } - 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() @@ -61,19 +68,24 @@ namespace AlternateEditor { 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); - TitleName = fileName; - IsDirty = false; + rtb.LoadFile(stream, RichTextBoxStreamType.PlainText); + TitleName = file.FileName; } - public override void Load(string fileName) + void TextChanged(object source, EventArgs e) { - rtb.LoadFile(fileName, RichTextBoxStreamType.PlainText); - TitleName = fileName; - IsDirty = false; + if (PrimaryFile != null) { + PrimaryFile.MakeDirty(); + } } } } diff --git a/samples/DisplayBindings/HtmlPreview/Src/PreviewDisplayBinding.cs b/samples/DisplayBindings/HtmlPreview/Src/PreviewDisplayBinding.cs index 2b6047ada5..26a46bb7f8 100644 --- a/samples/DisplayBindings/HtmlPreview/Src/PreviewDisplayBinding.cs +++ b/samples/DisplayBindings/HtmlPreview/Src/PreviewDisplayBinding.cs @@ -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) }; } } } diff --git a/samples/DisplayBindings/HtmlPreview/Src/PreviewViewContent.cs b/samples/DisplayBindings/HtmlPreview/Src/PreviewViewContent.cs index c6e73d718b..c7143980b2 100644 --- a/samples/DisplayBindings/HtmlPreview/Src/PreviewViewContent.cs +++ b/samples/DisplayBindings/HtmlPreview/Src/PreviewViewContent.cs @@ -37,8 +37,12 @@ namespace HtmlPreview /// public class PreviewViewContent : AbstractSecondaryViewContent { - public PreviewViewContent() + IEditable editable; + + public PreviewViewContent(IViewContent viewContent) : base(viewContent) { + TabPageText = "Preview"; + editable = viewContent as IEditable; } WebBrowser browser = new WebBrowser(); @@ -48,24 +52,18 @@ namespace HtmlPreview get { return browser; } - } + } - 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 diff --git a/samples/DisplayBindings/ImageViewer/Src/ImageViewContent.cs b/samples/DisplayBindings/ImageViewer/Src/ImageViewContent.cs index 147448a6b6..aed00bcad3 100644 --- a/samples/DisplayBindings/ImageViewer/Src/ImageViewContent.cs +++ b/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. 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 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); + + /// + /// 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 + /// + public override void Load(OpenedFile file, Stream stream) + { + Image image = Image.FromStream(stream); + format = image.RawFormat; + 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); + box.Image = new Bitmap(image.Width, image.Height); + using (Graphics graphics = Graphics.FromImage(box.Image)) { + graphics.DrawImage(image, 0, 0); + } } - public override bool IsReadOnly { - get { - return (File.GetAttributes(this.FileName) - & FileAttributes.ReadOnly) != 0; - } + public override void Save(OpenedFile file, Stream stream) + { + box.Image.Save(stream, format); } } } diff --git a/samples/DisplayBindings/ImageViewer/Src/ImageViewerDisplayBinding.cs b/samples/DisplayBindings/ImageViewer/Src/ImageViewerDisplayBinding.cs index 6dc68dd6d2..456af714ff 100644 --- a/samples/DisplayBindings/ImageViewer/Src/ImageViewerDisplayBinding.cs +++ b/samples/DisplayBindings/ImageViewer/Src/ImageViewerDisplayBinding.cs @@ -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(); - } } } diff --git a/samples/LineCounter/LineCounter.addin b/samples/LineCounter/LineCounter.addin index 20f2903c67..2bace2f462 100644 --- a/samples/LineCounter/LineCounter.addin +++ b/samples/LineCounter/LineCounter.addin @@ -5,7 +5,7 @@ - + diff --git a/samples/NRefactoryExample/WrapperGeneratorVisitor.cs b/samples/NRefactoryExample/WrapperGeneratorVisitor.cs index 5315aa8eb3..d6994e5747 100644 --- a/samples/NRefactoryExample/WrapperGeneratorVisitor.cs +++ b/samples/NRefactoryExample/WrapperGeneratorVisitor.cs @@ -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 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); diff --git a/samples/SdaUser/SdaAddIns/SdaBase.addin b/samples/SdaUser/SdaAddIns/SdaBase.addin index daf35919d8..4e98dcd4d7 100644 --- a/samples/SdaUser/SdaAddIns/SdaBase.addin +++ b/samples/SdaUser/SdaAddIns/SdaBase.addin @@ -235,4 +235,15 @@ class = "ICSharpCode.SharpDevelop.Commands.OptionsCommand"/> + + + + + diff --git a/samples/SdaUser/SdaUser.sln b/samples/SdaUser/SdaUser.sln index 1f2d8c5a7c..c0c5dca0e9 100644 --- a/samples/SdaUser/SdaUser.sln +++ b/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}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpDevelopInteraction", "SharpDevelopInteraction\SharpDevelopInteraction.csproj", "{84054D5E-0B81-4C4B-AABB-DCC43030830B}" diff --git a/samples/SdaUser/SharpDevelopInteraction/SharpDevelopInteraction.csproj b/samples/SdaUser/SharpDevelopInteraction/SharpDevelopInteraction.csproj index e5c5ea4f33..01e6da7e77 100644 --- a/samples/SdaUser/SharpDevelopInteraction/SharpDevelopInteraction.csproj +++ b/samples/SdaUser/SharpDevelopInteraction/SharpDevelopInteraction.csproj @@ -1,4 +1,4 @@ - + Library SharpDevelopInteraction @@ -15,6 +15,7 @@ 4096 4 false + v3.5 obj\ @@ -38,6 +39,12 @@ + + 3.5 + + + 3.5 + ..\..\..\bin\ICSharpCode.Core.dll @@ -55,6 +62,9 @@ False False + + 3.5 +