Exemple #1
0
            /// <summary>
            /// Initializes a new instance of the <see cref="PeerTradeSidePanel"/> class.
            /// </summary>
            /// <param name="parent">The parent.</param>
            /// <param name="position">The position.</param>
            /// <param name="isSourceSide">If this control handles the source character's side.</param>
            public PeerTradeSidePanel(PeerTradeFormBase <TChar, TItem, TItemInfo> parent, Vector2 position, bool isSourceSide)
                : base(parent, position, Vector2.One)
            {
                _isSourceSide  = isSourceSide;
                _peerTradeForm = parent;

                ResizeToChildren = true;

                // Create the title label
                _title = new Label(this, Vector2.Zero)
                {
                    Text = (isSourceSide ? "Source" : "Target"), AutoResize = false
                };
                _title.ClientSize = new Vector2(_title.ClientSize.X, _title.Font.DefaultSize);

                // Create the slots
                var slotSize   = Vector2.Zero;
                var slotOffset = new Vector2(0, Title.Size.Y + 4);

                for (var i = 0; i < PeerTradingSettings.Instance.MaxTradeSlots; i++)
                {
                    var slotControl = CreateItemSlotControl(slotOffset, ItemSlotClientSize, new InventorySlot(i));

                    // If this is the first control we created, use it to determine the size of the slot controls
                    if (slotSize == Vector2.Zero)
                    {
                        slotSize = slotControl.Size;
                    }

                    // Update the slot offset, resetting the row to the start
                    if ((i > 0) && ((i + 1) % ItemSlotColumns == 0))
                    {
                        // Start new row below
                        slotOffset.X  = 0;
                        slotOffset.Y += slotSize.Y + ItemSlotPadding.Y;
                    }
                    else
                    {
                        // Move to the right on the existing row
                        slotOffset.X += slotSize.X + ItemSlotPadding.X;
                    }
                }

                // Create the accept label
                _acceptedLabel = new Label(this, new Vector2(0, ClientSize.Y))
                {
                    Text = "Not Accepted", AutoResize = false
                };
                AcceptedLabel.ClientSize = new Vector2(AcceptedLabel.ClientSize.X, AcceptedLabel.Font.DefaultSize);
                AcceptedLabel.Position   = new Vector2(ClientSize.X - AcceptedLabel.ClientSize.X, ClientSize.Y);

                // Create the cash label
                CreateCashLabel(new Vector2(0, AcceptedLabel.Position.Y));

                PeerTradeForm.SetupTradePanelControl(this);
            }
Exemple #2
0
 /// <summary>
 /// Creates a <see cref="PeerTradeSidePanel"/> instance.
 /// </summary>
 /// <param name="parent">The parent control.</param>
 /// <param name="position">The position to place the control.</param>
 /// <param name="isSourceSide">If this panel is for the source trade character side.</param>
 /// <returns>The <see cref="PeerTradeSidePanel"/> instance.</returns>
 protected virtual PeerTradeSidePanel CreateTradeSidePanel(PeerTradeFormBase <TChar, TItem, TItemInfo> parent,
                                                           Vector2 position, bool isSourceSide)
 {
     return(new PeerTradeSidePanel(parent, position, isSourceSide));
 }