/// <summary> /// 打开指定脚本内容 /// </summary> /// <param name="source">脚本内容</param> /// <returns>bool</returns> public bool OpenScriptText(string source) { this.Clear(); if (this.m_scriptProperty == null) { this.m_scriptProperty = new ScriptProperty(); } this.m_scriptProperty.ScriptText = source; try { TextArea textArea = this.textEditorControl1.ActiveTextAreaControl.TextArea; textArea.Document.TextContent = source; textArea.Invalidate(); this.IsModified = false; //this.RefreshWindowTitle(); return(true); } catch (Exception ex) { LogManager.Instance.WriteLog("ScriptEditForm.OpenDoument", ex); return(false); } }
/// <summary> /// 创建一个新的脚本编辑窗口 /// </summary> internal void CreateNewScript() { ScriptNewForm frmNewScript = new ScriptNewForm(); if (frmNewScript.ShowDialog() != DialogResult.OK) { return; } ScriptEditForm scriptEditForm = new ScriptEditForm(this); scriptEditForm.Show(this.dockPanel1, DockState.Document); this.dockPanel1.Update(); string szScriptFile = frmNewScript.FileName; string szScriptText = null; if (!GlobalMethods.IO.GetFileText(szScriptFile, ref szScriptText)) { return; } ScriptProperty scriptProperty = new ScriptProperty(); scriptProperty.ScriptName = frmNewScript.ScriptTitle; scriptEditForm.ScriptProperty = scriptProperty; if (!scriptEditForm.OpenScriptText(szScriptText)) { MessageBoxEx.ShowError("脚本创建失败!"); } }
/// <summary> /// 编译当前脚本 /// </summary> /// <returns>bool</returns> public bool Compile() { if (this.DebuggerForm == null || this.DebuggerForm.IsDisposed) { return(false); } if (this.m_scriptProperty == null) { this.m_scriptProperty = new ScriptProperty(); } ScriptProperty scriptProperty = this.m_scriptProperty.Clone() as ScriptProperty; scriptProperty.ScriptText = this.textEditorControl1.Text; ScriptCompiler.Instance.WorkingPath = this.DebuggerForm.WorkingPath; CompileResults results = ScriptCompiler.Instance.CompileScript(scriptProperty); if (results.HasErrors) { this.DebuggerForm.ShowCompileErrorForm(results.Errors); return(false); } this.m_scriptProperty = scriptProperty; return(!results.HasErrors); }
private void DeclareConditionProperties(Condition c) { if (c == null || c.IsEmpty) { return; } foreach (var condition in c.Inactives) { ScriptProperty property = new ScriptProperty(condition.Flag, "bool", false); property.IsPublic = true; property.IsStatic = true; if (!state.Properties.Exists(x => x.Name == condition.Flag)) { state.Properties.Add(property); } } foreach (var condition in c.Actives) { ScriptProperty property = new ScriptProperty(condition.Flag, "bool", false); property.IsPublic = true; property.IsStatic = true; if (!state.Properties.Exists(x => x.Name == condition.Flag)) { state.Properties.Add(property); } } }
/// <summary> /// 显示脚本测试窗口 /// </summary> internal void ShowScriptTestForm() { if (this.m_ErrorsListForm != null && !this.m_ErrorsListForm.IsDisposed) { this.m_ErrorsListForm.Close(); } ScriptEditForm activeScriptForm = this.ActiveScriptForm; if (activeScriptForm == null || activeScriptForm.IsDisposed) { return; } ScriptProperty scriptProperty = activeScriptForm.ScriptProperty; if (scriptProperty == null) { scriptProperty = new ScriptProperty(); } ScriptCompiler.Instance.WorkingPath = this.WorkingPath; CompileResults results = ScriptCompiler.Instance.CompileScript(scriptProperty); if (results.HasErrors) { this.ShowCompileErrorForm(results.Errors); MessageBoxEx.Show("编译失败,无法启动测试程序!"); return; } ScriptTestForm scriptTestForm = new ScriptTestForm(); scriptTestForm.ShowDialog(scriptProperty.ScriptName, scriptProperty.ScriptText); }
/// <summary> /// 打开指定脚本配置信息的脚本 /// </summary> /// <param name="scriptProperty">脚本配置信息</param> internal void OpenScript(ScriptProperty scriptProperty) { if (scriptProperty == null) { return; } string szScriptFile = scriptProperty.FilePath; ScriptEditForm scriptEditForm = this.GetScriptEditForm(szScriptFile); if (scriptEditForm != null) { scriptEditForm.Activate(); scriptEditForm.OnRefreshView(); return; } if (scriptEditForm == null || scriptEditForm.IsDisposed) { scriptEditForm = new ScriptEditForm(this); scriptEditForm.Show(this.dockPanel1, DockState.Document); } scriptEditForm.ScriptProperty = scriptProperty; this.dockPanel1.Update(); if (!scriptEditForm.OpenScriptText(scriptProperty.ScriptText)) { MessageBoxEx.Show("文件打开失败!", MessageBoxIcon.Error); } }
/// <summary> /// 单击确定按钮,生成二进制DLL /// </summary> /// <returns>是否编译成功</returns> public bool CompileWithOK() { if (this.m_scriptProperty == null) { this.m_scriptProperty = new ScriptProperty(); } //ScriptEditForm activeScriptForm = this.GetScriptEditForm(this.m_scriptProperty.FilePath); ScriptEditForm activeScriptForm = this.ActiveScriptForm; if (activeScriptForm == null) { return(false); } activeScriptForm.Activate(); if (!activeScriptForm.Compile()) { MessageBoxEx.Show("编译失败,请查看错误列表!"); return(false); } //activeScriptForm.IsModified = false; this.m_scriptProperty = activeScriptForm.ScriptProperty; this.ScriptConfig = activeScriptForm.ScriptConfig; return(true); }
// ---------------------------------------------------------------------- // Setup // ---------------------------------------------------------------------- public InteropTypes(RewriterEnvironment env) { this.env = env; TheQualificationProperty = new QualificationProperty(this); TheNamespaceCasingProperty = new NamespaceCasingProperty(this); TheTypeNameCasingProperty = new TypeNameCasingProperty(this); ThePrefixNameCasingProperty = new PrefixNameCasingProperty(this); TheMemberNameCasingProperty = new MemberNameCasingProperty(this); TheRemoveAccessorPrefixProperty = new RemoveAccessorPrefixProperty(this); TheRemoveAccessorUnderscoreProperty = new RemoveAccessorUnderscoreProperty(this); TheDefaultKeyProperty = new DefaultKeyProperty(this); TheGlobalObjectProperty = new GlobalObjectProperty(this); TheScriptProperty = new ScriptProperty(this); ThePassRootAsArgumentProperty = new PassRootAsArgumentProperty(this); ThePassInstanceAsArgumentProperty = new PassInstanceAsArgumentProperty(this); TheInlineParamsArrayProperty = new InlineParamsArrayProperty(this); TheCreationProperty = new CreationProperty(this); TheSimulateMulticastEventsProperty = new SimulateMulticastEventsProperty(this); TheBindToPrototypeProperty = new BindToPrototypeProperty(this); TheLocationsProperty = new LocationsProperty(this); TheIsResourceProperty = new IsResourceProperty(this); TheIsAsyncProperty = new IsAsyncProperty(this); TheConditionProperty = new ConditionProperty(this); TheUndefinedIsNotNullProperty = new UndefinedIsNotNullProperty(this); TheStateProperty = new StateProperty(this); }
private void InitElementCalculators() { this.m_lstElementCalculators.Clear(); if (GlobalMethods.Misc.IsEmptyString(this.m_szScriptSource)) { return; } ScriptProperty scriptProperty = new ScriptProperty(); scriptProperty.ScriptText = this.m_szScriptSource; CompileResults results = null; try { results = ScriptCompiler.Instance.CompileScript(scriptProperty); if (results.HasErrors) { return; } } catch (Exception ex) { LogManager.Instance.WriteLog("ScriptTestForm.InitElementCalculators", ex); MessageBoxEx.Show("无法编译脚本,测试失败!"); return; } foreach (IElementCalculator elementCalculator in results.ElementCalculators) { elementCalculator.GetElementValueCallback = new GetElementValueCallback(this.GetElementValue); elementCalculator.SetElementValueCallback = new SetElementValueCallback(this.SetElementValue); elementCalculator.HideElementTipCallback = new HideElementTipCallback(this.HideElementTip); elementCalculator.ShowElementTipCallback = new ShowElementTipCallback(this.ShowElementTip); this.m_lstElementCalculators.Add(elementCalculator); } }
public ScriptEditForm(DebuggerForm mainForm) : base(mainForm) { this.MainForm = mainForm; this.ShowHint = DockState.Document; this.DockAreas = DockAreas.Document; this.m_scriptProperty = new ScriptProperty(); }
/// <summary> /// 刷新脚本属性信息对象 /// </summary> private void RefreshScriptProperty() { if (this.m_scriptProperty == null) { this.m_scriptProperty = new ScriptProperty(); } this.m_scriptProperty.ScriptText = this.textEditorControl1.Text; }
public override void AddProperty(ScriptProperty property) { var get = property.GetMethod; get = new ScriptMethod(get.Alias, get.TypeName, get.Parameters.Copy(), get.DeclaringType, get.ScriptLines, InnerScope, true, get.Access, get.Usage, get.ScriptTrace); var set = property.SetMethod; set = new ScriptMethod(set.Alias, set.TypeName, set.Parameters.Copy(), set.DeclaringType, set.ScriptLines, InnerScope, true, set.Access, set.Usage, set.ScriptTrace); property = new ScriptProperty(property.Alias, property.TypeName, get, set, property.Access, property.Usage, property.DeclaringType, property.ScriptTrace, InnerScope); Properties.Add(property.Alias, (property.GetFunc, property.SetFunc)); }
private void FixVMADScriptIDs(IMutagenReadStream stream, long fileOffset, ushort objectFormat) { // skip name var len = stream.ReadUInt16(); stream.Position += len; // Skip flags stream.Position += 1; var propCount = stream.ReadUInt16(); for (int j = 0; j < propCount; j++) { // skip name len = stream.ReadUInt16(); stream.Position += len; var type = (ScriptProperty.Type)stream.ReadUInt8(); // skip flags stream.Position += 1; // Going to cheat here, and use the autogenerated records ScriptProperty prop = type switch { ScriptProperty.Type.None => new ScriptProperty(), ScriptProperty.Type.Object => new ScriptObjectProperty(), ScriptProperty.Type.String => new ScriptStringProperty(), ScriptProperty.Type.Int => new ScriptIntProperty(), ScriptProperty.Type.Float => new ScriptFloatProperty(), ScriptProperty.Type.Bool => new ScriptBoolProperty(), ScriptProperty.Type.ArrayOfObject => new ScriptObjectListProperty(), ScriptProperty.Type.ArrayOfString => new ScriptStringListProperty(), ScriptProperty.Type.ArrayOfInt => new ScriptIntListProperty(), ScriptProperty.Type.ArrayOfFloat => new ScriptFloatListProperty(), ScriptProperty.Type.ArrayOfBool => new ScriptBoolListProperty(), _ => throw new NotImplementedException(), }; switch (prop) { case ScriptObjectProperty obj: FixObjectPropertyIDs(stream, fileOffset, objectFormat); break; case ScriptObjectListProperty objList: var count = stream.ReadUInt32(); for (int i = 0; i < count; i++) { FixObjectPropertyIDs(stream, fileOffset, objectFormat); } break; default: prop.CopyInFromBinary(new MutagenFrame(stream)); break; } } }
public static void WriteScripts( MutagenWriter writer, ushort objFormat, IReadOnlyList <IScriptEntryGetter> scripts) { writer.Write(checked ((ushort)scripts.Count)); foreach (var entry in scripts) { writer.Write(entry.Name, StringBinaryType.PrependLengthUShort, encoding: writer.MetaData.Encodings.NonTranslated); writer.Write((byte)entry.Flags); var properties = entry.Properties; writer.Write(checked ((ushort)properties.Count)); foreach (var property in properties) { writer.Write(property.Name, StringBinaryType.PrependLengthUShort, encoding: writer.MetaData.Encodings.NonTranslated); var type = property switch { ScriptObjectProperty _ => ScriptProperty.Type.Object, ScriptStringProperty _ => ScriptProperty.Type.String, ScriptIntProperty _ => ScriptProperty.Type.Int, ScriptFloatProperty _ => ScriptProperty.Type.Float, ScriptBoolProperty _ => ScriptProperty.Type.Bool, ScriptObjectListProperty _ => ScriptProperty.Type.ArrayOfObject, ScriptStringListProperty _ => ScriptProperty.Type.ArrayOfString, ScriptIntListProperty _ => ScriptProperty.Type.ArrayOfInt, ScriptFloatListProperty _ => ScriptProperty.Type.ArrayOfFloat, ScriptBoolListProperty _ => ScriptProperty.Type.ArrayOfBool, ScriptProperty _ => ScriptProperty.Type.None, _ => throw new NotImplementedException(), }; writer.Write((byte)type); writer.Write((byte)property.Flags); switch (property) { case ScriptObjectProperty obj: WriteObject(writer, obj, objFormat); break; case ScriptObjectListProperty objList: var objsList = objList.Objects; writer.Write(objsList.Count); foreach (var subObj in objsList) { WriteObject(writer, subObj, objFormat); } break; default: property.WriteToBinary(writer); break; } } } }
private ScriptProperty Read_Property(BinaryReader reader) { var result = new ScriptProperty(); result.Version = ReadVersion(reader, 1, 0x1411DD3E0); result.Name = ReadString(reader); result.TypeString = ReadString(reader); result.Type = reader.ReadUInt32(); result.Attributes = Read_List(reader, clusterDefinition.Read_ScriptComponent_parameter, 1, 0x1411CF800); return(result); }
public LuaScript CreateCopy() { if (this.properties.Length > 0) { var properties = new ScriptProperty[this.properties.Length]; this.properties.CopyTo(properties, 0); } return(new LuaScript { id = id, code = code, script = script, properties = properties }); }
static void FillProperties(MutagenFrame frame, ushort objectFormat, IScriptEntry item) { var count = frame.ReadUInt16(); for (int i = 0; i < count; i++) { var name = StringBinaryTranslation.Instance.Parse(frame, stringBinaryType: StringBinaryType.PrependLengthUShort, encoding: frame.MetaData.Encodings.NonTranslated); var type = (ScriptProperty.Type)frame.ReadUInt8(); var flags = (ScriptProperty.Flag)frame.ReadUInt8(); ScriptProperty prop = type switch { ScriptProperty.Type.None => new ScriptProperty(), ScriptProperty.Type.Object => new ScriptObjectProperty(), ScriptProperty.Type.String => new ScriptStringProperty(), ScriptProperty.Type.Int => new ScriptIntProperty(), ScriptProperty.Type.Float => new ScriptFloatProperty(), ScriptProperty.Type.Bool => new ScriptBoolProperty(), ScriptProperty.Type.ArrayOfObject => new ScriptObjectListProperty(), ScriptProperty.Type.ArrayOfString => new ScriptStringListProperty(), ScriptProperty.Type.ArrayOfInt => new ScriptIntListProperty(), ScriptProperty.Type.ArrayOfFloat => new ScriptFloatListProperty(), ScriptProperty.Type.ArrayOfBool => new ScriptBoolListProperty(), _ => throw new NotImplementedException(), }; prop.Name = name; prop.Flags = flags; switch (prop) { case ScriptObjectProperty obj: FillObject(frame, obj, objectFormat); break; case ScriptObjectListProperty objList: var objListCount = frame.ReadUInt32(); for (int j = 0; j < objListCount; j++) { var subObj = new ScriptObjectProperty(); FillObject(frame, subObj, objectFormat); objList.Objects.Add(subObj); } break; default: prop.CopyInFromBinary(frame); break; } item.Properties.Add(prop); } }
/// <summary> /// 打开本地文件 /// </summary> /// <param name="szFullName">文件路径</param> internal void OpenScript(string szFullName) { if (GlobalMethods.Misc.IsEmptyString(szFullName)) { return; } ScriptProperty scriptProperty = new ScriptProperty(); string szScriptText = null; GlobalMethods.IO.GetFileText(szFullName, ref szScriptText); scriptProperty.ScriptText = szScriptText; scriptProperty.FilePath = szFullName; scriptProperty.ScriptName = GlobalMethods.IO.GetFileName(szFullName, true); this.OpenScript(scriptProperty); }
internal override void ReadField(RecordReader reader) { // UESP - Contrary to UESP script name IS null terminated in addition to size recorded ushort scriptNameLength = reader.ReadUInt16(); Name = reader.ReadStringZeroTerminated(); byte numberOfProperties = reader.ReadByte(); Type = (ScriptType)reader.ReadByte(); while (numberOfProperties-- > 0) { var property = new ScriptProperty(); property.ReadProperty(reader); Properties.Add(property); } }
private void TestScript() { if (this.PatVisitInfo == null) { MessageBoxEx.ShowMessage("请先选择患者"); return; } if (this.QcCheckPoint == null) { MessageBoxEx.ShowMessage("缺陷规则未初始化"); return; } if (this.m_ErrorsListForm != null && !this.m_ErrorsListForm.IsDisposed) { this.m_ErrorsListForm.Close(); } ScriptEditForm activeScriptForm = this.ActiveScriptForm; if (activeScriptForm == null || activeScriptForm.IsDisposed) { return; } ScriptProperty scriptProperty = activeScriptForm.ScriptProperty; if (scriptProperty == null) { scriptProperty = new ScriptProperty(); } ScriptCompiler.Instance.WorkingPath = this.WorkingPath; CompileResults results = ScriptCompiler.Instance.CompileScript(scriptProperty); if (results.HasErrors) { this.ShowCompileErrorForm(results.Errors); MessageBoxEx.Show("编译失败,无法启动测试程序!"); return; } AutoCalcHandler.Instance.Start(); foreach (IElementCalculator item in results.ElementCalculators) { //item.Calculate("A"); AutoCalcHandler.Instance.CalcularTest(item, this.PatVisitInfo, this.QcCheckPoint, this.QcCheckResult); } }
public void Load(NpcData data) { Clear(); if (data == null) { HasChanges = false; return; } // string var_ai = data.GetValue(NpcData.VAR_NPC_AI, null); ScriptProperty prop = ScriptProperty.FromString(var_ai); string name = prop.ScriptName; // if (!string.IsNullOrEmpty(name)) { ScriptPageControl page, first_page; first_page = page = addTab(name); // string current, super; bool has_super; current = name; do { super = page.GetSuper(); has_super = (!string.IsNullOrEmpty(super) && super != current && super != "(null)"); if (has_super) { page = addTab(super); } }while (page != null && has_super); // is_loading = true; current_page = first_page; lstScript.SelectedItem = first_page.Script; setPage(first_page.Script); is_loading = false; } // HasChanges = false; }
/// <summary> /// 打开指定路径的文件 /// </summary> /// <param name="szFullName">文件路径</param> /// <returns>bool</returns> public bool OpenScriptFile(string szFullName) { this.Clear(); if (this.m_scriptProperty == null) { this.m_scriptProperty = new ScriptProperty(); } this.m_scriptProperty.FilePath = szFullName; this.m_vbsFile = szFullName; if (GlobalMethods.Misc.IsEmptyString(szFullName)) { return(true); } string szSource = null; if (!GlobalMethods.IO.GetFileText(szFullName, ref szSource)) { return(false); } return(this.OpenScriptText(szSource)); }
internal void ShowScriptTestForm() { DesignEditForm designForm = this.ActiveReport; ScriptEditForm scriptForm = this.ActiveScript; if (scriptForm == null && designForm == null) { return; } if (designForm != null) { scriptForm = this.GetScriptForm(designForm); } else if (scriptForm != null) { designForm = this.GetDesignForm(scriptForm); } ReportFileParser parser = new ReportFileParser(); string szScriptData = null; if (scriptForm != null) { szScriptData = scriptForm.Save(); } else { szScriptData = parser.GetScriptData(designForm.HndfFile); } string szDesignData = null; if (designForm != null) { designForm.Save(ref szDesignData); } else { szDesignData = parser.GetDesignData(scriptForm.HndfFile); } //编译脚本 ScriptProperty scriptProperty = new ScriptProperty(); scriptProperty.ScriptText = szScriptData; CompileResults results = null; results = ScriptCompiler.Instance.CompileScript(scriptProperty); if (!results.HasErrors) { this.MainForm.ShowCompileErrorForm(null); } else { if (scriptForm == null) { this.OpenScriptEditForm(designForm); } this.MainForm.ShowCompileErrorForm(this.GetCompileErrors(results)); MessageBoxEx.Show("编译失败,无法启动测试程序!"); return; } ScriptTestForm scriptTestForm = new ScriptTestForm(); scriptTestForm.ScriptData = szScriptData; scriptTestForm.DesignData = szDesignData; scriptTestForm.ShowDialog(); }
private Tuple <ScriptProperty, Action <string> >[] GetScriptProperties(NativeComponent component) { var type = component.GetType(); var properties = type.GetProperties().Where(p => System.Attribute.IsDefined(p, typeof(EditableFieldAttribute))); var propArray = new Tuple <ScriptProperty, Action <string> > [properties.Count()]; var index = 0; foreach (var prop in properties) { var current = prop; var p = new ScriptProperty() { name = current.Name }; Action <string> callback = null; if (current.PropertyType == typeof(bool)) { p.type = PropertyType.Boolean; p.value = current.GetValue(component).ToString(); callback = s => { current.SetValue(component, s == "true"); }; } else if (current.PropertyType == typeof(string)) { p.type = PropertyType.String; p.value = current.GetValue(component).ToString(); callback = s => { current.SetValue(component, s); }; } else if (current.PropertyType == typeof(float)) { p.type = PropertyType.Number; p.value = current.GetValue(component).ToString(); callback = s => { var floatNum = default(float); if (float.TryParse(s, System.Globalization.NumberStyles.Float, null, out floatNum)) { current.SetValue(component, floatNum); } }; } else if (current.PropertyType == typeof(int)) { p.type = PropertyType.Number; p.value = current.GetValue(component).ToString(); callback = s => { var intNum = default(int); if (int.TryParse(s, System.Globalization.NumberStyles.Integer, null, out intNum)) { current.SetValue(component, intNum); } }; } else if (current.PropertyType == typeof(double)) { p.type = PropertyType.Number; p.value = current.GetValue(component).ToString(); callback = s => { var doubleNum = default(double); if (double.TryParse(s, System.Globalization.NumberStyles.None, null, out doubleNum)) { current.SetValue(component, doubleNum); } }; } propArray[index++] = new Tuple <ScriptProperty, Action <string> > (p, callback); } return(propArray); }
private string getAI(string value) { ai_property = ScriptProperty.FromString(value); return(ai_property.ScriptName); }
static void Parse(string value) { var json = JsonConvert.DeserializeObject <JToken>(value); var comments = json.FindTokens("comment"); ScriptModule module = null; foreach (var comment in comments) { var attributes = comment["attributes"] as JObject; if (attributes == null) { continue; } var brief = (comment["brief"] ?? "").ToString(); var full = (comment["full"] ?? "").ToString(); if (attributes.ContainsKey("scriptModule")) { var scriptModule = attributes["scriptModule"]; var name = scriptModule.ToString(); if (!name.Contains('/')) { name = "FuseJS/" + name; } module = GetModule(name); module.Documentation = full; } if (attributes.ContainsKey("scriptMethod")) { var scriptMethod = attributes["scriptMethod"]; var result = new ScriptMethod { Name = scriptMethod["name"].ToString(), Documentation = full }; module.Methods.Add(result); foreach (var parameter in scriptMethod["parameters"]) { result.Parameters.Add(parameter.ToString()); } } if (attributes.ContainsKey("scriptProperty")) { var scriptProperty = attributes["scriptProperty"]; var result = new ScriptProperty { Name = scriptProperty.ToString(), Documentation = full }; // Extract type and docs if (result.Name.StartsWith("(")) { var i = result.Name.IndexOf(')', 1); result.Type = result.Name.Substring(1, i - 1); var parts = result.Name.Substring(i + 1).Trim().Split(' '); result.Name = parts[0]; result.Documentation = string.Join(" ", parts.Skip(1)); } // Skip duplicates if (module.Properties.Any(p => p.Name == result.Name)) { continue; } module.Properties.Add(result); } if (attributes.ContainsKey("scriptEvent")) { var scriptEvent = attributes["scriptEvent"]; var result = new ScriptEvent { Name = scriptEvent.ToString(), Documentation = brief }; module.Events.Add(result); } } }
private void AddPropertyChildren(ScriptProperty Property, CustomPropertyGridObject Obj, string path, bool isArray) { int index = 0; foreach (ScriptProperty Child in Property.Children) { object value = false; Type valueType = typeof(bool); string nodePath = path; if (isArray) { nodePath += "[" + index + "]"; } else { if (nodePath != "") { nodePath += "."; } nodePath += Child.Name; } switch (Child.TypeName) { case "Bool": { value = (Child.CurrentValue == "1"); valueType = typeof(bool); break; } case "String": { value = Child.CurrentValue; valueType = typeof(string); break; } case "Float": { value = float.Parse(Child.CurrentValue); valueType = typeof(float); break; } case "Int": { value = int.Parse(Child.CurrentValue); valueType = typeof(int); break; } case "Array": { if (Child.CurrentValue != "Null") { CustomPropertyGridObject SubChild = new CustomPropertyGridObject(); AddPropertyChildren(Child, SubChild, nodePath, true); value = SubChild; valueType = typeof(CustomPropertyGridObject); } else { value = null; valueType = typeof(object); } break; } case "Object": { if (Child.CurrentValue != "Null") { CustomPropertyGridObject SubChild = new CustomPropertyGridObject(); AddPropertyChildren(Child, SubChild, nodePath, false); value = SubChild; valueType = typeof(CustomPropertyGridObject); } else { value = null; valueType = typeof(object); } break; } } string DisplayName = Child.Name.Replace("_", " "); if (DisplayName.Length > 2 && DisplayName.Substring(0, 2) == "m ") { DisplayName = DisplayName.Substring(2); } if (DisplayName.Length > 0 && DisplayName[0] >= 'a' && DisplayName[0] <= 'z') { DisplayName = DisplayName.Substring(0, 1).ToUpper() + DisplayName.Substring(1); } bool bReadOnly = Child.bReadOnly; if (DisplayName.Length > 3 && Utils.ValidationHelper.IsUppercase(DisplayName)) { bReadOnly = true; } if (isArray) { DisplayName = "[" + index + "]"; } CustomProperty Prop = new CustomProperty(DisplayName, value, valueType, bReadOnly, true, nodePath); Prop.Changed += Property_Changed; Obj.Add(Prop); index++; } }
public override void AddProperty(ScriptProperty property) => throw new NotImplementedException();
set => SetValue(ScriptProperty, value);