示例#1
0
        private void dg_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (dg.SelectedIndex == dg.Items.Count - 1)
            {
                CmdType.SelectedIndex = 0; description.Text = ""; return;
            }
            if (!(dg.SelectedItem is DATA))
            {
                return;
            }
            DATA d = (DATA)dg.SelectedItem;

            switch (d.type)
            {
            case "原版命令": CmdType.SelectedIndex = 0; txtb.Text = d.data;
                break;

            case "绝对坐标": CmdType.SelectedIndex = 3; ((LocationEditor)dataEditor.Children[0]).importData(d.data);
                break;

            case "相对坐标": CmdType.SelectedIndex = 4; ((TLocationEditor)dataEditor.Children[0]).importData(d.data);
                break;

            case "玩家选择器": CmdType.SelectedIndex = 1;
                break;

            case "实体选择器": CmdType.SelectedIndex = 2;
                break;

            case "物品_Json书": CmdType.SelectedIndex = 5;
                break;

            case "物品_告示牌": CmdType.SelectedIndex = 6;
                break;

            case "方块_告示牌": CmdType.SelectedIndex = 7;
                break;

            case "物品NBT": CmdType.SelectedIndex = 8;
                break;

            case "实体NBT": CmdType.SelectedIndex = 9;
                break;
            }
            UIElement u = dataEditor.Children[0];

            if (u is Template)
            {
                ((Template)u).importData(d.data);
            }
            description.Text = d.des;
        }
示例#2
0
        private void insert_Click(object sender, RoutedEventArgs e)
        {
            if (dg.SelectedIndex == -1)
            {
                return;
            }
            int idx = int.Parse(index.Text) - 1;

            index.Text = idx + 1 + "";
            if (idx < 0)
            {
                idx = 0; index.Text = idx + 1 + "";
            }
            if (idx > dg.Items.Count)
            {
                idx = dg.Items.Count - 2; index.Text = dg.Items.Count - 2 + "";
            }
            DATA d = Data[dg.SelectedIndex];

            Data.RemoveAt(dg.SelectedIndex);
            Data.Insert(idx, d);
            updateIndex();
            dg.SelectedIndex = idx;
        }