protected void OnButtonReleaseEvent(UICommandElement element, object sender, ButtonReleaseEventArgs args) { GameConfigButtonDescriptor commandDescriptor = element.GetCommandDescriptor(); if (args.Event.Button == 1) { MainApp.GetInstance().OnButtonPressEvent(commandDescriptor); } else if (args.Event.Button == 3) { Gtk.Menu rightButtonMenu = new Gtk.Menu(); Gtk.MenuItem menuItem = new Gtk.MenuItem("Remove command"); menuItem.ButtonReleaseEvent += OnRemoveCommandButtonPressed; menuItem.Data.Add("UICommandElement", element); rightButtonMenu.Append(menuItem); menuItem = new Gtk.MenuItem("Edit command"); menuItem.ButtonReleaseEvent += OnEditCommandButtonPressed; menuItem.Data.Add("UICommandElement", element); rightButtonMenu.Append(menuItem); rightButtonMenu.ShowAll(); rightButtonMenu.Popup(); } }
public void AddNewButton(GameConfigButtonDescriptor buttonDescriptor, int sectionIndex) { UISection sectionSelected = _uiSections[sectionIndex]; sectionSelected.AddButton(buttonDescriptor); RefreshCanvas(); }
private void OnEditCommandButtonPressed(object sender, ButtonReleaseEventArgs e) { Gtk.MenuItem sourceMenuOption = Utils.static_cast <Gtk.MenuItem>(sender); object commandElementData = sourceMenuOption.Data["UICommandElement"]; UICommandElement uiCommandElement = Utils.dynamic_cast <UICommandElement>(commandElementData); GameConfigButtonDescriptor commandDescriptor = uiCommandElement.GetCommandDescriptor(); _parent.OnEditCommandButtonPressed(uiCommandElement, commandDescriptor); }
public void OnDropUIElement(UICommandElement uiCommandElement) { GameConfigButtonDescriptor commandDescriptor = uiCommandElement.GetCommandDescriptor(); int currentSectionIndex = 0; //remove it from UI foreach (UISection section in _uiSections) { if (section.GetUIElements().Exists(element => element == uiCommandElement)) { section.GetUIElements().Remove(uiCommandElement); ++currentSectionIndex; break; } } //remove it from DataBase _gameConfigDB.RemoveCommand(commandDescriptor); //find target section and position int sectionIndex = 0; UISection sectionTarget = null; Point commandLocation = uiCommandElement.GetDragLocation(); foreach (UISection section in _uiSections) { if (section.IsPointInside(commandLocation)) { sectionTarget = section; break; } ++sectionIndex; } if (sectionTarget == null) { sectionIndex = GetNearestSectionIndex(commandLocation); sectionTarget = _uiSections[sectionIndex]; } int elementIndex = sectionTarget.GetElementIndex(commandLocation); if (elementIndex < 0) { elementIndex = sectionTarget.GetUIElements().Count; } //add it to UI sectionTarget.InsertButtonAt(elementIndex, uiCommandElement); //add it to DataBase _gameConfigDB.AddCommandAtLocation(commandDescriptor, sectionIndex, elementIndex); RefreshCanvas(); }
public WindowAddExposedCommand(UITabPage parent, UICommandElement uiCommandElement, GameConfigButtonDescriptor commandDescriptor) : base(Gtk.WindowType.Toplevel) { this.Build(); _parent = parent; _editCommandDescriptor = commandDescriptor; _editUICommandElement = uiCommandElement; _inputTittle.Text = _editCommandDescriptor._tittle; _inputCommand.Text = _editCommandDescriptor._command; RefreshCommandPickerVisibility(); }
private void OnRemoveCommandButtonPressed(object sender, ButtonReleaseEventArgs e) { Gtk.MenuItem sourceMenuOption = Utils.static_cast <Gtk.MenuItem>(sender); UICommandElement uiCommandElement = Utils.dynamic_cast <UICommandElement>(sourceMenuOption.Data["UICommandElement"]); GameConfigButtonDescriptor commandDescriptor = uiCommandElement.GetCommandDescriptor(); _UIElements.Remove(uiCommandElement); uiCommandElement.Uninit(); _parent.OnRemoveCommandButtonPressed(commandDescriptor); }
public GameConfigButtonDescriptor AddNewSequenceCommand(GameConfigButtonDescriptor.Etype type, string tittle, List <KeyValuePair <string, string> > commandList, int sectionIndex) { GameConfigButtonDescriptor newCommand = new GameConfigButtonDescriptor(); newCommand._tittle = tittle; newCommand._type = type; newCommand.AddSequenceCommand(commandList); _sections[sectionIndex]._buttons.Add(newCommand); return(newCommand); }
public void OnAddNewSequenceCommandButtonClick(string tittle, List <KeyValuePair <string, string> > commandList, int sectionIndex) { UIUtils.ShutDownWindow(ref _windowAddSequenceCommand); GameConfigButtonDescriptor newButtonDescriptor = _gameConfigDB.AddNewSequenceCommand (GameConfigButtonDescriptor.Etype.MultiCommand , tittle , commandList , sectionIndex); AddNewButton(newButtonDescriptor, sectionIndex); }
public void OnAddNewCommandButtonPress(string tittle, string command, int sectionIndex) { UIUtils.ShutDownWindow(ref _windowAddExposedCommand); GameConfigButtonDescriptor newButtonDescriptor = _gameConfigDB.AddNewCommand (GameConfigButtonDescriptor.Etype.ExposedArgument , tittle , command , string.Empty , sectionIndex); AddNewButton(newButtonDescriptor, sectionIndex); }
public void OnEditSequenceCommandButtonPress (UICommandElement uiCommandElement , GameConfigButtonDescriptor buttonDescriptor , string tittle , List <KeyValuePair <string, string> > commandList) { UIUtils.ShutDownWindow(ref _windowAddSequenceCommand); buttonDescriptor._tittle = tittle; buttonDescriptor.AddSequenceCommand(commandList); uiCommandElement.Refresh(); }
public GameConfigButtonDescriptor AddNewCommand(GameConfigButtonDescriptor.Etype type, string tittle, string command, string arguments, int sectionIndex) { GameConfigButtonDescriptor newCommand = new GameConfigButtonDescriptor(); newCommand._tittle = tittle; newCommand._type = type; newCommand._command = command; newCommand._arguments = arguments; _sections[sectionIndex]._buttons.Add(newCommand); return(newCommand); }
public void RemoveCommand(GameConfigButtonDescriptor commandDescriptor) { foreach (GameConfigSectionDescriptor section in _sections) { foreach (GameConfigButtonDescriptor command in section._buttons) { if (command == commandDescriptor) { section._buttons.Remove(command); break; } } } }
public WindowAddSequenceCommand(UITabPage parent, UICommandElement uiCommandElement, GameConfigButtonDescriptor commandDescriptor) : base(Gtk.WindowType.Toplevel) { this.Build(); _parent = parent; _commandList = new List <WidgetSequenceCommandEntry>(); _editCommandDescriptor = commandDescriptor; _editUICommandElement = uiCommandElement; _inputTitle.Text = _editCommandDescriptor._tittle; foreach (GameConfigCommandDescriptor command in commandDescriptor._commandList) { AddCommandEntry(command); } }
public void OnButtonPressEvent(GameConfigButtonDescriptor commandDescriptor) { if (commandDescriptor._type == GameConfigButtonDescriptor.Etype.FixedArgument || commandDescriptor._type == GameConfigButtonDescriptor.Etype.ExposedArgument) { ExecuteCommand(commandDescriptor._command, commandDescriptor._arguments); } else if (commandDescriptor._type == GameConfigButtonDescriptor.Etype.MultiCommand) { foreach (GameConfigCommandDescriptor command in commandDescriptor._commandList) { ExecuteCommand(command._command, command._arguments); } } }
public void AddButton(GameConfigButtonDescriptor buttonDescriptor) { UICommandElement uiElement = null; if (buttonDescriptor._type == GameConfigButtonDescriptor.Etype.FixedArgument) { uiElement = new UICommandButton(_parent.GetCanvas(), buttonDescriptor); } else if (buttonDescriptor._type == GameConfigButtonDescriptor.Etype.ExposedArgument) { uiElement = new UICommandExposedArgument(_parent.GetCanvas(), buttonDescriptor); } else if (buttonDescriptor._type == GameConfigButtonDescriptor.Etype.MultiCommand) { uiElement = new UICommandSequence(_parent.GetCanvas(), buttonDescriptor); } uiElement.Init(); uiElement.ElementPressEvent += OnButtonReleaseEvent; _UIElements.Add(uiElement); Dispose(); }
public void OnEditCommandButtonPressed(UICommandElement uiCommandElement, GameConfigButtonDescriptor commandDescriptor) { UIUtils.ShutDownWindowSafe(ref _windowAddSingleCommand); UIUtils.ShutDownWindowSafe(ref _windowAddExposedCommand); UIUtils.ShutDownWindowSafe(ref _windowAddSequenceCommand); if (commandDescriptor._type == GameConfigButtonDescriptor.Etype.FixedArgument) { _windowAddSingleCommand = new WindowAddSingleCommand(this, uiCommandElement, commandDescriptor); MoveWindowToWindowPos(_windowAddSingleCommand); _windowAddSingleCommand.Show(); } else if (commandDescriptor._type == GameConfigButtonDescriptor.Etype.ExposedArgument) { _windowAddExposedCommand = new WindowAddExposedCommand(this, uiCommandElement, commandDescriptor); MoveWindowToWindowPos(_windowAddExposedCommand); _windowAddExposedCommand.Show(); } else if (commandDescriptor._type == GameConfigButtonDescriptor.Etype.MultiCommand) { _windowAddSequenceCommand = new WindowAddSequenceCommand(this, uiCommandElement, commandDescriptor); MoveWindowToWindowPos(_windowAddSequenceCommand); _windowAddSequenceCommand.Show(); } }
public UICommandExposedArgument(Gtk.Fixed parent, GameConfigButtonDescriptor commandDescriptor) : base(parent, commandDescriptor) { }
public void OnRemoveCommandButtonPressed(GameConfigButtonDescriptor commandDescriptor) { _gameConfigDB.RemoveCommand(commandDescriptor); RefreshCanvas(); }
public UICommandElement(Gtk.Fixed parent, GameConfigButtonDescriptor commandDescriptor) { _parent = parent; _commandDescriptor = commandDescriptor; }
public void AddCommandAtLocation(GameConfigButtonDescriptor commandDescriptor, int sectionIndex, int commandIndex) { _sections[sectionIndex]._buttons.Insert(commandIndex, commandDescriptor); }
public void OnEditExposedCommandButtonPress(UICommandElement uiCommandElement, GameConfigButtonDescriptor buttonDescriptor, string tittle, string command, string arguments) { UIUtils.ShutDownWindow(ref _windowAddExposedCommand); buttonDescriptor._tittle = tittle; buttonDescriptor._command = command; buttonDescriptor._arguments = arguments; uiCommandElement.Refresh(); }
public FileOperationResult Load() { try { XmlReader reader = XmlReader.Create(_descriptorFile); while (reader.Read()) { // Only detect start elements. if (reader.IsStartElement()) { // Get element name and switch on it. switch (reader.Name) { case "commands": { _gameConfigDB = new GameConfigDB(); string attribute = reader["name"]; Config.AssertResource(attribute); _gameConfigDB.SetName(attribute); attribute = reader["creationDate"]; Config.AssertResource(attribute); _gameConfigDB.SetCreationDate(Int32.Parse(attribute)); } break; case "section": { if (_currentGameConfigSectionDescriptor != null) { _gameConfigDB.AddSection(_currentGameConfigSectionDescriptor); _currentGameConfigSectionDescriptor = null; } _currentGameConfigSectionDescriptor = new GameConfigSectionDescriptor(); string attribute = reader["tittle"]; Config.AssertResource(attribute); _currentGameConfigSectionDescriptor._tittle = Utils.DecodeHTML(attribute); } break; case "command": { _currentGameConfigButtonDescriptor = new GameConfigButtonDescriptor(); string attribute = reader["type"]; Config.AssertResource(attribute); GameConfigButtonDescriptor.Etype type = Utils.static_cast <GameConfigButtonDescriptor.Etype>(Int32.Parse(attribute)); _currentGameConfigButtonDescriptor._type = type; attribute = reader["tittle"]; Config.AssertResource(attribute); _currentGameConfigButtonDescriptor._tittle = Utils.DecodeHTML(attribute); if (type == GameConfigButtonDescriptor.Etype.MultiCommand) { _currentGameConfigButtonDescriptor._commandList = new List <GameConfigCommandDescriptor>(); } else { attribute = reader["command"]; Config.AssertResource(attribute); _currentGameConfigButtonDescriptor._command = Utils.DecodeHTML(attribute); } if (type == GameConfigButtonDescriptor.Etype.FixedArgument || type == GameConfigButtonDescriptor.Etype.ExposedArgument) { attribute = reader["arguments"]; Config.AssertResource(attribute); _currentGameConfigButtonDescriptor._arguments = Utils.DecodeHTML(attribute); } _currentGameConfigSectionDescriptor._buttons.Add(_currentGameConfigButtonDescriptor); } break; case "command_sequence": { GameConfigCommandDescriptor commandDescriptor = new GameConfigCommandDescriptor(); string attribute = reader["command"]; Config.AssertResource(attribute); commandDescriptor._command = Utils.DecodeHTML(attribute); attribute = reader["arguments"]; Config.AssertResource(attribute); commandDescriptor._arguments = Utils.DecodeHTML(attribute); _currentGameConfigButtonDescriptor._commandList.Add(commandDescriptor); } break; } } } if (_currentGameConfigSectionDescriptor != null) { _gameConfigDB.AddSection(_currentGameConfigSectionDescriptor); _currentGameConfigSectionDescriptor = null; } reader.Close(); return(new FileOperationResult(true)); } catch (System.Exception ex) { return(new FileOperationResult(false, ex.Message)); } }
public UICommandButton(Gtk.Fixed parent, GameConfigButtonDescriptor commandDescriptor) : base(parent, commandDescriptor) { }