Browse Source
git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@806 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61shortcuts
22 changed files with 1058 additions and 97 deletions
@ -0,0 +1,21 @@
@@ -0,0 +1,21 @@
|
||||
<AddIn name = "AddInManager" |
||||
author = "Daniel Grunwald" |
||||
copyright = "GNU General Public License" |
||||
url = "" |
||||
description = "Can install, enable, disable and uninstall AddIns"> |
||||
|
||||
<Manifest> |
||||
<Identity name = "ICSharpCode.AddInManager"/> |
||||
</Manifest> |
||||
|
||||
<Runtime> |
||||
<Import assembly = "ICSharpCode.AddInManager.dll"/> |
||||
</Runtime> |
||||
|
||||
<Path name = "/SharpDevelop/Workbench/MainMenu/Tools"> |
||||
<MenuItem id = "ShowAddInManager" |
||||
insertafter = "Separator1" insertbefore = "Separator2" |
||||
label = "AddIn Manager" |
||||
class = "ICSharpCode.AddInManager.ShowCommand"/> |
||||
</Path> |
||||
</AddIn> |
@ -0,0 +1,67 @@
@@ -0,0 +1,67 @@
|
||||
<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>{F93E52FD-DA66-4CE5-A0CB-BCD902811122}</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>..\..\..\..\..\AddIns\AddIns\Misc\AddInManager\</OutputPath> |
||||
<Optimize>False</Optimize> |
||||
<DefineConstants>DEBUG;TRACE</DefineConstants> |
||||
<DebugSymbols>true</DebugSymbols> |
||||
<DebugType>Full</DebugType> |
||||
<CheckForOverflowUnderflow>True</CheckForOverflowUnderflow> |
||||
</PropertyGroup> |
||||
<PropertyGroup Condition=" '$(Configuration)' == 'Release' "> |
||||
<OutputPath>..\..\..\..\..\AddIns\AddIns\Misc\AddInManager\</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> |
||||
<None Include="AddInManager.addin"> |
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory> |
||||
</None> |
||||
<Compile Include="Configuration\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" /> |
||||
</ItemGroup> |
||||
<ItemGroup> |
||||
<ProjectReference Include="..\..\..\..\Main\Core\Project\ICSharpCode.Core.csproj"> |
||||
<Project>{35CEF10F-2D4C-45F2-9DD1-161E0FEC583C}</Project> |
||||
<Name>ICSharpCode.Core</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
<ProjectReference Include="..\..\..\..\Main\Base\Project\ICSharpCode.SharpDevelop.csproj"> |
||||
<Project>{2748AD25-9C63-4E12-877B-4DCE96FBED54}</Project> |
||||
<Name>ICSharpCode.SharpDevelop</Name> |
||||
<Private>False</Private> |
||||
</ProjectReference> |
||||
</ItemGroup> |
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.Targets" /> |
||||
</Project> |
@ -0,0 +1,34 @@
@@ -0,0 +1,34 @@
|
||||
// <file>
|
||||
// <copyright see="prj:///doc/copyright.txt">2002-2005 AlphaSierraPapa</copyright>
|
||||
// <license see="prj:///doc/license.txt">GNU General Public License</license>
|
||||
// <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("ICSharpCode")] |
||||
[assembly: AssemblyProduct("SharpDevelop")] |
||||
[assembly: AssemblyCopyright("GNU General Public Licence")] |
||||
[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.1")] |
||||
|
@ -0,0 +1,148 @@
@@ -0,0 +1,148 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Daniel Grunwald |
||||
* Date: 26.11.2005 |
||||
* Time: 15:54 |
||||
*/ |
||||
|
||||
using System; |
||||
using System.ComponentModel; |
||||
using System.Drawing; |
||||
using System.Drawing.Drawing2D; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.AddInManager |
||||
{ |
||||
/// <summary>
|
||||
/// Description of AddInControl.
|
||||
/// </summary>
|
||||
public class AddInControl : Control |
||||
{ |
||||
AddIn addIn; |
||||
|
||||
public AddIn AddIn { |
||||
get { |
||||
return addIn; |
||||
} |
||||
} |
||||
|
||||
public AddInControl(AddIn addIn) |
||||
{ |
||||
this.addIn = addIn; |
||||
this.BackColor = SystemColors.Window; |
||||
this.Size = new Size(100, 40); |
||||
this.SetStyle(ControlStyles.Selectable, true); |
||||
this.SetStyle(ControlStyles.UserPaint, 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(); |
||||
} |
||||
|
||||
protected override void OnPaint(PaintEventArgs e) |
||||
{ |
||||
Graphics g = e.Graphics; |
||||
Rectangle bounds = this.ClientRectangle; |
||||
bounds.Offset(1, 1); |
||||
bounds.Inflate(-2, -2); |
||||
Brush gradient = new LinearGradientBrush(bounds, |
||||
selected ? SystemColors.ControlLight : SystemColors.ControlLightLight, |
||||
selected ? SystemColors.Highlight : SystemColors.ControlDark, |
||||
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); |
||||
if (selected && textBrush == SystemBrushes.GrayText) |
||||
textBrush = SystemBrushes.HighlightText; |
||||
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); |
||||
g.DrawString(description, Font, textBrush, textBounds); |
||||
} |
||||
|
||||
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 "AddIn will be enabled after restarting SharpDevelop"; |
||||
} |
||||
case AddInAction.Disable: |
||||
textBrush = SystemBrushes.GrayText; |
||||
if (addIn.Enabled) |
||||
return "AddIn will be disabled after restarting SharpDevelop"; |
||||
else |
||||
return "Disabled"; // TODO: Test if it was disabled because of conflict
|
||||
case AddInAction.Install: |
||||
textBrush = SystemBrushes.ActiveCaption; |
||||
return "AddIn will be installed after restarting SharpDevelop"; |
||||
case AddInAction.Uninstall: |
||||
textBrush = SystemBrushes.GrayText; |
||||
return "AddIn will be removed after restarting SharpDevelop"; |
||||
case AddInAction.Update: |
||||
textBrush = SystemBrushes.ActiveCaption; |
||||
return "AddIn will be updated after restarting SharpDevelop"; |
||||
default: |
||||
textBrush = Brushes.Yellow; |
||||
return addIn.Action.ToString(); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,20 @@
@@ -0,0 +1,20 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Daniel Grunwald |
||||
* Date: 26.11.2005 |
||||
* Time: 14:53 |
||||
*/ |
||||
|
||||
using System; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.AddInManager |
||||
{ |
||||
public class ShowCommand : AbstractMenuCommand |
||||
{ |
||||
public override void Run() |
||||
{ |
||||
ManagerForm.ShowForm(); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,380 @@
@@ -0,0 +1,380 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Daniel Grunwald |
||||
* Date: 26.11.2005 |
||||
* Time: 14:53 |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.AddInManager |
||||
{ |
||||
public class ManagerForm : System.Windows.Forms.Form |
||||
{ |
||||
static ManagerForm instance; |
||||
|
||||
public static ManagerForm Instance { |
||||
get { |
||||
return instance; |
||||
} |
||||
} |
||||
|
||||
public static void ShowForm() |
||||
{ |
||||
if (instance == null) { |
||||
instance = new ManagerForm(); |
||||
instance.Owner = ICSharpCode.SharpDevelop.Gui.WorkbenchSingleton.MainForm; |
||||
instance.Show(); |
||||
} else { |
||||
instance.Activate(); |
||||
} |
||||
} |
||||
|
||||
public ManagerForm() |
||||
{ |
||||
//
|
||||
// The InitializeComponent() call is required for Windows Forms designer support.
|
||||
//
|
||||
InitializeComponent(); |
||||
|
||||
ICSharpCode.SharpDevelop.Gui.FormLocationHelper.Apply(this, "AddInManager.WindowBounds", true); |
||||
|
||||
Stack<AddInControl> stack = new Stack<AddInControl>(); |
||||
int index = 0; |
||||
AddInControl ctl; |
||||
|
||||
foreach (AddIn addIn in AddInTree.AddIns) { |
||||
string identity = addIn.Manifest.PrimaryIdentity; |
||||
if (identity == null || identity == "SharpDevelop") // || identity == "ICSharpCode.AddInManager"
|
||||
continue; |
||||
ctl = new AddInControl(addIn); |
||||
ctl.Dock = DockStyle.Top; |
||||
ctl.TabIndex = index++; |
||||
stack.Push(ctl); |
||||
ctl.Enter += OnControlEnter; |
||||
ctl.Click += OnControlClick; |
||||
} |
||||
while (stack.Count > 0) { |
||||
splitContainer.Panel1.Controls.Add(stack.Pop()); |
||||
} |
||||
splitContainer.Panel2Collapsed = true; |
||||
} |
||||
|
||||
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 == 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(); |
||||
} |
||||
|
||||
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; |
||||
uninstallButton.Enabled = false; |
||||
runActionButton.Enabled = false; |
||||
runActionButton.Visible = true; |
||||
uninstallButton.Visible = true; |
||||
|
||||
bool allEnabled = true; |
||||
bool allDisabled = true; |
||||
foreach (AddIn addIn in selected) { |
||||
allEnabled &= addIn.Action == AddInAction.Enable; |
||||
allDisabled &= addIn.Action == AddInAction.Disable; |
||||
} |
||||
if (allEnabled) { |
||||
selectedAction = AddInAction.Disable; |
||||
actionGroupBox.Text = runActionButton.Text = "Disable"; |
||||
actionDescription.Text = "Disables the selected AddIns."; |
||||
ShowDependencies(selected, false); |
||||
uninstallButton.Enabled = runActionButton.Enabled = !dependencyTable.Visible; |
||||
} else if (allDisabled) { |
||||
selectedAction = AddInAction.Enable; |
||||
actionGroupBox.Text = runActionButton.Text = "Enable"; |
||||
actionDescription.Text = "Enables the selected AddIns."; |
||||
ShowDependencies(selected, true); |
||||
runActionButton.Enabled = !dependencyTable.Visible; |
||||
uninstallButton.Enabled = true; |
||||
} else { |
||||
actionGroupBox.Text = ""; |
||||
actionDescription.Text = "AddIns with multiple states are selected"; |
||||
runActionButton.Visible = false; |
||||
uninstallButton.Visible = false; |
||||
} |
||||
} |
||||
ignoreFocusChange = false; |
||||
} |
||||
|
||||
void ShowDependencies(List<AddIn> addIns, bool enable) |
||||
{ |
||||
|
||||
} |
||||
|
||||
void CloseButtonClick(object sender, EventArgs e) |
||||
{ |
||||
Close(); |
||||
} |
||||
|
||||
void RunActionButtonClick(object sender, EventArgs e) |
||||
{ |
||||
if (selectedAction == AddInAction.Disable) { |
||||
ICSharpCode.Core.AddInManager.Disable(selected); |
||||
} else if (selectedAction == AddInAction.Enable) { |
||||
ICSharpCode.Core.AddInManager.Enable(selected); |
||||
} |
||||
foreach (AddInControl ctl in splitContainer.Panel1.Controls) { |
||||
ctl.Invalidate(); |
||||
} |
||||
UpdateActionBox(); |
||||
} |
||||
|
||||
protected override void OnClosed(EventArgs e) |
||||
{ |
||||
base.OnClosed(e); |
||||
instance = 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() |
||||
{ |
||||
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.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.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.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 = 0; |
||||
//
|
||||
// bottomPanel
|
||||
//
|
||||
this.bottomPanel.Controls.Add(this.installButton); |
||||
this.bottomPanel.Controls.Add(this.closeButton); |
||||
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 = 2; |
||||
//
|
||||
// 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 = 0; |
||||
this.installButton.Text = "Install AddIn"; |
||||
this.installButton.UseCompatibleTextRendering = true; |
||||
this.installButton.UseVisualStyleBackColor = true; |
||||
//
|
||||
// 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 = 1; |
||||
this.closeButton.Text = "Close"; |
||||
this.closeButton.UseCompatibleTextRendering = true; |
||||
this.closeButton.UseVisualStyleBackColor = true; |
||||
this.closeButton.Click += new System.EventHandler(this.CloseButtonClick); |
||||
//
|
||||
// splitContainer
|
||||
//
|
||||
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.AutoScroll = true; |
||||
this.splitContainer.Panel1.BackColor = System.Drawing.SystemColors.Window; |
||||
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 = 310; |
||||
this.splitContainer.TabIndex = 1; |
||||
//
|
||||
// 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(146, 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.Location = new System.Drawing.Point(3, 17); |
||||
this.actionFlowLayoutPanel.Name = "actionFlowLayoutPanel"; |
||||
this.actionFlowLayoutPanel.Size = new System.Drawing.Size(140, 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.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink; |
||||
this.dependencyTable.ColumnCount = 2; |
||||
this.dependencyTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); |
||||
this.dependencyTable.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Absolute, 20F)); |
||||
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(System.Windows.Forms.SizeType.Percent, 50F)); |
||||
this.dependencyTable.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50F)); |
||||
this.dependencyTable.Size = new System.Drawing.Size(106, 100); |
||||
this.dependencyTable.TabIndex = 1; |
||||
//
|
||||
// runActionButton
|
||||
//
|
||||
this.runActionButton.Location = new System.Drawing.Point(3, 127); |
||||
this.runActionButton.Name = "runActionButton"; |
||||
this.runActionButton.Size = new System.Drawing.Size(91, 23); |
||||
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.Location = new System.Drawing.Point(3, 156); |
||||
this.uninstallButton.Name = "uninstallButton"; |
||||
this.uninstallButton.Size = new System.Drawing.Size(91, 23); |
||||
this.uninstallButton.TabIndex = 3; |
||||
this.uninstallButton.Text = "Uninstall"; |
||||
this.uninstallButton.UseCompatibleTextRendering = true; |
||||
this.uninstallButton.UseVisualStyleBackColor = true; |
||||
//
|
||||
// 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.ResumeLayout(false); |
||||
} |
||||
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> |
@ -0,0 +1,71 @@
@@ -0,0 +1,71 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Daniel Grunwald |
||||
* Date: 26.11.2005 |
||||
* Time: 15:27 |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Drawing; |
||||
using System.Windows.Forms; |
||||
using ICSharpCode.Core; |
||||
|
||||
namespace ICSharpCode.SharpDevelop.Gui |
||||
{ |
||||
/// <summary>
|
||||
/// Description of FormLocationHelper.
|
||||
/// </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 = WorkbenchSingleton.MainForm.Bounds; |
||||
Size size = form.Size; |
||||
return new Point(parent.Left + (parent.Width - size.Width) / 2, |
||||
parent.Top + (parent.Height - size.Height) / 2); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,125 @@
@@ -0,0 +1,125 @@
|
||||
/* |
||||
* Created by SharpDevelop. |
||||
* User: Daniel Grunwald |
||||
* Date: 26.11.2005 |
||||
* Time: 18:27 |
||||
*/ |
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.IO; |
||||
using System.Xml; |
||||
using System.Text; |
||||
|
||||
namespace ICSharpCode.Core |
||||
{ |
||||
public enum AddInAction |
||||
{ |
||||
Enable, |
||||
Disable, |
||||
Install, |
||||
Uninstall, |
||||
Update |
||||
} |
||||
|
||||
public static class AddInManager |
||||
{ |
||||
static string configurationFileName; |
||||
|
||||
public static string ConfigurationFileName { |
||||
get { |
||||
return configurationFileName; |
||||
} |
||||
set { |
||||
configurationFileName = value; |
||||
} |
||||
} |
||||
|
||||
public static void Enable(List<AddIn> addIns) |
||||
{ |
||||
List<string> addInFiles = new List<string>(); |
||||
List<string> disabled = new List<string>(); |
||||
LoadAddInConfiguration(addInFiles, disabled); |
||||
|
||||
foreach (AddIn addIn in addIns) { |
||||
string identity = addIn.Manifest.PrimaryIdentity; |
||||
if (identity == null) |
||||
throw new ArgumentException("The AddIn cannot be disabled because it has no identity."); |
||||
|
||||
disabled.Remove(identity); |
||||
addIn.Action = AddInAction.Enable; |
||||
} |
||||
|
||||
SaveAddInConfiguration(addInFiles, disabled); |
||||
} |
||||
|
||||
public static void Disable(List<AddIn> addIns) |
||||
{ |
||||
List<string> addInFiles = new List<string>(); |
||||
List<string> disabled = new List<string>(); |
||||
LoadAddInConfiguration(addInFiles, disabled); |
||||
|
||||
foreach (AddIn addIn in addIns) { |
||||
string identity = addIn.Manifest.PrimaryIdentity; |
||||
if (identity == null) |
||||
throw new ArgumentException("The AddIn cannot be disabled because it has no identity."); |
||||
|
||||
if (!disabled.Contains(identity)) |
||||
disabled.Add(identity); |
||||
addIn.Action = AddInAction.Disable; |
||||
} |
||||
|
||||
SaveAddInConfiguration(addInFiles, disabled); |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Loads a configuration file.
|
||||
/// The 'file' from XML elements in the form "<AddIn file='full path to .addin file'>" will
|
||||
/// be added to <paramref name="addInFiles"/>, the 'addin' element from
|
||||
/// "<Disable addin='addin identity'>" will be added to <paramref name="disabledAddIns"/>,
|
||||
/// all other XML elements are ignored.
|
||||
/// </summary>
|
||||
public static void LoadAddInConfiguration(List<string> addInFiles, List<string> disabledAddIns) |
||||
{ |
||||
if (!File.Exists(configurationFileName)) |
||||
return; |
||||
using (XmlTextReader reader = new XmlTextReader(configurationFileName)) { |
||||
while (reader.Read()) { |
||||
if (reader.NodeType == XmlNodeType.Element) { |
||||
if (reader.Name == "AddIn") { |
||||
string fileName = reader.GetAttribute("file"); |
||||
if (fileName != null && fileName.Length > 0) { |
||||
addInFiles.Add(fileName); |
||||
} |
||||
} else if (reader.Name == "Disable") { |
||||
string addIn = reader.GetAttribute("addin"); |
||||
if (addIn != null && addIn.Length > 0) { |
||||
disabledAddIns.Add(addIn); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
public static void SaveAddInConfiguration(List<string> addInFiles, List<string> disabledAddIns) |
||||
{ |
||||
using (XmlTextWriter writer = new XmlTextWriter(configurationFileName, Encoding.UTF8)) { |
||||
writer.Formatting = Formatting.Indented; |
||||
writer.WriteStartDocument(); |
||||
writer.WriteStartElement("AddInConfiguration"); |
||||
foreach (string file in addInFiles) { |
||||
writer.WriteStartElement("AddIn"); |
||||
writer.WriteAttributeString("file", file); |
||||
writer.WriteEndElement(); |
||||
} |
||||
foreach (string name in disabledAddIns) { |
||||
writer.WriteStartElement("Disable"); |
||||
writer.WriteAttributeString("addin", name); |
||||
writer.WriteEndElement(); |
||||
} |
||||
writer.WriteEndDocument(); |
||||
} |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue