示例#1
0
 public void NotifyClientsGUIControlAddedOrRemoved(GUI owningGUI, GUIControl control)
 {
     if (GUIControlAddedOrRemoved != null)
     {
         GUIControlAddedOrRemoved(owningGUI, control);
     }
 }
示例#2
0
文件: GUI.cs 项目: jdiperla/ags
 public void DeleteControl(GUIControl controlToDelete)
 {
     BringControlToFront(controlToDelete);
     _controls.Remove(controlToDelete);
     int currentID = controlToDelete.ID;
     foreach (GUIControl control in _controls)
     {
         if (control.ID > currentID)
         {
             control.ID--;
         }
     }
 }
示例#3
0
文件: GUI.cs 项目: jdiperla/ags
        public void SendControlToBack(GUIControl controlToSend)
        {
            int currentZOrder = controlToSend.ZOrder;
            foreach (GUIControl control in _controls)
            {
                if (control.ZOrder < currentZOrder)
                {
                    control.ZOrder++;
                }
            }

            controlToSend.ZOrder = 0;
        }
示例#4
0
 private GUIButtonOrTextWindowEdge(GUIControl control)
 {
     _ctrl = control;
 }
示例#5
0
文件: GUI.cs 项目: jdiperla/ags
        public void BringControlToFront(GUIControl controlToSend)
        {
            int currentZOrder = controlToSend.ZOrder;
            foreach (GUIControl control in _controls)
            {
                if (control.ZOrder > currentZOrder)
                {
                    control.ZOrder--;
                }
            }

            controlToSend.ZOrder = _controls.Count - 1;
        }
示例#6
0
        private void ShowContextMenu(int x, int y, GUIControl control)
        {
            if (_gui is NormalGUI)
            {

                ContextMenuStrip menu = new ContextMenuStrip();
                if (control != null)
                {
                menu.Items.Add(new ToolStripMenuItem("Bring to Front", null, new EventHandler(BringToFrontClick), "BringToFront"));
                menu.Items.Add(new ToolStripMenuItem("Send to Back", null, new EventHandler(SendToBackClick), "SendToBack"));

                    if (_selected.Count > 1)
                    {
                        if (!AllSelectedInSameGroup() || control.MemberOf == null)
                        {
                            menu.Items.Add(new ToolStripMenuItem("Group", null, new EventHandler(Group), "LockControl"));
                        }
                        if (control.MemberOf != null) menu.Items.Add(new ToolStripMenuItem("Ungroup", null, new EventHandler(Ungroup), "LockControl"));
                        menu.Items.Add(new ToolStripMenuItem("Lock All", null, new EventHandler(LockControl), "LockControl"));
                        menu.Items.Add(new ToolStripMenuItem("Unlock All", null, new EventHandler(UnlockControl), "LockControl"));
                        menu.Items.Add(new ToolStripMenuItem("Distribute Vertically", null, new EventHandler(DistributeVertiClick), "DistVert"));
                        menu.Items.Add(new ToolStripMenuItem("Distribute Horizontally", null, new EventHandler(DistributeHorizClick), "DistVert"));
                        menu.Items.Add(new ToolStripMenuItem("Align Left", null, new EventHandler(AlignLeftClick), "DistVert"));
                        menu.Items.Add(new ToolStripMenuItem("Align Top", null, new EventHandler(AlignTopClick), "DistVert"));
                    }
                    else
                    {
                        if (control.Locked)
                        {
                            menu.Items.Add(new ToolStripMenuItem("Unlock", null, new EventHandler(UnlockControl), "LockControl"));
                        }
                        else
                        {
                            menu.Items.Add(new ToolStripMenuItem("Lock", null, new EventHandler(LockControl), "LockControl"));
                        }

                    }
                menu.Items.Add(new ToolStripSeparator());

                    menu.Items.Add(new ToolStripMenuItem("Copy", null, new EventHandler(CopyControlClick), Keys.Control & Keys.C));
                menu.Items.Add(new ToolStripMenuItem("Delete", null, new EventHandler(DeleteControlClick), Keys.Delete));
                }

                if (GUIControl.AvailableOnClipboard()) menu.Items.Add(new ToolStripMenuItem("Paste", null, new EventHandler(PasteControlClick), Keys.Control & Keys.V));

                if (menu.Items.Count > 0) menu.Show(bgPanel, x, y);
            }
        }
示例#7
0
 private void WriteGUIControl(GUIControl control, int flags)
 {
     WriteGUIControl(control, flags, new string[0]);
 }
示例#8
0
        private void PasteControlClick(object sender, EventArgs e)
        {
            if (_gui.Controls.Count >= GUI.MAX_CONTROLS_PER_GUI)
            {
                Factory.GUIController.ShowMessage("You already have the maximum number of controls on this GUI, and cannot add any more.", MessageBoxIcon.Warning);
                return;
            }
            GUIControl newControl = GUIControl.GetFromClipBoard();
            if (newControl != null)
            {

                newControl.Name = Factory.AGSEditor.GetFirstAvailableScriptName(newControl.ControlType);
                newControl.ZOrder = _gui.Controls.Count;
                newControl.ID = _gui.Controls.Count;
                newControl.MemberOf = null;

                newControl.Left = _currentMouseX / Factory.AGSEditor.CurrentGame.GUIScaleFactor;
                newControl.Top = _currentMouseY / Factory.AGSEditor.CurrentGame.GUIScaleFactor;
                _gui.Controls.Add(newControl);
                _selected.Clear();
                _selectedControl = newControl;
                _selected.Add(newControl);

                RaiseOnControlsChanged();

                Factory.GUIController.SetPropertyGridObject(newControl);

                bgPanel.Invalidate();
                UpdateCursorImage();
                // Revert back to Select cursor
                OnCommandClick(Components.GuiComponent.MODE_SELECT_CONTROLS);
            }
        }
示例#9
0
        private void SetSelectedControlToControlAtPosition(int mouseX, int mouseY)
        {
            GUIControl controlFound = null;
            int zorderFound = -1;
            foreach (GUIControl control in _gui.Controls)
            {
                if ((mouseX >= control.Left) && (mouseX < control.Left + control.Width) &&
                    (mouseY >= control.Top) && (mouseY < control.Top + control.Height) &&
                    (control.ZOrder > zorderFound))
                {
                    controlFound = control;
                    zorderFound = control.ZOrder;
                }
            }

            _selectedControl = controlFound;

            // check for ctrl

            if (controlFound != null)
            {
                if (Factory.NativeProxy.IsControlPressed())
                {
                    if (_selected.Contains(controlFound) && _selected.Count > 1)
                    {
                        _selected.Remove(controlFound);
                        if (_selected.Count > 0)
                        {
                            _selectedControl = _selected[_selected.Count - 1];
                        }
                        else _selectedControl = null;

                    }
                    else if (!_selected.Contains(controlFound))
                    {
                        if (controlFound.MemberOf != null)
                        {
                            foreach (GUIControl gc in controlFound.MemberOf)
                            {
                                _selected.Add(gc);
                            }
                        }
                        else _selected.Add(controlFound);
                    }
                }
                else
                {

                    if (!_selected.Contains(controlFound))
                    {
                        _selected.Clear();
                        if (controlFound.MemberOf != null)
                        {
                            foreach (GUIControl gc in controlFound.MemberOf)
                            {
                                _selected.Add(gc);
                            }
                        }
                        else _selected.Add(controlFound);

                    }
                    _selectedControl = controlFound;
                }
            }
            else if (!Factory.NativeProxy.IsControlPressed())
            {
                _selected.Clear();
                _selectedControl = null;
            }

            if (_selectedControl == null)
            {
                DeSelectControl();
            }
        }
示例#10
0
 private void DeSelectControl()
 {
     _selectedControl = null;
     _movingControl = false;
     _resizingControl = false;
 }
示例#11
0
 void GUIController_OnPropertyObjectChanged(object newPropertyObject)
 {
     if (newPropertyObject is GUIControl)
     {
         _selectedControl = (GUIControl)newPropertyObject;
         if (fromCombo)
         {
             _selected.Clear();
             _selected.Add((GUIControl)newPropertyObject);
         }
         fromCombo = true;
     }
     else if (newPropertyObject is GUI)
     {
         DeSelectControl();
         _selected.Clear();
     }
     bgPanel.Invalidate();
 }
示例#12
0
 private void DeleteControlClick(object sender, EventArgs e)
 {
     if (_selectedControl != null && !_selectedControl.Locked)
     {
         _selected.Remove(_selectedControl);
         _gui.DeleteControl(_selectedControl);
         if (_selectedControl.MemberOf != null)
         {
             _selectedControl.MemberOf.RemoveFromGroup(_selectedControl);
         }
         if (_selected.Count > 0)
         {
             _selectedControl = _selected[_selected.Count - 1];
         }
         else _selectedControl = null;
         RaiseOnControlsChanged();
         if (_selectedControl != null)
         {
             Factory.GUIController.SetPropertyGridObject(_selectedControl);
         }
         else
         {
             Factory.GUIController.SetPropertyGridObject(_gui);
         }
         bgPanel.Invalidate();
     }
 }
示例#13
0
        private void CreateNewControl()
        {
            int left, top, width, height;
            GetSelectionRectangle(out left, out top, out width, out height);
            ConvertCoordinatesToGameUnits(ref left, ref top, ref width, ref height);

            if ((width < 2) || (height < 2))
            {
                return;
            }

            GUIControl newControl = null;

            switch (_controlAddMode)
            {
                case GUIAddType.Button:
                    newControl = new GUIButton(left, top, width, height);
                    break;
                case GUIAddType.Label:
                    newControl = new GUILabel(left, top, width, height);
                    break;
                case GUIAddType.TextBox:
                    newControl = new GUITextBox(left, top, width, height);
                    break;
                case GUIAddType.ListBox:
                    newControl = new GUIListBox(left, top, width, height);
                    break;
                case GUIAddType.Slider:
                    newControl = new GUISlider(left, top, width, height);
                    break;
                case GUIAddType.InvWindow:
                    newControl = new GUIInventory(left, top, width, height);
                    break;
                default:
                    throw new AGSEditorException("Unknown control type added: " + _controlAddMode.ToString());
            }

            newControl.Name = Factory.AGSEditor.GetFirstAvailableScriptName(newControl.ControlType);
            newControl.ZOrder = _gui.Controls.Count;
            newControl.ID = _gui.Controls.Count;
            _gui.Controls.Add(newControl);
            _selectedControl = newControl;
            _selected.Clear();
            _selected.Add(newControl);

            RaiseOnControlsChanged();

            Factory.GUIController.SetPropertyGridObject(newControl);

            bgPanel.Invalidate();
            UpdateCursorImage();
            // Revert back to Select cursor
            OnCommandClick(Components.GuiComponent.MODE_SELECT_CONTROLS);
        }
示例#14
0
        private void bgPanel_MouseUp(object sender, MouseEventArgs e)
        {
            _snappedx = -1;
            _snappedy = -1;

            if ((_drawingSelectionBox) && (e.X == _selectionBoxX) && (e.Y == _selectionBoxY))
            {
                _drawingSelectionBox = false;
            }

            if (_addingControl)
            {
                _addingControl = false;
                CreateNewControl();
            }
            else if (_resizingControl)
            {
                _resizingControl = false;
            }
            else if (_drawingSelectionBox)
            {
               _drawingSelectionBox = false;
               foreach (GUIControl _gc in _gui.Controls)
               {
                   if (_selectionRect.Contains(_gc.GetRectangle()) && !_selected.Contains(_gc)) _selected.Add(_gc);
               }
               if (_selected.Count > 0) _selectedControl = _selected[_selected.Count - 1];
               bgPanel.Invalidate();
            }
            else
            {
                _movingControl = false;
                if (_selectedControl != null)
                {

                    Factory.GUIController.SetPropertyGridObject(_selectedControl);
                }
                else
                {
                    Factory.GUIController.SetPropertyGridObject(_gui);
                }
                bgPanel.Invalidate();

                if ((e.Button == MouseButtons.Right))
                {
                    ShowContextMenu(e.X, e.Y, _selectedControl);
                }
            }
        }
示例#15
0
 public static int CompareByLeft(GUIControl x, GUIControl y)
 {
     if (x.Left < y.Left) return 1;
     else if (x.Left == y.Left) return 0;
     else return -1;
 }
示例#16
0
 /// <summary>
 /// Writes the common elements of this GUIControl to the file. Type-specific
 /// data is written only by the respective method for that type.
 /// </summary>
 private void WriteGUIControl(GUIControl control, int flags, string[] events)
 {
     writer.Write(flags); // flags
     writer.Write(control.Left);
     writer.Write(control.Top);
     writer.Write(control.Width);
     writer.Write(control.Height);
     writer.Write(control.ZOrder);
     writer.Write(0); // activated
     FilePutNullTerminatedString(control.Name, NativeConstants.MAX_GUIOBJ_SCRIPTNAME_LEN + 1, writer);
     writer.Write(events.Length); // numSupportedEvents
     foreach (string sevent in events)
     {
         FilePutNullTerminatedString(sevent, NativeConstants.MAX_GUIOBJ_EVENTHANDLER_LEN + 1, writer);
     }
 }
示例#17
0
 public static int CompareByTop(GUIControl x, GUIControl y)
 {
     if (x.Top < y.Top) return 1;
     else if (x.Top == y.Top) return 0;
     else return -1;
 }
示例#18
0
        private void PasteControlClick(object sender, EventArgs e)
        {
            GUIControl newControl = GUIControl.GetFromClipBoard();
            if (newControl != null)
            {

                newControl.Name = Factory.AGSEditor.GetFirstAvailableScriptName(newControl.ControlType);
                newControl.ZOrder = _gui.Controls.Count;
                newControl.ID = _gui.Controls.Count;
                newControl.MemberOf = null;

                newControl.Left = _currentMouseX / Factory.AGSEditor.CurrentGame.GUIScaleFactor;
                newControl.Top = _currentMouseY / Factory.AGSEditor.CurrentGame.GUIScaleFactor;
                _gui.Controls.Add(newControl);
                _selected.Clear();
                _selectedControl = newControl;
                _selected.Add(newControl);

                RaiseOnControlsChanged();
                Factory.AGSEditor.CurrentGame.NotifyClientsGUIControlAddedOrRemoved(_gui, newControl);

                Factory.GUIController.SetPropertyGridObject(newControl);

                bgPanel.Invalidate();
                UpdateCursorImage();
                // Revert back to Select cursor
                OnCommandClick(Components.GuiComponent.MODE_SELECT_CONTROLS);
            }
        }