1
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
2
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
5
using ICSharpCode.Core;
6
using ICSharpCode.SharpDevelop.Gui;
8
namespace ICSharpCode.SharpDevelop
11
/// Indicates the default position for a pad.
12
/// This is a bit-flag enum, Hidden can be combined with the directions.
15
public enum DefaultPadPositions
28
public class PadDescriptor : IDisposable
39
IPadContent padContent;
40
bool padContentCreated;
43
/// Creates a new pad descriptor from the AddIn tree.
45
public PadDescriptor(Codon codon)
48
throw new ArgumentNullException("codon");
50
shortcut = codon.Properties["shortcut"];
51
category = codon.Properties["category"];
52
icon = codon.Properties["icon"];
53
title = codon.Properties["title"];
54
@class = codon.Properties["class"];
55
if (!string.IsNullOrEmpty(codon.Properties["defaultPosition"])) {
56
DefaultPosition = (DefaultPadPositions)Enum.Parse(typeof(DefaultPadPositions), codon.Properties["defaultPosition"]);
61
/// Creates a pad descriptor for the specified pad type.
63
public PadDescriptor(Type padType, string title, string icon)
66
throw new ArgumentNullException("padType");
68
throw new ArgumentNullException("title");
70
throw new ArgumentNullException("icon");
71
this.padType = padType;
72
this.@class = padType.FullName;
75
this.category = "none";
80
/// Returns the title of the pad.
89
/// Returns the icon bitmap resource name of the pad. May be an empty string
90
/// if the pad has no icon defined.
99
/// Returns the category (this is used for defining where the menu item to
102
public string Category {
108
throw new ArgumentNullException("value");
114
/// Returns the menu shortcut for the view menu item.
116
public string Shortcut {
122
throw new ArgumentNullException("value");
128
/// Gets the name of the pad class.
130
public string Class {
137
/// Gets/sets the default position of the pad.
139
public DefaultPadPositions DefaultPosition { get; set; }
141
public IPadContent PadContent {
148
public void Dispose()
150
if (padContent != null) {
151
padContent.Dispose();
156
public void CreatePad()
158
if (WorkbenchSingleton.InvokeRequired)
159
throw new InvalidOperationException("This action could trigger pad creation and is only valid on the main thread!");
160
if (!padContentCreated) {
161
padContentCreated = true;
164
LoggingService.Debug("Creating pad " + Class + "...");
165
padContent = (IPadContent)addIn.CreateObject(Class);
167
padContent = (IPadContent)Activator.CreateInstance(padType);
169
} catch (Exception ex) {
170
MessageService.ShowException(ex, "Error creating pad instance");
175
public void BringPadToFront()
178
if (padContent == null) return;
179
WorkbenchSingleton.Workbench.WorkbenchLayout.ActivatePad(this);
182
public override string ToString()
184
return "[PadDescriptor " + this.Class + "]";