コード例 #1
0
ファイル: TabControl.cs プロジェクト: LaudableBauble/Bedlam
        /// <summary>
        /// Add a tab page to the tab control.
        /// </summary>
        /// <param name="item">The items to be displayed on the new tab page.</param>
        /// <param name="title">The title of the tab page.</param>
        public void AddTab(Component item, string title)
        {
            //Create the new tabpage.
            TabPage tab = new TabPage(_GUI, _Position + new Vector2(_Tabs.Count * 55, 0), 50, 25);

            //set the caption of the tab page.
            tab.Title = title;

            //Add the item to the tabpage.
            tab.AddItem(item);
            //Add the tabpage to this tab control.
            _Tabs.Add(tab);
            Add(tab);

            //Change the selected tab to this.
            TabSelectInvoke(tab);

            //Perform the additional event subscribing here.
            tab.MouseClick += OnTabClick;
        }
コード例 #2
0
ファイル: Expander.cs プロジェクト: LaudableBauble/Bedlam
        /// <summary>
        /// Add an item to the expander control.
        /// </summary>
        /// <param name="item">The item to be displayed on the expander control.</param>
        public void AddItem(Component item)
        {
            //Add the item to this control.
            _ItemContent.Add(item);
            _Layout.Add(item);
            Add(item);

            //Change the size of the layout to accomodate for the new item.
            _Layout.SetToDesiredSize();
            //Calculate the complete size of the expander.
            UpdateTrueSize();

            //Perform the additional event subscribing here.
        }
コード例 #3
0
 /// <summary>
 /// Remove events from an item.
 /// </summary>
 /// <param name="item">The item to remove events from.</param>
 private void RemoveItemEvents(Component item)
 {
     //Unsubscribe some events from this item.
     item.Dispose -= OnItemDispose;
 }
コード例 #4
0
ファイル: List.cs プロジェクト: LaudableBauble/Bedlam
        /// <summary>
        /// An item has been added.
        /// </summary>
        /// <param name="item">The added item.</param>
        protected void ItemAddedInvoke(Component item)
        {
            //Let the list know it has been changed.
            _IsDirty = true;

            //If someone has hooked up a delegate to the event, fire it.
            if (ItemAdded != null) { ItemAdded(this, new ListItemAddedEventArgs((ListItem)item)); }
        }
コード例 #5
0
ファイル: Events.cs プロジェクト: LaudableBauble/Bedlam
 /// <summary>
 /// Create the event used when an item has had a change in focus for some reason.
 /// </summary>
 /// <param name="item">The selected item.</param>
 public FocusChangeEventArgs(Component item)
 {
     //Pass along the data.
     _Item = item;
 }
コード例 #6
0
ファイル: Component.cs プロジェクト: LaudableBauble/Bedlam
 /// <summary>
 /// Listen to the GUI's focus notification.
 /// <param name="item">The item that has gained focus.</param>
 /// </summary>
 protected virtual void OnFocusNotification(Component item)
 {
     //If you got solitary rights to focus, come and claim them.
     if (item == this) { FocusChangeInvoke(true); }
     //Otherwise relinquish focus.
     else { FocusChangeInvoke(false); }
 }
コード例 #7
0
ファイル: Component.cs プロジェクト: LaudableBauble/Bedlam
        /// <summary>
        /// Add a component.
        /// </summary>
        /// <param name="item">The component to add.</param>
        protected virtual Component Add(Component item)
        {
            //Add the component to the list of components.
            _Items.Add(item);
            item.Parent = this;
            item.DrawOrder = _Items.Count;

            //Load the item's content if necessary.
            if (_IsContentLoaded) { item.LoadContent(); }

            //Subscribe to some events.
            item.BoundsChange += OnItemBoundsChange;
            item.FocusChange += OnItemFocusChange;
            item.DrawOrderChange += OnDrawOrderChange;

            //Return the component.
            return item;
        }
コード例 #8
0
ファイル: Layout.cs プロジェクト: LaudableBauble/Bedlam
        /// <summary>
        /// Add a component to the layout and automatically choose an appropriate cell for it.
        /// </summary>
        /// <param name="component">The component to add.</param>
        public void Add(Component component)
        {
            //The cell position.
            int xCell;
            int yCell;

            //Find the 'best' empty cell and add the component to it.
            FindFirstEmptyCell(out xCell, out yCell);
            AddToCell(xCell, yCell, component);

            //Subscribe to some of the item's events.
            //component.BoundsChange += delegate(object sender, BoundsChangedEventArgs e) { UpdateLayout(); };

            //Finally update the grid layout to accomodate for the addition.
            RequestUpdate();
        }
コード例 #9
0
        /// <summary>
        /// Add an item to the GUI.
        /// </summary>
        /// <param name="item">The item to add.</param>
        public void AddItem(Component item)
        {
            //Add the item, try to load its content and update its draw order.
            _Items.Add(item);
            if (_IsContentLoaded) { item.LoadContent(); }
            item.DrawOrder = _Items.CompleteCount;

            //Hook up some events.
            AddItemEvents(item);
        }
コード例 #10
0
ファイル: LayoutCell.cs プロジェクト: LaudableBauble/Bedlam
 /// <summary>
 /// Create a layout grid cell.
 /// </summary>
 /// <param name="layout">The layout grid that this cell will be a part of.</param>
 /// <param name="component">The component this cell will contain.</param>
 public LayoutCell(Layout layout, Component component)
 {
     //Initialize some variables.
     Initialize(layout, component);
 }
コード例 #11
0
ファイル: LayoutCell.cs プロジェクト: LaudableBauble/Bedlam
        /// <summary>
        /// Initialize the layout grid.
        /// </summary>
        /// <param name="layout">The layout grid that this cell will be a part of.</param>
        /// <param name="component">The component this cell will contain.</param>
        public void Initialize(Layout layout, Component component)
        {
            //Initialize some variables.
            _Layout = layout;
            _Component = component;
            _Position = component.Position;
            _Width = component.Width;
            _Height = component.Height;
            _GoalWidth = _Width;
            _GoalHeight = _Height;
            _CellStyle = CellStyle.Dynamic;

            //Set some boundaries.
            _MinWidth = 0;
            _MaxWidth = 500;
            _MinHeight = 0;
            _MaxHeight = 500;

            //Subscribe to events.
            component.BoundsChange += OnItemBoundsChange;
        }
コード例 #12
0
ファイル: Form.cs プロジェクト: LaudableBauble/Bedlam
        /// <summary>
        /// Add a component to the form.
        /// </summary>
        /// <param name="item">The component to add.</param>
        public Component AddItem(Component item)
        {
            //Call the base method.
            base.Add(item);

            //Add the item to the layout.
            _Layout.Add(item);

            //Return the component.
            return item;
        }
コード例 #13
0
ファイル: List.cs プロジェクト: LaudableBauble/Bedlam
        /// <summary>
        /// An item has been selected.
        /// </summary>
        /// <param name="item">The selected item.</param>
        protected virtual void ItemSelectInvoke(Component item)
        {
            //Save the selected item.
            _SelectedItem = (ListItem)item;

            //If someone has hooked up a delegate to the event, fire it.
            if (ItemSelect != null) { ItemSelect(this, new ListItemSelectEventArgs((ListItem)item)); }
        }
コード例 #14
0
ファイル: Combobox.cs プロジェクト: LaudableBauble/Bedlam
 /// <summary>
 /// Tell the world that an item has been selected.
 /// </summary>
 /// <param name="item">The selected component.</param>
 protected void ItemSelectInvoke(Component item)
 {
     //If someone has hooked up a delegate to the event, fire it.
     if (ItemSelect != null) { ItemSelect(this, new ItemSelectEventArgs(item)); }
 }
コード例 #15
0
        /// <summary>
        /// Bring an item's particular family line to the front by changing its draw orders.
        /// </summary>
        /// <param name="item">The item to send to front.</param>
        public void BringToFront(Component item)
        {
            //The parent item.
            Component parent = item;

            //While the parent isn't null, go deeper into the rabbit hole and set their draw orders.
            while (parent != null) { parent.DrawOrder = 0; parent = parent.Parent; }
        }
コード例 #16
0
ファイル: TabPage.cs プロジェクト: LaudableBauble/Bedlam
        /// <summary>
        /// Add an item to the tabpage.
        /// </summary>
        /// <param name="item">The items to be displayed on the tab page.</param>
        public void AddItem(Component item)
        {
            //Call the base method.
            Add(item);

            //Make sure that the item follows the tab page's visibility demands.
            if (_IsHiding) { item.IsActive = false; }
        }
コード例 #17
0
        /// <summary>
        /// Remove an item from the GUI.
        /// </summary>
        /// <param name="item">The item to remove.</param>
        public void RemoveItem(Component item)
        {
            //Unsubscribe from the item.
            RemoveItemEvents(item);

            //Remove the item from the list of items.
            _Items.Remove(item);
            _ForegroundItems.Remove(item);
        }
コード例 #18
0
ファイル: Layout.cs プロジェクト: LaudableBauble/Bedlam
 /// <summary>
 /// Add a GUI component to a specified cell in the layout grid.
 /// Beware that you might overwrite a cell without warning.
 /// </summary>
 /// <param name="x">The horizontal position in the grid.</param>
 /// <param name="y">The vertical position in the grid.</param>
 /// <param name="component">The GUI component to add.</param>
 private void AddToCell(int x, int y, Component component)
 {
     //Add the component to the layout grid.
     _Grid[x, y] = new LayoutCell(this, component);
 }
コード例 #19
0
 /// <summary>
 /// Request focus to an item in the GUI.
 /// </summary>
 /// <param name="item">The item to focus upon.</param>
 public void RequestFocus(Component item)
 {
     //Add the item to the focus queue.
     _FocusQueue.Add(item);
 }
コード例 #20
0
ファイル: Component.cs プロジェクト: LaudableBauble/Bedlam
        /// <summary>
        /// Initialize the component.
        /// </summary>
        /// <param name="gui">The GUI that this component will be a part of.</param>
        /// <param name="position">The position of the component.</param>
        /// <param name="width">The width of this component.</param>
        /// <param name="height">The height of this component.</param>
        protected virtual void Initialize(GraphicalUserInterface gui, Vector2 position, float width, float height)
        {
            //Initialize some variables.
            _GUI = gui;
            _Position = position;
            _Sprite = new SpriteManager();
            _Width = width;
            _Height = height;
            _IsActive = true;
            _IsVisible = true;
            _HasFocus = false;
            _IsMouseHovering = false;
            _Transparence = .5f;
            _MaxTransparence = 0;
            _MinTransparence = 1;
            _DrawOrder = 0;
            _CellStyle = CellStyle.Dynamic;
            _Items = new List<Component>();
            _Parent = null;

            //Subscribe to events.
            _GUI.FocusNotification += OnFocusNotification;
        }
コード例 #21
0
 /// <summary>
 /// Add events from an item.
 /// </summary>
 /// <param name="item">The item to add events from.</param>
 private void AddItemEvents(Component item)
 {
     //Hook up some events from this item.
     item.DrawOrderChange += OnDrawOrderChange;
     item.MouseClick += OnItemClick;
     item.MouseDown += OnItemClick;
     item.Dispose += OnItemDispose;
 }
コード例 #22
0
ファイル: Events.cs プロジェクト: LaudableBauble/Bedlam
 /// <summary>
 /// Create the event used when an item is about to get disposed of.
 /// </summary>
 /// <param name="item">The item to be disposed of.</param>
 public DisposeEventArgs(Component item)
 {
     //Pass along the data.
     _Item = item;
 }
コード例 #23
0
        /// <summary>
        /// Notify all interested of which item claimed solitary right to focus this round.
        /// </summary>
        /// <param name="item">The item who gained focus.</param>
        private void FocusNotificationInvoke(Component item)
        {
            //Change the draw order of the item's family line.
            BringToFront(item);

            //If someone has hooked up a delegate to the event, fire it.
            if (FocusNotification != null) { FocusNotification(item); }
        }
コード例 #24
0
ファイル: Events.cs プロジェクト: LaudableBauble/Bedlam
 /// <summary>
 /// Create the event used when an item has been selected.
 /// </summary>
 /// <param name="item">The selected item.</param>
 public ItemSelectEventArgs(Component item)
 {
     //Pass along the data.
     _Item = item;
 }
コード例 #25
0
ファイル: List.cs プロジェクト: LaudableBauble/Bedlam
 /// <summary>
 /// Insert an item.
 /// </summary>
 /// <param name="index">The index of where to insert the item.</param>
 /// <param name="item">The item to insert.</param>
 public void InsertItem(int index, Component item)
 {
     //Insert the item to the list.
     _Items.Insert(index, item);
     if (_GUI.ContentManager != null) { item.LoadContent(); }
     //Hook up some events.
     item.MouseClick += OnItemClick;
     //Call the event.
     ItemAddedInvoke(item);
 }