예제 #1
0
        public static void Test()
        {
            ItemBox box = Gui.Instance.CreateWidget <ItemBox>("ItemBox", new IntCoord(20, 320, 100, 100), Align.Default, "Main");

            box.EventNotifyItem         += new ItemBox.HandleNotifyItem(box_EventNotifyItem);
            box.EventMouseItemActivate  += new ItemBox.HandleMouseItemActivate(box_EventMouseItemActivate);
            box.EventChangeItemPosition += new ItemBox.HandleChangeItemPosition(box_EventChangeItemPosition);
            box.EventSelectItemAccept   += new ItemBox.HandleSelectItemAccept(box_EventSelectItemAccept);
            box.RequestDrawItem         += new ItemBox.HandleDrawItem(box_RequestDrawItem);
            box.RequestCoordItem        += new ItemBox.HandleCoordItem(box_RequestCoordItem);
            box.RequestCreateWidgetItem += new ItemBox.HandleCreateWidgetItem(box_RequestCreateWidgetItem);

            box.AddItem("cell0");

            box.ResetDrag();
            Widget cell  = box.GetWidgetByIndex(0);
            uint   index = box.GetIndexByWidget(cell);
            Widget drag  = box.GetWidgetDrag();

            box.VerticalAlignment = !box.VerticalAlignment;
            box.ClearItemDataAt(0);
            box.SetItemDataAt(0, "new cell0");
            box.ClearIndexSelected();
            box.IndexSelected = 0;
            box.RedrawAllItems();
            box.RedrawItemAt(0);
            box.RemoveItemAt(0);
            box.RemoveAllItems();

            box.AddItem("cell0");
            box.SetItemDataAt(0, "new cell0");
            box.InsertItemAt(0, "insert cell0");
            uint count = box.ItemCount;
        }
예제 #2
0
    void Import(byte[] buffer)
    {
        mItemBox.Clear();
        MemoryStream ms          = new MemoryStream(buffer);
        BinaryReader _in         = new BinaryReader(ms);
        int          saveVersion = _in.ReadInt32();

        LastItemID = _in.ReadInt32();
        int count = _in.ReadInt32();

        switch (saveVersion)
        {
        case 1:
            for (int i = 0; i < count; i++)
            {
                ItemBox newBox = CreateItemBox();
                newBox.transform.parent = transform;
                newBox.mID  = _in.ReadInt32();
                newBox.mPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle());
                mItemBox.Add(newBox.mID, newBox);
            }
            break;

        case 2:
            for (int i = 0; i < count; i++)
            {
                ItemBox newBox = CreateItemBox();
                newBox.transform.parent = transform;
                newBox.mID  = _in.ReadInt32();
                newBox.mPos = new Vector3(_in.ReadSingle(), _in.ReadSingle(), _in.ReadSingle());
                int size = _in.ReadInt32();
                for (int j = 0; j < size; j++)
                {
                    newBox.AddItem(_in.ReadInt32());
                }
                mItemBox.Add(newBox.mID, newBox);
            }
            break;
        }
        _in.Close();
        ms.Close();
    }