Пример #1
0
 private void ConfirmButton_Click(object sender, EventArgs e)
 {
     if (editValue == null)
     {
         string name = NameBox.Text;
         if (!Regex.Match(name, @"^[a-zA-Z_][a-zA-Z_0-9]*$").Success
             || InvokeLua.util_iskeyword(name))
         {
             MessageBox.Show("Invalid name. Please choose another.");
             NameBox.Focus();
             return;
         }
         if (parentTable.HasField(name))
         {
             MessageBox.Show("This variable name is already in use. Please choose another.");
             NameBox.Focus();
             return;
         }
         VisualLuaValue newValue;
         switch (creatingType)
         {
             case VisualLuaValueType.String:
                 VisualLuaStringValue newString = new VisualLuaStringValue(component, parentTable.Namespace);
                 newString.Value = InitialValueBox.Text;
                 newValue = newString;
                 break;
             default:
                 throw new Exception("Unsupported type");
         }
         newValue.Name = name;
         parentTable[name] = newValue;
         parentTable.RefreshChildren();
         this.Close();
         return;
     }
 }
Пример #2
0
 public static VisualLuaValue GetFromXml(LuaForAGSEditorComponent editorComponent, string ns, XmlNode node)
 {
     string name = node.Name;
     switch (node.Attributes["Type"].Value)
     {
         case "Number":
             VisualLuaNumberValue num = new VisualLuaNumberValue(editorComponent, ns);
             num.FromXml(node);
             return num;
         case "String":
             VisualLuaStringValue str = new VisualLuaStringValue(editorComponent, ns);
             str.FromXml(node);
             return str;
         case "Boolean":
             VisualLuaBooleanValue bl = new VisualLuaBooleanValue(editorComponent, ns);
             bl.FromXml(node);
             return bl;
         case "Table":
             VisualLuaTableValue tbl = new VisualLuaTableValue(editorComponent, ns);
             tbl.FromXml(node);
             return tbl;
     }
     return null;
 }