private void SetControlText(Control controlparent, Control ctrl) { if (ctrl == null) { return; } PhraseControl pc = allControlKey.GetItem(ctrl); Phrase p = null; if (pc != null) { if (pc.PhrasePointer != null && !pc.PhrasePointer.IsFormatted) { ctrl.Text = pc.PhrasePointer.Text; } return; } else { p = this[ctrl.Name]; if (p == null && controlparent != null) { p = this[string.Format("{0}.{1}", controlparent.Name, ctrl.Name)]; } if (p != null && !p.IsFormatted) { ctrl.Text = p.Text; } } }
/// <summary> /// Gönderilen obje tarafından atanmış olan denetimlerin textlerini otomatik değiştirir.(FOrmatlı biçimler hariç) /// </summary> /// <param name="obj">Bağlantı yapan obje</param> public void SetControlTextBySender(object obj) { if (obj == null) { return; } for (int i = 0; i < this.allControlKey.Count; i++) { PhraseControl pControl = this.allControlKey[i]; if (pControl.PSender == obj) { if (pControl.PhrasePointer == null || pControl.PhrasePointer.IsFormatted) { continue; } if (pControl.PControl != null) { pControl.PControl.Text = pControl.PhrasePointer.Text; } if (pControl.TIControl != null) { pControl.TIControl.Text = pControl.PhrasePointer.Text; } } } }
/// <summary> /// Denetimlere atanmış phrase nameleri gönderilen objeyeye göre temizler /// </summary> /// <param name="obj">Bağlantı yapan obje</param> public void ClearControlKeysBySender(object obj) { if (obj == null) { return; } for (int i = 0; i < this.allControlKey.Count; i++) { PhraseControl pControl = this.allControlKey[i]; if (pControl.PSender == obj) { this.allControlKey.RemoveAt(i); i--; continue; } } }
/// <summary> /// Cümle ekler veya değiştirir. /// </summary> /// <param name="name">Cümle adı</param> /// <param name="text">Cümle içeriği</param> /// <param name="overwriteexisting">true ayarlanırsa girilen cümle mevcutsa değiştirir diğer türlü değiştirmez.</param> public void Set(string name, string text, bool overwriteexisting = true) { if (allphrases.ContainsKey(name)) { if (!overwriteexisting) { return; } allphrases.Remove(name); } Phrase phs = new Phrase(this) { Name = name, Text = text }; PhraseControl pc = this.allControlKey.GetItem(name); if (pc != null) { pc.PhrasePointer = phs; } allphrases.Add(name, phs); }