Browse Source

Add samples/ICSharpCode.Core.Demo and samples/NRefactoryExample.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1132 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
c53e01d14f
  1. 2199
      samples/CodonCreation/CodonCreation.rtf
  2. 2
      samples/CodonCreation/TestDoozer.cs
  3. 2202
      samples/CustomPad/CustomPad.rtf
  4. 2183
      samples/CustomView/CustomView.rtf
  5. 2200
      samples/DisplayBindings/AlternateEditor/AlternateEditor.rtf
  6. 74
      samples/ICSharpCode.Core.Demo/AddInManager/AddInManager.addin
  7. 75
      samples/ICSharpCode.Core.Demo/AddInManager/AddInManager.csproj
  8. 6
      samples/ICSharpCode.Core.Demo/AddInManager/AddInManager.sln
  9. 33
      samples/ICSharpCode.Core.Demo/AddInManager/AssemblyInfo.cs
  10. 217
      samples/ICSharpCode.Core.Demo/AddInManager/Src/AboutForm.cs
  11. 123
      samples/ICSharpCode.Core.Demo/AddInManager/Src/AboutForm.resx
  12. 191
      samples/ICSharpCode.Core.Demo/AddInManager/Src/AddInControl.cs
  13. 39
      samples/ICSharpCode.Core.Demo/AddInManager/Src/AddInInstallBinding.cs
  14. 152
      samples/ICSharpCode.Core.Demo/AddInManager/Src/Commands.cs
  15. 123
      samples/ICSharpCode.Core.Demo/AddInManager/Src/InstallableAddIn.cs
  16. 918
      samples/ICSharpCode.Core.Demo/AddInManager/Src/ManagerForm.cs
  17. 120
      samples/ICSharpCode.Core.Demo/AddInManager/Src/ManagerForm.resx
  18. BIN
      samples/ICSharpCode.Core.Demo/AddInManager/StringResources.de.resources
  19. BIN
      samples/ICSharpCode.Core.Demo/AddInManager/StringResources.resources
  20. BIN
      samples/ICSharpCode.Core.Demo/AddInManager/WizardBackground.png
  21. 34
      samples/ICSharpCode.Core.Demo/Base/AssemblyInfo.cs
  22. 67
      samples/ICSharpCode.Core.Demo/Base/Base.csproj
  23. 6
      samples/ICSharpCode.Core.Demo/Base/Base.sln
  24. 74
      samples/ICSharpCode.Core.Demo/Base/FileCommands.cs
  25. 147
      samples/ICSharpCode.Core.Demo/Base/FileViewContent.cs
  26. 68
      samples/ICSharpCode.Core.Demo/Base/FormLocationHelper.cs
  27. 22
      samples/ICSharpCode.Core.Demo/Base/IClipboardHandler.cs
  28. 40
      samples/ICSharpCode.Core.Demo/Base/IDisplayBinding.cs
  29. 15
      samples/ICSharpCode.Core.Demo/Base/IUndoHandler.cs
  30. 45
      samples/ICSharpCode.Core.Demo/Base/IViewContent.cs
  31. 233
      samples/ICSharpCode.Core.Demo/Base/InfoForm.cs
  32. 141
      samples/ICSharpCode.Core.Demo/Base/InfoForm.resx
  33. 128
      samples/ICSharpCode.Core.Demo/Base/TextViewContent.cs
  34. 141
      samples/ICSharpCode.Core.Demo/Base/Workbench.cs
  35. 29
      samples/ICSharpCode.Core.Demo/ICSharpCode.Core.Demo.rtf
  36. 46
      samples/ICSharpCode.Core.Demo/ICSharpCode.Core.Demo.sln
  37. BIN
      samples/ICSharpCode.Core.Demo/RequiredLibraries/ICSharpCode.SharpZipLib.dll
  38. 27
      samples/ICSharpCode.Core.Demo/RichTextEditor/AssemblyInfo.cs
  39. 25
      samples/ICSharpCode.Core.Demo/RichTextEditor/RichTextEditor.addin
  40. 125
      samples/ICSharpCode.Core.Demo/RichTextEditor/RichTextEditor.cs
  41. 62
      samples/ICSharpCode.Core.Demo/RichTextEditor/RichTextEditor.csproj
  42. 6
      samples/ICSharpCode.Core.Demo/RichTextEditor/RichTextEditor.sln
  43. 93
      samples/ICSharpCode.Core.Demo/Startup/AddIns/Base.addin
  44. 27
      samples/ICSharpCode.Core.Demo/Startup/AssemblyInfo.cs
  45. BIN
      samples/ICSharpCode.Core.Demo/Startup/ImageResources.resources
  46. 95
      samples/ICSharpCode.Core.Demo/Startup/Start.cs
  47. 77
      samples/ICSharpCode.Core.Demo/Startup/Startup.csproj
  48. 19
      samples/ICSharpCode.Core.Demo/Startup/Startup.exe.config
  49. 17
      samples/ICSharpCode.Core.Demo/Startup/Startup.exe.manifest
  50. 6
      samples/ICSharpCode.Core.Demo/Startup/Startup.sln
  51. BIN
      samples/ICSharpCode.Core.Demo/Startup/StringResources.resources
  52. 4
      samples/ICSharpCode.Core.Demo/Startup/data/options/AppProperties.xml
  53. BIN
      samples/ICSharpCode.Core.Demo/Startup/data/resources/StringResources.de.resources
  54. 20
      samples/ICSharpCode.Core.Demo/doc/copyright.txt
  55. 496
      samples/ICSharpCode.Core.Demo/doc/license.txt
  56. 27
      samples/NRefactoryExample/AssemblyInfo.cs
  57. 151
      samples/NRefactoryExample/MainForm.cs
  58. 184
      samples/NRefactoryExample/MainForm.resx
  59. 46
      samples/NRefactoryExample/NRefactoryExample.csproj
  60. 16
      samples/NRefactoryExample/NRefactoryExample.sln
  61. 123
      samples/NRefactoryExample/WrapperGeneratorVisitor.cs
  62. 2184
      samples/SharpPad/SharpPad.rtf
  63. 2175
      samples/readme.rtf

2199
samples/CodonCreation/CodonCreation.rtf

File diff suppressed because it is too large Load Diff

2
samples/CodonCreation/TestDoozer.cs

@ -35,7 +35,7 @@ namespace CodonCreation @@ -35,7 +35,7 @@ namespace CodonCreation
// a custom codon object.
// A arraylist with the subitems : if this codon has subitems in it's path here are the
// build items stored for these the codon may use these
// or not, if not they get lost, if any where there.
// or not, if not they get lost, if any were there.
// 'Normal' codons don't need them (then the tree-path is a list)
// But for example menuitems use them.
public object BuildItem(object caller, Codon codon, ArrayList subItems)

2202
samples/CustomPad/CustomPad.rtf

File diff suppressed because it is too large Load Diff

2183
samples/CustomView/CustomView.rtf

File diff suppressed because it is too large Load Diff

2200
samples/DisplayBindings/AlternateEditor/AlternateEditor.rtf

File diff suppressed because it is too large Load Diff

74
samples/ICSharpCode.Core.Demo/AddInManager/AddInManager.addin

@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
<AddIn name = "AddInManager"
author = "Daniel Grunwald"
copyright = "prj:///doc/copyright.txt"
description = "Can install, enable, disable and uninstall AddIns">
<Manifest>
<Identity name = "ICSharpCode.AddInManager"/>
</Manifest>
<Runtime>
<Import assembly = "ICSharpCode.AddInManager.dll">
<ConditionEvaluator name="AddInManagerAddInState" class="ICSharpCode.AddInManager.AddInManagerAddInStateConditionEvaluator"/>
</Import>
</Runtime>
<Path name = "/Workspace/Tools">
<MenuItem id = "ShowAddInManager"
label = "${res:AddInManager.Title}"
class = "ICSharpCode.AddInManager.ShowCommand"/>
</Path>
<Path name = "/SharpDevelop/Workbench/DisplayBindings">
<DisplayBinding id = "AddInManager"
class = "ICSharpCode.AddInManager.AddInInstallBinding"
insertbefore = "Text"
fileNamePattern = "\.sdaddin$"
languagePattern = "^SDAddInPackageFiles$"/>
</Path>
<Path name = "/AddIns/AddInManager/ContextMenu">
<Condition name="AddInManagerAddInState" states="Enable">
<MenuItem id="Disable"
label="${res:AddInManager.ActionDisable}"
class="ICSharpCode.AddInManager.DisableCommand"/>
</Condition>
<Condition name="AddInManagerAddInState" states="Disable">
<MenuItem id="Enable"
label="${res:AddInManager.ActionEnable}"
class="ICSharpCode.AddInManager.EnableCommand"/>
</Condition>
<Condition name="AddInManagerAddInState" states="Enable,Disable,InstalledTwice,DependencyError">
<MenuItem id="Uninstall"
label="${res:AddInManager.ActionUninstall}"
class="ICSharpCode.AddInManager.UninstallCommand"/>
</Condition>
<Condition name="AddInManagerAddInState" states="Install">
<MenuItem id="AbortInstall"
label="${res:AddInManager.ActionCancelInstallation}"
class="ICSharpCode.AddInManager.AbortInstallCommand"/>
</Condition>
<Condition name="AddInManagerAddInState" states="Uninstall">
<MenuItem id="AbortUninstall"
label="${res:AddInManager.ActionCancelDeinstallation}"
class="ICSharpCode.AddInManager.EnableCommand"/>
</Condition>
<Condition name="AddInManagerAddInState" states="Update">
<MenuItem id="AbortUpdate"
label="${res:AddInManager.ActionCancelUpdate}"
class="ICSharpCode.AddInManager.AbortUpdateCommand"/>
</Condition>
<MenuItem id="Separator1" type="Separator"/>
<MenuItem id="GoToHomepage"
label="${res:AddInManager.OpenWebsite}"
class="ICSharpCode.AddInManager.OpenHomepageCommand"
loadclasslazy="false"/>
<MenuItem id="Options"
label="${res:AddInManager.Options}"
class="ICSharpCode.AddInManager.OptionsCommand"
loadclasslazy="false"/>
<MenuItem id="About"
label="${res:AddInManager.About}"
class="ICSharpCode.AddInManager.AboutCommand"/>
</Path>
</AddIn>

75
samples/ICSharpCode.Core.Demo/AddInManager/AddInManager.csproj

@ -0,0 +1,75 @@ @@ -0,0 +1,75 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>ICSharpCode.AddInManager</RootNamespace>
<AssemblyName>ICSharpCode.AddInManager</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{8B4FE9EF-5899-4E84-88DE-C37D021A0658}</ProjectGuid>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<OutputPath>..\bin\AddIns\AddInManager\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Optimize>False</Optimize>
<DefineConstants>STANDALONE;SHOWALLADDINS;DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>True</Optimize>
<DefineConstants>STANDALONE;SHOWALLADDINS;TRACE</DefineConstants>
<DebugSymbols>false</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Xml" />
<Reference Include="System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<Reference Include="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
<Reference Include="ICSharpCode.SharpZipLib">
<HintPath>..\RequiredLibraries\ICSharpCode.SharpZipLib.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Src\Commands.cs" />
<Compile Include="Src\ManagerForm.cs" />
<EmbeddedResource Include="Src\ManagerForm.resx">
<DependentUpon>ManagerForm.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="Src\AddInControl.cs" />
<Compile Include="Src\InstallableAddIn.cs" />
<Compile Include="Src\AboutForm.cs" />
<EmbeddedResource Include="Src\AboutForm.resx">
<DependentUpon>AboutForm.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="Src\AddInInstallBinding.cs" />
<EmbeddedResource Include="WizardBackground.png">
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="StringResources.resources" />
<EmbeddedResource Include="StringResources.de.resources" />
</ItemGroup>
<ItemGroup>
<Content Include="AddInManager.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<ProjectReference Include="..\..\..\src\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

6
samples/ICSharpCode.Core.Demo/AddInManager/AddInManager.sln

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.936
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInManager", "AddInManager.csproj", "{8B4FE9EF-5899-4E84-88DE-C37D021A0658}"
EndProject
Global
EndGlobal

33
samples/ICSharpCode.Core.Demo/AddInManager/AssemblyInfo.cs

@ -0,0 +1,33 @@ @@ -0,0 +1,33 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("AddInManager")]
[assembly: AssemblyDescription("AddInManager for ICSharpCode.Core")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ic#code")]
[assembly: AssemblyProduct("SharpDevelop")]
[assembly: AssemblyCopyright("2005 AlphaSierraPapa")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("2.0.0.936")]

217
samples/ICSharpCode.Core.Demo/AddInManager/Src/AboutForm.cs

@ -0,0 +1,217 @@ @@ -0,0 +1,217 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace ICSharpCode.AddInManager
{
public class AboutForm : System.Windows.Forms.Form
{
Font boldFont;
public AboutForm(AddIn addIn)
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
boldFont = new Font(Font, FontStyle.Bold);
List<string> titles = new List<string>();
List<string> values = new List<string>();
this.Text = addIn.Name;
closeButton.Text = ResourceService.GetString("Global.CloseButtonText");
titles.Add("AddIn name");
values.Add(addIn.Name);
if (addIn.Manifest.PrimaryVersion != null && addIn.Manifest.PrimaryVersion.ToString() != "0.0.0.0") {
titles.Add("Version");
values.Add(addIn.Manifest.PrimaryVersion.ToString());
}
if (addIn.Properties["author"].Length > 0) {
titles.Add("Author");
values.Add(addIn.Properties["author"]);
}
if (addIn.Properties["copyright"].Length > 0) {
if (!addIn.Properties["copyright"].StartsWith("prj:")) {
titles.Add("Copyright");
values.Add(addIn.Properties["copyright"]);
}
}
if (addIn.Properties["license"].Length > 0) {
titles.Add("License");
values.Add(addIn.Properties["license"]);
}
if (addIn.Properties["url"].Length > 0) {
titles.Add("Website");
values.Add(addIn.Properties["url"]);
}
if (addIn.Properties["description"].Length > 0) {
titles.Add("Description");
values.Add(addIn.Properties["description"]);
}
titles.Add("AddIn file");
values.Add(System.IO.Path.GetFullPath(addIn.FileName));
titles.Add("Internal name");
values.Add(addIn.Manifest.PrimaryIdentity);
table.RowCount = titles.Count + 1;
table.RowStyles.Clear();
for (int i = 0; i < titles.Count; i++) {
table.RowStyles.Add(new RowStyle(SizeType.AutoSize));
AddRow(titles[i], values[i], i);
}
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
if (disposing) {
if (boldFont != null)
boldFont.Dispose();
}
}
void AddRow(string desc, string val, int rowIndex)
{
Label descLabel = new Label();
descLabel.AutoSize = true;
descLabel.Anchor = AnchorStyles.Top | AnchorStyles.Right;
descLabel.Font = boldFont;
descLabel.Text = StringParser.Parse(desc) + ":";
table.Controls.Add(descLabel, 0, rowIndex);
Label valLabel;
string link = GetLink(val);
if (link != null) {
LinkLabel linkLabel = new LinkLabel();
linkLabel.LinkClicked += delegate {
try {
System.Diagnostics.Process.Start(link);
} catch (Exception ex) {
MessageService.ShowMessage(ex.ToString());
}
};
valLabel = linkLabel;
} else {
valLabel = new Label();
}
valLabel.AutoSize = true;
valLabel.Text = val;
table.Controls.Add(valLabel, 1, rowIndex);
}
string GetLink(string text)
{
switch (text) {
case "GNU General Public License":
case "GPL":
return "http://www.gnu.org/licenses/gpl.html";
case "LGPL":
case "GNU Lesser General Public License":
return "http://www.gnu.org/licenses/lgpl.html";
default:
if (text.StartsWith("http://"))
return text;
if (text.StartsWith("www."))
return "http://" + text;
return null;
}
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.Panel bottomPanel;
this.closeButton = new System.Windows.Forms.Button();
this.table = new System.Windows.Forms.TableLayoutPanel();
bottomPanel = new System.Windows.Forms.Panel();
bottomPanel.SuspendLayout();
this.SuspendLayout();
//
// bottomPanel
//
bottomPanel.Controls.Add(this.closeButton);
bottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
bottomPanel.Location = new System.Drawing.Point(0, 233);
bottomPanel.Name = "bottomPanel";
bottomPanel.Size = new System.Drawing.Size(351, 35);
bottomPanel.TabIndex = 0;
//
// closeButton
//
this.closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.closeButton.Location = new System.Drawing.Point(264, 6);
this.closeButton.Name = "closeButton";
this.closeButton.Size = new System.Drawing.Size(75, 23);
this.closeButton.TabIndex = 0;
this.closeButton.Text = "Close";
this.closeButton.UseCompatibleTextRendering = true;
this.closeButton.UseVisualStyleBackColor = true;
this.closeButton.Click += new System.EventHandler(this.CloseButtonClick);
//
// table
//
this.table.ColumnCount = 2;
this.table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.table.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));
this.table.Dock = System.Windows.Forms.DockStyle.Fill;
this.table.Location = new System.Drawing.Point(0, 8);
this.table.Name = "table";
this.table.RowCount = 2;
this.table.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.table.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F));
this.table.Size = new System.Drawing.Size(351, 225);
this.table.TabIndex = 1;
//
// AboutForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.SystemColors.Info;
this.ClientSize = new System.Drawing.Size(351, 268);
this.Controls.Add(this.table);
this.Controls.Add(bottomPanel);
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "AboutForm";
this.Padding = new System.Windows.Forms.Padding(0, 8, 0, 0);
this.ShowInTaskbar = false;
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "AboutForm";
bottomPanel.ResumeLayout(false);
this.ResumeLayout(false);
}
private System.Windows.Forms.Button closeButton;
private System.Windows.Forms.TableLayoutPanel table;
#endregion
void CloseButtonClick(object sender, EventArgs e)
{
Close();
}
}
}

123
samples/ICSharpCode.Core.Demo/AddInManager/Src/AboutForm.resx

@ -0,0 +1,123 @@ @@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="bottomPanel.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

191
samples/ICSharpCode.Core.Demo/AddInManager/Src/AddInControl.cs

@ -0,0 +1,191 @@ @@ -0,0 +1,191 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace ICSharpCode.AddInManager
{
public class AddInControl : Control
{
AddIn addIn;
bool isExternal;
public AddIn AddIn {
get {
return addIn;
}
}
public AddInControl(AddIn addIn)
{
this.addIn = addIn;
this.BackColor = SystemColors.Window;
this.ContextMenuStrip = MenuService.CreateContextMenu(this, "/AddIns/AddInManager/ContextMenu");
isExternal = !FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, addIn.FileName)
&& !FileUtility.IsBaseDirectory(PropertyService.ConfigDirectory, addIn.FileName);
this.ClientSize = new Size(100, isExternal ? 35 + pathHeight : 35);
this.SetStyle(ControlStyles.Selectable, true);
this.SetStyle(ControlStyles.UserPaint, true);
this.SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
this.SetStyle(ControlStyles.ResizeRedraw, true);
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
}
bool selected;
public bool Selected {
get {
return selected;
}
set {
if (selected != value) {
selected = value;
Invalidate();
}
}
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
Focus();
}
Color Mix(Color c1, Color c2, double perc)
{
double p1 = 1 - perc;
double p2 = perc;
return Color.FromArgb((int)(c1.R * p1 + c2.R * p2),
(int)(c1.G * p1 + c2.G * p2),
(int)(c1.B * p1 + c2.B * p2));
}
protected override void OnPaint(PaintEventArgs e)
{
Graphics g = e.Graphics;
Rectangle bounds = this.ClientRectangle;
bounds.Offset(1, 1);
bounds.Inflate(-2, -2);
Color startColor = SystemColors.ControlLightLight;
Color endColor = SystemColors.Control;
if (selected) {
startColor = Mix(SystemColors.ControlLightLight, SystemColors.Highlight, 0.1);
endColor = Mix(SystemColors.ControlLightLight, SystemColors.Highlight, 0.65);
}
Brush gradient = new LinearGradientBrush(bounds,
startColor,
endColor,
LinearGradientMode.ForwardDiagonal);
GraphicsPath path = new GraphicsPath();
const int egdeRadius = 3;
const int innerMargin = egdeRadius + 2;
RectangleF arcRect = new RectangleF(bounds.Location, new SizeF(egdeRadius * 2, egdeRadius * 2));
//top left Arc
path.AddArc(arcRect, 180, 90);
path.AddLine(bounds.X + egdeRadius, bounds.Y, bounds.Right - egdeRadius, bounds.Y);
// top right arc
arcRect.X = bounds.Right - egdeRadius * 2;
path.AddArc(arcRect, 270, 90);
path.AddLine(bounds.Right, bounds.Left + egdeRadius, bounds.Right, bounds.Bottom - egdeRadius);
// bottom right arc
arcRect.Y = bounds.Bottom - egdeRadius * 2;
path.AddArc(arcRect, 0, 90);
path.AddLine(bounds.X + egdeRadius, bounds.Bottom, bounds.Right - egdeRadius, bounds.Bottom);
// bottom left arc
arcRect.X = bounds.Left;
path.AddArc(arcRect, 90, 90);
path.AddLine(bounds.X, bounds.Left + egdeRadius, bounds.X, bounds.Bottom - egdeRadius);
g.FillPath(gradient, path);
g.DrawPath(SystemPens.ControlText, path);
path.Dispose();
gradient.Dispose();
Brush textBrush;
string description = GetText(out textBrush);
int titleWidth;
using (Font boldFont = new Font("Arial", 8, FontStyle.Bold)) {
g.DrawString(addIn.Name, boldFont, textBrush, innerMargin, innerMargin);
titleWidth = (int)g.MeasureString(addIn.Name, boldFont).Width + 1;
}
if (addIn.Version != null && addIn.Version.ToString() != "0.0.0.0") {
g.DrawString(addIn.Version.ToString(), Font, textBrush, innerMargin + titleWidth + 4, innerMargin);
}
RectangleF textBounds = bounds;
textBounds.Offset(innerMargin, innerMargin);
textBounds.Inflate(-innerMargin * 2, -innerMargin * 2 + 2);
if (isExternal)
textBounds.Height -= pathHeight;
using (StringFormat sf = new StringFormat(StringFormatFlags.LineLimit)) {
sf.Trimming = StringTrimming.EllipsisWord;
g.DrawString(description, Font, textBrush, textBounds, sf);
}
if (isExternal) {
textBounds.Y = textBounds.Bottom + 2;
textBounds.Height = pathHeight + 2;
using (Font font = new Font(Font.Name, 7, FontStyle.Italic)) {
using (StringFormat sf = new StringFormat(StringFormatFlags.NoWrap)) {
sf.Trimming = StringTrimming.EllipsisPath;
sf.Alignment = StringAlignment.Far;
g.DrawString(addIn.FileName, font,
selected ? SystemBrushes.HighlightText : SystemBrushes.ControlText,
textBounds, sf);
}
}
}
}
const int pathHeight = 10;
string GetText(out Brush textBrush)
{
switch (addIn.Action) {
case AddInAction.Enable:
if (addIn.Enabled) {
textBrush = SystemBrushes.ControlText;
return addIn.Properties["description"];
} else {
textBrush = SystemBrushes.ActiveCaption;
return ResourceService.GetString("AddInManager.AddInEnabled");
}
case AddInAction.Disable:
textBrush = SystemBrushes.GrayText;
if (addIn.Enabled)
return ResourceService.GetString("AddInManager.AddInWillBeDisabled");
else
return ResourceService.GetString("AddInManager.AddInDisabled");
case AddInAction.Install:
textBrush = SystemBrushes.ActiveCaption;
return ResourceService.GetString("AddInManager.AddInInstalled");
case AddInAction.Uninstall:
textBrush = SystemBrushes.GrayText;
return ResourceService.GetString("AddInManager.AddInRemoved");
case AddInAction.Update:
textBrush = SystemBrushes.ActiveCaption;
return ResourceService.GetString("AddInManager.AddInUpdated");
case AddInAction.InstalledTwice:
textBrush = Brushes.Red;
return ResourceService.GetString("AddInManager.AddInInstalledTwice");
case AddInAction.DependencyError:
textBrush = Brushes.Red;
return ResourceService.GetString("AddInManager.AddInDependencyFailed");
default:
textBrush = Brushes.Yellow;
return addIn.Action.ToString();
}
}
}
}

39
samples/ICSharpCode.Core.Demo/AddInManager/Src/AddInInstallBinding.cs

@ -0,0 +1,39 @@ @@ -0,0 +1,39 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using ICSharpCode.Core;
namespace ICSharpCode.AddInManager
{
#if !STANDALONE
public class AddInInstallBinding : IDisplayBinding
{
public bool CanCreateContentForFile(string fileName)
{
return true;
}
public ICSharpCode.SharpDevelop.Gui.IViewContent CreateContentForFile(string fileName)
{
ManagerForm.ShowForm();
ManagerForm.Instance.ShowInstallableAddIns(new string[] { fileName });
return null;
}
public bool CanCreateContentForLanguage(string languageName)
{
return false;
}
public ICSharpCode.SharpDevelop.Gui.IViewContent CreateContentForLanguage(string languageName, string content)
{
throw new NotImplementedException();
}
}
#endif
}

152
samples/ICSharpCode.Core.Demo/AddInManager/Src/Commands.cs

@ -0,0 +1,152 @@ @@ -0,0 +1,152 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace ICSharpCode.AddInManager
{
public class ShowCommand : AbstractMenuCommand
{
#if STANDALONE
static bool resourcesRegistered;
#endif
public override void Run()
{
#if STANDALONE
if (!resourcesRegistered) {
resourcesRegistered = true;
ResourceService.RegisterStrings("ICSharpCode.AddInManager.StringResources", typeof(ShowCommand).Assembly);
}
#endif
ManagerForm.ShowForm();
}
}
public class AddInManagerAddInStateConditionEvaluator : IConditionEvaluator
{
public bool IsValid(object caller, Condition condition)
{
string states = condition.Properties["states"];
string action = ((AddInControl)caller).AddIn.Action.ToString();
foreach (string state in states.Split(',')) {
if (state == action)
return true;
}
return false;
}
}
public class DisableCommand : AbstractMenuCommand
{
public override void Run()
{
ManagerForm.Instance.TryRunAction(((AddInControl)Owner).AddIn, AddInAction.Disable);
}
}
public class EnableCommand : AbstractMenuCommand
{
public override void Run()
{
ManagerForm.Instance.TryRunAction(((AddInControl)Owner).AddIn, AddInAction.Enable);
}
}
public class AbortInstallCommand : AbstractMenuCommand
{
public override void Run()
{
ManagerForm.Instance.TryRunAction(((AddInControl)Owner).AddIn, AddInAction.Uninstall);
}
}
public class AbortUpdateCommand : AbstractMenuCommand
{
public override void Run()
{
ManagerForm.Instance.TryRunAction(((AddInControl)Owner).AddIn, AddInAction.InstalledTwice);
}
}
public class UninstallCommand : AbstractMenuCommand
{
public override void Run()
{
ManagerForm.Instance.TryUninstall(((AddInControl)Owner).AddIn);
}
}
public class OpenHomepageCommand : AbstractMenuCommand
{
public override bool IsEnabled {
get {
return ((AddInControl)Owner).AddIn.Properties["url"].Length > 0;
}
}
public override void Run()
{
#if STANDALONE
try {
System.Diagnostics.Process.Start(((AddInControl)Owner).AddIn.Properties["url"]);
} catch {}
#else
FileService.OpenFile(((AddInControl)Owner).AddIn.Properties["url"]);
#endif
ManagerForm.Instance.Close();
}
}
public class AboutCommand : AbstractMenuCommand
{
public override void Run()
{
using (AboutForm form = new AboutForm(((AddInControl)Owner).AddIn)) {
form.ShowDialog(ManagerForm.Instance);
}
}
}
public class OptionsCommand : AbstractMenuCommand
{
public override bool IsEnabled {
get {
#if !STANDALONE
AddIn addIn = ((AddInControl)Owner).AddIn;
if (addIn.Enabled) {
foreach (KeyValuePair<string, ExtensionPath> pair in addIn.Paths) {
if (pair.Key.StartsWith("/SharpDevelop/Dialogs/OptionsDialog")) {
return true;
}
}
}
#endif
return false;
}
}
public override void Run()
{
#if !STANDALONE
AddIn addIn = ((AddInControl)Owner).AddIn;
AddInTreeNode dummyNode = new AddInTreeNode();
foreach (KeyValuePair<string, ExtensionPath> pair in addIn.Paths) {
if (pair.Key.StartsWith("/SharpDevelop/Dialogs/OptionsDialog")) {
dummyNode.Codons.AddRange(pair.Value.Codons);
}
}
ICSharpCode.SharpDevelop.Commands.OptionsCommand.ShowTabbedOptions(addIn.Name + " " + ResourceService.GetString("AddInManager.Options"),
dummyNode);
#endif
}
}
}

123
samples/ICSharpCode.Core.Demo/AddInManager/Src/InstallableAddIn.cs

@ -0,0 +1,123 @@ @@ -0,0 +1,123 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.IO;
using ICSharpCode.Core;
using ICSharpCode.SharpZipLib.Zip;
namespace ICSharpCode.AddInManager
{
public class InstallableAddIn
{
string fileName;
bool isPackage;
AddIn addIn;
public AddIn AddIn {
get {
return addIn;
}
}
public InstallableAddIn(string fileName, bool isPackage)
{
this.fileName = fileName;
this.isPackage = isPackage;
if (isPackage) {
ZipFile file = new ZipFile(fileName);
try {
LoadAddInFromZip(file);
} finally {
file.Close();
}
} else {
addIn = AddIn.Load(fileName);
}
if (addIn.Manifest.PrimaryIdentity == null)
throw new AddInLoadException("The AddIn must have an <Identity> for use with the AddIn-Manager.");
}
void LoadAddInFromZip(ZipFile file)
{
ZipEntry addInEntry = null;
foreach (ZipEntry entry in file) {
if (entry.Name.EndsWith(".addin")) {
if (addInEntry != null)
throw new AddInLoadException("The package may only contain one .addin file.");
addInEntry = entry;
}
}
if (addInEntry == null)
throw new AddInLoadException("The package must contain one .addin file.");
using (Stream s = file.GetInputStream(addInEntry)) {
using (StreamReader r = new StreamReader(s)) {
addIn = AddIn.Load(r);
}
}
}
public void Install(bool isUpdate)
{
foreach (string identity in addIn.Manifest.Identities.Keys) {
ICSharpCode.Core.AddInManager.AbortRemoveUserAddInOnNextStart(identity);
}
if (isPackage) {
string targetDir = Path.Combine(ICSharpCode.Core.AddInManager.AddInInstallTemp,
addIn.Manifest.PrimaryIdentity);
if (Directory.Exists(targetDir))
Directory.Delete(targetDir, true);
Directory.CreateDirectory(targetDir);
FastZip fastZip = new FastZip();
fastZip.CreateEmptyDirectories = true;
fastZip.ExtractZip(fileName, targetDir, null);
addIn.Action = AddInAction.Install;
if (!isUpdate) {
AddInTree.InsertAddIn(addIn);
}
} else {
ICSharpCode.Core.AddInManager.AddExternalAddIns(new AddIn[] { addIn });
}
}
public static void CancelUpdate(IList<AddIn> addIns)
{
foreach (AddIn addIn in addIns) {
foreach (string identity in addIn.Manifest.Identities.Keys) {
// delete from installation temp (if installation or update is pending)
string targetDir = Path.Combine(ICSharpCode.Core.AddInManager.AddInInstallTemp,
identity);
if (Directory.Exists(targetDir))
Directory.Delete(targetDir, true);
}
}
}
public static void Uninstall(IList<AddIn> addIns)
{
CancelUpdate(addIns);
foreach (AddIn addIn in addIns) {
foreach (string identity in addIn.Manifest.Identities.Keys) {
// remove the user AddIn
string targetDir = Path.Combine(ICSharpCode.Core.AddInManager.UserAddInPath, identity);
if (Directory.Exists(targetDir)) {
if (!addIn.Enabled) {
try {
Directory.Delete(targetDir, true);
continue;
} catch {
}
}
ICSharpCode.Core.AddInManager.RemoveUserAddInOnNextStart(identity);
}
}
}
}
}
}

918
samples/ICSharpCode.Core.Demo/AddInManager/Src/ManagerForm.cs

@ -0,0 +1,918 @@ @@ -0,0 +1,918 @@
// <file>
// <copyright see="prj:///doc/copyright.txt"/>
// <license see="prj:///doc/license.txt"/>
// <owner name="Daniel Grunwald" email="daniel@danielgrunwald.de"/>
// <version>$Revision$</version>
// </file>
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace ICSharpCode.AddInManager
{
public class ManagerForm : System.Windows.Forms.Form
{
#region Form Initialization
static ManagerForm instance;
public static ManagerForm Instance {
get {
return instance;
}
}
public static void ShowForm()
{
if (instance == null) {
instance = new ManagerForm();
#if !STANDALONE
instance.Owner = ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm;
#endif
instance.Show();
} else {
instance.Activate();
}
}
public ManagerForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
#if !STANDALONE
ICSharpCode.SharpDevelop.Gui.FormLocationHelper.Apply(this, "AddInManager.WindowBounds", true);
#endif
#if STANDALONE
actionFlowLayoutPanel.BackgroundImage = new Bitmap(typeof(ManagerForm).Assembly.GetManifestResourceStream("ICSharpCode.AddInManager.WizardBackground.png"));
#else
actionFlowLayoutPanel.BackgroundImage = ResourceService.GetBitmap("GeneralWizardBackground");
#endif
installButton.Text = ResourceService.GetString("AddInManager.InstallButton");
uninstallButton.Text = ResourceService.GetString("AddInManager.ActionUninstall");
closeButton.Text = ResourceService.GetString("Global.CloseButtonText");
showPreinstalledAddInsCheckBox.Text = ResourceService.GetString("AddInManager.ShowPreinstalledAddIns");
this.Text = ResourceService.GetString("AddInManager.Title");
CreateAddInList();
}
void OnSplitContainerPanel1Paint(object sender, PaintEventArgs e)
{
if (visibleAddInCount == 0) {
Rectangle rect = splitContainer.Panel1.ClientRectangle;
rect.Offset(16, 16);
rect.Inflate(-32, -32);
e.Graphics.DrawString(ResourceService.GetString("AddInManager.NoAddInsInstalled"),
Font, SystemBrushes.WindowText, rect);
}
}
void CreateAddInList()
{
Stack<AddInControl> stack = new Stack<AddInControl>();
int index = 0;
AddInControl addInControl;
List<AddIn> addInList = new List<AddIn>(AddInTree.AddIns);
addInList.Sort(delegate(AddIn a, AddIn b) {
return a.Name.CompareTo(b.Name);
});
foreach (AddIn addIn in addInList) {
string identity = addIn.Manifest.PrimaryIdentity;
if (identity == null || addIn.Properties["addInManagerHidden"] == "true")
continue;
addInControl = new AddInControl(addIn);
addInControl.Dock = DockStyle.Top;
addInControl.TabIndex = index++;
stack.Push(addInControl);
addInControl.Enter += OnControlEnter;
addInControl.Click += OnControlClick;
}
while (stack.Count > 0) {
splitContainer.Panel1.Controls.Add(stack.Pop());
}
ShowPreinstalledAddInsCheckBoxCheckedChanged(null, null);
#if SHOWALLADDINS
showPreinstalledAddInsCheckBox.Visible = false;
showPreinstalledAddInsCheckBox.Checked = true;
#endif
splitContainer.Panel2Collapsed = true;
}
void RefreshAddInList()
{
List<AddIn> oldSelected = selected;
foreach (Control ctl in splitContainer.Panel1.Controls) {
ctl.Dispose();
}
splitContainer.Panel1.Controls.Clear();
CreateAddInList();
if (oldSelected != null) {
foreach (AddInControl ctl in splitContainer.Panel1.Controls) {
if (oldSelected.Contains(ctl.AddIn))
ctl.Selected = true;
}
}
UpdateActionBox();
}
#endregion
#region AddInList-Management
int visibleAddInCount = 0;
void ShowPreinstalledAddInsCheckBoxCheckedChanged(object sender, EventArgs e)
{
visibleAddInCount = 0;
foreach (AddInControl ctl in splitContainer.Panel1.Controls) {
ctl.Selected = false;
bool visible;
if (showPreinstalledAddInsCheckBox.Checked) {
visible = true;
} else {
if (ctl == oldFocus)
oldFocus = null;
visible = !FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, ctl.AddIn.FileName);
}
if (visible)
visibleAddInCount += 1;
ctl.Visible = visible;
}
UpdateActionBox();
}
void OnControlClick(object sender, EventArgs e)
{
// clicking again on already focused item:
// remove selection of other items / or with Ctrl: toggle selection
if (((Control)sender).Focused)
OnControlEnter(sender, e);
}
AddInControl oldFocus;
bool ignoreFocusChange;
void OnControlEnter(object sender, EventArgs e)
{
if (ignoreFocusChange)
return;
bool ctrl = (ModifierKeys & Keys.Control) == Keys.Control;
if ((ModifierKeys & Keys.Shift) == Keys.Shift && sender != oldFocus) {
bool sel = false;
foreach (AddInControl ctl in splitContainer.Panel1.Controls) {
if (!ctl.Visible) continue;
if (ctl == sender || ctl == oldFocus) {
sel = !sel;
ctl.Selected = true;
} else {
if (sel || !ctrl) {
ctl.Selected = sel;
}
}
}
} else if (ctrl) {
foreach (AddInControl ctl in splitContainer.Panel1.Controls) {
if (ctl == sender)
ctl.Selected = !ctl.Selected;
}
oldFocus = (AddInControl)sender;
} else {
foreach (AddInControl ctl in splitContainer.Panel1.Controls) {
ctl.Selected = ctl == sender;
}
oldFocus = (AddInControl)sender;
}
UpdateActionBox();
}
#endregion
#region UpdateActionBox
List<AddIn> selected;
AddInAction selectedAction;
void UpdateActionBox()
{
ignoreFocusChange = true;
selected = new List<AddIn>();
foreach (AddInControl ctl in splitContainer.Panel1.Controls) {
if (ctl.Selected)
selected.Add(ctl.AddIn);
}
splitContainer.Panel2Collapsed = selected.Count == 0;
if (selected.Count > 0) {
dependencyTable.Visible = false;
runActionButton.Visible = true;
uninstallButton.Visible = true;
bool allEnabled = true;
bool allDisabled = true;
bool allInstalling = true;
bool allUninstalling = true;
bool allUpdating = true;
bool allUninstallable = true;
bool hasErrors = false;
foreach (AddIn addIn in selected) {
allEnabled &= addIn.Action == AddInAction.Enable;
if (addIn.Action == AddInAction.DependencyError || addIn.Action == AddInAction.InstalledTwice)
hasErrors = true;
else
allDisabled &= addIn.Action == AddInAction.Disable;
allUpdating &= addIn.Action == AddInAction.Update;
allInstalling &= addIn.Action == AddInAction.Install;
allUninstalling &= addIn.Action == AddInAction.Uninstall;
if (allUninstallable) {
if (FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, addIn.FileName)) {
allUninstallable = false;
}
}
}
if (allEnabled) {
selectedAction = AddInAction.Disable;
actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionDisable");
actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionDisable");
runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Disable);
uninstallButton.Enabled = allUninstallable && runActionButton.Enabled;
} else if (allDisabled) {
selectedAction = AddInAction.Enable;
actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionEnable");
actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionEnable");
runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Enable);
if (hasErrors)
runActionButton.Enabled = false;
uninstallButton.Enabled = allUninstallable;
} else if (allInstalling) {
selectedAction = AddInAction.Uninstall;
actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionCancelInstallation");
actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionCancelInstall");
runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Disable);
uninstallButton.Visible = false;
} else if (allUninstalling) {
selectedAction = AddInAction.Enable;
actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionCancelDeinstallation");
actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionCancelDeinstallation");
runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.Enable);
uninstallButton.Visible = false;
} else if (allUpdating) {
selectedAction = AddInAction.InstalledTwice;
actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionCancelUpdate");
actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionCancelUpdate");
runActionButton.Enabled = ShowDependencies(selected, ShowDependencyMode.CancelUpdate);
uninstallButton.Visible = false;
} else {
actionGroupBox.Text = "";
actionDescription.Text = ResourceService.GetString("AddInManager.DescriptionInconsistentSelection");
runActionButton.Visible = false;
uninstallButton.Visible = false;
}
}
ignoreFocusChange = false;
}
enum ShowDependencyMode {
Disable,
Enable,
CancelUpdate
}
bool ShowDependencies(IList<AddIn> addIns, ShowDependencyMode mode)
{
List<AddInReference> dependencies = new List<AddInReference>(); // only used with enable=true
List<KeyValuePair<AddIn, AddInReference>> dependenciesToSel = new List<KeyValuePair<AddIn, AddInReference>>();
Dictionary<string, Version> addInDict = new Dictionary<string, Version>();
Dictionary<string, Version> modifiedAddIns = new Dictionary<string, Version>();
// add available addins
foreach (AddIn addIn in AddInTree.AddIns) {
if (addIn.Action != AddInAction.Enable && addIn.Action != AddInAction.Install)
continue;
if (addIns.Contains(addIn))
continue;
foreach (KeyValuePair<string, Version> pair in addIn.Manifest.Identities) {
addInDict[pair.Key] = pair.Value;
}
}
// create list of modified addin names
foreach (AddIn addIn in addIns) {
foreach (KeyValuePair<string, Version> pair in addIn.Manifest.Identities) {
modifiedAddIns[pair.Key] = pair.Value;
}
}
// add new addins
if (mode != ShowDependencyMode.Disable) {
foreach (AddIn addIn in addIns) {
if (mode == ShowDependencyMode.CancelUpdate && !addIn.Enabled) {
continue;
}
foreach (KeyValuePair<string, Version> pair in addIn.Manifest.Identities) {
addInDict[pair.Key] = pair.Value;
}
foreach (AddInReference dep in addIn.Manifest.Dependencies) {
if (!dependencies.Contains(dep))
dependencies.Add(dep);
}
}
}
// add dependencies to the to-be-changed addins
foreach (AddIn addIn in AddInTree.AddIns) {
if (addIn.Action != AddInAction.Enable && addIn.Action != AddInAction.Install)
continue;
if (addIns.Contains(addIn))
continue;
foreach (AddInReference dep in addIn.Manifest.Dependencies) {
if (modifiedAddIns.ContainsKey(dep.Name)) {
dependenciesToSel.Add(new KeyValuePair<AddIn, AddInReference>(addIn, dep));
}
}
}
foreach (Control ctl in dependencyTable.Controls) {
ctl.Dispose();
}
dependencyTable.Controls.Clear();
bool allDepenciesOK = true;
if (dependencies.Count > 0 || dependenciesToSel.Count > 0) {
if (dependencies.Count == 0) {
dependencyTable.RowCount = 1 + dependenciesToSel.Count;
} else if (dependenciesToSel.Count == 0) {
dependencyTable.RowCount = 1 + dependencies.Count;
} else {
dependencyTable.RowCount = 2 + dependencies.Count + dependenciesToSel.Count;
}
while (dependencyTable.RowStyles.Count < dependencyTable.RowCount) {
dependencyTable.RowStyles.Add(new RowStyle(SizeType.AutoSize));
}
int rowIndex = 0;
if (dependencies.Count > 0) {
AddLabelRow(rowIndex++, ResourceService.GetString("AddInManager.RequiredDependencies"));
foreach (AddInReference dep in dependencies) {
if (!AddDependencyRow(addInDict, dep, rowIndex++, null))
allDepenciesOK = false;
}
}
if (dependenciesToSel.Count > 0) {
AddLabelRow(rowIndex++, ResourceService.GetString("AddInManager.RequiredBy"));
foreach (KeyValuePair<AddIn, AddInReference> pair in dependenciesToSel) {
if (!AddDependencyRow(addInDict, pair.Value, rowIndex++, pair.Key.Name))
allDepenciesOK = false;
}
}
dependencyTable.Visible = true;
}
return allDepenciesOK;
}
bool AddDependencyRow(Dictionary<string, Version> addInDict, AddInReference dep, int rowIndex, string requiredByName)
{
string text = requiredByName ?? GetDisplayName(dep.Name);
Version versionFound;
Label label = new Label();
label.AutoSize = true;
label.Text = text;
PictureBox box = new PictureBox();
box.BorderStyle = BorderStyle.None;
box.Size = new Size(16, 16);
bool isOK = dep.Check(addInDict, out versionFound);
box.SizeMode = PictureBoxSizeMode.CenterImage;
box.Image = isOK ? ResourceService.GetBitmap("Icons.16x16.OK") : ResourceService.GetBitmap("Icons.16x16.DeleteIcon");
dependencyTable.Controls.Add(label, 1, rowIndex);
dependencyTable.Controls.Add(box, 0, rowIndex);
return isOK;
}
void AddLabelRow(int rowIndex, string text)
{
Label label = new Label();
label.AutoSize = true;
label.Text = text;
dependencyTable.Controls.Add(label, 0, rowIndex);
dependencyTable.SetColumnSpan(label, 2);
}
string GetDisplayName(string identity)
{
foreach (AddIn addIn in AddInTree.AddIns) {
if (addIn.Manifest.Identities.ContainsKey(identity))
return addIn.Name;
}
return identity;
}
#endregion
#region Install new AddIns
void InstallButtonClick(object sender, EventArgs e)
{
using (OpenFileDialog dlg = new OpenFileDialog()) {
dlg.Filter = ResourceService.GetString("AddInManager.FileFilter");
dlg.Multiselect = true;
if (dlg.ShowDialog() == DialogResult.OK) {
if (ShowInstallableAddIns(dlg.FileNames)) {
if (runActionButton.Visible && runActionButton.Enabled)
runActionButton.PerformClick();
}
}
}
}
public bool ShowInstallableAddIns(IEnumerable<string> fileNames)
{
foreach (AddInControl ctl in splitContainer.Panel1.Controls) {
ctl.Selected = false;
}
UpdateActionBox();
List<InstallableAddIn> list = new List<InstallableAddIn>();
foreach (string file in fileNames) {
try {
// Same file-extension check is in Panel1DragEnter
switch (Path.GetExtension(file).ToLowerInvariant()) {
case ".addin":
if (FileUtility.IsBaseDirectory(FileUtility.ApplicationRootPath, file)) {
MessageService.ShowMessage("You cannot install AddIns inside the SharpDevelop directory, " +
"they will be picked up as pre-installed AddIns automatically.");
return false;
}
list.Add(new InstallableAddIn(file, false));
break;
case ".sdaddin":
case ".zip":
list.Add(new InstallableAddIn(file, true));
break;
default:
MessageService.ShowMessage("Unknown file format: " + Path.GetExtension(file));
return false;
}
} catch (AddInLoadException ex) {
MessageService.ShowMessage("Error loading " + file + ":\n" + ex.Message);
return false;
}
}
ShowInstallableAddIns(list);
return true;
}
IList<InstallableAddIn> shownAddInPackages;
void ShowInstallableAddIns(IList<InstallableAddIn> addInPackages)
{
shownAddInPackages = addInPackages;
ignoreFocusChange = true;
splitContainer.Panel2Collapsed = false;
dependencyTable.Visible = false;
runActionButton.Visible = true;
uninstallButton.Visible = false;
selectedAction = AddInAction.Install;
List<string> installAddIns = new List<string>();
List<string> updateAddIns = new List<string>();
foreach (InstallableAddIn addInPackage in addInPackages) {
string identity = addInPackage.AddIn.Manifest.PrimaryIdentity;
AddIn foundAddIn = null;
foreach (AddIn addIn in AddInTree.AddIns) {
if (addIn.Action != AddInAction.Install
&& addIn.Manifest.Identities.ContainsKey(identity))
{
foundAddIn = addIn;
break;
}
}
if (foundAddIn != null) {
updateAddIns.Add(addInPackage.AddIn.Name);
} else {
installAddIns.Add(addInPackage.AddIn.Name);
}
}
if (updateAddIns.Count == 0) {
actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionInstall");
} else if (installAddIns.Count == 0) {
actionGroupBox.Text = runActionButton.Text = ResourceService.GetString("AddInManager.ActionUpdate");
} else {
actionGroupBox.Text = runActionButton.Text =
ResourceService.GetString("AddInManager.ActionInstall")
+ " + " +
ResourceService.GetString("AddInManager.ActionUpdate");
}
List<AddIn> addInList = new List<AddIn>();
StringBuilder b = new StringBuilder();
if (installAddIns.Count == 1) {
b.Append("Installs the AddIn " + installAddIns[0]);
} else if (installAddIns.Count > 1) {
b.Append("Installs the AddIns " + string.Join(",", installAddIns.ToArray()));
}
if (updateAddIns.Count > 0 && installAddIns.Count > 0)
b.Append("; ");
if (updateAddIns.Count == 1) {
b.Append("Updates the AddIn " + updateAddIns[0]);
} else if (updateAddIns.Count > 1) {
b.Append("Updates the AddIns " + string.Join(",", updateAddIns.ToArray()));
}
actionDescription.Text = b.ToString();
runActionButton.Enabled = ShowDependencies(addInList, ShowDependencyMode.Enable);
}
void RunInstallation()
{
// install new AddIns
foreach (InstallableAddIn addInPackage in shownAddInPackages) {
string identity = addInPackage.AddIn.Manifest.PrimaryIdentity;
AddIn foundAddIn = null;
foreach (AddIn addIn in AddInTree.AddIns) {
if (addIn.Manifest.Identities.ContainsKey(identity)) {
foundAddIn = addIn;
break;
}
}
if (foundAddIn != null) {
addInPackage.Install(true);
if (foundAddIn.Action != AddInAction.Enable) {
ICSharpCode.Core.AddInManager.Enable(new AddIn[] { foundAddIn });
}
if (foundAddIn.Action != AddInAction.Install) {
foundAddIn.Action = AddInAction.Update;
}
} else {
addInPackage.Install(false);
}
}
RefreshAddInList();
}
#endregion
#region Uninstall AddIns
void UninstallButtonClick(object sender, EventArgs e)
{
ICSharpCode.Core.AddInManager.RemoveExternalAddIns(selected);
InstallableAddIn.Uninstall(selected);
RefreshAddInList();
}
#endregion
#region Drag'N'Drop
void Panel1DragEnter(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop)) {
e.Effect = DragDropEffects.None;
return;
}
string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
int addInCount = 0;
int packageCount = 0;
foreach (string file in files) {
switch (Path.GetExtension(file).ToLowerInvariant()) {
case ".addin":
addInCount += 1;
break;
case ".sdaddin":
case ".zip":
packageCount += 1;
break;
default:
e.Effect = DragDropEffects.None;
return;
}
}
if (addInCount == 0 && packageCount == 0) {
e.Effect = DragDropEffects.None;
} else if (addInCount == 0) {
e.Effect = DragDropEffects.Copy;
} else {
e.Effect = DragDropEffects.Link;
}
}
void Panel1DragDrop(object sender, DragEventArgs e)
{
if (!e.Data.GetDataPresent(DataFormats.FileDrop))
return;
ShowInstallableAddIns((string[])e.Data.GetData(DataFormats.FileDrop));
}
#endregion
void CloseButtonClick(object sender, EventArgs e)
{
Close();
}
protected override void OnClosed(EventArgs e)
{
base.OnClosed(e);
instance = null;
}
public void TryRunAction(AddIn addIn, AddInAction action)
{
foreach (AddInControl ctl in splitContainer.Panel1.Controls) {
ctl.Selected = ctl.AddIn == addIn;
}
UpdateActionBox();
if (selectedAction == action && runActionButton.Visible && runActionButton.Enabled)
runActionButton.PerformClick();
}
public void TryUninstall(AddIn addIn)
{
foreach (AddInControl ctl in splitContainer.Panel1.Controls) {
ctl.Selected = ctl.AddIn == addIn;
}
UpdateActionBox();
if (uninstallButton.Visible && uninstallButton.Enabled)
uninstallButton.PerformClick();
}
void RunActionButtonClick(object sender, EventArgs e)
{
switch (selectedAction) {
case AddInAction.Disable:
for (int i = 0; i < selected.Count; i++) {
if (selected[i].Manifest.PrimaryIdentity == "ICSharpCode.AddInManager") {
MessageService.ShowMessage("You cannot disable the AddInManager because you need it to re-enable AddIns!");
selected.RemoveAt(i--);
}
}
ICSharpCode.Core.AddInManager.Disable(selected);
break;
case AddInAction.Enable:
ICSharpCode.Core.AddInManager.Enable(selected);
break;
case AddInAction.Install:
RunInstallation();
return;
case AddInAction.Uninstall:
UninstallButtonClick(sender, e);
return;
case AddInAction.InstalledTwice: // used to cancel installation of update
InstallableAddIn.CancelUpdate(selected);
foreach (AddIn addIn in selected) {
addIn.Action = addIn.Enabled ? AddInAction.Enable : AddInAction.Disable;
}
break;
default:
throw new NotImplementedException();
}
foreach (AddInControl ctl in splitContainer.Panel1.Controls) {
ctl.Invalidate();
}
UpdateActionBox();
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
this.topPanel = new System.Windows.Forms.Panel();
this.bottomPanel = new System.Windows.Forms.Panel();
this.installButton = new System.Windows.Forms.Button();
this.closeButton = new System.Windows.Forms.Button();
this.showPreinstalledAddInsCheckBox = new System.Windows.Forms.CheckBox();
this.splitContainer = new System.Windows.Forms.SplitContainer();
this.actionGroupBox = new System.Windows.Forms.GroupBox();
this.actionFlowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
this.actionDescription = new System.Windows.Forms.Label();
this.dependencyTable = new System.Windows.Forms.TableLayoutPanel();
this.dummyLabel1 = new System.Windows.Forms.Label();
this.dummyLabel2 = new System.Windows.Forms.Label();
this.runActionButton = new System.Windows.Forms.Button();
this.uninstallButton = new System.Windows.Forms.Button();
this.bottomPanel.SuspendLayout();
this.splitContainer.Panel2.SuspendLayout();
this.splitContainer.SuspendLayout();
this.actionGroupBox.SuspendLayout();
this.actionFlowLayoutPanel.SuspendLayout();
this.dependencyTable.SuspendLayout();
this.SuspendLayout();
//
// topPanel
//
this.topPanel.Dock = System.Windows.Forms.DockStyle.Top;
this.topPanel.Location = new System.Drawing.Point(0, 0);
this.topPanel.Name = "topPanel";
this.topPanel.Size = new System.Drawing.Size(460, 33);
this.topPanel.TabIndex = 1;
this.topPanel.Visible = false;
//
// bottomPanel
//
this.bottomPanel.Controls.Add(this.installButton);
this.bottomPanel.Controls.Add(this.closeButton);
this.bottomPanel.Controls.Add(this.showPreinstalledAddInsCheckBox);
this.bottomPanel.Dock = System.Windows.Forms.DockStyle.Bottom;
this.bottomPanel.Location = new System.Drawing.Point(0, 355);
this.bottomPanel.Name = "bottomPanel";
this.bottomPanel.Size = new System.Drawing.Size(460, 35);
this.bottomPanel.TabIndex = 0;
//
// installButton
//
this.installButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.installButton.Location = new System.Drawing.Point(274, 6);
this.installButton.Name = "installButton";
this.installButton.Size = new System.Drawing.Size(93, 23);
this.installButton.TabIndex = 1;
this.installButton.Text = "Install AddIn";
this.installButton.UseCompatibleTextRendering = true;
this.installButton.UseVisualStyleBackColor = true;
this.installButton.Click += new System.EventHandler(this.InstallButtonClick);
//
// closeButton
//
this.closeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
this.closeButton.Location = new System.Drawing.Point(373, 6);
this.closeButton.Name = "closeButton";
this.closeButton.Size = new System.Drawing.Size(75, 23);
this.closeButton.TabIndex = 2;
this.closeButton.Text = "Close";
this.closeButton.UseCompatibleTextRendering = true;
this.closeButton.UseVisualStyleBackColor = true;
this.closeButton.Click += new System.EventHandler(this.CloseButtonClick);
//
// showPreinstalledAddInsCheckBox
//
this.showPreinstalledAddInsCheckBox.Location = new System.Drawing.Point(3, 6);
this.showPreinstalledAddInsCheckBox.Name = "showPreinstalledAddInsCheckBox";
this.showPreinstalledAddInsCheckBox.Size = new System.Drawing.Size(169, 24);
this.showPreinstalledAddInsCheckBox.TabIndex = 0;
this.showPreinstalledAddInsCheckBox.Text = "Show preinstalled AddIns";
this.showPreinstalledAddInsCheckBox.UseCompatibleTextRendering = true;
this.showPreinstalledAddInsCheckBox.UseVisualStyleBackColor = true;
this.showPreinstalledAddInsCheckBox.CheckedChanged += new System.EventHandler(this.ShowPreinstalledAddInsCheckBoxCheckedChanged);
//
// splitContainer
//
this.splitContainer.BackColor = System.Drawing.SystemColors.Window;
this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer.FixedPanel = System.Windows.Forms.FixedPanel.Panel2;
this.splitContainer.Location = new System.Drawing.Point(0, 33);
this.splitContainer.Name = "splitContainer";
//
// splitContainer.Panel1
//
this.splitContainer.Panel1.AllowDrop = true;
this.splitContainer.Panel1.AutoScroll = true;
this.splitContainer.Panel1.DragDrop += new System.Windows.Forms.DragEventHandler(this.Panel1DragDrop);
this.splitContainer.Panel1.DragEnter += new System.Windows.Forms.DragEventHandler(this.Panel1DragEnter);
this.splitContainer.Panel1.Paint += new System.Windows.Forms.PaintEventHandler(this.OnSplitContainerPanel1Paint);
this.splitContainer.Panel1MinSize = 100;
//
// splitContainer.Panel2
//
this.splitContainer.Panel2.Controls.Add(this.actionGroupBox);
this.splitContainer.Panel2MinSize = 100;
this.splitContainer.Size = new System.Drawing.Size(460, 322);
this.splitContainer.SplitterDistance = 248;
this.splitContainer.TabIndex = 2;
//
// actionGroupBox
//
this.actionGroupBox.Controls.Add(this.actionFlowLayoutPanel);
this.actionGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.actionGroupBox.Location = new System.Drawing.Point(0, 0);
this.actionGroupBox.Name = "actionGroupBox";
this.actionGroupBox.Size = new System.Drawing.Size(208, 322);
this.actionGroupBox.TabIndex = 0;
this.actionGroupBox.TabStop = false;
this.actionGroupBox.Text = "actionGroupBox";
this.actionGroupBox.UseCompatibleTextRendering = true;
//
// actionFlowLayoutPanel
//
this.actionFlowLayoutPanel.AutoScroll = true;
this.actionFlowLayoutPanel.Controls.Add(this.actionDescription);
this.actionFlowLayoutPanel.Controls.Add(this.dependencyTable);
this.actionFlowLayoutPanel.Controls.Add(this.runActionButton);
this.actionFlowLayoutPanel.Controls.Add(this.uninstallButton);
this.actionFlowLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill;
this.actionFlowLayoutPanel.FlowDirection = System.Windows.Forms.FlowDirection.TopDown;
this.actionFlowLayoutPanel.ForeColor = System.Drawing.SystemColors.WindowText;
this.actionFlowLayoutPanel.Location = new System.Drawing.Point(3, 17);
this.actionFlowLayoutPanel.Name = "actionFlowLayoutPanel";
this.actionFlowLayoutPanel.Size = new System.Drawing.Size(202, 302);
this.actionFlowLayoutPanel.TabIndex = 0;
this.actionFlowLayoutPanel.WrapContents = false;
//
// actionDescription
//
this.actionDescription.AutoSize = true;
this.actionDescription.Location = new System.Drawing.Point(3, 0);
this.actionDescription.Name = "actionDescription";
this.actionDescription.Size = new System.Drawing.Size(90, 18);
this.actionDescription.TabIndex = 0;
this.actionDescription.Text = "actionDescription";
this.actionDescription.UseCompatibleTextRendering = true;
//
// dependencyTable
//
this.dependencyTable.AutoSize = true;
this.dependencyTable.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.dependencyTable.ColumnCount = 2;
this.dependencyTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F));
this.dependencyTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle());
this.dependencyTable.Controls.Add(this.dummyLabel1, 1, 0);
this.dependencyTable.Controls.Add(this.dummyLabel2, 1, 1);
this.dependencyTable.Location = new System.Drawing.Point(3, 21);
this.dependencyTable.Name = "dependencyTable";
this.dependencyTable.RowCount = 2;
this.dependencyTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.dependencyTable.RowStyles.Add(new System.Windows.Forms.RowStyle());
this.dependencyTable.Size = new System.Drawing.Size(55, 36);
this.dependencyTable.TabIndex = 1;
//
// dummyLabel1
//
this.dummyLabel1.AutoSize = true;
this.dummyLabel1.Location = new System.Drawing.Point(23, 0);
this.dummyLabel1.Name = "dummyLabel1";
this.dummyLabel1.Size = new System.Drawing.Size(29, 18);
this.dummyLabel1.TabIndex = 0;
this.dummyLabel1.Text = "dep1";
this.dummyLabel1.UseCompatibleTextRendering = true;
//
// dummyLabel2
//
this.dummyLabel2.AutoSize = true;
this.dummyLabel2.Location = new System.Drawing.Point(23, 18);
this.dummyLabel2.Name = "dummyLabel2";
this.dummyLabel2.Size = new System.Drawing.Size(29, 18);
this.dummyLabel2.TabIndex = 1;
this.dummyLabel2.Text = "dep2";
this.dummyLabel2.UseCompatibleTextRendering = true;
//
// runActionButton
//
this.runActionButton.AutoSize = true;
this.runActionButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.runActionButton.Location = new System.Drawing.Point(3, 63);
this.runActionButton.MinimumSize = new System.Drawing.Size(91, 25);
this.runActionButton.Name = "runActionButton";
this.runActionButton.Size = new System.Drawing.Size(91, 25);
this.runActionButton.TabIndex = 2;
this.runActionButton.Text = "runAction";
this.runActionButton.UseCompatibleTextRendering = true;
this.runActionButton.UseVisualStyleBackColor = true;
this.runActionButton.Click += new System.EventHandler(this.RunActionButtonClick);
//
// uninstallButton
//
this.uninstallButton.AutoSize = true;
this.uninstallButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
this.uninstallButton.Location = new System.Drawing.Point(3, 94);
this.uninstallButton.MinimumSize = new System.Drawing.Size(91, 25);
this.uninstallButton.Name = "uninstallButton";
this.uninstallButton.Size = new System.Drawing.Size(91, 25);
this.uninstallButton.TabIndex = 3;
this.uninstallButton.Text = "Uninstall";
this.uninstallButton.UseCompatibleTextRendering = true;
this.uninstallButton.UseVisualStyleBackColor = true;
this.uninstallButton.Click += new System.EventHandler(this.UninstallButtonClick);
//
// ManagerForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(460, 390);
this.Controls.Add(this.splitContainer);
this.Controls.Add(this.bottomPanel);
this.Controls.Add(this.topPanel);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.MinimumSize = new System.Drawing.Size(250, 200);
this.Name = "ManagerForm";
this.Text = "AddIn Manager";
this.bottomPanel.ResumeLayout(false);
this.splitContainer.Panel2.ResumeLayout(false);
this.splitContainer.ResumeLayout(false);
this.actionGroupBox.ResumeLayout(false);
this.actionFlowLayoutPanel.ResumeLayout(false);
this.actionFlowLayoutPanel.PerformLayout();
this.dependencyTable.ResumeLayout(false);
this.dependencyTable.PerformLayout();
this.ResumeLayout(false);
}
private System.Windows.Forms.Label dummyLabel2;
private System.Windows.Forms.Label dummyLabel1;
private System.Windows.Forms.CheckBox showPreinstalledAddInsCheckBox;
private System.Windows.Forms.Button installButton;
private System.Windows.Forms.Button uninstallButton;
private System.Windows.Forms.Button runActionButton;
private System.Windows.Forms.TableLayoutPanel dependencyTable;
private System.Windows.Forms.Label actionDescription;
private System.Windows.Forms.FlowLayoutPanel actionFlowLayoutPanel;
private System.Windows.Forms.GroupBox actionGroupBox;
private System.Windows.Forms.Button closeButton;
private System.Windows.Forms.SplitContainer splitContainer;
private System.Windows.Forms.Panel bottomPanel;
private System.Windows.Forms.Panel topPanel;
#endregion
}
}

120
samples/ICSharpCode.Core.Demo/AddInManager/Src/ManagerForm.resx

@ -0,0 +1,120 @@ @@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

BIN
samples/ICSharpCode.Core.Demo/AddInManager/StringResources.de.resources

Binary file not shown.

BIN
samples/ICSharpCode.Core.Demo/AddInManager/StringResources.resources

Binary file not shown.

BIN
samples/ICSharpCode.Core.Demo/AddInManager/WizardBackground.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

34
samples/ICSharpCode.Core.Demo/Base/AssemblyInfo.cs

@ -0,0 +1,34 @@ @@ -0,0 +1,34 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 22.12.2005
* Time: 19:32
*/
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("Base")]
[assembly: AssemblyDescription("Base AddIn for ICSharpCode.Core.Demo")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ic#code")]
[assembly: AssemblyProduct("ICSharpCode.Core.Demo")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

67
samples/ICSharpCode.Core.Demo/Base/Base.csproj

@ -0,0 +1,67 @@ @@ -0,0 +1,67 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>Base</RootNamespace>
<AssemblyName>Base</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C9A2B6BC-5260-4DE3-8082-DCE8B391F7BB}</ProjectGuid>
<OutputPath>..\bin\</OutputPath>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Workbench.cs" />
<Compile Include="FormLocationHelper.cs" />
<Compile Include="FileCommands.cs" />
<Compile Include="TextViewContent.cs" />
<Compile Include="IViewContent.cs" />
<Compile Include="FileViewContent.cs" />
<Compile Include="IClipboardHandler.cs" />
<Compile Include="IUndoHandler.cs" />
<Compile Include="InfoForm.cs" />
<EmbeddedResource Include="InfoForm.resx">
<DependentUpon>InfoForm.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="IDisplayBinding.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="..\Startup\AddIns\Base.addin">
<Link>Base.addin</Link>
</Content>
<ProjectReference Include="..\..\..\src\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

6
samples/ICSharpCode.Core.Demo/Base/Base.sln

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.932
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Base", "Base.csproj", "{C9A2B6BC-5260-4DE3-8082-DCE8B391F7BB}"
EndProject
Global
EndGlobal

74
samples/ICSharpCode.Core.Demo/Base/FileCommands.cs

@ -0,0 +1,74 @@ @@ -0,0 +1,74 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace Base
{
public class NewFileCommand : AbstractMenuCommand
{
public override void Run()
{
Workbench workbench = (Workbench)this.Owner;
if (workbench.CloseCurrentContent()) {
workbench.ShowContent(new TextViewContent());
}
}
}
public class OpenFileCommand : AbstractMenuCommand
{
public override void Run()
{
Workbench workbench = (Workbench)this.Owner;
if (workbench.CloseCurrentContent()) {
using (OpenFileDialog dlg = new OpenFileDialog()) {
dlg.CheckFileExists = true;
dlg.DefaultExt = ".txt";
dlg.Filter = FileViewContent.GetFileFilter("/Workspace/FileFilter");
if (dlg.ShowDialog() == DialogResult.OK) {
IViewContent content = DisplayBindingManager.CreateViewContent(dlg.FileName);
if (content != null) {
workbench.ShowContent(content);
}
}
}
}
}
}
public class SaveFileCommand : AbstractMenuCommand
{
public override void Run()
{
Workbench workbench = (Workbench)this.Owner;
if (workbench.ActiveViewContent != null) {
workbench.ActiveViewContent.Save();
}
}
}
public class SaveFileAsCommand : AbstractMenuCommand
{
public override void Run()
{
Workbench workbench = (Workbench)this.Owner;
if (workbench.ActiveViewContent != null) {
workbench.ActiveViewContent.SaveAs();
}
}
}
public class ExitCommand : AbstractMenuCommand
{
public override void Run()
{
Workbench workbench = (Workbench)this.Owner;
if (workbench.CloseCurrentContent()) {
workbench.Close();
}
}
}
}

147
samples/ICSharpCode.Core.Demo/Base/FileViewContent.cs

@ -0,0 +1,147 @@ @@ -0,0 +1,147 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
using System.Text;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace Base
{
/// <summary>
/// Base ViewContent for files.
/// </summary>
public abstract class FileViewContent : IViewContent
{
public abstract Control Control {
get;
}
string fileName;
public event EventHandler FileNameChanged;
public string FileName {
get {
return fileName;
}
set {
if (fileName != value) {
fileName = value;
ChangeTitleToFileName();
if (FileNameChanged != null) {
FileNameChanged(this, EventArgs.Empty);
}
}
}
}
protected virtual void ChangeTitleToFileName()
{
this.Title = System.IO.Path.GetFileName(this.FileName);
}
string title = "Untitled";
public event EventHandler TitleChanged;
public string Title {
get {
return title;
}
set {
if (title != value) {
title = value;
if (TitleChanged != null) {
TitleChanged(this, EventArgs.Empty);
}
}
}
}
bool dirty;
public event EventHandler DirtyChanged;
public bool Dirty {
get {
return dirty;
}
set {
if (dirty != value) {
dirty = value;
if (DirtyChanged != null) {
DirtyChanged(this, EventArgs.Empty);
}
}
}
}
public bool Save()
{
if (fileName == null) {
return SaveAs();
} else {
if (Save(fileName)) {
Dirty = false;
return true;
} else {
return false;
}
}
}
public virtual bool SaveAs()
{
return ShowSaveAsDialog(GetFileFilter("/Workspace/FileFilter"), ".txt");
}
public static string GetFileFilter(string addInTreePath)
{
StringBuilder b = new StringBuilder();
b.Append("All known file types|");
foreach (string filter in AddInTree.BuildItems(addInTreePath, null, true)) {
b.Append(filter.Substring(filter.IndexOf('|') + 1));
b.Append(';');
}
foreach (string filter in AddInTree.BuildItems(addInTreePath, null, true)) {
b.Append('|');
b.Append(filter);
}
b.Append("|All files|*.*");
return b.ToString();
}
protected bool ShowSaveAsDialog(string filter, string defaultExtension)
{
using (SaveFileDialog dlg = new SaveFileDialog()) {
dlg.Filter = filter;
dlg.DefaultExt = defaultExtension;
if (dlg.ShowDialog() == DialogResult.OK) {
FileName = dlg.FileName;
if (Save(dlg.FileName)) {
Dirty = false;
return true;
}
}
}
return false;
}
protected abstract bool Save(string fileName);
public virtual bool Close()
{
if (this.Dirty) {
DialogResult res = MessageBox.Show("The file was modified. Do you want to save it?", "Modified file", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button3);
if (res == DialogResult.Yes)
return Save();
else if (res == DialogResult.No)
return true; // close without saving
else
return false;
} else {
return true;
}
}
}
}

68
samples/ICSharpCode.Core.Demo/Base/FormLocationHelper.cs

@ -0,0 +1,68 @@ @@ -0,0 +1,68 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace Base
{
/// <summary>
/// Static helper class that loads and stores the position and size of a Form in the
/// PropertyService.
/// </summary>
public static class FormLocationHelper
{
public static void Apply(Form form, string propertyName, bool isResizable)
{
form.StartPosition = FormStartPosition.Manual;
if (isResizable) {
form.Bounds = Validate(PropertyService.Get(propertyName, GetDefaultBounds(form)));
} else {
form.Location = Validate(PropertyService.Get(propertyName, GetDefaultLocation(form)), form.Size);
}
form.Closing += delegate {
if (isResizable) {
PropertyService.Set(propertyName, form.Bounds);
} else {
PropertyService.Set(propertyName, form.Location);
}
};
}
static Rectangle Validate(Rectangle bounds)
{
// Check if form is outside the screen and get it back if necessary.
// This is important when the user uses multiple screens, a window stores its location
// on the secondary monitor and then the secondary monitor is removed.
Rectangle screen1 = Screen.FromPoint(new Point(bounds.X, bounds.Y)).WorkingArea;
Rectangle screen2 = Screen.FromPoint(new Point(bounds.X + bounds.Width, bounds.Y)).WorkingArea;
if (bounds.Y < screen1.Y - 5 && bounds.Y < screen2.Y - 5)
bounds.Y = screen1.Y - 5;
if (bounds.X < screen1.X - bounds.Width / 2)
bounds.X = screen1.X - bounds.Width / 2;
else if (bounds.X > screen2.Right - bounds.Width / 2)
bounds.X = screen2.Right - bounds.Width / 2;
return bounds;
}
static Point Validate(Point location, Size size)
{
return Validate(new Rectangle(location, size)).Location;
}
static Rectangle GetDefaultBounds(Form form)
{
return new Rectangle(GetDefaultLocation(form), form.Size);
}
static Point GetDefaultLocation(Form form)
{
Rectangle parent = (form.Owner != null) ? form.Owner.Bounds : Screen.FromPoint(Control.MousePosition).WorkingArea;
Size size = form.Size;
return new Point(parent.Left + (parent.Width - size.Width) / 2,
parent.Top + (parent.Height - size.Height) / 2);
}
}
}

22
samples/ICSharpCode.Core.Demo/Base/IClipboardHandler.cs

@ -0,0 +1,22 @@ @@ -0,0 +1,22 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
namespace Base
{
public interface IClipboardHandler
{
bool CanPaste { get; }
void Paste();
bool CanCut { get; }
void Cut();
bool CanCopy { get; }
void Copy();
bool CanDelete { get; }
void Delete();
}
}

40
samples/ICSharpCode.Core.Demo/Base/IDisplayBinding.cs

@ -0,0 +1,40 @@ @@ -0,0 +1,40 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
using System.Collections;
using ICSharpCode.Core;
namespace Base
{
/// <summary>
/// Interface for classes that are able to open a file and create a <see cref="IViewContent"/> for it.
/// </summary>
public interface IDisplayBinding
{
/// <summary>
/// Loads the file and opens a <see cref="IViewContent"/>.
/// When this method returns <c>null</c>, the display binding cannot handle the file type.
/// </summary>
IViewContent OpenFile(string fileName);
}
public static class DisplayBindingManager
{
static ArrayList items;
public static IViewContent CreateViewContent(string fileName)
{
if (items == null) {
items = AddInTree.BuildItems("/Workspace/DisplayBindings", null, true);
}
foreach (IDisplayBinding binding in items) {
IViewContent content = binding.OpenFile(fileName);
if (content != null) {
return content;
}
}
return null;
}
}
}

15
samples/ICSharpCode.Core.Demo/Base/IUndoHandler.cs

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
namespace Base
{
public interface IUndoHandler
{
bool CanUndo { get; }
void Undo();
bool CanRedo { get; }
void Redo();
}
}

45
samples/ICSharpCode.Core.Demo/Base/IViewContent.cs

@ -0,0 +1,45 @@ @@ -0,0 +1,45 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
namespace Base
{
/// <summary>
/// Interface for content displayed in the application.
/// </summary>
public interface IViewContent
{
/// <summary>
/// Gets the control used to display this view content.
/// </summary>
Control Control {
get;
}
string Title {
get;
}
event EventHandler TitleChanged;
/// <summary>
/// Closes the view content. Returns true when the content was closed successfully,
/// false when closing the content was aborted (e.g. by the user)
/// </summary>
bool Close();
/// <summary>
/// Saves the content, e.g. to a file. Returns true when the content has been saved successfully.
/// </summary>
bool Save();
/// <summary>
/// Asks the user to specify the file location/name and saves the content using the new name.
/// Returns true when the content has been saved successfully.
/// </summary>
bool SaveAs();
}
}

233
samples/ICSharpCode.Core.Demo/Base/InfoForm.cs

@ -0,0 +1,233 @@ @@ -0,0 +1,233 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
using System.Drawing;
using System.Reflection;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace Base
{
public class InfoForm : System.Windows.Forms.Form
{
public InfoForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
FormLocationHelper.Apply(this, "InfoForm", false);
versionLabel.Text = typeof(AddInTree).Assembly.GetName().Version.ToString();
demoVersionLabel.Text = Assembly.GetEntryAssembly().GetName().Version.ToString();
listBox.UseCustomTabOffsets = true;
listBox.CustomTabOffsets.Add(100);
foreach (Assembly asm in AppDomain.CurrentDomain.GetAssemblies()) {
AssemblyName name = asm.GetName();
listBox.Items.Add(name.Name + "\t" + name.Version.ToString());
}
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
System.Windows.Forms.LinkLabel linkLabel1;
System.Windows.Forms.LinkLabel linkLabel2;
System.Windows.Forms.LinkLabel linkLabel3;
System.Windows.Forms.Label label1;
System.Windows.Forms.Label label3;
System.Windows.Forms.Button okButton;
System.Windows.Forms.Label label4;
this.listBox = new System.Windows.Forms.ListBox();
this.versionLabel = new System.Windows.Forms.Label();
this.demoVersionLabel = new System.Windows.Forms.Label();
linkLabel1 = new System.Windows.Forms.LinkLabel();
linkLabel2 = new System.Windows.Forms.LinkLabel();
linkLabel3 = new System.Windows.Forms.LinkLabel();
label1 = new System.Windows.Forms.Label();
label3 = new System.Windows.Forms.Label();
okButton = new System.Windows.Forms.Button();
label4 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// linkLabel1
//
linkLabel1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
linkLabel1.LinkArea = new System.Windows.Forms.LinkArea(43, 12);
linkLabel1.Location = new System.Drawing.Point(12, 9);
linkLabel1.Name = "linkLabel1";
linkLabel1.Size = new System.Drawing.Size(368, 45);
linkLabel1.TabIndex = 1;
linkLabel1.TabStop = true;
linkLabel1.Tag = "http://sharpdevelop.net/";
linkLabel1.Text = "Demo application for ICSharpCode.Core, the SharpDevelop add-in architecture.";
linkLabel1.UseCompatibleTextRendering = true;
linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelLinkClicked);
//
// linkLabel2
//
linkLabel2.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
linkLabel2.LinkArea = new System.Windows.Forms.LinkArea(16, 15);
linkLabel2.Location = new System.Drawing.Point(12, 54);
linkLabel2.Name = "linkLabel2";
linkLabel2.Size = new System.Drawing.Size(368, 28);
linkLabel2.TabIndex = 2;
linkLabel2.TabStop = true;
linkLabel2.Tag = "mailto:daniel@danielgrunwald.de";
linkLabel2.Text = "Demo written by Daniel Grunwald on the 22nd December, 2005.";
linkLabel2.UseCompatibleTextRendering = true;
linkLabel2.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelLinkClicked);
//
// linkLabel3
//
linkLabel3.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
linkLabel3.LinkArea = new System.Windows.Forms.LinkArea(81, 17);
linkLabel3.Location = new System.Drawing.Point(12, 82);
linkLabel3.Name = "linkLabel3";
linkLabel3.Size = new System.Drawing.Size(368, 42);
linkLabel3.TabIndex = 3;
linkLabel3.TabStop = true;
linkLabel3.Tag = "http://wiki.sharpdevelop.net/default.aspx/SharpDevelop.Contributors";
linkLabel3.Text = "ICSharpCode.Core was written by Mike Krüger, Daniel Grunwald and the rest of the " +
"SharpDevelop team.";
linkLabel3.UseCompatibleTextRendering = true;
linkLabel3.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.LinkLabelLinkClicked);
//
// label1
//
label1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
label1.Location = new System.Drawing.Point(12, 172);
label1.Name = "label1";
label1.Size = new System.Drawing.Size(368, 23);
label1.TabIndex = 6;
label1.Tag = "";
label1.Text = "List of loaded assemblies:";
label1.UseCompatibleTextRendering = true;
//
// label3
//
label3.Location = new System.Drawing.Point(35, 124);
label3.Name = "label3";
label3.Size = new System.Drawing.Size(144, 23);
label3.TabIndex = 4;
label3.Text = "ICSharpCode.Core version:";
label3.TextAlign = System.Drawing.ContentAlignment.TopRight;
label3.UseCompatibleTextRendering = true;
//
// okButton
//
okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
okButton.Location = new System.Drawing.Point(305, 302);
okButton.Name = "okButton";
okButton.Size = new System.Drawing.Size(75, 23);
okButton.TabIndex = 0;
okButton.Text = "OK";
okButton.UseCompatibleTextRendering = true;
okButton.UseVisualStyleBackColor = true;
okButton.Click += new System.EventHandler(this.OkButtonClick);
//
// listBox
//
this.listBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.listBox.FormattingEnabled = true;
this.listBox.Location = new System.Drawing.Point(12, 188);
this.listBox.Name = "listBox";
this.listBox.Size = new System.Drawing.Size(368, 108);
this.listBox.TabIndex = 7;
//
// versionLabel
//
this.versionLabel.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.World);
this.versionLabel.Location = new System.Drawing.Point(185, 124);
this.versionLabel.Name = "versionLabel";
this.versionLabel.Size = new System.Drawing.Size(112, 23);
this.versionLabel.TabIndex = 5;
this.versionLabel.Text = "#.#.#.#";
this.versionLabel.UseCompatibleTextRendering = true;
//
// demoVersionLabel
//
this.demoVersionLabel.Font = new System.Drawing.Font("Tahoma", 11F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.World);
this.demoVersionLabel.Location = new System.Drawing.Point(185, 147);
this.demoVersionLabel.Name = "demoVersionLabel";
this.demoVersionLabel.Size = new System.Drawing.Size(112, 23);
this.demoVersionLabel.TabIndex = 9;
this.demoVersionLabel.Text = "#.#.#.#";
this.demoVersionLabel.UseCompatibleTextRendering = true;
//
// label4
//
label4.Location = new System.Drawing.Point(35, 147);
label4.Name = "label4";
label4.Size = new System.Drawing.Size(144, 23);
label4.TabIndex = 8;
label4.Text = "Demo application version:";
label4.TextAlign = System.Drawing.ContentAlignment.TopRight;
label4.UseCompatibleTextRendering = true;
//
// InfoForm
//
this.AcceptButton = okButton;
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(392, 330);
this.Controls.Add(this.demoVersionLabel);
this.Controls.Add(label4);
this.Controls.Add(okButton);
this.Controls.Add(this.versionLabel);
this.Controls.Add(label3);
this.Controls.Add(this.listBox);
this.Controls.Add(label1);
this.Controls.Add(linkLabel3);
this.Controls.Add(linkLabel2);
this.Controls.Add(linkLabel1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.MaximizeBox = false;
this.MinimizeBox = false;
this.Name = "InfoForm";
this.Text = "About ICSharpCode.Core.Demo";
this.ResumeLayout(false);
}
private System.Windows.Forms.Label demoVersionLabel;
private System.Windows.Forms.ListBox listBox;
private System.Windows.Forms.Label versionLabel;
#endregion
void LinkLabelLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
string url = (sender as Control).Tag.ToString();
try {
System.Diagnostics.Process.Start(url);
} catch (Exception) {
MessageService.ShowMessage(url);
}
}
void OkButtonClick(object sender, EventArgs e)
{
Close();
}
}
public class InfoCommand : AbstractMenuCommand
{
public override void Run()
{
using (InfoForm frm = new InfoForm()) {
frm.ShowDialog(this.Owner as IWin32Window);
}
}
}
}

141
samples/ICSharpCode.Core.Demo/Base/InfoForm.resx

@ -0,0 +1,141 @@ @@ -0,0 +1,141 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<metadata name="linkLabel1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="linkLabel2.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="linkLabel3.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label1.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label3.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="okButton.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
<metadata name="label4.GenerateMember" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>False</value>
</metadata>
</root>

128
samples/ICSharpCode.Core.Demo/Base/TextViewContent.cs

@ -0,0 +1,128 @@ @@ -0,0 +1,128 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
namespace Base
{
public class TextDisplayBinding : IDisplayBinding
{
public IViewContent OpenFile(string fileName)
{
return new TextViewContent(fileName);
}
}
/// <summary>
/// ViewContent showing a text file.
/// </summary>
public class TextViewContent : FileViewContent, IClipboardHandler, IUndoHandler
{
TextBox textBox = new TextBox();
public TextViewContent()
{
textBox.Multiline = true;
textBox.AcceptsReturn = true;
textBox.AcceptsTab = true;
textBox.Font = new Font("Courier New", 10f);
textBox.WordWrap = false;
textBox.ScrollBars = ScrollBars.Both;
textBox.TextChanged += delegate {
this.Dirty = true;
};
}
public TextViewContent(string fileName) : this()
{
textBox.Text = File.ReadAllText(fileName);
this.FileName = fileName;
this.Dirty = false;
}
public override Control Control {
get {
return textBox;
}
}
protected override bool Save(string fileName)
{
File.WriteAllText(fileName, textBox.Text);
return true;
}
#region IClipboardHandler implementation
bool IClipboardHandler.CanPaste {
get {
return !textBox.ReadOnly;
}
}
bool IClipboardHandler.CanCut {
get {
return !textBox.ReadOnly && textBox.SelectionLength > 0;
}
}
bool IClipboardHandler.CanCopy {
get {
return textBox.SelectionLength > 0;
}
}
bool IClipboardHandler.CanDelete {
get {
return !textBox.ReadOnly && textBox.SelectionLength > 0;
}
}
void IClipboardHandler.Paste()
{
textBox.Paste();
}
void IClipboardHandler.Cut()
{
textBox.Cut();
}
void IClipboardHandler.Copy()
{
textBox.Copy();
}
void IClipboardHandler.Delete()
{
textBox.SelectedText = "";
}
#endregion
#region IUndoHandler implementation
bool IUndoHandler.CanUndo {
get {
return textBox.CanUndo;
}
}
bool IUndoHandler.CanRedo {
get {
return false;
}
}
void IUndoHandler.Undo()
{
textBox.Undo();
}
void IUndoHandler.Redo()
{
throw new NotImplementedException();
}
#endregion
}
}

141
samples/ICSharpCode.Core.Demo/Base/Workbench.cs

@ -0,0 +1,141 @@ @@ -0,0 +1,141 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
using ICSharpCode.Core;
namespace Base
{
/// <summary>
/// The main form of the application.
/// </summary>
public sealed class Workbench : Form
{
static Workbench instance;
public static Workbench Instance {
get {
return instance;
}
}
public static void InitializeWorkbench()
{
instance = new Workbench();
}
MenuStrip menu;
ToolStrip toolbar;
Panel contentPanel;
private Workbench()
{
// restore form location from last session
FormLocationHelper.Apply(this, "StartupFormPosition", true);
contentPanel = new Panel();
contentPanel.Dock = DockStyle.Fill;
this.Controls.Add(contentPanel);
menu = new MenuStrip();
MenuService.AddItemsToMenu(menu.Items, this, "/Workbench/MainMenu");
toolbar = ToolbarService.CreateToolStrip(this, "/Workbench/Toolbar");
this.Controls.Add(toolbar);
this.Controls.Add(menu);
// Start with an empty text file
ShowContent(new TextViewContent());
// Use the Idle event to update the status of menu and toolbar items.
Application.Idle += OnApplicationIdle;
}
protected override void Dispose(bool disposing)
{
if (disposing) {
Application.Idle -= OnApplicationIdle;
}
base.Dispose(disposing);
}
void OnApplicationIdle(object sender, EventArgs e)
{
// Use the Idle event to update the status of menu and toolbar.
// Depending on your application and the number of menu items with complex conditions,
// you might want to update the status less frequently.
UpdateMenuItemStatus();
}
/// <summary>Update Enabled/Visible state of items in the main menu based on conditions</summary>
void UpdateMenuItemStatus()
{
foreach (ToolStripItem item in menu.Items) {
if (item is IStatusUpdate)
(item as IStatusUpdate).UpdateStatus();
}
}
/// <summary>The active view content</summary>
IViewContent viewContent;
public IViewContent ActiveViewContent {
get {
return viewContent;
}
}
protected override void OnClosing(CancelEventArgs e)
{
base.OnClosing(e);
if (!e.Cancel) {
e.Cancel = !CloseCurrentContent();
}
}
public bool CloseCurrentContent()
{
IViewContent content = viewContent;
if (content != null) {
if (!content.Close()) {
return false;
}
viewContent = null;
content.TitleChanged -= OnTitleChanged;
OnTitleChanged(content, EventArgs.Empty);
foreach (Control ctl in contentPanel.Controls) {
ctl.Dispose();
}
contentPanel.Controls.Clear();
}
return true;
}
public void ShowContent(IViewContent content)
{
if (viewContent != null)
throw new InvalidOperationException("There is still another content opened.");
viewContent = content;
Control ctl = content.Control;
ctl.Dock = DockStyle.Fill;
contentPanel.Controls.Add(ctl);
ctl.Focus();
content.TitleChanged += OnTitleChanged;
OnTitleChanged(content, EventArgs.Empty);
}
void OnTitleChanged(object sender, EventArgs e)
{
if (viewContent != null) {
this.Text = viewContent.Title + " - ICSharpCode.Core.Demo";
} else {
this.Text = "ICSharpCode.Core.Demo";
}
}
}
}

29
samples/ICSharpCode.Core.Demo/ICSharpCode.Core.Demo.rtf

@ -0,0 +1,29 @@ @@ -0,0 +1,29 @@
{\rtf1\ansi\ansicpg1252\uc1\deff0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deflang1031\deflangfe1031{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}
{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}{\f37\froman\fcharset238\fprq2 Times New Roman CE;}{\f38\froman\fcharset204\fprq2 Times New Roman Cyr;}{\f40\froman\fcharset161\fprq2 Times New Roman Greek;}
{\f41\froman\fcharset162\fprq2 Times New Roman Tur;}{\f42\froman\fcharset177\fprq2 Times New Roman (Hebrew);}{\f43\froman\fcharset178\fprq2 Times New Roman (Arabic);}{\f44\froman\fcharset186\fprq2 Times New Roman Baltic;}
{\f45\froman\fcharset163\fprq2 Times New Roman (Vietnamese);}{\f57\fmodern\fcharset238\fprq1 Courier New CE;}{\f58\fmodern\fcharset204\fprq1 Courier New Cyr;}{\f60\fmodern\fcharset161\fprq1 Courier New Greek;}
{\f61\fmodern\fcharset162\fprq1 Courier New Tur;}{\f62\fmodern\fcharset177\fprq1 Courier New (Hebrew);}{\f63\fmodern\fcharset178\fprq1 Courier New (Arabic);}{\f64\fmodern\fcharset186\fprq1 Courier New Baltic;}
{\f65\fmodern\fcharset163\fprq1 Courier New (Vietnamese);}}{\colortbl;\red0\green0\blue0;\red0\green0\blue255;\red0\green255\blue255;\red0\green255\blue0;\red255\green0\blue255;\red255\green0\blue0;\red255\green255\blue0;\red255\green255\blue255;
\red0\green0\blue128;\red0\green128\blue128;\red0\green128\blue0;\red128\green0\blue128;\red128\green0\blue0;\red128\green128\blue0;\red128\green128\blue128;\red192\green192\blue192;}{\stylesheet{
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs24\lang1031\langfe1031\cgrid\langnp1031\langfenp1031 \snext0 \styrsid3083618 Normal;}{\*\cs10 \additive \ssemihidden Default Paragraph Font;}{\*
\ts11\tsrowd\trftsWidthB3\trpaddl108\trpaddr108\trpaddfl3\trpaddft3\trpaddfb3\trpaddfr3\trcbpat1\trcfpat1\tscellwidthfts0\tsvertalt\tsbrdrt\tsbrdrl\tsbrdrb\tsbrdrr\tsbrdrdgl\tsbrdrdgr\tsbrdrh\tsbrdrv
\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0 \fs20\lang1024\langfe1024\cgrid\langnp1024\langfenp1024 \snext11 \ssemihidden Normal Table;}{\s15\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0
\f2\fs20\lang1033\langfe1031\cgrid\langnp1033\langfenp1031 \sbasedon0 \snext15 \styrsid13049063 Plain Text;}{\*\cs16 \additive \ul\cf2 \sbasedon10 \styrsid3083618 Hyperlink;}}{\*\latentstyles\lsdstimax156\lsdlockeddef0}{\*\rsidtbl \rsid2842370\rsid3083618
\rsid7370522\rsid13049063\rsid15619894}{\*\generator Microsoft Word 11.0.6502;}{\info{\title ICSharpCode}{\author Daniel Grunwald}{\operator Daniel Grunwald}{\creatim\yr2006\mo2\dy12\hr15\min28}{\revtim\yr2006\mo2\dy12\hr15\min28}{\version2}{\edmins0}
{\nofpages1}{\nofwords39}{\nofchars249}{\nofcharsws287}{\vern24579}}\paperw11906\paperh16838\margl1152\margr1152\margt1417\margb1134
\deftab708\widowctrl\ftnbj\aenddoc\hyphhotz425\noxlattoyen\expshrtn\noultrlspc\dntblnsbdb\nospaceforul\formshade\horzdoc\dgmargin\dghspace180\dgvspace180\dghorigin1152\dgvorigin1417\dghshow1\dgvshow1
\jexpand\viewkind1\viewscale80\pgbrdrhead\pgbrdrfoot\splytwnine\ftnlytwnine\htmautsp\nolnhtadjtbl\useltbaln\alntblind\lytcalctblwd\lyttblrtgr\lnbrkrule\nobrkwrptbl\snaptogridincell\allowfieldendsel\wrppunct
\asianbrkrule\rsidroot2842370\newtblstyruls\nogrowautofit \fet0\sectd \linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl\sectrsid13049063\sftnbj {\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl2
\pnucltr\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang {\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang {\pntxta )}}{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl6
\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl8\pnlcltr\pnstart1\pnindent720\pnhang {\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang
{\pntxtb (}{\pntxta )}}\pard\plain \qj \li0\ri0\sa120\nowidctlpar\faauto\rin0\lin0\itap0\pararsid3083618 \fs24\lang1031\langfe1031\cgrid\langnp1031\langfenp1031 {\b\fs48\lang1023\langfe1031\langnp1023\insrsid3083618 ICSharpCode.Core Demo}{
\lang1023\langfe1031\langnp1023\insrsid3083618
\par This example shows you how you can use ICSharpCode.Core to create an AddIn-system for your own applications.
\par A description is available at }{\field{\*\fldinst {\lang1023\langfe1031\langnp1023\insrsid3083618 HYPERLINK "}{\lang1023\langfe1031\langnp1023\insrsid3083618\charrsid3083618 http://www.codeproject.com/csharp/ICSharpCodeCore.asp}{
\lang1023\langfe1031\langnp1023\insrsid3083618 " }{\lang1023\langfe1031\langnp1023\insrsid3083618\charrsid216981 {\*\datafield
00d0c9ea79f9bace118c8200aa004ba90b02000000170000003600000068007400740070003a002f002f007700770077002e0063006f0064006500700072006f006a006500630074002e0063006f006d002f006300730068006100720070002f00490043005300680061007200700043006f006400650043006f0072006500
2e006100730070000000e0c9ea79f9bace118c8200aa004ba90b6c00000068007400740070003a002f002f007700770077002e0063006f0064006500700072006f006a006500630074002e0063006f006d002f006300730068006100720070002f00490043005300680061007200700043006f006400650043006f00720065
002e006100730070000000}}}{\fldrslt {\cs16\ul\cf2\lang1023\langfe1031\langnp1023\insrsid3083618\charrsid216981 http://www.codeproject.com/csharp/ICSharpCodeCore.asp}}}{\lang1023\langfe1031\langnp1023\insrsid3083618 .}{
\lang1023\langfe1031\langnp1023\insrsid3083618\charrsid3083618
\par }\pard\plain \s15\ql \li0\ri0\widctlpar\aspalpha\aspnum\faauto\adjustright\rin0\lin0\itap0\pararsid13049063 \f2\fs20\lang1033\langfe1031\cgrid\langnp1033\langfenp1031 {\insrsid3083618\charrsid13049063
\par }}

46
samples/ICSharpCode.Core.Demo/ICSharpCode.Core.Demo.sln

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.1128
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Base", "Base\Base.csproj", "{C9A2B6BC-5260-4DE3-8082-DCE8B391F7BB}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Startup", "Startup\Startup.csproj", "{0AF8FEF6-32B9-46BD-A270-AB3B20EB39A3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AddInManager", "AddInManager\AddInManager.csproj", "{8B4FE9EF-5899-4E84-88DE-C37D021A0658}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "doc", "doc", "{491D60D3-3F16-4887-8ED2-541535E4AACD}"
ProjectSection(SolutionItems) = postProject
doc\copyright.txt = doc\copyright.txt
doc\license.txt = doc\license.txt
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RichTextEditor", "RichTextEditor\RichTextEditor.csproj", "{C663289E-DD00-463F-8988-9913DDDAEEE1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ICSharpCode.Core", "..\..\src\Main\Core\Project\ICSharpCode.Core.csproj", "{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C9A2B6BC-5260-4DE3-8082-DCE8B391F7BB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C9A2B6BC-5260-4DE3-8082-DCE8B391F7BB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C9A2B6BC-5260-4DE3-8082-DCE8B391F7BB}.Release|Any CPU.Build.0 = Release|Any CPU
{C9A2B6BC-5260-4DE3-8082-DCE8B391F7BB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0AF8FEF6-32B9-46BD-A270-AB3B20EB39A3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0AF8FEF6-32B9-46BD-A270-AB3B20EB39A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0AF8FEF6-32B9-46BD-A270-AB3B20EB39A3}.Release|Any CPU.Build.0 = Release|Any CPU
{0AF8FEF6-32B9-46BD-A270-AB3B20EB39A3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8B4FE9EF-5899-4E84-88DE-C37D021A0658}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8B4FE9EF-5899-4E84-88DE-C37D021A0658}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8B4FE9EF-5899-4E84-88DE-C37D021A0658}.Release|Any CPU.Build.0 = Release|Any CPU
{8B4FE9EF-5899-4E84-88DE-C37D021A0658}.Release|Any CPU.ActiveCfg = Release|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.Build.0 = Release|Any CPU
{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C663289E-DD00-463F-8988-9913DDDAEEE1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C663289E-DD00-463F-8988-9913DDDAEEE1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C663289E-DD00-463F-8988-9913DDDAEEE1}.Release|Any CPU.Build.0 = Release|Any CPU
{C663289E-DD00-463F-8988-9913DDDAEEE1}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

BIN
samples/ICSharpCode.Core.Demo/RequiredLibraries/ICSharpCode.SharpZipLib.dll

Binary file not shown.

27
samples/ICSharpCode.Core.Demo/RichTextEditor/AssemblyInfo.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("RichTextEditor")]
[assembly: AssemblyDescription("RTF addin for ICSharpCode.Core.Demo")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ic#code")]
[assembly: AssemblyProduct("ICSharpCode.Core.Demo")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

25
samples/ICSharpCode.Core.Demo/RichTextEditor/RichTextEditor.addin

@ -0,0 +1,25 @@ @@ -0,0 +1,25 @@
<AddIn name = "Rich Text Editor"
author = "Daniel Grunwald"
url = "http://www.codeproject.com/TBD"
description = "Supports editing .rtf files in the ICSharpCode.Core example editor">
<Manifest>
<!-- unique name of the AddIn, used when others AddIns want to reference this AddIn -->
<Identity name="ICSharpCode.Core.Demo.RichTextEditor" version = "@RichTextEditor.dll"/>
<Dependency addin="ICSharpCode.Core.Demo" version="1.0"/>
</Manifest>
<Runtime>
<Import assembly="RichTextEditor.dll"/>
</Runtime>
<Path name = "/Workspace/FileFilter">
<FileFilter id = "RTF" name = "Rich text files" extensions = "*.rtf"/>
</Path>
<Path name = "/Workspace/DisplayBindings">
<Class id = "RTF"
class = "RichTextEditor.DisplayBinding"
insertbefore = "Text"/>
</Path>
</AddIn>

125
samples/ICSharpCode.Core.Demo/RichTextEditor/RichTextEditor.cs

@ -0,0 +1,125 @@ @@ -0,0 +1,125 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
using System.IO;
using System.Windows.Forms;
using Base;
namespace RichTextEditor
{
public class DisplayBinding : IDisplayBinding
{
public IViewContent OpenFile(string fileName)
{
if (Path.GetExtension(fileName).ToLowerInvariant() == ".rtf") {
return new RichTextViewContent(fileName);
}
return null;
}
}
public class RichTextViewContent : FileViewContent, IClipboardHandler, IUndoHandler
{
RichTextBox textBox = new RichTextBox();
public RichTextViewContent()
{
textBox.RichTextShortcutsEnabled = false;
textBox.AcceptsTab = true;
textBox.ScrollBars = RichTextBoxScrollBars.Both;
textBox.TextChanged += delegate {
this.Dirty = true;
};
}
public RichTextViewContent(string fileName) : this()
{
textBox.LoadFile(fileName);
this.FileName = fileName;
this.Dirty = false;
}
public override Control Control {
get {
return textBox;
}
}
protected override bool Save(string fileName)
{
textBox.SaveFile(fileName);
return true;
}
#region IClipboardHandler implementation
bool IClipboardHandler.CanPaste {
get {
return !textBox.ReadOnly;
}
}
bool IClipboardHandler.CanCut {
get {
return !textBox.ReadOnly && textBox.SelectionLength > 0;
}
}
bool IClipboardHandler.CanCopy {
get {
return textBox.SelectionLength > 0;
}
}
bool IClipboardHandler.CanDelete {
get {
return !textBox.ReadOnly && textBox.SelectionLength > 0;
}
}
void IClipboardHandler.Paste()
{
textBox.Paste();
}
void IClipboardHandler.Cut()
{
textBox.Cut();
}
void IClipboardHandler.Copy()
{
textBox.Copy();
}
void IClipboardHandler.Delete()
{
textBox.SelectedText = "";
}
#endregion
#region IUndoHandler implementation
bool IUndoHandler.CanUndo {
get {
return textBox.CanUndo;
}
}
bool IUndoHandler.CanRedo {
get {
return textBox.CanRedo;
}
}
void IUndoHandler.Undo()
{
textBox.Undo();
}
void IUndoHandler.Redo()
{
textBox.Redo();
}
#endregion
}
}

62
samples/ICSharpCode.Core.Demo/RichTextEditor/RichTextEditor.csproj

@ -0,0 +1,62 @@ @@ -0,0 +1,62 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>Library</OutputType>
<RootNamespace>RichTextEditor</RootNamespace>
<AssemblyName>RichTextEditor</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{C663289E-DD00-463F-8988-9913DDDAEEE1}</ProjectGuid>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>..\bin\AddIns\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="RichTextEditor.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Base\Base.csproj">
<Project>{C9A2B6BC-5260-4DE3-8082-DCE8B391F7BB}</Project>
<Name>Base</Name>
<Private>False</Private>
</ProjectReference>
<Content Include="RichTextEditor.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<ProjectReference Include="..\..\..\src\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
<Private>False</Private>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

6
samples/ICSharpCode.Core.Demo/RichTextEditor/RichTextEditor.sln

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.936
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RichTextEditor", "RichTextEditor.csproj", "{C663289E-DD00-463F-8988-9913DDDAEEE1}"
EndProject
Global
EndGlobal

93
samples/ICSharpCode.Core.Demo/Startup/AddIns/Base.addin

@ -0,0 +1,93 @@ @@ -0,0 +1,93 @@
<AddIn name = "Demo Application"
author = "Daniel Grunwald"
url = "http://www.codeproject.com/TBD"
description = "Base add-in of ICSharpCode.Core example"
addInManagerHidden = "true">
<Manifest>
<!-- unique name of the AddIn, used when others AddIns want to reference this AddIn -->
<Identity name="ICSharpCode.Core.Demo" version = "@EntryAssemblyVersion"/>
<!--
others AddIns can specify dependencies like this:
<Dependency addin="ICSharpCode.Core.Demo" version="1.0.0.x-1.0.0.y"/>
-->
</Manifest>
<Runtime>
<Import assembly = "../Base.dll"/>
</Runtime>
<Path name = "/Workspace/FileFilter">
<FileFilter id = "Text" name = "Text files" extensions = "*.txt"/>
<FileFilter id = "LogFiles" name = "Log files" extensions = "*.log"/>
</Path>
<Path name = "/Workspace/DisplayBindings">
<Class id = "Text" class = "Base.TextDisplayBinding"/>
</Path>
<Path name = "/Workspace/Tools">
</Path>
<Path name = "/Workbench/MainMenu">
<MenuItem id = "File"
type = "Menu"
label = "${res:Demo.Menu.File}">
<MenuItem id = "New"
label = "&amp;New"
shortcut = "Control|N"
icon = "Icons.New"
class = "Base.NewFileCommand"/>
<MenuItem id = "Open"
label = "&amp;Open..."
shortcut = "Control|O"
icon = "Icons.Open"
class = "Base.OpenFileCommand"/>
<MenuItem id = "Save"
label = "&amp;Save"
shortcut = "Control|S"
icon = "Icons.Save"
class = "Base.SaveFileCommand"/>
<MenuItem id = "SaveAs"
label = "&amp;Save as..."
class = "Base.SaveFileAsCommand"/>
<MenuItem id = "Separator1" type = "Separator"/>
<MenuItem id = "Exit"
label = "&amp;Exit"
class = "Base.ExitCommand"/>
</MenuItem>
<MenuItem id = "Tools"
type = "Menu"
label = "&amp;Tools">
<Include id = "ToolList" path = "/Workspace/Tools"/>
</MenuItem>
<MenuItem id = "Help"
type = "Menu"
label = "&amp;?">
<MenuItem id = "Info"
label = "&amp;Info..."
icon = "Icons.Help"
class = "Base.InfoCommand"/>
</MenuItem>
</Path>
<Path name = "/Workbench/Toolbar">
<ToolbarItem id = "New"
tooltip = "Create new text file"
icon = "Icons.New"
class = "Base.NewFileCommand"/>
<ToolbarItem id = "Open"
tooltip = "Open existing file"
icon = "Icons.Open"
class = "Base.OpenFileCommand"/>
<ToolbarItem id = "Save"
tooltip = "Save the current file"
icon = "Icons.Save"
class = "Base.SaveFileCommand"/>
<ToolbarItem id = "Separator1" type = "Separator"/>
<ToolbarItem id = "Info"
tooltip = "Show about dialog"
icon = "Icons.Help"
class = "Base.InfoCommand"/>
</Path>
</AddIn>

27
samples/ICSharpCode.Core.Demo/Startup/AssemblyInfo.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("ICSharpCode.Core.Demo startup")]
[assembly: AssemblyDescription("Startup application for ICSharpCode.Core.Demo")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("ic#code")]
[assembly: AssemblyProduct("ICSharpCode.Core.Demo")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

BIN
samples/ICSharpCode.Core.Demo/Startup/ImageResources.resources

Binary file not shown.

95
samples/ICSharpCode.Core.Demo/Startup/Start.cs

@ -0,0 +1,95 @@ @@ -0,0 +1,95 @@
// Copyright (c) 2005 Daniel Grunwald
// Licensed under the terms of the "BSD License", see doc/license.txt
using System;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Windows.Forms;
using ICSharpCode.Core;
using Base;
namespace Startup
{
public static class Start
{
[STAThread]
public static void Main(string[] args)
{
// The LoggingService is a small wrapper around log4net.
// Our application contains a .config file telling log4net to write
// to System.Diagnostics.Trace.
LoggingService.Info("Application start");
// Get a reference to the entry assembly (Startup.exe)
Assembly exe = typeof(Start).Assembly;
// Set the root path of our application. ICSharpCode.Core looks for some other
// paths relative to the application root:
// "data/resources" for language resources, "data/options" for default options
FileUtility.ApplicationRootPath = Path.GetDirectoryName(exe.Location);
LoggingService.Info("Starting core services...");
// CoreStartup is a helper class making starting the Core easier.
// The parameter is used as the application name, e.g. for the default title of
// MessageService.ShowMessage() calls.
CoreStartup coreStartup = new CoreStartup("Test application");
// It is also used as default storage location for the application settings:
// "%Application Data%\%Application Name%", but you can override that by setting c.ConfigDirectory
// Specify the name of the application settings file (.xml is automatically appended)
coreStartup.PropertiesName = "AppProperties";
// Initializes the Core services (ResourceService, PropertyService, etc.)
coreStartup.StartCoreServices();
// Registeres the default (English) strings and images. They are compiled as
// "EmbeddedResource" into Startup.exe.
// Localized strings are automatically picked up when they are put into the
// "data/resources" directory.
ResourceService.RegisterNeutralStrings(new ResourceManager("Startup.StringResources", exe));
ResourceService.RegisterNeutralImages(new ResourceManager("Startup.ImageResources", exe));
LoggingService.Info("Looking for AddIns...");
// Searches for ".addin" files in the application directory.
coreStartup.AddAddInsFromDirectory(Path.Combine(FileUtility.ApplicationRootPath, "AddIns"));
// Searches for a "AddIns.xml" in the user profile that specifies the names of the
// add-ins that were deactivated by the user, and adds "external" AddIns.
coreStartup.ConfigureExternalAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddIns.xml"));
// Searches for add-ins installed by the user into his profile directory. This also
// performs the job of installing, uninstalling or upgrading add-ins if the user
// requested it the last time this application was running.
coreStartup.ConfigureUserAddIns(Path.Combine(PropertyService.ConfigDirectory, "AddInInstallTemp"),
Path.Combine(PropertyService.ConfigDirectory, "AddIns"));
LoggingService.Info("Loading AddInTree...");
// Now finally initialize the application. This parses the ".addin" files and
// creates the AddIn tree. It also automatically runs the commands in
// "/Workspace/Autostart"
coreStartup.RunInitialization();
LoggingService.Info("Initializing Workbench...");
// Workbench is our class from the base project, this method creates an instance
// of the main form.
Workbench.InitializeWorkbench();
try {
LoggingService.Info("Running application...");
// Workbench.Instance is the instance of the main form, run the message loop.
Application.Run(Workbench.Instance);
} finally {
try {
// Save changed properties
PropertyService.Save();
} catch (Exception ex) {
MessageService.ShowError(ex, "Error storing properties");
}
}
LoggingService.Info("Application shutdown");
}
}
}

77
samples/ICSharpCode.Core.Demo/Startup/Startup.csproj

@ -0,0 +1,77 @@ @@ -0,0 +1,77 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<RootNamespace>Startup</RootNamespace>
<AssemblyName>Startup</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{0AF8FEF6-32B9-46BD-A270-AB3B20EB39A3}</ProjectGuid>
<AllowUnsafeBlocks>False</AllowUnsafeBlocks>
<NoStdLib>False</NoStdLib>
<RegisterForComInterop>False</RegisterForComInterop>
<GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
<BaseAddress>4194304</BaseAddress>
<PlatformTarget>AnyCPU</PlatformTarget>
<FileAlignment>4096</FileAlignment>
<WarningLevel>4</WarningLevel>
<TreatWarningsAsErrors>false</TreatWarningsAsErrors>
<OutputPath>..\bin\</OutputPath>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>true</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="AssemblyInfo.cs" />
<Compile Include="Start.cs" />
<EmbeddedResource Include="StringResources.resources" />
<EmbeddedResource Include="ImageResources.resources" />
<None Include="data\resources\StringResources.de.resources">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Content Include="Startup.exe.config">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Content Include="Startup.exe.manifest">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<ProjectReference Include="..\Base\Base.csproj">
<Project>{C9A2B6BC-5260-4DE3-8082-DCE8B391F7BB}</Project>
<Name>Base</Name>
</ProjectReference>
<Folder Include="data" />
<Folder Include="data\options" />
<Content Include="data\options\AppProperties.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Folder Include="AddIns" />
<Content Include="AddIns\Base.addin">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
<Folder Include="data\resources" />
<ProjectReference Include="..\..\..\src\Main\Core\Project\ICSharpCode.Core.csproj">
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project>
<Name>ICSharpCode.Core</Name>
</ProjectReference>
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

19
samples/ICSharpCode.Core.Demo/Startup/Startup.exe.config

@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
<configuration>
<configSections>
<section name="log4net" type="System.Configuration.IgnoreSectionHandler" />
</configSections>
<runtime>
</runtime>
<log4net>
<appender name="TraceAppender" type="log4net.Appender.TraceAppender">
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%date [%thread] %-5level- %message%newline" />
</layout>
</appender>
<root>
<level value="DEBUG" />
<appender-ref ref="TraceAppender" />
</root>
</log4net>
</configuration>

17
samples/ICSharpCode.Core.Demo/Startup/Startup.exe.manifest

@ -0,0 +1,17 @@ @@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<description>Startup for ICSharpCode.Core</description>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
</assembly>

6
samples/ICSharpCode.Core.Demo/Startup/Startup.sln

@ -0,0 +1,6 @@ @@ -0,0 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.932
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Startup", "Startup.csproj", "{0AF8FEF6-32B9-46BD-A270-AB3B20EB39A3}"
EndProject
Global
EndGlobal

BIN
samples/ICSharpCode.Core.Demo/Startup/StringResources.resources

Binary file not shown.

4
samples/ICSharpCode.Core.Demo/Startup/data/options/AppProperties.xml

@ -0,0 +1,4 @@ @@ -0,0 +1,4 @@
<?xml version="1.0"?>
<AppProperties>
<!-- start configuration of properties -->
</AppProperties>

BIN
samples/ICSharpCode.Core.Demo/Startup/data/resources/StringResources.de.resources

Binary file not shown.

20
samples/ICSharpCode.Core.Demo/doc/copyright.txt

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
"Base", "Startup" and "RichTextEditor":
Copyright 2005 by
Daniel Grunwald
Bierberger Str. 9
31174 Schellerten
Germany
email: daniel@danielgrunwald.de
ICSharpCode.Core, AddInManager:
Copyright 2002-2006 by
AlphaSierraPapa, Christoph Wille
Vordernberger Strasse 27/8
A-8700 Leoben
Austria
email: office@alphasierrapapa.com
court of jurisdiction: Landesgericht Leoben

496
samples/ICSharpCode.Core.Demo/doc/license.txt

@ -0,0 +1,496 @@ @@ -0,0 +1,496 @@
The demo projects "Base", "Startup" and "RichTextEditor" are licensed under
these terms (MIT license):
-----------------------------------------------------------------------------
Copyright (c) 2005, Daniel Grunwald
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 Daniel Grunwald 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.
=============================================================================
=============================================================================
"ICSharpCode.Core" and "AddInManager" are licensed under the terms of
the GNU Lesser General Public License:
-----------------------------------------------------------------------------
GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
Licenses are intended to guarantee your freedom to share and change
free software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that
there is no warranty for the free library. Also, if the library is
modified by someone else and passed on, the recipients should know
that what they have is not the original version, so that the original
author's reputation will not be affected by problems that might be
introduced by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using
a shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it becomes
a de-facto standard. To achieve this, non-free programs must be
allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
GNU LESSER GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License").
Each licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control compilation
and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does
and what the program that uses the Library does.
1. You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy,
and you may at your option offer warranty protection in exchange for a
fee.
2. You may modify your copy or copies of the Library or any portion
of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) The modified work must itself be a software library.
b) You must cause the files modified to carry prominent notices
stating that you changed the files and the date of any change.
c) You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
d) If a facility in the modified Library refers to a function or a
table of data to be supplied by an application program that uses
the facility, other than as an argument passed when the facility
is invoked, then you must make a good faith effort to ensure that,
in the event an application does not supply such function or
table, the facility still operates, and performs whatever part of
its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of the
application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may opt to apply the terms of the ordinary GNU General Public
License instead of this License to a given copy of the Library. To do
this, you must alter all the notices that refer to this License, so
that they refer to the ordinary GNU General Public License, version 2,
instead of to this License. (If a newer version than version 2 of the
ordinary GNU General Public License has appeared, then you can specify
that version instead if you wish.) Do not make any other change in
these notices.
Once this change is made in a given copy, it is irreversible for
that copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of
the Library into a program that is not a library.
4. You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy
from a designated place, then offering equivalent access to copy the
source code from the same place satisfies the requirement to
distribute the source code, even though third parties are not
compelled to copy the source along with the object code.
5. A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a
work, in isolation, is not a derivative work of the Library, and
therefore falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License.
Section 6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data
structure layouts and accessors, and small macros and small inline
functions (ten lines or less in length), then the use of the object
file is unrestricted, regardless of whether it is legally a derivative
work. (Executables containing this object code plus portions of the
Library will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
6. As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a
work containing portions of the Library, and distribute that work
under terms of your choice, provided that the terms permit
modification of the work for the customer's own use and reverse
engineering for debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
a) Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood
that the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
b) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (1) uses at run time a
copy of the library already present on the user's computer system,
rather than copying library functions into the executable, and (2)
will operate properly with a modified version of the library, if
the user installs one, as long as the modified version is
interface-compatible with the version that the work was made with.
c) Accompany the work with a written offer, valid for at
least three years, to give the same user the materials
specified in Subsection 6a, above, for a charge no more
than the cost of performing this distribution.
d) If distribution of the work is made by offering access to copy
from a designated place, offer equivalent access to copy the above
specified materials from the same place.
e) Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
7. You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
a) Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other library
facilities. This must be distributed under the terms of the
Sections above.
b) Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
8. You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
9. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
10. Each time you redistribute the Library (or any work based on the
Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
11. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Library at all. For example, if a patent
license would not permit royalty-free redistribution of the Library by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Library.
If any portion of this section is held invalid or unenforceable under any
particular circumstance, the balance of the section is intended to apply,
and the section as a whole is intended to apply in other circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
12. If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License may add
an explicit geographical distribution limitation excluding those countries,
so that distribution is permitted only in or among countries not thus
excluded. In such case, this License incorporates the limitation as if
written in the body of this License.
13. The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time.
Such new versions will be similar in spirit to the present version,
but may differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
14. If you wish to incorporate parts of the Library into other free
programs whose distribution conditions are incompatible with these,
write to the author to ask for permission. For software which is
copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
NO WARRANTY
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
END OF TERMS AND CONDITIONS

27
samples/NRefactoryExample/AssemblyInfo.cs

@ -0,0 +1,27 @@ @@ -0,0 +1,27 @@
using System.Reflection;
using System.Runtime.CompilerServices;
// Information about this assembly is defined by the following
// attributes.
//
// change them to the information which is associated with the assembly
// you compile.
[assembly: AssemblyTitle("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has following format :
//
// Major.Minor.Build.Revision
//
// You can specify all values by your own or you can build default build and revision
// numbers with the '*' character (the default):
[assembly: AssemblyVersion("1.0.*")]

151
samples/NRefactoryExample/MainForm.cs

@ -0,0 +1,151 @@ @@ -0,0 +1,151 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
using ICSharpCode.NRefactory.PrettyPrinter;
namespace NRefactoryExample
{
public class MainForm : System.Windows.Forms.Form
{
public MainForm()
{
// The InitializeComponent() call is required for Windows Forms designer support.
InitializeComponent();
}
[STAThread]
public static void Main(string[] args)
{
Application.EnableVisualStyles();
Application.Run(new MainForm());
}
#region Windows Forms Designer generated code
/// <summary>
/// This method is required for Windows Forms designer support.
/// Do not change the method contents inside the source code editor. The Forms designer might
/// not be able to load this method if it was changed manually.
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(MainForm));
this.splitContainer1 = new System.Windows.Forms.SplitContainer();
this.inputTextBox = new System.Windows.Forms.TextBox();
this.panel1 = new System.Windows.Forms.Panel();
this.runButton = new System.Windows.Forms.Button();
this.outputTextBox = new System.Windows.Forms.TextBox();
this.splitContainer1.Panel1.SuspendLayout();
this.splitContainer1.Panel2.SuspendLayout();
this.splitContainer1.SuspendLayout();
this.panel1.SuspendLayout();
this.SuspendLayout();
//
// splitContainer1
//
this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
this.splitContainer1.Location = new System.Drawing.Point(0, 0);
this.splitContainer1.Name = "splitContainer1";
//
// splitContainer1.Panel1
//
this.splitContainer1.Panel1.Controls.Add(this.inputTextBox);
this.splitContainer1.Panel1.Controls.Add(this.panel1);
//
// splitContainer1.Panel2
//
this.splitContainer1.Panel2.Controls.Add(this.outputTextBox);
this.splitContainer1.Size = new System.Drawing.Size(804, 422);
this.splitContainer1.SplitterDistance = 394;
this.splitContainer1.TabIndex = 0;
//
// inputTextBox
//
this.inputTextBox.AcceptsReturn = true;
this.inputTextBox.AcceptsTab = true;
this.inputTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.inputTextBox.Location = new System.Drawing.Point(0, 0);
this.inputTextBox.Multiline = true;
this.inputTextBox.Name = "inputTextBox";
this.inputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.inputTextBox.Size = new System.Drawing.Size(394, 372);
this.inputTextBox.TabIndex = 1;
this.inputTextBox.Text = resources.GetString("inputTextBox.Text");
//
// panel1
//
this.panel1.Controls.Add(this.runButton);
this.panel1.Dock = System.Windows.Forms.DockStyle.Bottom;
this.panel1.Location = new System.Drawing.Point(0, 372);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(394, 50);
this.panel1.TabIndex = 0;
//
// runButton
//
this.runButton.Anchor = System.Windows.Forms.AnchorStyles.None;
this.runButton.Location = new System.Drawing.Point(128, 15);
this.runButton.Name = "runButton";
this.runButton.Size = new System.Drawing.Size(131, 23);
this.runButton.TabIndex = 0;
this.runButton.Text = "Run";
this.runButton.UseCompatibleTextRendering = true;
this.runButton.UseVisualStyleBackColor = true;
this.runButton.Click += new System.EventHandler(this.RunButtonClick);
//
// outputTextBox
//
this.outputTextBox.Dock = System.Windows.Forms.DockStyle.Fill;
this.outputTextBox.Location = new System.Drawing.Point(0, 0);
this.outputTextBox.Multiline = true;
this.outputTextBox.Name = "outputTextBox";
this.outputTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
this.outputTextBox.Size = new System.Drawing.Size(406, 422);
this.outputTextBox.TabIndex = 0;
//
// MainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(804, 422);
this.Controls.Add(this.splitContainer1);
this.Name = "MainForm";
this.Text = "NRefactory Example";
this.splitContainer1.Panel1.ResumeLayout(false);
this.splitContainer1.Panel1.PerformLayout();
this.splitContainer1.Panel2.ResumeLayout(false);
this.splitContainer1.Panel2.PerformLayout();
this.splitContainer1.ResumeLayout(false);
this.panel1.ResumeLayout(false);
this.ResumeLayout(false);
}
private System.Windows.Forms.Button runButton;
private System.Windows.Forms.TextBox outputTextBox;
private System.Windows.Forms.TextBox inputTextBox;
private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.SplitContainer splitContainer1;
#endregion
void RunButtonClick(object sender, EventArgs e)
{
StringReader input = new StringReader(inputTextBox.Text);
IParser parser = ParserFactory.CreateParser(SupportedLanguage.CSharp, input);
parser.Parse();
if (parser.Errors.count > 0) {
outputTextBox.Text = parser.Errors.ErrorOutput;
return;
}
CompilationUnit cu = parser.CompilationUnit;
cu.AcceptVisitor(new WrapperGeneratorVisitor(), null);
IOutputASTVisitor output = new CSharpOutputVisitor(); //new VBNetOutputVisitor();
cu.AcceptVisitor(output, null);
outputTextBox.Text = output.Text;
}
}
}

184
samples/NRefactoryExample/MainForm.resx

@ -0,0 +1,184 @@ @@ -0,0 +1,184 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="inputTextBox.Text" xml:space="preserve">
<value>// &lt;file&gt;
// &lt;copyright see="prj:///doc/copyright.txt"&gt;2002-2005 AlphaSierraPapa&lt;/copyright&gt;
// &lt;license see="prj:///doc/license.txt"&gt;GNU General Public License&lt;/license&gt;
// &lt;owner name="David Srbecký" email="dsrbecky@gmail.com"/&gt;
// &lt;version&gt;$Revision: 698 $&lt;/version&gt;
// &lt;/file&gt;
namespace Debugger.Interop.CorDebug
{
using System;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
[ComImport, Guid("3D6F5F63-7538-11D3-8D5B-00104B35E7EF"), ComConversionLoss, InterfaceType((short) 1)]
public interface ICorDebugAppDomain : ICorDebugController
{
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Stop([In] uint dwTimeoutIgnored);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Continue([In] int fIsOutOfBand);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void IsRunning(out int pbRunning);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void HasQueuedCallbacks([In, MarshalAs(UnmanagedType.Interface)] ICorDebugThread pThread, out int pbQueued);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void EnumerateThreads([MarshalAs(UnmanagedType.Interface)] out ICorDebugThreadEnum ppThreads);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void SetAllThreadsDebugState([In] CorDebugThreadState state, [In, MarshalAs(UnmanagedType.Interface)] ICorDebugThread pExceptThisThread);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Detach();
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Terminate([In] uint exitCode);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void CanCommitChanges([In] uint cSnapshots, [In, MarshalAs(UnmanagedType.Interface)] ref ICorDebugEditAndContinueSnapshot pSnapshots, [MarshalAs(UnmanagedType.Interface)] out ICorDebugErrorInfoEnum pError);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void CommitChanges([In] uint cSnapshots, [In, MarshalAs(UnmanagedType.Interface)] ref ICorDebugEditAndContinueSnapshot pSnapshots, [MarshalAs(UnmanagedType.Interface)] out ICorDebugErrorInfoEnum pError);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void GetProcess([MarshalAs(UnmanagedType.Interface)] out ICorDebugProcess ppProcess);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void EnumerateAssemblies([MarshalAs(UnmanagedType.Interface)] out ICorDebugAssemblyEnum ppAssemblies);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void GetModuleFromMetaDataInterface([In, MarshalAs(UnmanagedType.IUnknown)] object pIMetaData, [MarshalAs(UnmanagedType.Interface)] out ICorDebugModule ppModule);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void EnumerateBreakpoints([MarshalAs(UnmanagedType.Interface)] out ICorDebugBreakpointEnum ppBreakpoints);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void EnumerateSteppers([MarshalAs(UnmanagedType.Interface)] out ICorDebugStepperEnum ppSteppers);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void IsAttached(out int pbAttached);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void GetName([In] uint cchName, out uint pcchName, [Out] IntPtr szName);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void GetObject([MarshalAs(UnmanagedType.Interface)] out ICorDebugValue ppObject);
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void Attach();
[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType=MethodCodeType.Runtime)]
void GetID(out uint pId);
}
}
</value>
</data>
<metadata name="outputTextBox.Locked" type="System.Boolean, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">
<value>True</value>
</metadata>
</root>

46
samples/NRefactoryExample/NRefactoryExample.csproj

@ -0,0 +1,46 @@ @@ -0,0 +1,46 @@
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<RootNamespace>NRefactoryExample</RootNamespace>
<AssemblyName>NRefactoryExample</AssemblyName>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{5C8AF075-BB4A-4D24-BE69-46057C1B0107}</ProjectGuid>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
<OutputPath>bin\Debug\</OutputPath>
<Optimize>False</Optimize>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugSymbols>True</DebugSymbols>
<DebugType>Full</DebugType>
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)' == 'Release' ">
<OutputPath>bin\Release\</OutputPath>
<Optimize>True</Optimize>
<DefineConstants>TRACE</DefineConstants>
<DebugSymbols>False</DebugSymbols>
<DebugType>None</DebugType>
<CheckForOverflowUnderflow>False</CheckForOverflowUnderflow>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Data" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml" />
<Reference Include="ICSharpCode.NRefactory">
<HintPath>..\..\bin\ICSharpCode.NRefactory.dll</HintPath>
<SpecificVersion>False</SpecificVersion>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="MainForm.cs" />
<Compile Include="AssemblyInfo.cs" />
<EmbeddedResource Include="MainForm.resx">
<DependentUpon>MainForm.cs</DependentUpon>
</EmbeddedResource>
<Compile Include="WrapperGeneratorVisitor.cs" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" />
</Project>

16
samples/NRefactoryExample/NRefactoryExample.sln

@ -0,0 +1,16 @@ @@ -0,0 +1,16 @@
Microsoft Visual Studio Solution File, Format Version 9.00
# SharpDevelop 2.0.0.704
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "NRefactoryExample", "NRefactoryExample.csproj", "{5C8AF075-BB4A-4D24-BE69-46057C1B0107}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{5C8AF075-BB4A-4D24-BE69-46057C1B0107}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5C8AF075-BB4A-4D24-BE69-46057C1B0107}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5C8AF075-BB4A-4D24-BE69-46057C1B0107}.Release|Any CPU.Build.0 = Release|Any CPU
{5C8AF075-BB4A-4D24-BE69-46057C1B0107}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
EndGlobal

123
samples/NRefactoryExample/WrapperGeneratorVisitor.cs

@ -0,0 +1,123 @@ @@ -0,0 +1,123 @@
/*
* Created by SharpDevelop.
* User: Daniel Grunwald
* Date: 09.11.2005
* Time: 18:15
*/
using System;
using System.Collections.Generic;
using ICSharpCode.NRefactory.Parser;
using ICSharpCode.NRefactory.Parser.AST;
namespace NRefactoryExample
{
public class WrapperGeneratorVisitor : AbstractAstVisitor
{
public override object Visit(TypeDeclaration typeDeclaration, object data)
{
base.Visit(typeDeclaration, data); // visit methods
typeDeclaration.Attributes.Clear();
typeDeclaration.BaseTypes.Clear();
// add constructor accepting the wrapped object and the field holding the object
FieldDeclaration fd = new FieldDeclaration(null, // no attributes
new TypeReference(typeDeclaration.Name),
Modifier.Private);
fd.Fields.Add(new VariableDeclaration("wrappedObject"));
typeDeclaration.AddChild(fd);
typeDeclaration.Name += "Wrapper";
if (typeDeclaration.Type == ClassType.Interface) {
typeDeclaration.Type = ClassType.Class;
typeDeclaration.Name = typeDeclaration.Name.Substring(1);
}
ConstructorDeclaration cd = new ConstructorDeclaration(typeDeclaration.Name,
Modifier.Public,
new List<ParameterDeclarationExpression>(),
null);
cd.Parameters.Add(new ParameterDeclarationExpression(fd.TypeReference,
"wrappedObject"));
// this.wrappedObject = wrappedObject;
Expression fieldReference = new FieldReferenceExpression(new ThisReferenceExpression(),
"wrappedObject");
Expression assignment = new AssignmentExpression(fieldReference,
AssignmentOperatorType.Assign,
new IdentifierExpression("wrappedObject"));
cd.Body = new BlockStatement();
cd.Body.AddChild(new StatementExpression(assignment));
typeDeclaration.AddChild(cd);
for (int i = 0; i < typeDeclaration.Children.Count; i++) {
object child = typeDeclaration.Children[i];
if (child is MethodDeclaration) {
MethodDeclaration method = (MethodDeclaration)child;
if (method.Parameters.Count == 0 &&
(method.Name.StartsWith("Is") || method.Name.StartsWith("Get")))
{
// replace the method with a property
PropertyDeclaration prop = new PropertyDeclaration(method.Name,
method.TypeReference,
method.Modifier,
method.Attributes);
prop.GetRegion = new PropertyGetRegion(method.Body, null);
typeDeclaration.Children[i] = prop;
}
}
}
return null;
}
public override object Visit(MethodDeclaration methodDeclaration, object data)
{
base.Visit(methodDeclaration, data); // visit parameters
methodDeclaration.Attributes.Clear();
methodDeclaration.Body = new BlockStatement();
methodDeclaration.Modifier = Modifier.Public;
if (methodDeclaration.Parameters.Count > 0) {
ParameterDeclarationExpression lastParameter = methodDeclaration.Parameters[methodDeclaration.Parameters.Count - 1];
if (lastParameter.ParamModifier == ParamModifier.Out) {
methodDeclaration.TypeReference = lastParameter.TypeReference;
methodDeclaration.Parameters.RemoveAt(methodDeclaration.Parameters.Count - 1);
VariableDeclaration tmpVarDecl = new VariableDeclaration("tmp");
tmpVarDecl.TypeReference = methodDeclaration.TypeReference;
methodDeclaration.Body.AddChild(new LocalVariableDeclaration(tmpVarDecl));
IdentifierExpression tmpIdent = new IdentifierExpression("tmp");
InvocationExpression ie = CreateMethodCall(methodDeclaration);
ie.Arguments.Add(new DirectionExpression(FieldDirection.Out, tmpIdent));
methodDeclaration.Body.AddChild(new StatementExpression(ie));
methodDeclaration.Body.AddChild(new ReturnStatement(tmpIdent));
return null;
}
}
methodDeclaration.Body.AddChild(new StatementExpression(CreateMethodCall(methodDeclaration)));
return null;
}
static InvocationExpression CreateMethodCall(MethodDeclaration method)
{
IdentifierExpression wrappedObject = new IdentifierExpression("wrappedObject");
FieldReferenceExpression methodName = new FieldReferenceExpression(wrappedObject, method.Name);
InvocationExpression ie = new InvocationExpression(methodName, null);
foreach (ParameterDeclarationExpression param in method.Parameters) {
Expression expr = new IdentifierExpression(param.ParameterName);
if (param.ParamModifier == ParamModifier.Ref) {
expr = new DirectionExpression(FieldDirection.Ref, expr);
}
ie.Arguments.Add(expr);
}
return ie;
}
public override object Visit(ParameterDeclarationExpression parameterDeclarationExpression, object data)
{
parameterDeclarationExpression.Attributes.Clear();
return null;
}
}
}

2184
samples/SharpPad/SharpPad.rtf

File diff suppressed because it is too large Load Diff

2175
samples/readme.rtf

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save