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 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 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(); }
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 SetDraggingElement(UICommandElement draggedElement) { UICommandElement previousDraggedElement = _draggedElement; _draggedElement = draggedElement; if (previousDraggedElement != null && draggedElement == null) { OnDropEvent?.Invoke(previousDraggedElement); } }
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 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(); }
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 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 Dispose() { bool isIntersecting = false; _nextPosition = _origin; UIUtils.SetWidgetPosition(_parent.GetCanvas(), _label, _nextPosition); _nextPosition.Y += incrementSection.Y; UICommandElement dragElement = DraggingController.GetInstance().GetDraggedElement(); foreach (UICommandElement element in _UIElements) { if (dragElement != null) { if (element == dragElement) { continue; } if (!isIntersecting && IsElementInsideTargetBoundaries(dragElement, _nextPosition)) { isIntersecting = true; _nextPosition.X += increment.X; if (_nextPosition.X > _boundaryX) { _nextPosition.X = _origin.X; _nextPosition.Y += increment.Y; } } } element.SetLocation(_nextPosition); _nextPosition.X += increment.X; if (_nextPosition.X > _boundaryX) { _nextPosition.X = _origin.X; _nextPosition.Y += increment.Y; } } _nextPosition.X = _origin.X; _nextPosition.Y += increment.Y; }
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 void InsertButtonAt(int targetIndex, UICommandElement uiCommandElement) { _UIElements.Insert(targetIndex, uiCommandElement); }
private bool IsElementInsideTargetBoundaries(UICommandElement element, Point target) { return(IsPointInsideTargetBoundaries(element.GetDragLocation(), target)); }