public SectorUiState(ICommandPool commandPool, IAnimationBlockerService animationBlockerService, ICommandLoopUpdater commandLoopUpdater) { _commandPool = commandPool; _animationBlockerService = animationBlockerService; _commandLoopUpdater = commandLoopUpdater; }
/// <summary> /// 执行命令 /// </summary> /// <param name="cmdprogid"></param> /// <returns></returns> public bool ExecuteCommand(string cmdprogid) { ICommandPool pCmdPool = axToolbarControl1.CommandPool; UID pUid = GetUIDFromStr(cmdprogid); ICommand pCmd = pCmdPool.FindByUID(pUid); if (pCmd != null) { if (pCmd is ITool) { if (m_bMapView && m_mapControl != null) { m_mapControl.CurrentTool = pCmd as ITool; } else if (m_pageControl != null) { m_pageControl.CurrentTool = pCmd as ITool; } } else { pCmd.OnClick(); } return(true); } return(false); }
private static void HandleMoveCommand( IServiceScope serviceScope, ISectorUiState uiState, ICommandPool commandManager, ISectorNode playerActorSectorNode, string inputText) { var components = inputText.Split(' '); var x = int.Parse(components[1], CultureInfo.InvariantCulture); var y = int.Parse(components[2], CultureInfo.InvariantCulture); var offsetCoords = new OffsetCoords(x, y); ISectorMap map = playerActorSectorNode.Sector.Map; var targetNode = map.Nodes.OfType <HexNode>() .SingleOrDefault(node => node.OffsetCoords == offsetCoords); var command = serviceScope.ServiceProvider.GetRequiredService <MoveCommand>(); uiState.SelectedViewModel = new NodeViewModel { Node = targetNode }; PushCommandToExecution(commandManager, command); }
private void InitItemsForEquipment(List <TextButton> list, ICommandPool commandPool) { for (var slotIndex = 0; slotIndex < _equipmentModule.Slots.Length; slotIndex++) { var slot = _equipmentModule.Slots[slotIndex]; var equipCommand = _serviceProvider.GetRequiredService <EquipCommand>(); equipCommand.SlotIndex = slotIndex; if (equipCommand.CanExecute().IsSuccess) { var slotTitle = GetSlotTitle(slot.Types); var equipButtonTitle = string.Format(UiResources.EquipInSlotTemplateCommandButton, slotTitle); var equipButton = new TextButton(equipButtonTitle, _uiContentStorage.GetMenuItemTexture(), _uiContentStorage.GetMenuItemFont(), new Rectangle( MENU_MARGIN + _position.X, MENU_MARGIN + _position.Y + (list.Count * MENU_ITEM_HEIGHT), MENU_WIDTH, MENU_ITEM_HEIGHT)); equipButton.OnClick += (s, e) => { commandPool.Push(equipCommand); CloseMenu(); IsCommandUsed = true; }; list.Add(equipButton); } } }
public CommandLoopUpdater(ICommandLoopContext commandLoopContext, ICommandPool commandPool) { _commandLoopContext = commandLoopContext; _commandPool = commandPool; _semaphoreSlim = new SemaphoreSlim(1, 1); }
/// <summary> /// 更新工具可用状态 /// </summary> public void RefreshButtonState() { try { string progID = ""; UID pUid = new UIDClass(); ICommandPool pCmdPool = m_cmdManager.ToolbarControl.CommandPool; for (int i = 0; i < ribbonctrl.Items.Count; i++) { BarItem baritem = ribbonctrl.Items[i]; if (baritem == null || baritem.Tag == null) { continue; } progID = baritem.Tag.ToString(); try { pUid.Value = m_cmdManager.GetUIDFromStr(progID); //progID; ICommand pCmd = pCmdPool.FindByUID(pUid); if (pCmd != null) { baritem.Enabled = pCmd.Enabled; } } catch { } } } catch { } }
//Gis Command click private void tsb_Click(object sender, EventArgs e) { object tag = (sender as ToolStripButton).Tag; if (tag == null) { return; } string cmdName = tag.ToString(); if (string.IsNullOrEmpty(cmdName)) { return; } ICommand pCmd; ICommandPool pCmdPool = axToolbarControl.CommandPool; for (int i = 0; i < pCmdPool.Count; i++) { pCmd = pCmdPool.get_Command(i); if (pCmd.Name == cmdName) { if (pCmd is ITool) { (axToolbarControl.Buddy as IMapControl3).CurrentTool = pCmd as ITool; } pCmd.OnClick(); break; } } }
public CommandBinder() { _bindings = new Dictionary <EventBase, List <CommandBindingBase> >(); _bindingsToUnbind = new List <CommandBindingBase>(8); _commandPool = new CommandPool(); _commandsPoolableData = new Dictionary <Type, bool>(64); }
private static void PushCommandToExecution(ICommandPool commandManager, ICommand command) { if (command.CanExecute().IsSuccess) { commandManager.Push(command); } else { Console.WriteLine(UiResource.CommandCantExecuteMessage); } }
/// <summary> /// 更新工具条图标和状态:仅初始时 /// </summary> public void UpdateToolbar() { Bitmap bitmap = null; string progID = ""; UID pUid = new UIDClass(); ICommandPool pCmdPool = m_cmdManager.ToolbarControl.CommandPool; for (int i = 0; i < ribbonctrl.Items.Count; i++) { BarItem baritem = ribbonctrl.Items[i]; if (baritem == null || baritem.Tag == null || baritem.Tag.ToString().Equals("")) { continue; } progID = baritem.Tag.ToString(); try { pUid.Value = m_cmdManager.GetUIDFromStr(progID); ICommand pCmd = pCmdPool.FindByUID(pUid); if (pCmd != null) { if (!baritem.IsImageExist && pCmd.Bitmap != 0) //if (!baritem.IsImageExist) { bitmap = Bitmap.FromHbitmap((IntPtr)pCmd.Bitmap); bitmap.MakeTransparent(bitmap.GetPixel(0, 0)); baritem.Glyph = bitmap; } try { //提示信息 if (baritem.Hint.Length == 0) { baritem.Hint = pCmd.Tooltip; } //可用状态 baritem.Enabled = pCmd.Enabled; } catch { } } baritem.ItemClick += barButtonItem_ItemClick; } catch (Exception ex) { MessageBox.Show("装载工具" + progID + "时出错:" + ex.Message); } } }
public CommandInput( ISectorUiState sectorUiState, ICommandPool commandPool, Camera camera, ISector sector, SectorViewModelContext sectorViewModelContext, ServiceProviderCommandFactory commandFactory) { _uiState = sectorUiState; _commandPool = commandPool; _camera = camera; _sector = sector; _sectorViewModelContext = sectorViewModelContext; _commandFactory = commandFactory; }
public BottomMenuPanel( IHumanActorTaskSource <ISectorTaskSourceContext> humanActorTaskSource, ICombatActModule combatActModule, IUiContentStorage uiContentStorage, IEquipmentModule equipmentModule, ISectorUiState sectorUiState, ICommandPool commandPool, ServiceProviderCommandFactory commandFactory, ICommandLoopContext commandLoopContext, IPlayerEventLogService logService) { _travelPanel = new TravelPanel(humanActorTaskSource, uiContentStorage, commandPool, commandFactory, commandLoopContext); _combatActPanel = new CombatActPanel(combatActModule, equipmentModule, uiContentStorage, sectorUiState); _travelPanel.PropButtonClicked += PersonPropButton_OnClick; _travelPanel.StatButtonClicked += PersonStatsButton_OnClick; _travelPanel.TraitsButtonClicked += PersonTraitsButton_OnClick; _travelPanel.FastDeathButtonClicked += FastDeathButtonClicked; _currentModeMenu = _travelPanel; var combatButtonIcon = new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(48, 0, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT) ); var idleButtonIcon = new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(0, 32, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT) ); _idleModeSwitcherButton = new IconButton( uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), idleButtonIcon, new Rectangle(0, 0, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT)); _idleModeSwitcherButton.OnClick += IdleModeSwitcherButton_OnClick; _combatActModule = combatActModule; _uiContentStorage = uiContentStorage; _sectorUiState = sectorUiState; _logService = logService; _combatModeSwitcherButton = new IconButton( texture: uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), iconData: combatButtonIcon, rect: new Rectangle(0, 0, SWITCHER_MODE_BUTTON_WIDTH, SWITCHER_MODE_BUTTON_HEIGHT)); _combatModeSwitcherButton.OnClick += CombatModeSwitcherButton_OnClick; }
public bool start(ICommandPool commandPool, ICompileNotifier notifier) { if (isRunning()) { return(false); } setRunning(true); m_forcingStop = false; m_commandPool = commandPool; m_notifier = notifier; m_thread = new Thread(m_threadStart); m_thread.Start(); return(true); }
public PersonMarkersPanel(int positionOffsetY, IUiContentStorage uiContentStorage, SectorViewModelContext sectorViewModelContext, IPlayer player, ISectorUiState sectorUiState, ICommandPool commandPool, ServiceProviderCommandFactory commandFactory) { _positionOffsetY = positionOffsetY; _uiContentStorage = uiContentStorage; _sectorViewModelContext = sectorViewModelContext; _player = player; _sectorUiState = sectorUiState; _commandPool = commandPool; _commandFactory = commandFactory; _visibleActors = new List <ActorViewModel>(); _drawnItemList = new List <Marker>(); }
private static void HandleAttackCommand(string inputText, IServiceScope serviceScope, ISectorUiState uiState, ISectorNode playerActorSectorNode, ICommandPool commandManager) { var components = inputText.Split(' '); var targetId = int.Parse(components[1], CultureInfo.InvariantCulture); if (components.Length == 3) { var targetMarker = components[2].ToUpper(CultureInfo.InvariantCulture); switch (targetMarker) { case "A": SelectActor(uiState, playerActorSectorNode, targetId); break; case "S": SelectStaticObject(uiState, playerActorSectorNode, targetId); break; default: SelectActor(uiState, playerActorSectorNode, targetId); break; } } else { SelectActor(uiState, playerActorSectorNode, targetId); } var acts = uiState.ActiveActor.Actor.Person.GetModule <ICombatActModule>().GetCurrentCombatActs(); uiState.TacticalAct = acts .OrderBy(x => x.Equipment is null) .First(x => x.Constrains is null); var command = serviceScope.ServiceProvider.GetRequiredService <AttackCommand>(); PushCommandToExecution(commandManager, command); }
private void Form1_Load(object sender, System.EventArgs e) { //Set the Buddy property axToolbarControl1.SetBuddyControl(axMapControl1); axToolbarControl2.SetBuddyControl(axMapControl1); //Add items to the ToolbarControls axToolbarControl1.AddItem("esriControls.ControlsOpenDocCommand", -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsMapZoomInTool", -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconAndText); axToolbarControl1.AddItem("esriControls.ControlsMapZoomOutTool", -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconAndText); axToolbarControl1.AddItem("esriControls.ControlsMapPanTool", -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconAndText); axToolbarControl2.AddItem("esriControls.ControlsMapFullExtentCommand", -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapZoomInTool", -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconAndText); axToolbarControl2.AddItem("esriControls.ControlsMapZoomOutTool", -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconAndText); axToolbarControl2.AddItem("esriControls.ControlsMapPanTool", -1, -1, false, -1, esriCommandStyles.esriCommandStyleIconAndText); //Get the CommandPool of ToolbarControl's m_CommandPool1 = axToolbarControl1.CommandPool; m_CommandPool2 = axToolbarControl2.CommandPool; UpdateUsageCount(); }
private void Form1_Load(object sender, System.EventArgs e) { //Set buddy controls axTOCControl1.SetBuddyControl(axMapControl1); axToolbarControl1.SetBuddyControl(axMapControl1); axToolbarControl2.SetBuddyControl(axMapControl1); //Share command pools m_CommandPool = new CommandPoolClass(); axToolbarControl1.CommandPool = m_CommandPool; axToolbarControl2.CommandPool = m_CommandPool; //Add items to the ToolbarControl axToolbarControl1.AddItem("esriControls.ControlsEditingEditorMenu", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingEditTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingSketchTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsUndoCommand", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsRedoCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingTargetToolControl", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingTaskToolControl", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingAttributeCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingSketchPropertiesCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingCutCommand", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingPasteCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingCopyCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingClearCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsOpenDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsSaveAsDocCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapZoomInTool", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapZoomOutTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapPanTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapFullExtentCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapZoomToLastExtentBackCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapZoomToLastExtentForwardCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsFullScreenCommand", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapIdentifyTool", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); //Create popup menus m_toolbarMenuSketch = new ToolbarMenuClass(); m_toolbarMenuVertex = new ToolbarMenuClass(); m_toolbarMenuSketch.AddItem("esriControls.ControlsEditingSketchContextMenu", 0, 0, false, esriCommandStyles.esriCommandStyleTextOnly); m_toolbarMenuVertex.AddItem("esriControls.ControlsEditingVertexContextMenu", 0, 0, false, esriCommandStyles.esriCommandStyleTextOnly); //Create an operation stack for the undo and redo commands to use IOperationStack operationStack = new ControlsOperationStackClass(); axToolbarControl1.OperationStack = operationStack; axToolbarControl2.OperationStack = operationStack; //Instantiate the EngineEditor singleton m_engineEditor = new EngineEditorClass(); //Create each command on the ToolbarMenu so that the Accelerator Keys are recognized. //Alternatively the user must popup the menu before using the Accelerator Keys long itemCount = m_toolbarMenuSketch.CommandPool.Count; for (int i = 0; i < itemCount; i++) { ICommand pCommand = m_toolbarMenuSketch.CommandPool.get_Command(i); pCommand.OnCreate(axMapControl1.Object); } //Share the commandpool with the ToolbarMenu m_toolbarMenuSketch.CommandPool = m_CommandPool; m_toolbarMenuVertex.CommandPool = m_CommandPool; }
private void EditorForm_Load(object sender, EventArgs e) { //********* Important ************* //Obtain a reference to the MainForm using the EditHelper class m_mainForm = EditHelper.TheMainForm; m_mapControl = m_mainForm.MapControl; //buddy the toolbars with the MapControl axBlankToolBar.SetBuddyControl(m_mapControl); axModifyToolbar.SetBuddyControl(m_mapControl); axReshapeToolbar.SetBuddyControl(m_mapControl); axUndoRedoToolbar.SetBuddyControl(m_mapControl); axCreateToolbar.SetBuddyControl(m_mapControl); //Create and share command pool m_pool = new CommandPoolClass(); axCreateToolbar.CommandPool = m_pool; axBlankToolBar.CommandPool = m_pool; axModifyToolbar.CommandPool = m_pool; axReshapeToolbar.CommandPool = m_pool; axUndoRedoToolbar.CommandPool = m_pool; //Create and share operation stack m_operationStack = new ControlsOperationStackClass(); axModifyToolbar.OperationStack = m_operationStack; axReshapeToolbar.OperationStack = m_operationStack; axUndoRedoToolbar.OperationStack = m_operationStack; axCreateToolbar.OperationStack = m_operationStack; //load items for the axModifyToolbar axModifyToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 1, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axModifyToolbar.AddItem("VertexCommands_CS.CustomVertexCommands", 2, 2, false, 0, esriCommandStyles.esriCommandStyleIconOnly); //load items for the axReshapeToolbar axReshapeToolbar.AddItem("esriControls.ControlsEditingEditTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axReshapeToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); //load items for the axCreateToolbar axCreateToolbar.AddItem("esriControls.ControlsEditingSketchTool", 0, 0, false, 0, esriCommandStyles.esriCommandStyleIconOnly); //set up the EngineEditor m_engineEditor = new EngineEditorClass(); m_engineEditor.EnableUndoRedo(true); ((IEngineEditProperties2)m_engineEditor).StickyMoveTolerance = 10000; object tbr = (object)axCreateToolbar.Object; IExtension engineEditorExt = m_engineEditor as IExtension; engineEditorExt.Startup(ref tbr); //ensures that the operationStack will function correctly //Listen to OnSketchModified engine editor event ((IEngineEditEvents_Event)m_engineEditor).OnSketchModified += new IEngineEditEvents_OnSketchModifiedEventHandler(OnSketchModified); //listen to MainForm events in case application is closed while editing EditHelper.TheMainForm.FormClosing += new FormClosingEventHandler(TheMainForm_FormClosing); #region Form Management m_commands = new ArrayList(); m_commands.Add(cmdModify); m_commands.Add(cmdReshape); m_commands.Add(cmdCreate); DisableButtons(); txtInfo.Text = ""; this.Size = new Size(242, 208); this.FormBorderStyle = FormBorderStyle.FixedSingle; SetErrorLabel(""); EditHelper.IsEditorFormOpen = true; #endregion }
private static void HandleIdleCommand(IServiceScope serviceScope, ICommandPool commandManager) { var command = serviceScope.ServiceProvider.GetRequiredService <IdleCommand>(); PushCommandToExecution(commandManager, command); }
public MainScreen(Game game, SpriteBatch spriteBatch) : base(game) { _spriteBatch = spriteBatch; var serviceScope = ((LivGame)Game).ServiceProvider; _uiState = serviceScope.GetRequiredService <ISectorUiState>(); _player = serviceScope.GetRequiredService <IPlayer>(); _transitionPool = serviceScope.GetRequiredService <ITransitionPool>(); _animationBlockerService = serviceScope.GetRequiredService <IAnimationBlockerService>(); _commandPool = serviceScope.GetRequiredService <ICommandPool>(); _commandFactory = new ServiceProviderCommandFactory(((LivGame)game).ServiceProvider); var uiSoundStorage = serviceScope.GetRequiredService <IUiSoundStorage>(); _uiContentStorage = serviceScope.GetRequiredService <IUiContentStorage>(); var soundtrackManager = serviceScope.GetRequiredService <SoundtrackManager>(); _camera = new Camera(); _personEffectsPanel = new PersonConditionsPanel(_uiState, screenX: game.GraphicsDevice.Viewport.Bounds.Center.X, screenY: 8, _uiContentStorage, uiSoundStorage, soundtrackManager, Game.GraphicsDevice); _personEquipmentModal = new PersonPropsModalDialog( _uiContentStorage, game.GraphicsDevice, _uiState, ((LivGame)game).ServiceProvider); _personStatsModal = new PersonStatsModalDialog( _uiContentStorage, game.GraphicsDevice, _uiState); _personTraitsModal = new PersonTraitsModalDialog( _uiContentStorage, game.GraphicsDevice, _uiState); _containerModal = new ContainerModalDialog( _uiState, _uiContentStorage, Game.GraphicsDevice, serviceScope); var humanActorTaskSource = serviceScope.GetRequiredService <IHumanActorTaskSource <ISectorTaskSourceContext> >(); var mainPerson = _player.MainPerson; if (mainPerson is null) { throw new InvalidOperationException("Main person is not initalized. Generate globe first."); } _logService = serviceScope.GetRequiredService <IPlayerEventLogService>(); _bottomMenu = new BottomMenuPanel( humanActorTaskSource, mainPerson.GetModule <ICombatActModule>(), _uiContentStorage, mainPerson.GetModule <IEquipmentModule>(), _uiState, _commandPool, _commandFactory, serviceScope.GetRequiredService <ICommandLoopContext>(), _logService); _bottomMenu.PropButtonClicked += BottomMenu_PropButtonClicked; _bottomMenu.StatButtonClicked += BottomMenu_StatButtonClicked; _bottomMenu.TraitsButtonClicked += BottomMenu_TraitsButtonClicked; _scoreManager = serviceScope.GetRequiredService <IScoreManager>(); }
public IPerformer Create(ICommandPool commandPool) => new Performer(commandPool);
public Performer(ICommandPool commandPool) { _commandPool = commandPool; }
private void InitItemsForResource(List <TextButton> list, UseSelfCommand useCommand, ICommandPool commandPool) { if (_prop is null) { return; } if (!useCommand.CanExecute().IsSuccess) { return; } var localizedCommandTitle = GetInventoryMenuItemContent(_prop); var useButton = new TextButton(localizedCommandTitle, _uiContentStorage.GetMenuItemTexture(), _uiContentStorage.GetMenuItemFont(), new Rectangle( MENU_MARGIN + _position.X, MENU_MARGIN + _position.Y, MENU_WIDTH, MENU_ITEM_HEIGHT)); useButton.OnClick += (s, e) => { commandPool.Push(useCommand); CloseMenu(); IsCommandUsed = true; }; list.Add(useButton); }
private void Form1_Load(object sender, System.EventArgs e) { //Set buddy controls axTOCControl1.SetBuddyControl(axMapControl1); axToolbarControl1.SetBuddyControl(axMapControl1); axToolbarControl2.SetBuddyControl(axMapControl1); //Share command pools m_CommandPool = new CommandPoolClass(); axToolbarControl1.CommandPool = m_CommandPool; axToolbarControl2.CommandPool = m_CommandPool; //Add items to the ToolbarControl axToolbarControl1.AddItem("esriControls.ControlsEditingEditorMenu",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingEditTool",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingSketchTool",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsUndoCommand",0,-1,true,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsRedoCommand",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingTargetToolControl", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingTaskToolControl",0,-1,true,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingAttributeCommand",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingSketchPropertiesCommand",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingCutCommand", 0, -1, true, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingPasteCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingCopyCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl1.AddItem("esriControls.ControlsEditingClearCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsOpenDocCommand",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsAddDataCommand", 0, -1, false, 0, esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsSaveAsDocCommand",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapZoomInTool",0,-1,true,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapZoomOutTool",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapPanTool",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapFullExtentCommand",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapZoomToLastExtentBackCommand",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapZoomToLastExtentForwardCommand",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsFullScreenCommand",0,-1,true,0,esriCommandStyles.esriCommandStyleIconOnly); axToolbarControl2.AddItem("esriControls.ControlsMapIdentifyTool",0,-1,false,0,esriCommandStyles.esriCommandStyleIconOnly); //Create popup menus m_toolbarMenuSketch = new ToolbarMenuClass(); m_toolbarMenuVertex = new ToolbarMenuClass(); m_toolbarMenuSketch.AddItem("esriControls.ControlsEditingSketchContextMenu",0,0,false,esriCommandStyles.esriCommandStyleTextOnly); m_toolbarMenuVertex.AddItem("esriControls.ControlsEditingVertexContextMenu",0,0,false,esriCommandStyles.esriCommandStyleTextOnly); //Create an operation stack for the undo and redo commands to use IOperationStack operationStack = new ControlsOperationStackClass(); axToolbarControl1.OperationStack = operationStack; axToolbarControl2.OperationStack = operationStack; //Instantiate the EngineEditor singleton m_engineEditor = new EngineEditorClass(); //Create each command on the ToolbarMenu so that the Accelerator Keys are recognized. //Alternatively the user must popup the menu before using the Accelerator Keys long itemCount = m_toolbarMenuSketch.CommandPool.Count; for (int i = 0; i < itemCount; i++) { ICommand pCommand = m_toolbarMenuSketch.CommandPool.get_Command(i); pCommand.OnCreate(axMapControl1.Object); } //Share the commandpool with the ToolbarMenu m_toolbarMenuSketch.CommandPool = m_CommandPool; m_toolbarMenuVertex.CommandPool = m_CommandPool; }
public void SetUp() { _pool = new CommandPool(); }
public TravelPanel(IHumanActorTaskSource <ISectorTaskSourceContext> humanActorTaskSource, IUiContentStorage uiContentStorage, ICommandPool commandPool, ServiceProviderCommandFactory commandFactory, ICommandLoopContext commandLoopContext) { _humanActorTaskSource = humanActorTaskSource; _uiContentStorage = uiContentStorage; _commandPool = commandPool; _commandFactory = commandFactory; _commandLoopContext = commandLoopContext; _autoplayModeButton = new IconButton( texture: uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), iconData: new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT) ), rect: new Rectangle(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT) ); _autoplayModeButton.OnClick += AutoplayModeButton_OnClick; _autoplayModeButtonTitle = string.Format(UiResources.SwitchAutomodeButtonTitle, UiResources.SwitchAutomodeButtonOffTitle); var personPropButton = new IconButton( texture: uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), iconData: new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(16, 0, BUTTON_WIDTH, BUTTON_HEIGHT) ), rect: new Rectangle(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT)); personPropButton.OnClick += PersonEquipmentButton_OnClick; _personPropButton = personPropButton; var personStatsButton = new IconButton( texture: uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), iconData: new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(32, 0, BUTTON_WIDTH, BUTTON_HEIGHT) ), rect: new Rectangle(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT)); personStatsButton.OnClick += PersonStatsButton_OnClick; var personTraitsButton = new IconButton( texture: uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), iconData: new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(48, 32, BUTTON_WIDTH, BUTTON_HEIGHT) ), rect: new Rectangle(48, 32, BUTTON_WIDTH, BUTTON_HEIGHT)); personTraitsButton.OnClick += PersonTraitsButton_OnClick; var gameSpeedButton = new IconButton( texture: uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), iconData: new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(16, 32, BUTTON_WIDTH, BUTTON_HEIGHT) ), rect: new Rectangle(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT)); gameSpeedButton.OnClick += GameSpeedButton_OnClick; _personStatsButton = personStatsButton; var idleButton = new IconButton(texture: uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), iconData: new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(32, 32, BUTTON_WIDTH, BUTTON_HEIGHT) ), rect: new Rectangle(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT)); idleButton.OnClick += IdleButton_OnClick; _idleButton = idleButton; var fastDeathButton = new IconButton(texture: uiContentStorage.GetSmallVerticalButtonBackgroundTexture(), iconData: new IconData( uiContentStorage.GetSmallVerticalButtonIconsTexture(), new Rectangle(32, 32, BUTTON_WIDTH, BUTTON_HEIGHT) ), rect: new Rectangle(0, 0, BUTTON_WIDTH, BUTTON_HEIGHT)); fastDeathButton.OnClick += FastDeathButton_OnClick; #if DEBUG _buttons = new[] { _autoplayModeButton, personPropButton, personStatsButton, personTraitsButton, idleButton, gameSpeedButton, fastDeathButton }; #else _buttons = new[] { personPropButton, personStatsButton, personTraitsButton, idleButton }; #endif }