Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@1132 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
63 changed files with 5161 additions and 12937 deletions
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -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> |
@ -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> |
@ -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 |
@ -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")] |
@ -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(); |
||||
} |
||||
} |
||||
} |
@ -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> |
@ -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(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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
|
||||
} |
@ -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
|
||||
} |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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
|
||||
} |
||||
} |
@ -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> |
Binary file not shown.
Binary file not shown.
After Width: | Height: | Size: 16 KiB |
@ -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.*")] |
||||
|
@ -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> |
@ -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 |
@ -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(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
@ -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; |
||||
} |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
@ -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(); |
||||
} |
||||
} |
@ -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); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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> |
@ -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
|
||||
} |
||||
} |
@ -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"; |
||||
} |
||||
} |
||||
} |
||||
} |
@ -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 }} |
@ -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 |
Binary file not shown.
@ -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.*")] |
||||
|
@ -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> |
@ -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
|
||||
} |
||||
} |
@ -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> |
@ -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 |
@ -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 = "&New" |
||||
shortcut = "Control|N" |
||||
icon = "Icons.New" |
||||
class = "Base.NewFileCommand"/> |
||||
<MenuItem id = "Open" |
||||
label = "&Open..." |
||||
shortcut = "Control|O" |
||||
icon = "Icons.Open" |
||||
class = "Base.OpenFileCommand"/> |
||||
<MenuItem id = "Save" |
||||
label = "&Save" |
||||
shortcut = "Control|S" |
||||
icon = "Icons.Save" |
||||
class = "Base.SaveFileCommand"/> |
||||
<MenuItem id = "SaveAs" |
||||
label = "&Save as..." |
||||
class = "Base.SaveFileAsCommand"/> |
||||
<MenuItem id = "Separator1" type = "Separator"/> |
||||
<MenuItem id = "Exit" |
||||
label = "&Exit" |
||||
class = "Base.ExitCommand"/> |
||||
</MenuItem> |
||||
<MenuItem id = "Tools" |
||||
type = "Menu" |
||||
label = "&Tools"> |
||||
<Include id = "ToolList" path = "/Workspace/Tools"/> |
||||
</MenuItem> |
||||
<MenuItem id = "Help" |
||||
type = "Menu" |
||||
label = "&?"> |
||||
<MenuItem id = "Info" |
||||
label = "&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> |
@ -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.*")] |
||||
|
Binary file not shown.
@ -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"); |
||||
} |
||||
} |
||||
} |
@ -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> |
@ -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> |
@ -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> |
@ -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 |
Binary file not shown.
@ -0,0 +1,4 @@
@@ -0,0 +1,4 @@
|
||||
<?xml version="1.0"?> |
||||
<AppProperties> |
||||
<!-- start configuration of properties --> |
||||
</AppProperties> |
Binary file not shown.
@ -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 |
||||
|
@ -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.*")] |
||||
|
@ -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; |
||||
} |
||||
} |
||||
} |
@ -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>// <file> |
||||
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright> |
||||
// <license see="prj:///doc/license.txt">GNU General Public License</license> |
||||
// <owner name="David Srbecký" email="dsrbecky@gmail.com"/> |
||||
// <version>$Revision: 698 $</version> |
||||
// </file> |
||||
|
||||
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> |
@ -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> |
@ -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 |
@ -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; |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue