/// <summary> /// 写入属性 /// Big:大项名称 /// Small:小项名称 /// Value:要写入的值 /// </summary> public void SetString(string Big, string Small, string Value) { if (!(FActive)) { return; } if (CanOnSetValue) { I3IntGetSetValueEventArgs e = new I3IntGetSetValueEventArgs(); e.Big = Big; e.Small = Small; e.Value = Value; OnSetValue(this, e); Big = e.Big; Small = e.Small; Value = e.Value; } DataTable newTable = ini.Tables[Big]; if (newTable == null) { newTable = new DataTable(Big); ini.Tables.Add(newTable); } DataColumn newColumn = newTable.Columns[Small]; if (newColumn == null) { newColumn = new DataColumn(Small, typeof(string)); newTable.Columns.Add(newColumn); } DataRow newRow; try { newRow = newTable.Rows[0]; } catch (Exception) { newRow = newTable.NewRow(); newTable.Rows.Add(newRow); } try { newRow[Small] = Value; } catch (Exception) { } if (UP) { ini.WriteXml(FileName, XmlWriteMode.WriteSchema); } }
/// <summary> /// 控件的SetStringEvent事件 /// </summary> internal void OnSetValue(object Sender, I3IntGetSetValueEventArgs e) { if (!this.DesignMode) { if (SetValueEvent != null) { SetValueEvent(Sender, e); } } }
/// <summary> /// 控件的GetStringEvent事件 /// </summary> internal virtual void OnGetValue(Object Sender, I3IntGetSetValueEventArgs e) { if (!this.DesignMode) { if (GetValueEvent != null) { GetValueEvent(Sender, e); } } }
/// <summary> /// 读取属性 /// Big:大项名称 /// Small:小项名称 /// Default:默认值,无法取到值时返回默认值 /// </summary> public string GetString(string Big, string Small, string Default) { if (!(FActive)) { return(Default); } string s; DataTable newTable = ini.Tables[Big]; if (newTable == null) { s = Default; goto OnGetString; } DataColumn newColumn = newTable.Columns[Small]; if (newColumn == null) { s = Default; goto OnGetString; } try { s = newTable.Rows[0][Small].ToString(); } catch (Exception) { s = Default; } OnGetString: if (CanOnGetValue) { I3IntGetSetValueEventArgs e = new I3IntGetSetValueEventArgs(); e.Big = Big; e.Small = Small; e.Value = s; OnGetValue(this, e); return(e.Value); } else { return(s); } }