public void Initialize(IEnvironment environment) { this.environment = environment; LoadSettings(); if (environment.Mode == EnvironmentMode.Designer) { ICommandContext context = environment.Commands.GetContext(PredefinedContexts.Communication); context.AddCommand(new PropertyCommand(this)); } }
public void Initialize(IEnvironment environment) { this.environment = environment; environment.Project.ProjectLoaded += new System.EventHandler(OnProjectLoad); LoadSettings(); if (environment.Mode == EnvironmentMode.Designer) { ICommandContext context = environment.Commands.GetContext(PredefinedContexts.Communication); context.AddCommand(new PropertyCommand(this)); } }
ArchiverMain() { Env.Current.Project.ProjectLoaded += new System.EventHandler(OnProjectLoaded); Env.Current.Project.ProjectClosed += new System.EventHandler(OnProjectClosed); OnProjectLoaded(Env.Current.Project, new System.EventArgs()); if (Env.Current.Mode == EnvironmentMode.Designer) { ICommandContext context = Env.Current.Commands.GetContext(PredefinedContexts.Project); context.AddCommand(new PropertyCommand()); } }
public void RegisterCommand() { MenuStrip menu = new MenuStrip(); ToolStrip toolbar = new ToolStrip(); Commands commands = new Commands(menu, toolbar); CommandMock testCommand1 = new CommandMock("Test command 1"); CommandMock testCommand2 = new CommandMock("Test command 2"); ICommandContext context = commands.GetContext(FreeSCADA.Interfaces.PredefinedContexts.Communication); Assert.IsNotNull(context); context.AddCommand(testCommand1); context.AddCommand(testCommand2); Assert.AreEqual(2, context.GetCommands().Count); ToolStripMenuItem group = (ToolStripMenuItem)menu.Items[0]; Assert.AreEqual("Test command 1", group.DropDown.Items[0].Text); Assert.AreEqual("Test command 2", group.DropDown.Items[1].Text); }
ArchiverMain(Project prj) { _project = prj; channelSettings = new RulesSettings(_project); databaseSettings = new DatabaseSettings(_project); databaseSettings.Load(); channelSettings.Load(); Accessor = new ArchiverAccessor(this); Accessor.Open(); SubscribeEvents(); if (Env.Current.Mode == EnvironmentMode.Designer) { ICommandContext context = Env.Current.Commands.GetContext(PredefinedContexts.Project); context.AddCommand(new PropertyCommand()); } }
public void Initialize(IEnvironment environment) { this.environment = environment; environment.Project.ProjectLoaded += new System.EventHandler(OnProjectLoad); /*container = new UnityContainer(); * UnityConfigurationSection section * = (UnityConfigurationSection)System.Configuration.ConfigurationManager.GetSection("unity"); * //section.Containers.Default.Configure(Container);*/ LoadSettings(); if (environment.Mode == EnvironmentMode.Designer) { ICommandContext context = environment.Commands.GetContext(PredefinedContexts.Communication); context.AddCommand(new PropertyCommand(this)); } }
void CreateItems(List <string> strings) { int i = 0; foreach (ICommand cmd in _context.GetCommands()) { if (cmd is GlobalCommands.MruLoadProjectCommand) { _context.RemoveCommand(cmd); } } foreach (string str in strings) { if (i++ >= Size) { break; } _context.AddCommand(new GlobalCommands.MruLoadProjectCommand(this, _windowManager, str)); } }
public void HandlingEvents() { MenuStrip menu = new MenuStrip(); ToolStrip toolbar = new ToolStrip(); Commands commands = new Commands(menu, toolbar); CommandMock testCommand = new CommandMock("Test command 1"); ICommandContext context = commands.GetContext(FreeSCADA.Interfaces.PredefinedContexts.GlobalMenu); context.AddCommand(testCommand); foreach (ICommand cmd in context.GetCommands()) { cmd.Execute(); } Assert.IsTrue(testCommand.isExecuted); testCommand.isExecuted = false; ToolStripItem menuItem = null; foreach (ToolStripItem item in menu.Items) { if (item.Text == testCommand.Name) { menuItem = item; } } Assert.IsNotNull(menuItem); menuItem.PerformClick(); Assert.IsTrue(testCommand.isExecuted); testCommand.isExecuted = false; toolbar.Items[0].PerformClick(); Assert.IsTrue(testCommand.isExecuted); }