Пример #1
0
        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();
            }
        }
Пример #2
0
 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();
 }
Пример #3
0
        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();
        }
Пример #4
0
        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);
            }
        }
Пример #6
0
        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();
 }
Пример #8
0
        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);
            }
        }
Пример #10
0
        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;
        }
Пример #11
0
        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();
        }
Пример #12
0
 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();
     }
 }
Пример #13
0
 public void InsertButtonAt(int targetIndex, UICommandElement uiCommandElement)
 {
     _UIElements.Insert(targetIndex, uiCommandElement);
 }
Пример #14
0
 private bool IsElementInsideTargetBoundaries(UICommandElement element, Point target)
 {
     return(IsPointInsideTargetBoundaries(element.GetDragLocation(), target));
 }