Ejemplo n.º 1
0
        public static string GetStringFromItemType(VDFItemType type)
        {
            switch (type)
            {
            case VDFItemType.Boolean:
                return("Boolean");

            case VDFItemType.Double:
                return("Double");

            case VDFItemType.Float:
                return("Float");

            case VDFItemType.Int:
                return("Int");

            case VDFItemType.Long:
                return("Long");

            case VDFItemType.String:
                return("String");

            default:
                return("Unknown");
            }
        }
Ejemplo n.º 2
0
        private void addItemToRootToolStripMenuItem_Click(object sender, EventArgs e)
        {
            VDFItemType type = VDFItemType.String;

            ShowItemTypeBox(ref type, "Item type");

            string itemName = "Item";

            ShowInputDialog(ref itemName, "Item name");

            VDFItem item;

            switch (type)
            {
            case VDFItemType.String:
                string input = "String";
                ShowInputDialog(ref input, "Set string");
                item = new VDFStringItem(itemName, input);
                break;

            case VDFItemType.Boolean:
                bool boolInput = false;
                ShowBoolBox(ref boolInput, "Set bool");
                item = new VDFBoolItem(itemName, boolInput);
                break;

            case VDFItemType.Int:
                int intInput = 0;
                ShowIntBox(ref intInput, "Set int", int.MaxValue);
                item = new VDFIntItem(itemName, intInput);
                break;

            case VDFItemType.Double:
                double doubleInput = 0;
                ShowDoubleBox(ref doubleInput, "Set double", double.MaxValue);
                item = new VDFDoubleItem(itemName, doubleInput);
                break;

            case VDFItemType.Long:
                long longInput = 0;
                ShowLongBox(ref longInput, "Set long", long.MaxValue);
                item = new VDFLongItem(itemName, longInput);
                break;

            case VDFItemType.Float:
                GeneralUtil.NotImplementedError("Float setting unavailable");
                item = new VDFFloatItem(itemName, 0.0f);
                break;

            default:
                return;
            }

            SetStatus("Created item: " + item.name);
            vdf.items.Add(item);

            LoadVDF();
        }
Ejemplo n.º 3
0
        private void addItemToSelectedCatagoryToolStripMenuItem_Click(object sender, EventArgs e)
        {
            VDFItemType type = VDFItemType.String;

            if (ShowItemTypeBox(ref type, "Item type") == DialogResult.Cancel)
            {
                return;
            }

            string itemName = "Item";

            if (ShowInputDialog(ref itemName, "Item name") == DialogResult.Cancel)
            {
                return;
            }

            VDFCatagory cat = catagoryViaNode[treeView1.SelectedNode];
            VDFItem     item;

            switch (type)
            {
            case VDFItemType.String:
                string input = "String";
                ShowInputDialog(ref input, "Set string");
                item = new VDFStringItem(itemName, input);
                break;

            case VDFItemType.Boolean:
                bool boolInput = false;
                ShowBoolBox(ref boolInput, "Set bool");
                item = new VDFBoolItem(itemName, boolInput);
                break;

            case VDFItemType.Int:
                int intInput = 0;
                ShowIntBox(ref intInput, "Set int", int.MaxValue);
                item = new VDFIntItem(itemName, intInput);
                break;

            case VDFItemType.Double:
                double doubleInput = 0;
                ShowDoubleBox(ref doubleInput, "Set double", double.MaxValue);
                item = new VDFDoubleItem(itemName, doubleInput);
                break;

            case VDFItemType.Long:
                long longInput = 0;
                ShowLongBox(ref longInput, "Set long", long.MaxValue);
                item = new VDFLongItem(itemName, longInput);
                break;

            case VDFItemType.Float:
                GeneralUtil.NotImplementedError("Float setting unavailable");
                item = new VDFFloatItem(itemName, 0.0f);
                break;

            default:
                return;
            }

            cat.AddItem(item);
            SetStatus("Created item: '" + item.name + "' in catagory: '" + cat.name + "'");

            LoadVDF();
        }
Ejemplo n.º 4
0
        private static DialogResult ShowItemTypeBox(ref VDFItemType type, string title)
        {
            System.Drawing.Size size = new System.Drawing.Size(inputBoxWidth, 70);
            Form inputBox            = new Form();

            inputBox.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog;
            inputBox.ClientSize      = size;
            inputBox.Text            = title;

            ComboBox comboBox = new ComboBox();

            comboBox.Size     = new System.Drawing.Size(size.Width - 10, 23);
            comboBox.Location = new System.Drawing.Point(5, 5);
            comboBox.Items.Clear();
            comboBox.Items.Add("String");
            comboBox.Items.Add("Int");
            comboBox.Items.Add("Float");
            comboBox.Items.Add("Boolean");
            comboBox.Items.Add("Double");
            comboBox.Items.Add("Long");
            inputBox.Controls.Add(comboBox);

            Button okButton = new Button();

            okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
            okButton.Name         = "okButton";
            okButton.Size         = new System.Drawing.Size(75, 23);
            okButton.Text         = "&OK";
            okButton.Location     = new System.Drawing.Point(size.Width - 80 - 80, 39);
            inputBox.Controls.Add(okButton);

            Button cancelButton = new Button();

            cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            cancelButton.Name         = "cancelButton";
            cancelButton.Size         = new System.Drawing.Size(75, 23);
            cancelButton.Text         = "&Cancel";
            cancelButton.Location     = new System.Drawing.Point(size.Width - 80, 39);
            inputBox.Controls.Add(cancelButton);

            inputBox.AcceptButton = okButton;
            inputBox.CancelButton = cancelButton;

            DialogResult result = inputBox.ShowDialog();

            if (comboBox.SelectedIndex == 0)
            {
                type = VDFItemType.String;
            }
            else if (comboBox.SelectedIndex == 1)
            {
                type = VDFItemType.Int;
            }
            else if (comboBox.SelectedIndex == 2)
            {
                type = VDFItemType.Float;
            }
            else if (comboBox.SelectedIndex == 3)
            {
                type = VDFItemType.Boolean;
            }
            else if (comboBox.SelectedIndex == 4)
            {
                type = VDFItemType.Double;
            }
            else if (comboBox.SelectedIndex == 5)
            {
                type = VDFItemType.Long;
            }
            return(result);
        }