private void AddNewNote() { var service = new SupportService(User); List <String> noteTypes = service.GetNoteTypesForCategory(TraitCategory.ToString()); var picklist = new PickListWindow(User, "Choose a note type...", () => { return(noteTypes); }, (text) => { noteTypes.Add(text); return(true); }); picklist.Owner = this.FindParentWindow(); if (picklist.ShowDialog().ValueOrFalse()) { Note note = new Note(); note.NoteID = -1; note.NoteType = picklist.SelectedValue as String; note.NoteCategory = TraitCategory.ToString(); note.IntraCatID = Owner.ObjectID.Value; note.NoteRTF = "New Note"; NoteViewModel viewModel = new NoteViewModel(note); _model.Add(viewModel); RegisterUniquePendingChange(new InsertNoteCommand(note, Owner)); RedrawNotes(viewModel); } }
private string SelectRefType() { var frm = new PickListWindow(User, "Reference Link types", () => { 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); }, (newval) => { Service.InsertRefLinkType(newval, Category.ToString()); return(true); }); if (frm.ShowDialog().ValueOrFalse()) { return(frm.SelectedValue as string); } return(null); }
private void txtCollector_Click(object sender, RoutedEventArgs e) { Func<IEnumerable<string>> itemsFunc = () => { var service = new MaterialService(User); return service.GetDistinctCollectors(); }; PickListWindow frm = new PickListWindow(User, "Select a collector", itemsFunc, null); if (frm.ShowDialog().ValueOrFalse()) { if (String.IsNullOrWhiteSpace(txtCollector.Text)) { txtCollector.Text = frm.SelectedValue as string; } else { txtCollector.Text += ", " + frm.SelectedValue; } } }
public static string ShowDistinctList(User user, string table, string field, string filter, Control ownerControl = null, Control ownerAncestor = null) { var service = new SupportService(user); Func <IEnumerable <string> > itemsFunc = () => { return(service.GetDistinctValues(table, field)); }; PickListWindow frm = new PickListWindow(user, String.Format("Distinct values for {0}_{1}", table, field), itemsFunc, null, filter, ownerControl, ownerAncestor); if (frm.ShowDialog().GetValueOrDefault(false)) { return(frm.SelectedValue as string); } ; return(null); }
private void AddNewTrait() { var service = new SupportService(User); List <String> traitTypes = service.GetTraitNamesForCategory(TraitCategory.ToString()); var picklist = new PickListWindow(User, "Choose a trait type...", () => { return(traitTypes); }, (text) => { traitTypes.Add(text); return(true); }); picklist.Owner = this.FindParentWindow(); if (picklist.ShowDialog().ValueOrFalse()) { var existing = FindTraitByName(picklist.SelectedValue as string); if (existing == null) { Trait t = new Trait(); t.TraitID = -1; t.Value = "<New Trait Value>"; t.Category = TraitCategory.ToString(); t.IntraCatID = Owner.ObjectID.Value; t.Name = picklist.SelectedValue as string; TraitViewModel viewModel = new TraitViewModel(t); _model.Add(viewModel); RegisterUniquePendingChange(new UpdateTraitDatabaseCommand(t, Owner)); ReloadTraitPanel(); SelectTrait(viewModel); } else { SelectTrait(existing); } } }
private int? ChooseTemplateId(Func<List<SiteExplorerNode>> func) { var pickList = new PickListWindow(User, "Select template", () => { var templates = func(); return templates.Select(m => new SiteExplorerNodeViewModel(m)); }, null); if (pickList.ShowDialog().ValueOrFalse()) { var selected = pickList.SelectedValue as SiteExplorerNodeViewModel; if (selected != null) { return selected.ElemID; } } return null; }
public int? ChooseTemplate(SiteExplorerNodeType templateType) { var picklist = new PickListWindow(User, "Select Template", () => { var service = new MaterialService(User); List<SiteExplorerNode> list = new List<SiteExplorerNode>(); switch (templateType) { case SiteExplorerNodeType.Site: list.AddRange(service.GetSiteTemplates()); break; case SiteExplorerNodeType.SiteVisit: list.AddRange(service.GetSiteVisitTemplates()); break; case SiteExplorerNodeType.Material: list.AddRange(service.GetMaterialTemplates()); break; } return list.ConvertAll((node) => { return new SiteExplorerNodeViewModel(node); }); }, null); if (picklist.ShowDialog().GetValueOrDefault(false)) { var selected = picklist.SelectedValue as SiteExplorerNodeViewModel; if (selected != null) { return selected.ElemID; } } return null; }
private void AddNewTrait() { var service = new SupportService(User); List<String> traitTypes = service.GetTraitNamesForCategory(TraitCategory.ToString()); var picklist = new PickListWindow(User, "Choose a trait type...", () => { return traitTypes; }, (text) => { traitTypes.Add(text); return true; }); picklist.Owner = this.FindParentWindow(); if (picklist.ShowDialog().ValueOrFalse()) { var existing = FindTraitByName(picklist.SelectedValue as string); if (existing == null) { Trait t = new Trait(); t.TraitID = -1; t.Value = "<New Trait Value>"; t.Category = TraitCategory.ToString(); t.IntraCatID = Owner.ObjectID.Value; t.Name = picklist.SelectedValue as string; TraitViewModel viewModel = new TraitViewModel(t); _model.Add(viewModel); RegisterUniquePendingChange(new UpdateTraitDatabaseCommand(t, Owner)); ReloadTraitPanel(); SelectTrait(viewModel); } else { SelectTrait(existing); } } }
private string SelectRefType() { var frm = new PickListWindow(User, "Reference Link types", () => { 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; }, (newval) => { Service.InsertRefLinkType(newval, Category.ToString()); return true; }); if (frm.ShowDialog().ValueOrFalse()) { return frm.SelectedValue as string; } return null; }
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; }
public static string ShowDistinctList(User user, string table, string field, string filter, Control ownerControl = null, Control ownerAncestor = null) { var service = new SupportService(user); Func<IEnumerable<string>> itemsFunc = () => { return service.GetDistinctValues(table, field); }; PickListWindow frm = new PickListWindow(user, String.Format("Distinct values for {0}_{1}",table, field), itemsFunc, null, filter, ownerControl, ownerAncestor); if (frm.ShowDialog().GetValueOrDefault(false)) { return frm.SelectedValue as string; }; return null; }
private void DoFind(bool PositionUnderControl) { var preSelectionLength = txt.SelectionLength; Func<IEnumerable<string>> itemsFunc = () => { var service = new MaterialService(User); return service.GetDistinctCollectors(); }; Control owner = null; if (PositionUnderControl) { owner = txt; } PickListWindow frm = new PickListWindow(User, "Select a collector", itemsFunc, null, txt.Text, owner, this); if (frm.ShowDialog().ValueOrFalse()) { txt.SelectedText = frm.SelectedValue as string; } }
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); }