public TraitControl(User user, TraitCategoryType category, ViewModelBase owner, bool RDEMode = false) : base(user, "Traits:" + category.ToString() + ":" + (owner == null ? -1 : owner.ObjectID.Value)) { this.TraitCategory = category; this.Owner = owner; _rdeMode = RDEMode; InitializeComponent(); }
public static int GetTraitCategoryTypeID(TraitCategoryType type) { lock (_IDMap) { if (!_IDMap.ContainsKey(type)) { var service = new XMLIOService(PluginManager.Instance.User); var id = service.GetTraitCategoryID(type.ToString()); _IDMap[type] = id; } } return(_IDMap[type]); }
public ReferencesControl(User user, TraitCategoryType category, int?intraCategoryID) : base(user, String.Format("References::{0}::{1}", category, intraCategoryID)) { InitializeComponent(); this.Category = category; this.IntraCategoryID = intraCategoryID.Value; txtRefType.Click += new RoutedEventHandler((source, e) => { var reftype = SelectRefType(); if (!string.IsNullOrEmpty(reftype)) { txtRefType.Text = reftype; } }); txtReference.BindUser(user, LookupType.Reference); txtReference.ObjectSelected += new ObjectSelectedHandler(txtReference_ObjectSelected); var list = Service.GetReferenceLinks(category.ToString(), IntraCategoryID); _model = new ObservableCollection <RefLinkViewModel>(list.ConvertAll((rl) => { var vm = new RefLinkViewModel(rl); vm.DataChanged += new DataChangedHandler((changed) => { RegisterUniquePendingChange(new UpdateRefLinkCommand(vm.Model, Category.ToString())); }); return(vm); })); gridRefLink.IsEnabled = false; lstReferences.ItemsSource = _model; lstReferences.SelectionChanged += new SelectionChangedEventHandler((source, e) => { if (!gridRefLink.IsEnabled) { gridRefLink.IsEnabled = true; } gridRefLink.DataContext = lstReferences.SelectedItem; }); }
public ReferencesControl(User user, TraitCategoryType category, int? intraCategoryID) : base(user, String.Format("References::{0}::{1}", category, intraCategoryID)) { InitializeComponent(); this.Category = category; this.IntraCategoryID = intraCategoryID.Value; txtRefType.Click += new RoutedEventHandler((source, e) => { var reftype = SelectRefType(); if (!string.IsNullOrEmpty(reftype)) { txtRefType.Text = reftype; } }); txtReference.BindUser(user, LookupType.Reference); txtReference.ObjectSelected += new ObjectSelectedHandler(txtReference_ObjectSelected); var list = Service.GetReferenceLinks(category.ToString(), IntraCategoryID); _model = new ObservableCollection<RefLinkViewModel>(list.ConvertAll((rl) => { var vm = new RefLinkViewModel(rl); vm.DataChanged += new DataChangedHandler((changed) => { RegisterUniquePendingChange(new UpdateRefLinkCommand(vm.Model, Category.ToString())); }); return vm; })); gridRefLink.IsEnabled = false; lstReferences.ItemsSource = _model; lstReferences.SelectionChanged += new SelectionChangedEventHandler((source, e) => { if (!gridRefLink.IsEnabled) { gridRefLink.IsEnabled = true; } gridRefLink.DataContext = lstReferences.SelectedItem; }); }
public MultimediaControl(User user, TraitCategoryType category, ViewModelBase owner) : base(user, "Multimedia:" + category.ToString() + ":" + (owner == null ? -1 : owner.ObjectID.Value)) { this.CategoryType = category; this.Owner = owner; InitializeComponent(); txtMultimediaType.BindUser(user, PickListType.MultimediaType, null, TraitCategoryType.Multimedia); _tempFileManager = new KeyedObjectTempFileManager<int?>((mmId) => { if (mmId.HasValue) { byte[] bytes = Service.GetMultimediaBytes(mmId.Value); if (bytes != null) { return new MemoryStream(bytes); } } return null; }); detailGrid.IsEnabled = false; thumbList.SelectionChanged += new SelectionChangedEventHandler(thumbList_SelectionChanged); }
public MultimediaControl(User user, TraitCategoryType category, ViewModelBase owner) : base(user, "Multimedia:" + category.ToString() + ":" + (owner == null ? -1 : owner.ObjectID.Value)) { this.CategoryType = category; this.Owner = owner; InitializeComponent(); txtMultimediaType.BindUser(user, PickListType.MultimediaType, null, TraitCategoryType.Multimedia); _tempFileManager = new KeyedObjectTempFileManager <int?>((mmId) => { if (mmId.HasValue) { byte[] bytes = Service.GetMultimediaBytes(mmId.Value); if (bytes != null) { return(new MemoryStream(bytes)); } } return(null); }); detailGrid.IsEnabled = false; thumbList.SelectionChanged += new SelectionChangedEventHandler(thumbList_SelectionChanged); }
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 int GetTraitCategoryTypeID(TraitCategoryType type) { lock (_IDMap) { if (!_IDMap.ContainsKey(type)) { var service = new XMLIOService(PluginManager.Instance.User); var id = service.GetTraitCategoryID(type.ToString()); _IDMap[type] = id; } } return _IDMap[type]; }
public NotesControl(User user, TraitCategoryType category, ViewModelBase owner) : base(user, "Notes:" + category.ToString() + ":" + owner.ObjectID.Value) { InitializeComponent(); TraitCategory = category; this.Owner = owner; btnColor.SelectedColorChanged += new RoutedPropertyChangedEventHandler <Color>(btnColor_SelectedColorChanged); }
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 TraitControl(User user, TraitCategoryType category, ViewModelBase owner, bool RDEMode = false) : base(user, "Traits:" + category.ToString() + ":" + (owner == null ? -1 : owner.ObjectID.Value)) { this.TraitCategory = category; this.Owner = owner; _rdeMode = RDEMode; InitializeComponent(); }