/// <summary>
        /// 初始化图结点
        /// </summary>
        /// <param name="graphElement">结点对象</param>
        /// <param name="id">结点ID</param>
        /// <param name="name">结点名称</param>
        private void InitSlotContainer(SlotContainer slotContainer, int id, string name)
        {
            slotContainer.ID   = id;
            slotContainer.Name = name;
            slotContainer.Init();
            graphManager.SlotContainerList.Add(slotContainer);

            description = "创建图元 " + slotContainer.Name;
            dataManager.AddDataElement(slotContainer);
            graphManager.SelectGraphElement(slotContainer, false);
            graphManager.ReconstructCanvasGraphElementList();
        }
Beispiel #2
0
        public TaskStorage(Manager manager, Slot[] itemSlots, BlockItem storageItem, int slotsX, int slotsY)
            : base(manager)
        {
            imageCaption = new ImageBox(manager);
            imageCaption.Init();
            if (storageItem.RenderMode == BlockRenderMode.Single)
            {
                imageCaption.Image = ContentPack.Textures["spritesheets\\" + storageItem.Name];
            }
            else
            {
                imageCaption.Image = ContentPack.Textures["items\\" + storageItem.Name];
            }
            imageCaption.Left   = 8;
            imageCaption.Width  = imageCaption.Image.Width;
            imageCaption.Height = imageCaption.Image.Height;
            imageCaption.Top    = 4;
            Add(imageCaption);
            Caption.Left    = Description.Left = imageCaption.Left + imageCaption.Width + 8;
            TopPanel.Height = imageCaption.Image.Height + 12;
            Resizable       = false;

            Text             = storageItem.Name;
            TopPanel.Visible = true;
            Remove(BottomPanel);
            Caption.Text          = storageItem.Name;
            Description.Text      = storageItem.Description + " - " + storageItem.StorageSlots.X * storageItem.StorageSlots.Y + " Slots";
            Description.TextColor = Color.Gray;
            Caption.TextColor     = Color.LightGray;

            slotContainer = new SlotContainer(Manager, slotsX, slotsY);
            slotContainer.Init();
            slotContainer.ItemSlots        = itemSlots;
            slotContainer.Left             = 8;
            slotContainer.Top              = TopPanel.Height + TopPanel.Top + 8;
            slotContainer.ShiftClickItems += slotContainer_ShiftClickItems;
            Add(slotContainer);

            ClientWidth  = slotContainer.Left + slotContainer.ClientWidth;
            ClientHeight = slotContainer.Top + slotContainer.ClientHeight;
            Center();

            Top     = Interface.MainWindow.inventory.Top + Interface.MainWindow.InventoryOpenHeight + 48;
            Closed += TaskStorage_Closed;
            SendToBack();

            //For some reason Center() changes with width, this resets it to the correct amount.
            ClientWidth = slotContainer.Left + slotContainer.ClientWidth;

            //Open inventory
            Interface.MainWindow.hiding    = false;
            Interface.MainWindow.expanding = true;
        }
Beispiel #3
0
        void FillBox()
        {
            List <Item> Items = Item.ItemList.ToList();

            Items = Items.Where(x => !((x is BackgroundBlockItem) && (x as BackgroundBlockItem).ForegroundEquivelent != null)).ToList <Item>();
            //Reset
            if (slotContainer == null)
            {
                itemSlots = new Slot[10 * ((Items.Count / 10) + (Items.Count % 10) - 1)];
            }
            for (int i = 0; i < Items.Count; i++)
            {
                itemSlots[i] = new Slot(Item.Blank);
            }
            if (!string.IsNullOrEmpty(searchBox.Text) && searchBox.Text != "Search...")
            {
                Items = Items.Where(x => x.Name.ToLowerFast().Contains(searchBox.Text.Trim().ToLowerFast())).ToList <Item>();
            }

            for (int i = 0; i < Items.Count; i++)
            {
                itemSlots[i] = new Slot(Items[i], Items[i].MaxStack);
            }
            if (slotContainer == null)
            {
                slotContainer = new SlotContainer(Manager, 10, (Items.Count / 10) + (Items.Count % 10) - 1, true);
                slotContainer.Init();
                slotContainer.ItemSlots        = itemSlots;
                slotContainer.Left             = 8;
                slotContainer.Top              = TopPanel.Height + TopPanel.Top + 8;
                slotContainer.ShiftClickItems += slotContainer_ShiftClickItems;
                slotContainer.CanAdd           = false;
                slotContainer.MoveItems       += slotContainer_MoveItems;
                Add(slotContainer);
            }
        }