Пример #1
0
 public ToolBarConnector(ButtonAction action, ToolBarButton toolBarButton)
 {
     this.toolBarButton        = toolBarButton;
     this.toolBarButton.Click += toolBarButton_Click;
     this.action = action;
     this.action.EnabledChanged += new EventHandler <EventArgs>(action_EnabledChanged).MakeWeak(e => this.action.EnabledChanged -= e);
 }
Пример #2
0
        public static ButtonAction AddButton(this ActionCollection actions, string id, string text, EventHandler <EventArgs> activated)
        {
            ButtonAction action = new ButtonAction(id, text, activated);

            actions.Add(action);
            return(action);
        }
Пример #3
0
 public ToolBarConnector(ButtonAction action, ToolBarButton toolBarButton)
 {
     this.toolBarButton = toolBarButton;
     this.toolBarButton.Click += toolBarButton_Click;
     this.action = action;
     this.action.EnabledChanged += new EventHandler<EventArgs>(action_EnabledChanged).MakeWeak(e => this.action.EnabledChanged -= e);
 }
Пример #4
0
 public MenuConnector(ButtonAction action, ImageMenuItem menuItem)
 {
     this.action = action;
     this.menuItem = menuItem;
     this.menuItem.Click += menuItem_Clicked;
     this.action.EnabledChanged += new EventHandler<EventArgs>(action_EnabledChanged).MakeWeak((e) => this.action.EnabledChanged -= e);
 }
Пример #5
0
 public MenuConnector(ButtonAction action, ButtonMenuItem menuItem)
 {
     this.action             = action;
     this.menuItem           = menuItem;
     this.menuItem.Click    += HandleClick;
     this.menuItem.Validate += HandleValidate;
 }
Пример #6
0
        public void GetSystemActions(GenerateActionArgs args, bool addStandardItems = false)
        {
            // map new commands/menus back to actions for backwards compatibility
            var commands = GetSystemCommands().ToArray();

            foreach (var command in commands)
            {
                var currentCommand = command;
                var action         = new ButtonAction
                {
                    ID          = currentCommand.ID,
                    MenuText    = currentCommand.MenuText,
                    ToolBarText = currentCommand.ToolBarText,
                    TooltipText = currentCommand.ToolTip,
                    Accelerator = currentCommand.Shortcut,
                    command     = currentCommand
                };
                currentCommand.Executed += (sender, e) => action.Activate();
                action.EnabledChanged   += (sender, e) => currentCommand.Enabled = action.Enabled;
                args.Actions.Add(action);
            }
                        #if DESKTOP
            if (addStandardItems)
            {
                var menu = new MenuBar(Generator);
                CreateStandardMenu(menu.Items, commands);
                args.Menu.ExtractMenu(menu);
            }
                        #endif
        }
Пример #7
0
		public static ButtonAction AddButton(this ActionCollection actions, string id, string text, EventHandler<EventArgs> activated, params Key[] accelerators)
		{
			ButtonAction action = new ButtonAction(id, text, activated);
			action.Accelerators = accelerators;
			actions.Add(action);
			return action;
		}
Пример #8
0
        public static ButtonAction AddButton(this ActionCollection actions, string id, string text)
        {
            ButtonAction action = new ButtonAction(id, text);

            actions.Add(action);
            return(action);
        }
Пример #9
0
			public MenuConnector(ButtonAction action, ImageMenuItem menuItem)
			{
				this.action = action;
				this.menuItem = menuItem;
				this.menuItem.Click += HandleClick;
				this.menuItem.Validate += HandleValidate;
			}
Пример #10
0
        public static ButtonAction AddButton(this ActionCollection actions, string id, string text, EventHandler <EventArgs> activated, params Key[] accelerators)
        {
            ButtonAction action = new ButtonAction(id, text, activated);

            action.Accelerators = accelerators;
            actions.Add(action);
            return(action);
        }
Пример #11
0
		public static ButtonAction AddButton(this ActionCollection actions, string id, string text, string iconResource, EventHandler<EventArgs> activated)
		{
			Icon icon = null;
			if (!string.IsNullOrEmpty(iconResource)) icon = Icon.FromResource (Assembly.GetCallingAssembly (), iconResource);
			ButtonAction action = new ButtonAction(id, text, icon, activated);
			actions.Add(action);
			return action;
		}
Пример #12
0
		public static ButtonAction AddButton(this ActionCollection actions, string id, string text, string iconResource, EventHandler<EventArgs> activated, params Key[] accelerators)
		{
			Icon icon = null;
			if (iconResource != string.Empty) icon = Icon.FromResource (Assembly.GetCallingAssembly (), iconResource);
			ButtonAction action = new ButtonAction(id, text, icon, activated);
			action.Accelerators = accelerators;
			actions.Add(action);
			return action;
		}
Пример #13
0
		public static ButtonAction AddButton(this ActionCollection actions, string id, string text, string iconResource, EventHandler<EventArgs> activated)
		{
#if WINRT
			throw new NotImplementedException("WinRT does not support Assembly.GetCallingAssembly");
#else
			Icon icon = null;
			if (!string.IsNullOrEmpty(iconResource)) icon = Icon.FromResource (Assembly.GetCallingAssembly (), iconResource);
			var action = new ButtonAction(id, text, icon, activated);
			actions.Add(action);
			return action;
#endif
		}
Пример #14
0
        public static ButtonAction AddButton(this ActionCollection actions, string id, string text, string iconResource, EventHandler <EventArgs> activated)
        {
            Icon icon = null;

            if (!string.IsNullOrEmpty(iconResource))
            {
                icon = Icon.FromResource(Assembly.GetCallingAssembly(), iconResource);
            }
            ButtonAction action = new ButtonAction(id, text, icon, activated);

            actions.Add(action);
            return(action);
        }
Пример #15
0
        public static ButtonAction AddButton(this ActionCollection actions, string id, string text, string iconResource, EventHandler <EventArgs> activated, params Key[] accelerators)
        {
            Icon icon = null;

            if (iconResource != string.Empty)
            {
                icon = Icon.FromResource(Assembly.GetCallingAssembly(), iconResource);
            }
            ButtonAction action = new ButtonAction(id, text, icon, activated);

            action.Accelerators = accelerators;
            actions.Add(action);
            return(action);
        }
Пример #16
0
        public static ButtonAction AddButton(this ActionCollection actions, string id, string text, string iconResource, EventHandler <EventArgs> activated)
        {
#if WINRT
            throw new NotImplementedException("WinRT does not support Assembly.GetCallingAssembly");
#else
            Icon icon = null;
            if (!string.IsNullOrEmpty(iconResource))
            {
                icon = Icon.FromResource(Assembly.GetCallingAssembly(), iconResource);
            }
            var action = new ButtonAction(id, text, icon, activated);
            actions.Add(action);
            return(action);
#endif
        }
Пример #17
0
		void GenerateActions()
		{
			var actions = new GenerateActionArgs(this);
			Application.Instance.GetSystemActions(actions, true);

			var quitAction = new ButtonAction { Text = "Quit", Accelerator = Application.Instance.CommonModifier | Key.Q };
			quitAction.Activated += (sender, e) => Application.Instance.Quit();
				
			// add action to file sub-menu
			var file = actions.Menu.FindAddSubMenu("&File");
			file.Actions.Add(quitAction);

			// generate menu
			this.Menu = actions.Menu.GenerateMenuBar();
		}
Пример #18
0
		public void GetSystemActions(GenerateActionArgs args, bool addStandardItems = false)
		{
			// map new commands/menus back to actions for backwards compatibility
			var commands = GetSystemCommands().ToArray();
			foreach (var command in commands)
			{
				var currentCommand = command;
				var action = new ButtonAction
				{
					ID = currentCommand.ID,
					MenuText = currentCommand.MenuText,
					ToolBarText = currentCommand.ToolBarText,
					TooltipText = currentCommand.ToolTip,
					Accelerator = currentCommand.Shortcut,
					command = currentCommand
				};
				currentCommand.Executed += (sender, e) => action.Activate();
				action.EnabledChanged += (sender, e) => currentCommand.Enabled = action.Enabled;
				args.Actions.Add(action);
			}
			#if DESKTOP
			if (addStandardItems)
			{
				var menu = new MenuBar(Generator);
				CreateStandardMenu(menu.Items, commands);
				args.Menu.ExtractMenu(menu);
			}
			#endif
		}
Пример #19
0
		public static ButtonAction AddButton(this ActionCollection actions, string id, string text, EventHandler<EventArgs> activated)
		{
			ButtonAction action = new ButtonAction(id, text, activated);
			actions.Add(action);
			return action;
		}
Пример #20
0
		public static ButtonAction AddButton(this ActionCollection actions, string id, string text)
		{
			ButtonAction action = new ButtonAction(id, text);
			actions.Add(action);
			return action;
		}