//------------------------------------------------------------ private void AddSourceChoice(string label, string key, string description) { MultiText name = new MultiText(); name[_ws.Id] = label; Option item = new Option(key, name); item.Description.SetAlternative(_ws.Id, description); _sourceChoices.Options.Add(item); _choiceKeys.Add(key); }
public void SaveToFile() { Option x = new Option(); x.Abbreviation.SetAlternative("a", "aabrev"); x.Abbreviation.SetAlternative("b", "babrev"); x.Key = "akey"; x.Name.SetAlternative("a", "aname"); x.Name.SetAlternative("b", "bname"); Option y = new Option(); y.Abbreviation.SetAlternative("a", "aabrev"); y.Abbreviation.SetAlternative("b", "babrev"); y.Key = "akey"; y.Name.SetAlternative("a", "aname"); y.Name.SetAlternative("b", "bname"); OptionsList list = new OptionsList(); list.Options.Add(x); list.Options.Add(y); string path = Path.GetTempFileName(); list.SaveToFile(path); // Debug.WriteLine(xml); OptionsList.LoadFromFile(path); Assert.AreEqual("aname", list.Options[1].Name.GetBestAlternative("a")); }
private void OnSelectedIndexChanged(object sender, EventArgs e) { if (_listBox.SelectedIndex > -1 && ((Option.OptionDisplayProxy) _listBox.SelectedItem).UnderlyingOption != _currentOption) { SaveEditsToCurrentItem(); Option.OptionDisplayProxy proxy = (Option.OptionDisplayProxy) _listBox.SelectedItem; splitContainer1.Panel2.Controls.Remove(_nameMultiTextControl); _currentOption = proxy.UnderlyingOption; MultiTextControl m = new MultiTextControl(_currentField.WritingSystemIds, _currentOption.Name, _currentField.FieldName, false, BasilProject.Project.WritingSystems, CommonEnumerations.VisibilitySetting. Visible, _currentField.IsSpellCheckingEnabled); m.SizeChanged += OnNameControlSizeChanged; m.Bounds = _nameMultiTextControl.Bounds; m.Top = _nameLabel.Top; m.BorderStyle = BorderStyle.FixedSingle; m.Anchor = _nameMultiTextControl.Anchor; _nameMultiTextControl = m; splitContainer1.Panel2.Controls.Add(m); _keyText.TextChanged -= OnKeyTextChanged; _keyText.Text = proxy.UnderlyingOption.Key; _keyText.TextChanged += OnKeyTextChanged; foreach (WeSayTextBox box in m.TextBoxes) { TextBinding binding = new TextBinding(_currentOption.Name, box.WritingSystem.Id, box); //hooking on to this is more reliable, sequence-wise, than directly wiring to m.TextChanged binding.DataTarget.PropertyChanged += DataTarget_PropertyChanged; } _keyText.Left = _nameMultiTextControl.Left; UpdateDisplay(); } }
private void _btnAdd_Click(object sender, EventArgs e) { Option newOption = new Option(); _newlyCreatedOptions.Add(newOption); _currentList.Options.Add(newOption); int index = _listBox.Items.Add(newOption.GetDisplayProxy(PreferredWritingSystem)); _listBox.SelectedIndex = index; UpdateDisplay(); _nameMultiTextControl.TextBoxes[0].Focus(); UserModifiedList(); }
public OptionDisplayProxy(Option option, string writingSystemId) { _writingSystemId = writingSystemId; _option = option; }