public InsertPhraseCommand(Phrase phrase) : base(phrase) { }
public DeletePhraseCommand(Phrase phrase) : base(phrase) { }
public RenamePhraseCommand(Phrase phrase, string newvalue) : base(phrase) { this.NewValue = newvalue; }
protected PhraseDatabaseCommand(Phrase phrase) { this.Phrase = phrase; }
private void AddNewPhraseValue() { if (CurrentCategory == null) { return; } Phrase phrase = new Phrase(); phrase.PhraseText = "<New Phrase>"; phrase.PhraseID = -1; phrase.PhraseCatID = CurrentCategory.CategoryID; PhraseViewModel viewModel = new PhraseViewModel(phrase); (lvwPhrases.ItemsSource as ObservableCollection<PhraseViewModel>).Add(viewModel); viewModel.IsSelected = true; lvwPhrases.Dispatcher.BeginInvoke(new Action(() => { lvwPhrases.ScrollIntoView(viewModel); ListViewItem item = (ListViewItem)lvwPhrases.ItemContainerGenerator.ContainerFromItem(viewModel); if (item != null) { item.Focus(); } })); RegisterPendingChange(new InsertPhraseCommand(phrase)); viewModel.IsRenaming = true; }
public static string ShowPickList(User user, PickListType type, string categoryName, TraitCategoryType traitCategory, string filter = null, Control owner = null, Control ownerAncestor = null) { Func<IEnumerable<string>> itemsFunc = null; Func<string, bool> addItemFunc = null; string caption = "Select a value"; var service = new SupportService(user); switch (type) { case PickListType.Phrase: int phraseCategoryID = service.GetPhraseCategoryId(categoryName, true); caption = String.Format("Values for '{0}'", categoryName); itemsFunc = () => service.GetPhrases(phraseCategoryID).ConvertAll((phrase) => phrase.PhraseText); addItemFunc = (newphrase) => { Phrase phrase = new Phrase(); phrase.PhraseID = -1; phrase.PhraseCatID = phraseCategoryID; phrase.PhraseText = newphrase; // Save the new phrase value... service.InsertPhrase(phrase); return true; }; break; case PickListType.DistinctTraitList: caption = String.Format("Values for '{0}'", categoryName); itemsFunc = () => service.GetTraitValues(categoryName, traitCategory.ToString()); break; case PickListType.DistinctList: break; case PickListType.Trait: caption = String.Format("Existing trait names for {0}", traitCategory.ToString()); itemsFunc = () => service.GetTraitNamesForCategory(traitCategory.ToString()); break; case PickListType.MultimediaType: caption = "Select a multimedia type..."; itemsFunc = () => { return service.GetMultimediaTypes().ConvertAll((mmtype) => mmtype.Name); }; break; case PickListType.RefLinkType: caption = "Reference Link types"; itemsFunc = () => { var list = service.GetRefLinkTypes(); SortedDictionary<string, string> filtered = new SortedDictionary<string, string>(); // Remove the duplicates...Something really dodgey is going on when inserting ref links, it looks like // duplicate ref link types are being created. foreach (string item in list) { filtered[item] = item; } return filtered.Keys; }; addItemFunc = (newval) => { service.InsertRefLinkType(newval, traitCategory.ToString()); return true; }; break; default: throw new Exception("Unhandled pick list type: " + type); } PickListWindow frm = new PickListWindow(user, caption, itemsFunc, addItemFunc, filter, owner, ownerAncestor); if (frm.ShowDialog().GetValueOrDefault(false)) { return frm.SelectedValue as string; }; return null; }