public void Compose()
        {
            var tabs = new GuiTab[] { new GuiTab()
                                      {
                                          Name = Lang.Get("Local goods"), DataInt = 0
                                      }, new GuiTab()
                                      {
                                          Name = Lang.Get("Auction house"), DataInt = 1
                                      }, new GuiTab()
                                      {
                                          Name = Lang.Get("Your Auctions"), DataInt = 2
                                      } };
            var tabBounds = ElementBounds.Fixed(0, -24, 500, 25);
            var tabFont   = CairoFont.WhiteDetailText();

            if (!auctionHouseEnabled)
            {
                tabs = new GuiTab[] { new GuiTab()
                                      {
                                          Name = Lang.Get("Local goods"), DataInt = 0
                                      } };
            }


            ElementBounds bgBounds = ElementBounds.Fill.WithFixedPadding(GuiStyle.ElementToDialogPadding);

            bgBounds.BothSizing = ElementSizing.FitToChildren;
            ElementBounds dialogBounds = ElementStdBounds
                                         .AutosizedMainDialog.WithAlignment(EnumDialogArea.RightMiddle)
                                         .WithFixedAlignmentOffset(-GuiStyle.DialogToScreenPadding, 0);


            ElementBounds leftButton  = ElementBounds.Fixed(EnumDialogArea.LeftFixed, 0, 0, 0, 0).WithFixedPadding(8, 5);
            ElementBounds rightButton = ElementBounds.Fixed(EnumDialogArea.RightFixed, 0, 0, 0, 0).WithFixedPadding(8, 5);


            string traderName = owningEntity.GetBehavior <EntityBehaviorNameTag>().DisplayName;
            string dlgTitle   = Lang.Get("tradingwindow-" + owningEntity.Code.Path, traderName);

            if (curTab > 0)
            {
                dlgTitle = Lang.Get("tradertabtitle-" + curTab);
            }

            SingleComposer =
                capi.Gui
                .CreateCompo("traderdialog-" + owningEntity.EntityId, dialogBounds)
                .AddShadedDialogBG(bgBounds, true)
                .AddDialogTitleBar(dlgTitle, OnTitleBarClose)
                .AddHorizontalTabs(tabs, tabBounds, OnTabClicked, tabFont, tabFont.Clone().WithColor(GuiStyle.ActiveButtonTextColor), "tabs")
                .BeginChildElements(bgBounds)
            ;

            SingleComposer.GetHorizontalTabs("tabs").activeElement = curTab;

            if (curTab == 0)
            {
                double pad = GuiElementItemSlotGrid.unscaledSlotPadding;

                ElementBounds leftTopSlotBounds  = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad, 70 + pad, cols, rows).FixedGrow(2 * pad, 2 * pad);
                ElementBounds rightTopSlotBounds = ElementStdBounds.SlotGrid(EnumDialogArea.None, pad + leftTopSlotBounds.fixedWidth + 20, 70 + pad, cols, rows).FixedGrow(2 * pad, 2 * pad);

                ElementBounds rightBotSlotBounds = ElementStdBounds
                                                   .SlotGrid(EnumDialogArea.None, pad + leftTopSlotBounds.fixedWidth + 20, 15 + pad, cols, 1)
                                                   .FixedGrow(2 * pad, 2 * pad)
                                                   .FixedUnder(rightTopSlotBounds, 5)
                ;

                ElementBounds leftBotSlotBounds = ElementStdBounds
                                                  .SlotGrid(EnumDialogArea.None, pad, 15 + pad, cols, 1)
                                                  .FixedGrow(2 * pad, 2 * pad)
                                                  .FixedUnder(leftTopSlotBounds, 5)
                ;

                ElementBounds costTextBounds  = ElementBounds.Fixed(pad, 85 + 2 * pad + leftTopSlotBounds.fixedHeight + leftBotSlotBounds.fixedHeight, 200, 25);
                ElementBounds offerTextBounds = ElementBounds.Fixed(leftTopSlotBounds.fixedWidth + pad + 20, 85 + 2 * pad + leftTopSlotBounds.fixedHeight + leftBotSlotBounds.fixedHeight, 200, 25);

                ElementBounds traderMoneyBounds = offerTextBounds.FlatCopy().WithFixedOffset(0, offerTextBounds.fixedHeight);
                ElementBounds playerMoneyBounds = costTextBounds.FlatCopy().WithFixedOffset(0, costTextBounds.fixedHeight);


                double daysLeft       = (owningEntity as EntityTrader).NextRefreshTotalDays();
                string daysLeftString = daysLeft < 1 ? Lang.Get("Delievery of new goods in less than 1 day") : Lang.Get("Delievery of new goods in {0} days", (int)daysLeft);

                CairoFont deliveryTextFont = CairoFont.WhiteDetailText();
                deliveryTextFont.Color[3] *= 0.7;

                SingleComposer
                .AddStaticText(daysLeftString, deliveryTextFont, ElementBounds.Fixed(pad, 20 + pad, 500, 25))

                .AddStaticText(Lang.Get("You can Buy"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(pad, 50 + pad, 200, 25))
                .AddStaticText(Lang.Get("You can Sell"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(leftTopSlotBounds.fixedWidth + pad + 20, 50 + pad, 200, 25))

                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[rows * cols]).Fill(i => i), leftTopSlotBounds, "traderSellingSlots")
                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[cols]).Fill(i => rows * cols + i), leftBotSlotBounds, "playerBuyingSlots")

                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[rows * cols]).Fill(i => rows * cols + cols + i), rightTopSlotBounds, "traderBuyingSlots")
                .AddItemSlotGrid(traderInventory, DoSendPacket, cols, (new int[cols]).Fill(i => rows * cols + cols + rows * cols + i), rightBotSlotBounds, "playerSellingSlots")

                .AddStaticText(Lang.Get("trader-yourselection"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(pad, 70 + 2 * pad + leftTopSlotBounds.fixedHeight, 150, 25))
                .AddStaticText(Lang.Get("trader-youroffer"), CairoFont.WhiteDetailText(), ElementBounds.Fixed(leftTopSlotBounds.fixedWidth + pad + 20, 70 + 2 * pad + leftTopSlotBounds.fixedHeight, 150, 25))

                // Cost
                .AddDynamicText("", CairoFont.WhiteDetailText(), costTextBounds, "costText")
                // Player money
                .AddDynamicText("", CairoFont.WhiteDetailText(), playerMoneyBounds, "playerMoneyText")
                // Offer
                .AddDynamicText("", CairoFont.WhiteDetailText(), offerTextBounds, "gainText")
                // Trader money
                .AddDynamicText("", CairoFont.WhiteDetailText(), traderMoneyBounds, "traderMoneyText")

                .AddSmallButton(Lang.Get("Goodbye!"), OnByeClicked, leftButton.FixedUnder(playerMoneyBounds, 20))
                .AddSmallButton(Lang.Get("Buy / Sell"), OnBuySellClicked, rightButton.FixedUnder(traderMoneyBounds, 20), EnumButtonStyle.Normal, EnumTextOrientation.Left, "buysellButton")

                .EndChildElements()
                .Compose()
                ;

                SingleComposer.GetButton("buysellButton").Enabled = false;
                CalcAndUpdateAssetsDisplay();
                return;
            }

            double        listHeight      = 377;
            ElementBounds stackListBounds = ElementBounds.Fixed(0, 25, 700, listHeight); //.FixedUnder(searchFieldBounds, 5);

            clipBounds = stackListBounds.ForkBoundingParent();
            ElementBounds insetBounds = stackListBounds.FlatCopy().FixedGrow(3).WithFixedOffset(0, 0);

            ElementBounds scrollbarBounds = insetBounds.CopyOffsetedSibling(3 + stackListBounds.fixedWidth + 7).WithFixedWidth(20);

            if (curTab == 1)
            {
                auctions = auctionSys.activeAuctions;

                SingleComposer
                .BeginClip(clipBounds)
                .AddInset(insetBounds, 3)
                .AddCellList(stackListBounds, createCell, auctionSys.activeAuctions, "stacklist")
                .EndClip()
                .AddVerticalScrollbar(OnNewScrollbarValue, scrollbarBounds, "scrollbar")

                .AddSmallButton(Lang.Get("Goodbye!"), OnByeClicked, leftButton.FixedUnder(clipBounds, 20))
                .AddSmallButton(Lang.Get("Buy"), OnBuyAuctionClicked, rightButton.FixedUnder(clipBounds, 20), EnumButtonStyle.Normal, EnumTextOrientation.Left, "buyauction")
                ;
            }

            if (curTab == 2)
            {
                auctions = auctionSys.ownAuctions;

                ElementBounds button    = ElementBounds.Fixed(EnumDialogArea.RightFixed, 0, 0, 0, 0).WithFixedPadding(8, 5);
                string        placeStr  = Lang.Get("Place Auction");
                string        cancelStr = Lang.Get("Cancel Auction");

                double placelen  = CairoFont.ButtonText().GetTextExtents(placeStr).Width / RuntimeEnv.GUIScale;
                double cancellen = CairoFont.ButtonText().GetTextExtents(cancelStr).Width / RuntimeEnv.GUIScale;

                SingleComposer
                .BeginClip(clipBounds)
                .AddInset(insetBounds, 3)
                .AddCellList(stackListBounds, createCell, auctionSys.ownAuctions, "stacklist")
                .EndClip()
                .AddVerticalScrollbar(OnNewScrollbarValue, scrollbarBounds, "scrollbar")

                .AddSmallButton(Lang.Get("Goodbye!"), OnByeClicked, leftButton.FixedUnder(clipBounds, 20))
                .AddSmallButton(Lang.Get("Place Auction"), OnCreateAuction, rightButton.FixedUnder(clipBounds, 20), EnumButtonStyle.Normal, EnumTextOrientation.Left, "placeAuction")
                .AddSmallButton(cancelStr, OnCancelAuction, button.FlatCopy().FixedUnder(clipBounds, 20).WithFixedAlignmentOffset(-placelen, 0), EnumButtonStyle.Normal, EnumTextOrientation.Center, "cancelAuction")
                .AddSmallButton(Lang.Get("Collect Funds"), OnCollectFunds, button.FlatCopy().FixedUnder(clipBounds, 20).WithFixedAlignmentOffset(-placelen, 0), EnumButtonStyle.Normal, EnumTextOrientation.Center, "collectFunds")
                .AddSmallButton(Lang.Get("Retrieve Items"), OnRetrieveItems, button.FixedUnder(clipBounds, 20).WithFixedAlignmentOffset(-placelen, 0), EnumButtonStyle.Normal, EnumTextOrientation.Center, "retrieveItems")
                ;
            }

            if (curTab == 1 || curTab == 2)
            {
                selectedElem = null;
                listElem     = SingleComposer.GetCellList <Auction>("stacklist");
                listElem.BeforeCalcBounds();
                listElem.UnscaledCellVerPadding = 0;
                listElem.unscaledCellSpacing    = 5;
                SingleComposer.EndChildElements().Compose();

                updateScrollbarBounds();


                didClickAuctionElem(-1);
            }
        }
 private void OnNewScrollbarValue(float value)
 {
     listElem = SingleComposer.GetCellList <Auction>("stacklist");
     listElem.Bounds.fixedY = 0 - value;
     listElem.Bounds.CalcWorldBounds();
 }