uielementbuilder.cs

来自「wpf和cab的结合使用源码(转载)」· CS 代码 · 共 43 行

CS
43 行
字号
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Text;
using System.Windows.Controls;
using Microsoft.Practices.CompositeUI;
using Microsoft.Practices.CompositeUI.UIElements;
using Microsoft.Practices.CompositeUI.Windows;

namespace BankShell
{
	/// <summary>
	/// This is a temporary implementation that will be replaced with something
	/// richer when we move it into the framework.
	/// </summary>
	public static class UIElementBuilder
	{
		// Loads the menu items from App.config and put them into the menu strip, hooking
		// up the menu URIs for command dispatching.
		public static void LoadFromConfig(WorkItem workItem)
		{
			ShellItemsSection section = (ShellItemsSection) ConfigurationManager.GetSection("shellitems");

			foreach (MenuItemElement menuItem in section.MenuItems)
			{
				MenuItem uiMenuItem = menuItem.ToMenuItem();

				workItem.UIExtensionSites[menuItem.Site].Add(uiMenuItem);

				if (menuItem.Register)
				{
					workItem.UIExtensionSites.RegisterSite(menuItem.RegistrationSite, uiMenuItem);
				}

				if (!string.IsNullOrEmpty(menuItem.CommandName))
				{
					workItem.Commands[menuItem.CommandName].AddInvoker(uiMenuItem, "Click");
				}
			}
		}
	}
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?