📄 menuitembuilders.cs
字号:
}
}
public CommandBarItem[] BuildSubmenu(ConditionCollection conditionCollection, object owner)
{
int contentCount = WorkbenchSingleton.Workbench.ViewContentCollection.Count;
if (contentCount == 0) {
return new CommandBarItem[] {};
}
CommandBarItem[] items = new CommandBarItem[contentCount + 1];
items[0] = new SdMenuSeparator(null, null);
for (int i = 0; i < contentCount; ++i) {
IViewContent content = (IViewContent)WorkbenchSingleton.Workbench.ViewContentCollection[i];
SdMenuCheckBox item = new MyMenuItem(content.WorkbenchWindow);
item.Tag = content.WorkbenchWindow;
item.IsChecked = WorkbenchSingleton.Workbench.ActiveWorkbenchWindow == content.WorkbenchWindow;
item.Description = "Activate this window ";
items[i + 1] = item;
}
return items;
}
}
public class IncludeFilesBuilder : ISubmenuBuilder
{
public ProjectBrowserView browser;
MyMenuItem includeInCompileItem;
MyMenuItem includeInDeployItem;
class MyMenuItem : SdMenuCheckBox
{
IncludeFilesBuilder builder;
public MyMenuItem(IncludeFilesBuilder builder, string name, EventHandler handler) : base(null, null, name)
{
base.Click += handler;
this.builder = builder;
}
public override void UpdateStatus()
{
base.UpdateStatus();
if (builder == null) {
return;
}
AbstractBrowserNode node = builder.browser.SelectedNode as AbstractBrowserNode;
if (node == null) {
return;
}
ProjectFile finfo = node.UserData as ProjectFile;
if (finfo == null) {
builder.includeInCompileItem.IsEnabled = builder.includeInCompileItem.IsEnabled = false;
} else {
if (!builder.includeInCompileItem.IsEnabled) {
builder.includeInCompileItem.IsEnabled = builder.includeInCompileItem.IsEnabled = true;
}
builder.includeInCompileItem.IsChecked = finfo.BuildAction == BuildAction.Compile;
builder.includeInDeployItem.IsChecked = !node.Project.DeployInformation.IsFileExcluded(finfo.Name);
}
}
}
public CommandBarItem[] BuildSubmenu(ConditionCollection conditionCollection, object owner)
{
browser = (ProjectBrowserView)owner;
includeInCompileItem = new MyMenuItem(this, "${res:ProjectComponent.ContextMenu.IncludeMenu.InCompile}", new EventHandler(ChangeCompileInclude));
includeInDeployItem = new MyMenuItem(this, "${res:ProjectComponent.ContextMenu.IncludeMenu.InDeploy}", new EventHandler(ChangeDeployInclude));
return new CommandBarItem[] {
includeInCompileItem,
includeInDeployItem
};
}
void ChangeCompileInclude(object sender, EventArgs e)
{
AbstractBrowserNode node = browser.SelectedNode as AbstractBrowserNode;
if (node == null) {
return;
}
ProjectFile finfo = node.UserData as ProjectFile;
if (finfo != null) {
if (finfo.BuildAction == BuildAction.Compile) {
finfo.BuildAction = BuildAction.Nothing;
} else {
finfo.BuildAction = BuildAction.Compile;
}
}
IProjectService projectService = (IProjectService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
projectService.SaveCombine();
}
void ChangeDeployInclude(object sender, EventArgs e)
{
AbstractBrowserNode node = browser.SelectedNode as AbstractBrowserNode;
if (node == null) {
return;
}
ProjectFile finfo = node.UserData as ProjectFile;
if (finfo != null) {
if (node.Project.DeployInformation.IsFileExcluded(finfo.Name)) {
node.Project.DeployInformation.RemoveExcludedFile(finfo.Name);
} else {
node.Project.DeployInformation.AddExcludedFile(finfo.Name);
}
}
IProjectService projectService = (IProjectService)ICSharpCode.Core.Services.ServiceManager.Services.GetService(typeof(IProjectService));
projectService.SaveCombine();
}
}
public class DebugViewMenuBuilder : ViewMenuBuilder
{
protected override string Category {
get {
return "Debugger";
}
}
}
public class MainViewMenuBuilder : ViewMenuBuilder
{
protected override string Category {
get {
return "Main";
}
}
}
public class ViewMenuBuilder : ISubmenuBuilder
{
class MyMenuItem : SdMenuCheckBox
{
IPadContent padContent;
bool IsPadVisible {
get {
return WorkbenchSingleton.Workbench.WorkbenchLayout.IsVisible(padContent);
}
}
public MyMenuItem(IPadContent padContent) : base(null, null, padContent.Title)
{
this.padContent = padContent;
IsChecked = IsPadVisible;
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
if (IsPadVisible) {
WorkbenchSingleton.Workbench.WorkbenchLayout.HidePad(padContent);
} else {
WorkbenchSingleton.Workbench.WorkbenchLayout.ShowPad(padContent);
}
IsChecked = IsPadVisible;
}
public override void UpdateStatus()
{
base.UpdateStatus();
IsChecked = IsPadVisible;
}
}
protected virtual string Category {
get {
return null;
}
}
public CommandBarItem[] BuildSubmenu(ConditionCollection conditionCollection, object owner)
{
ArrayList items = new ArrayList();
foreach (IPadContent padContent in WorkbenchSingleton.Workbench.PadContentCollection) {
if (padContent.Category == Category) {
items.Add(new MyMenuItem(padContent));
}
}
return (CommandBarItem[])items.ToArray(typeof(CommandBarItem));
}
}
public class DebugSelectionMenuBuilder : SelectionMenuBuilder
{
protected override string Category {
get {
return "Debugger";
}
}
}
public class MainSelectionMenuBuilder : SelectionMenuBuilder
{
protected override string Category {
get {
return "Main";
}
}
}
public class SelectionMenuBuilder : ISubmenuBuilder
{
class MyMenuItem : SdMenuCommand
{
IPadContent padContent;
public MyMenuItem(IPadContent padContent) : base(null, null, padContent.Title)
{
this.padContent = padContent;
if (padContent.Icon != null) {
IconService iconService = (IconService)ServiceManager.Services.GetService(typeof(IconService));
base.Image = iconService.GetBitmap(padContent.Icon);
}
if (padContent.Shortcut != null) {
try {
foreach (string key in padContent.Shortcut) {
Shortcut |= (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), key);
}
} catch (Exception) {
Shortcut = System.Windows.Forms.Keys.None;
}
}
}
protected override void OnClick(EventArgs e)
{
base.OnClick(e);
padContent.BringPadToFront();
}
}
protected virtual string Category {
get {
return null;
}
}
public CommandBarItem[] BuildSubmenu(ConditionCollection conditionCollection, object owner)
{
ArrayList items = new ArrayList();
foreach (IPadContent padContent in WorkbenchSingleton.Workbench.PadContentCollection) {
if (padContent.Category == Category) {
items.Add(new MyMenuItem(padContent));
}
}
return (CommandBarItem[])items.ToArray(typeof(CommandBarItem));
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -