public override Data.DataMatrix ExtractReportData(IProgressObserver progress) { var service = new MaterialService(User); if (progress != null) { progress.ProgressStart(string.Format("Retrieving Material records for Trap {0}", Trap.DisplayLabel), true); } var serviceMessage = new ServiceMessageDelegate((message) => { progress.ProgressMessage(message, 0); }); service.ServiceMessage += serviceMessage; DataMatrix matrix = service.GetMaterialForTrap(Trap.ElemID); service.ServiceMessage -= serviceMessage; if (progress != null) { progress.ProgressEnd(string.Format("{0} rows retreived", matrix.Rows.Count)); } matrix.Columns.Add(new FormattedLatLongVirtualColumn(matrix)); matrix.Columns.Add(new FormattedDateVirtualColumn(matrix)); return matrix; }
public MaterialDetails(User user, int materialID, bool readOnly) : base(user, "Material:" + materialID) { InitializeComponent(); var service = new MaterialService(user); var model = service.GetMaterial(materialID); _viewModel = new MaterialViewModel(model); _viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged); this.DataContext = _viewModel; this.IsReadOnly = readOnly; // General tab txtAccessionNumber.BindUser(User, "MaterialAccessionNo", "tblMaterial", "vchrAccessionNo"); txtRegistrationNumber.BindUser(User, "MaterialRegNo", "tblMaterial", "vchrRegNo" ); txtCollectorNo.BindUser(User, "MaterialCollectorNo", "tblMaterial", "vchrCollectorNo"); txtAbundance.BindUser(user, PickListType.Phrase, "Material Abundance", TraitCategoryType.Material); txtSource.BindUser(user, PickListType.Phrase, "Material Source", TraitCategoryType.Material); txtInstitution.BindUser(user, PickListType.Phrase, "Institution", TraitCategoryType.Material); txtCollectionMethod.BindUser(user, PickListType.Phrase, "Collection Method", TraitCategoryType.Material); txtMacroHabitat.BindUser(user, PickListType.Phrase, "Macro Habitat", TraitCategoryType.Material); txtMicroHabitat.BindUser(user, PickListType.Phrase, "Micro Habitat", TraitCategoryType.Material); txtTrap.BindUser(User, LookupType.Trap); // Identification tab txtIdentification.BindUser(User, LookupType.Taxon, LookupOptions.TaxonExcludeAvailableNames); txtIdentification.ObjectIDChanged += new ObjectIDChangedHandler(txtIdentification_ObjectIDChanged); txtIdentifiedBy.BindUser(User, "tblMaterial", "vchrIDBy"); txtReference.BindUser(User, LookupType.Reference); txtAccuracy.BindUser(User, PickListType.Phrase, "Identification Accuracy", TraitCategoryType.Material); txtMethod.BindUser(User, PickListType.Phrase, "Identification Method", TraitCategoryType.Material); txtNameQual.BindUser(User, PickListType.Phrase, "Identification Qualifier", TraitCategoryType.Material); _historyControl = new IdentificationHistoryControl(user, materialID); _historyControl.Margin = new Thickness(0); tabIDHistory.Content = _historyControl; var partsControl = new MaterialPartsControl(User, _viewModel) { IsReadOnly = readOnly }; tabMaterial.AddTabItem("Subparts", partsControl); tabMaterial.AddTabItem("Associates", new OneToManyControl(new AssociatesOneToManyController(User, TraitCategoryType.Material, _viewModel)) { IsReadOnly = readOnly }); tabMaterial.AddTabItem("Events", new CurationEventsControl(User, materialID, partsControl)); tabMaterial.AddTabItem("Labels", new MaterialLabelsControl(_viewModel)); tabMaterial.AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Material, _viewModel) { IsReadOnly = readOnly }); tabMaterial.AddTabItem("Notes", new NotesControl(User, TraitCategoryType.Material, _viewModel) { IsReadOnly = readOnly }); tabMaterial.AddTabItem("Multimedia", new MultimediaControl(User, TraitCategoryType.Material, _viewModel) { IsReadOnly = readOnly }); tabMaterial.AddTabItem("Ownership", new OwnershipDetails(model)); if (!model.IsTemplate) { tabMaterial.AddTabItem("Summary", new MaterialSummary(User, _viewModel)); } }
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 TrapDetails(User user, int trapID, bool readOnly) : base(user, "Trap:" + trapID) { InitializeComponent(); var service = new MaterialService(user); var model = service.GetTrap(trapID); var viewModel = new TrapViewModel(model); IsReadOnly = readOnly; this.DataContext = viewModel; viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged); txtTrapType.BindUser(User, PickListType.Phrase, "Trap Type", TraitCategoryType.Trap); tabTrap.AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Trap, viewModel) { IsReadOnly = readOnly }); tabTrap.AddTabItem("Notes", new NotesControl(User, TraitCategoryType.Trap, viewModel) { IsReadOnly = readOnly }); tabTrap.AddTabItem("Ownership", new OwnershipDetails(model)); }
public SiteVisitDetails(User user, int siteVisitId, bool readOnly) : base(user, "SiteVisit:" + siteVisitId) { InitializeComponent(); this.IsReadOnly = readOnly; var service = new MaterialService(user); var model = service.GetSiteVisit(siteVisitId); var viewModel = new SiteVisitViewModel(model); this.DataContext = viewModel; txtCollector.BindUser(user); viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged); tab.AddTabItem("Traits", new TraitControl(user, TraitCategoryType.SiteVisit, viewModel) { IsReadOnly = readOnly }); tab.AddTabItem("Notes", new NotesControl(user, TraitCategoryType.SiteVisit, viewModel) { IsReadOnly = readOnly }); tab.AddTabItem("Ownership", new OwnershipDetails(model)); }
public SiteDetails(User user, int siteID, bool readOnly) : base(user, "Site:" + siteID) { InitializeComponent(); this.SiteID = siteID; this.IsReadOnly = readOnly; var list = new List<Ellipsoid>(GeoUtils.ELLIPSOIDS); cmbDatum.ItemsSource = new ObservableCollection<string>(list.ConvertAll((ellipsoid) => { return ellipsoid.Name; })); if (GoogleEarth.IsInstalled()) { coordGrid.ColumnDefinitions[7].Width = new GridLength(23); } else { coordGrid.ColumnDefinitions[7].Width = new GridLength(0); } // Radio button checked event handlers optNearestPlace.Checked += new RoutedEventHandler((s, e) => { txtLocality.IsEnabled = false; txtDirectionFrom.IsEnabled = true; txtDistanceFrom.IsEnabled = true; txtFrom.IsEnabled = true; }); optLocality.Checked += new RoutedEventHandler((s, e) => { txtLocality.IsEnabled = true; txtDirectionFrom.IsEnabled = false; txtDistanceFrom.IsEnabled = false; txtFrom.IsEnabled = false; }); var service = new MaterialService(User); var model = service.GetSite(SiteID); _viewModel = new SiteViewModel(model); this.DataContext = _viewModel; tabSite.AddTabItem("Traits", new TraitControl(User, TraitCategoryType.Site, _viewModel) { IsReadOnly = readOnly }); tabSite.AddTabItem("Notes", new NotesControl(User, TraitCategoryType.Site, _viewModel) { IsReadOnly = readOnly }); tabSite.AddTabItem("Multimedia", new MultimediaControl(User, TraitCategoryType.Site, _viewModel) { IsReadOnly = readOnly }); tabSite.AddTabItem("Ownership", new OwnershipDetails(_viewModel.Model)); txtPosSource.BindUser(User, PickListType.Phrase, "Source", TraitCategoryType.Site); txtPosWho.BindUser(User, "tblSite", "vchrPosWho"); txtPosOriginal.BindUser(User, PickListType.Phrase, "OriginalDetermination", TraitCategoryType.Site); txtElevUnits.BindUser(User, PickListType.Phrase, "Units", TraitCategoryType.Site); txtElevSource.BindUser(User, PickListType.Phrase, "Source", TraitCategoryType.Site); txtGeoEra.BindUser(User, PickListType.Phrase, "Geological Era", TraitCategoryType.Site); txtGeoPlate.BindUser(User, PickListType.Phrase, "Geological Plate", TraitCategoryType.Site); txtGeoStage.BindUser(User, PickListType.Phrase, "Geological State", TraitCategoryType.Site); txtGeoFormation.BindUser(User, PickListType.Phrase, "Geological Formation", TraitCategoryType.Site); txtGeoMember.BindUser(User, PickListType.Phrase, "Geological Member", TraitCategoryType.Site); txtGeoBed.BindUser(User, PickListType.Phrase, "Geological Bed", TraitCategoryType.Site); this.ctlX1.CoordinateValueChanged += new CoordinateValueChangedHandler((s, v) => { UpdateMiniMap(ctlY1.Value, ctlX1.Value); }); this.ctlY1.CoordinateValueChanged += new CoordinateValueChangedHandler((s, v) => { UpdateMiniMap(ctlY1.Value, ctlX1.Value); }); this.ctlX2.Visibility = System.Windows.Visibility.Hidden; this.ctlY2.Visibility = System.Windows.Visibility.Hidden; txtPoliticalRegion.BindUser(User, LookupType.Region); string llmode = Config.GetUser(User, "SiteDetails.LatLongFormat", LatLongMode.DegreesMinutesSeconds.ToString()); if (!String.IsNullOrEmpty(llmode)) { LatLongMode mode = (LatLongMode)Enum.Parse(typeof(LatLongMode), llmode); SwitchLatLongFormat(mode); } optPoint.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); }); optLine.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); }); optBoundingBox.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); }); optCoordsNotSpecified.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); }); optEastingsNorthings.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); }); optLatLong.Checked += new RoutedEventHandler((s, e) => { UpdateGeomType(); }); optElevDepth.Checked += new RoutedEventHandler(UpdateElevation); optElevElevation.Checked += new RoutedEventHandler(UpdateElevation); optElevNotSpecified.Checked += new RoutedEventHandler(UpdateElevation); if (model.PosY1.HasValue && model.PosX1.HasValue) { UpdateMiniMap(model.PosY1.Value, model.PosX1.Value); } this.PreviewDragOver += new DragEventHandler(site_PreviewDragEnter); this.PreviewDragEnter += new DragEventHandler(site_PreviewDragEnter); //this.Drop += new DragEventHandler(site_Drop); HookLatLongControl(ctlX1); HookLatLongControl(ctlY1); HookLatLongControl(ctlX2); HookLatLongControl(ctlY2); this.Loaded += new RoutedEventHandler(SiteDetails_Loaded); }
private int AddMaterial(int siteVisitId, int taxonId) { var sparcService = new MaterialService(User); var sMaterialName = Get("Material.Material name"); var sAccessionNumber = Get("Material.Accession number"); var sRegistrationNumber = Get("Material.Registration number"); var sCollectorNumber = Get("Material.Collector number"); var sIDBy = Get("Material.Identified by"); var sIDOn = Get("Material.Identified on"); if (!string.IsNullOrWhiteSpace(sIDOn)) { string message; if (DateUtils.IsValidBLDate(sIDOn, out message)) { sIDOn = string.Format("{0:dd MMM yyyy}", DateUtils.MakeCompatibleBLDate(Int32.Parse(sIDOn))); } else { if (!Information.IsDate(sIDOn)) { throw new Exception("'Identified on' value (" + sIDOn + ") is not a valid date time! " + message); } } } var sIDRef = Get("Material.Identification reference"); var sIDRefPage = Get("Material.Identification reference page"); var sIDMethod = Get("Material.Identification method"); var sIDAccuracy = Get("Material.Identification accuracy"); var sIDNameQualifier = Get("Material.Name qualifier"); var sIDNotes = Get("Material.Identification notes"); var sInstitution = Get("Material.Institute"); var sCollectMethod = Get("Material.Collection method"); var sAbundance = Get("Material.Abundance"); var sMacroHabitat = Get("Material.Macrohabitat"); var sMicrohabitat = Get("Material.Microhabitat"); var sSource = Get("Material.Source"); var sSpecialLabel = Get("Material.Special label"); var bCreateLabel = GetConvert<bool>("Material.Create Label", false); var sDateStart = Get("SiteVisit.Start Date", "0"); string sOriginalLabel = ""; if (bCreateLabel) { if (sDateStart != "0") { string message; if (DateUtils.IsValidBLDate(sDateStart, out message)) { sDateStart = BuildDate(sDateStart); } } sOriginalLabel = "Import derived: " + Get("Site.Locality") + "; " + Get("SiteVisit.Collector(s)") + "; " + sDateStart; } else { sOriginalLabel = Get("Material.Original label"); } if (string.IsNullOrWhiteSpace(sMaterialName)) { if (!string.IsNullOrWhiteSpace(sInstitution)) { if (!string.IsNullOrWhiteSpace(sAccessionNumber)) { sMaterialName = string.Format("{0}:{1}", sInstitution, sAccessionNumber); } else { if (!string.IsNullOrWhiteSpace(sRegistrationNumber)) { sMaterialName = string.Format("{0}:{1}", sInstitution, sRegistrationNumber); } } } else { if (!string.IsNullOrWhiteSpace(sAccessionNumber)) { sMaterialName = sAccessionNumber; } else { if (!string.IsNullOrWhiteSpace(sRegistrationNumber)) { sMaterialName = sRegistrationNumber; } } } } var material = new Material { MaterialName = sMaterialName, SiteVisitID = siteVisitId, AccessionNumber = sAccessionNumber, RegistrationNumber = sRegistrationNumber, CollectorNumber = sCollectorNumber, BiotaID = taxonId, IdentifiedBy = sIDBy, IdentificationDate = (string.IsNullOrWhiteSpace(sIDOn) ? null : new DateTime?(DateAndTime.DateValue(sIDOn))), IdentificationReferenceID = (!string.IsNullOrWhiteSpace(sIDRef) && sIDRef.IsNumeric()) ? Int32.Parse(sIDRef) : 0, IdentificationRefPage = sIDRefPage, IdentificationMethod = sIDMethod, IdentificationAccuracy = sIDAccuracy, IdentificationNameQualification = sIDNameQualifier, IdentificationNotes = sIDNotes, Institution = sInstitution, CollectionMethod = sCollectMethod, Abundance = sAbundance, MacroHabitat = sMacroHabitat, MicroHabitat = sMicrohabitat, Source = sSource, SpecialLabel = sSpecialLabel, OriginalLabel = sOriginalLabel }; return Service.ImportMaterial(material); }
private void LoadSiteVisitTemplate(int templateId) { var service = new MaterialService(User); var list = service.GetRDESiteVisits(new[] { templateId }); if (list != null && list.Count > 0) { _siteVisitTemplate = new RDESiteVisitViewModel(list[0]); } if (_siteVisitTemplate != null) { mnuSetSiteVisitTemplate.Header = String.Format("Set Site _Visit Template ({0}) ...", _siteVisitTemplate.VisitName); Config.SetProfile(User, ConfigSitevisitTemplateId, templateId); } else { mnuSetSiteVisitTemplate.Header = "Set Site _Visit Template..."; Config.SetProfile(User, ConfigSitevisitTemplateId, -1); } }
private void LoadMaterialTemplate(int templateId) { var supportService = new SupportService(User); var service = new MaterialService(User); var list = service.GetRDEMaterial(new[] { templateId }); if (list != null && list.Count > 0) { _materialTemplate = new RDEMaterialViewModel(list[0]); _materialTemplate.Traits = supportService.GetTraits(TraitCategoryType.Material.ToString(), _materialTemplate.MaterialID); // need to get associates and subparts... var subparts = service.GetMaterialParts(templateId); var associates = supportService.GetAssociates(TraitCategoryType.Material.ToString(), templateId); foreach (Associate assoc in associates) { var vm = new AssociateViewModel(assoc); _materialTemplate.Associates.Add(vm); } foreach (MaterialPart part in subparts) { var vm = new MaterialPartViewModel(part); _materialTemplate.SubParts.Add(vm); } } if (_materialTemplate != null) { mnuSetMaterialTemplate.Header = String.Format("Set _Material Template ({0}) ...", _materialTemplate.MaterialName); Config.SetProfile(User, ConfigMaterialTemplateId, templateId); } else { mnuSetMaterialTemplate.Header = "Set _Material Template..."; Config.SetProfile(User, ConfigMaterialTemplateId, -1); } }
protected void LoadEvents() { detailsGrid.IsEnabled = false; var service = new MaterialService(User); var list = service.GetCurationEvents(MaterialID); _model = new ObservableCollection<CurationEventViewModel>(list.ConvertAll((model) => { var viewModel = new CurationEventViewModel(model); viewModel.DataChanged += new DataChangedHandler(viewModel_DataChanged); return viewModel; })); lstEvents.ItemsSource = _model; if (_model.Count > 0) { lstEvents.SelectedItem = _model[0]; } _populated = true; }
public int ImportMaterial(Material m) { var matService = new MaterialService(User); m.MaterialID = matService.InsertMaterial(m.SiteVisitID); matService.UpdateMaterial(m); return m.MaterialID; }
public override Data.DataMatrix ExtractReportData(Utilities.IProgressObserver progress) { var service = new MaterialService(PluginManager.Instance.User); return service.GetDarwinCoreForBiotaID(Taxon.TaxaID.Value); }
void grpDiff_DataContextChanged(object sender, DependencyPropertyChangedEventArgs e) { var service = new MaterialService(User); var other = e.NewValue as SiteExplorerNodeViewModel; if (other != null) { var differences = service.CompareSites(Destination.ElemID, other.ElemID); lvw.ItemsSource = new ObservableCollection<SiteDifferenceViewModel>(differences.ConvertAll((m) => { return new SiteDifferenceViewModel(m); })); } }
public override DataMatrix ExtractReportData(IProgressObserver progress) { var service = new MaterialService(User); var filterText = string.Format("Taxon: {0}, {1}: {2}", TaxonID.HasValue && TaxonID.Value > 0 ? TaxonName : "All taxon", ElemType, SiteRegionName); return service.GetTaxaForSites(true, ElemType, SiteRegionID.Value, TaxonID.GetValueOrDefault(-1), filterText); }
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; } }
private RDESiteViewModel BuildModel(int objectId, SiteExplorerNodeType objectType) { var service = new MaterialService(User); var supportService = new SupportService(User); RDESiteViewModel root = null; List<RDEMaterial> material; if (objectId < 0) { root = CreateSiteViewModel(new RDESite { LocalType=0 }); root.Locked = false; RegisterPendingChange(new InsertRDESiteCommand(root.Model)); var siteVisit = AddNewSiteVisit(root); AddNewMaterial(siteVisit); return root; } switch (objectType) { case SiteExplorerNodeType.Site: var sites = service.GetRDESites(new[] { objectId }); if (sites.Count > 0) { root = CreateSiteViewModel(sites[0]); var siteVisits = service.GetRDESiteVisits(new[] {root.SiteID}, RDEObjectType.Site); var idList = new List<Int32>(); // This collection will keep track of every site visit id for later use... root.SiteVisits = new ObservableCollection<ViewModelBase>(siteVisits.ConvertAll(sv => { var vm = CreateSiteVisitViewModel(sv, root); idList.Add(vm.SiteVisitID); return vm; })); // This service call gets all the material for all site visits, saving multiple round trips to the database material = service.GetRDEMaterial(idList.ToArray(), RDEObjectType.SiteVisit); // But now we have to attach the material to the right visit... foreach (RDESiteVisitViewModel sv in root.SiteVisits) { // select out which material belongs to the current visit... RDESiteVisitViewModel sv1 = sv; var selected = material.Where(m => m.SiteVisitID == sv1.SiteVisitID); // create the material view models and attach to the visit. sv.Material = CreateMaterialViewModels(selected, sv); } } break; case SiteExplorerNodeType.SiteVisit: var visits = service.GetRDESiteVisits(new[] { objectId }); if (visits.Count > 0) { // get the site ... sites = service.GetRDESites(new[] { visits[0].SiteID }); if (sites.Count > 0) { root = CreateSiteViewModel(sites[0]); var visitModel = CreateSiteVisitViewModel(visits[0], root); // get the material... material = service.GetRDEMaterial(new[] { visitModel.SiteVisitID }, RDEObjectType.SiteVisit); CreateMaterialViewModels(material, visitModel); } } break; case SiteExplorerNodeType.Material: material = service.GetRDEMaterial(new[] { objectId }); if (material.Count > 0) { var m = material[0]; // Get the Visit... visits = service.GetRDESiteVisits(new[] { m.SiteVisitID }); if (visits.Count > 0) { // Get the site... sites = service.GetRDESites(new[] { visits[0].SiteID }); if (sites.Count > 0) { root = CreateSiteViewModel(sites[0]); var siteVisit = CreateSiteVisitViewModel(visits[0], root); CreateMaterialViewModels(material, siteVisit); } } } break; } if (root != null) { // Get a single list of all the material view models loaded... var materialList = new List<RDEMaterialViewModel>(); root.SiteVisits.ForEach(vm => { var sv = vm as RDESiteVisitViewModel; if (sv != null) { sv.Material.ForEach(vm2 => { var m = vm2 as RDEMaterialViewModel; materialList.Add(m); }); } }); var materialIds = materialList.Select(m => m.MaterialID).ToArray(); // for the material id list we can extract all the subparts in one round trip... var subparts = service.GetMaterialParts(materialIds); // and associates as well. This means we only need one pass through the material list in order to // hook up subordinate records var associates = supportService.GetAssociates(TraitCategoryType.Material.ToString(), materialIds); // But we have to hook them back up to the right material. foreach (RDEMaterialViewModel m in materialList) { var mlocal = m; var selectedSubParts = subparts.Where(part => part.MaterialID == mlocal.MaterialID); m.SubParts = new ObservableCollection<ViewModelBase>(selectedSubParts.Select(part => { var vm = new MaterialPartViewModel(part) { Locked = mlocal.Locked }; vm.DataChanged += SubPartDataChanged; return vm; })); RDEMaterialViewModel m1 = m; var selectedAssociates = associates.Where(assoc => assoc.FromIntraCatID == m1.MaterialID || assoc.ToIntraCatID == m1.MaterialID); m.Associates = new ObservableCollection<ViewModelBase>(selectedAssociates.Select(assoc => { var vm = new AssociateViewModel(assoc); vm.DataChanged += AssociateDataChanged; return vm; })); } } return root; }
private void ChooseSiteVisitTemplate() { var service = new MaterialService(User); var templateId = ChooseTemplateId(service.GetSiteVisitTemplates); if (templateId != null) { LoadSiteVisitTemplate(templateId.Value); } }
void viewModel_LazyLoadChildren(HierarchicalViewModelBase item) { using (new OverrideCursor(Cursors.Wait)) { var parent = item as SiteExplorerNodeViewModel; if (parent != null) { parent.Children.Clear(); var service = new MaterialService(User); var list = service.GetExplorerElementsForParent(parent.ElemID, parent.ElemType); var viewModel = BuildExplorerModel(list, parent.IsFindViewModel); foreach (HierarchicalViewModelBase childViewModel in viewModel) { childViewModel.Parent = parent; parent.Children.Add(childViewModel); } } } }
private void LoadSiteTemplate(int templateId) { var service = new MaterialService(User); var list = service.GetRDESites(templateId); if (list != null && list.Count > 0) { _siteTemplate = CreateSiteViewModel(list[0], false); } else { _siteTemplate = null; } if (_siteTemplate != null) { mnuSetSiteTemplate.Header = String.Format("Set _Site Template ({0}) ...", _siteTemplate.SiteName); Config.SetProfile(User, ConfigSiteTemplateId, templateId); } else { mnuSetSiteTemplate.Header = "Set _Site Template..."; Config.SetProfile(User, ConfigSiteTemplateId, -1); } }
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; }
protected override Data.Model.BioLinkDataObject GetModel() { var service = new MaterialService(User); OwnedDataObject obj = null; switch (ElemType) { case "Region": obj = service.GetRegion(ObjectID); break; case "Site": obj = service.GetSite(ObjectID); break; case "SiteVisit": obj = service.GetSiteVisit(ObjectID); break; case "Material": obj = service.GetMaterial(ObjectID); break; case "SiteGroup": break; case "Trap": obj = service.GetTrap(ObjectID); break; } return obj; }
public void ShowInContents(SiteExplorerNodeViewModel node) { if (node == null) { return; } var parentage = new MaterialService(User).GetSiteExplorerNodeParentage(node.ElemID, node.NodeType); var childlist = RegionsModel; tabMaterial.InvokeIfRequired(() => { tabMaterial.SelectedIndex = 0; // ensure contents tab is showing }); tvwMaterial.InvokeIfRequired(() => { tvwMaterial.Focus(); }); tvwMaterial.InvokeIfRequired(() => { HierarchicalViewModelBase child = null; foreach (SiteExplorerNode element in parentage) { child = childlist.FirstOrDefault((vm) => (vm.ObjectID.HasValue ? vm.ObjectID.Value : 0) == element.ElemID); if (child == null) { break; } if (child.Parent != null && !child.Parent.IsExpanded) { child.Parent.IsExpanded = true; } child.IsExpanded = true; childlist = child.Children; } if (child != null) { tvwMaterial.BringModelToView(child, regionsNode); child.IsSelected = true; } }); }
public override bool Validate(List<string> messages) { if (Preferences.AccessionNumberIsMandatory.Value) { if (string.IsNullOrWhiteSpace(_viewModel.AccessionNumber)) { messages.Add("You must provide an Accession number. (See Tools -> Settings -> Preferences to turn off mandatory accession numbers)"); } } if (Preferences.UniqueAccessionNumbers.Value) { if (!string.IsNullOrWhiteSpace(_viewModel.AccessionNumber)) { var service = new MaterialService(User); var candidateIds = service.GetMaterialIdsByAccessionNo(_viewModel.AccessionNumber); var firstDuplicate = candidateIds.FirstOrDefault((id) => { return id != _viewModel.MaterialID; }); if (firstDuplicate > 0) { messages.Add("There is already material in the database with Accession number " + _viewModel.AccessionNumber + " (Material ID " + firstDuplicate + ")"); } } } return messages.Count == 0; }
public MaterialExplorer(MaterialPlugin owner) : base(owner.User) { InitializeComponent(); BuildDropMap(); this.ChangeRegistered += new PendingChangedRegisteredHandler((s, action) => { btnApply.IsEnabled = true; btnCancel.IsEnabled = true; }); this.ChangesCommitted += new PendingChangesCommittedHandler((list) => { ReloadModel(); btnApply.IsEnabled = false; btnCancel.IsEnabled = false; }); this.Owner = owner; this.RememberExpanded = Config.GetGlobal<bool>("Material.RememberExpandedNodes", true); var findScopes = new List<MaterialFindScope>(); findScopes.Add(new MaterialFindScope("Find in all", "")); findScopes.Add(new MaterialFindScope("Site name", "site")); findScopes.Add(new MaterialFindScope("Trap name", "trap")); findScopes.Add(new MaterialFindScope("Visit name", "visit")); findScopes.Add(new MaterialFindScope("Material name", "material")); findScopes.Add(new MaterialFindScope("Accession No.", "accessionno")); findScopes.Add(new MaterialFindScope("Registraton No.", "regno")); findScopes.Add(new MaterialFindScope("Region name", "region")); findScopes.Add(new MaterialFindScope("Site group name", "group")); findScopes.Add(new MaterialFindScope("Collector #", "collector")); cmbFindScope.ItemsSource = findScopes; cmbFindScope.DisplayMemberPath = "Label"; cmbFindScope.PreviewKeyDown += new KeyEventHandler(cmbFindScope_PreviewKeyDown); int lastSelectedIndex = Config.GetUser(User, "Material.Find.LastFilter", -1); if (lastSelectedIndex < 0 || lastSelectedIndex >= findScopes.Count) { cmbFindScope.SelectedIndex = 0; } else { cmbFindScope.SelectedIndex = lastSelectedIndex; } TreeViewDragHelper.Bind(tvwFind, CreatePinnableDragObject); TreeViewDragHelper.Bind(tvwMaterial, CreatePinnableDragObject); tvwMaterial.PreviewDragOver += new DragEventHandler(tvwMaterial_PreviewDragOver); tvwMaterial.PreviewDragEnter += new DragEventHandler(tvwMaterial_PreviewDragOver); tvwFind.PreviewDragOver += new DragEventHandler(tvwFind_PreviewDragOver); tvwFind.PreviewDragEnter += new DragEventHandler(tvwFind_PreviewDragOver); this.Drop += new DragEventHandler(MaterialExplorer_Drop); var service = new MaterialService(User); tvwMaterial.AllowDrop = true; _favorites = new MaterialFavorites(User, this); tabMaterial.AddTabItem("Favorites", _favorites); txtFind.PreviewKeyDown += new KeyEventHandler(txtFind_PreviewKeyDown); tvwFind.MouseDoubleClick +=new MouseButtonEventHandler((sender,e) => PerformDefaultAction(sender as TreeView) ); tvwMaterial.MouseDoubleClick += new MouseButtonEventHandler((sender, e) => PerformDefaultAction(sender as TreeView)); }
void AddToLabelSet_Loaded(object sender, RoutedEventArgs e) { var service = new MaterialService(User); this.Material = service.GetMaterial(MaterialID); txtItem.Text = Material.MaterialName; var supportService = new SupportService(User); var sets = supportService.GetLabelSets(); cmbLabelSets.ItemsSource = sets; if (sets.Count > 0) { cmbLabelSets.SelectedIndex = 0; optExisting.IsChecked = true; } else { optExisting.IsEnabled = false; optNewLabelSet.IsChecked = true; } }
private void DoFind() { int resultsCount = 0; var text = txtFind.Text; var scope = cmbFindScope.SelectedItem as MaterialFindScope; using (new OverrideCursor(Cursors.Wait)) { if (string.IsNullOrWhiteSpace(text)) { return; } var service = new MaterialService(User); string limitations = ""; if (scope != null) { limitations = scope.Value; } var list = service.FindNodesByName(text, limitations); if (!PluginManager.Instance.CheckSearchResults(list)) { return; } resultsCount = list.Count; var findModel = BuildExplorerModel(list, true); tvwFind.ItemsSource = findModel; tvwFind.UpdateLayout(); if (resultsCount == 0) { InfoBox.Show("No matching elements found.", "No results", this); } } }
private int AddMaterialPart(int materialId) { var numberOfSpecimens = GetConvert<int?>("Material.Number of specimens"); if (!numberOfSpecimens.HasValue || numberOfSpecimens.Value == 0) { numberOfSpecimens = 1; } var part = new MaterialPart { MaterialID = materialId, PartName = Get("Material.Part name"), SampleType = Get("Material.Sample type"), NoSpecimens = numberOfSpecimens, NoSpecimensQual = Get("Material.Number of specimens qualifier"), Lifestage = Get("Material.Life stage"), Gender = Get("Material.Gender"), RegNo = Get("Material.Part registration number"), Condition = Get("Material.Condition"), StorageSite = Get("Material.Storage site"), StorageMethod = Get("Material.Storage method"), CurationStatus = Get("Material.Curation status"), Notes = Get("Material.Subpart Notes") }; var matService = new MaterialService(User); return matService.InsertMaterialPart(part); }
private void LoadExplorerModel() { var service = new MaterialService(User); // Region explorer... var list = service.GetTopLevelExplorerItems(); RegionsModel = BuildExplorerModel(list, false); regionsNode.ItemsSource = RegionsModel; regionsNode.IsExpanded = true; // Unplaced sites (Sites with no region)... list = service.GetTopLevelExplorerItems(SiteExplorerNodeType.Unplaced); UnplacedModel = BuildExplorerModel(list, false); unplacedNode.ItemsSource = UnplacedModel; // Templates... templatesNode.ItemsSource = null; _siteTemplatesRoot = CreateTemplateNode("Site Templates", @"images\Site.png", () => { var templates = service.GetSiteTemplates(); return templates.ConvertAll((m) => { return new SiteExplorerNodeViewModel(m); }); }); _siteVisitTemplatesRoot = CreateTemplateNode("Site Visit Templates", @"images\SiteVisit.png", () => { var templates = service.GetSiteVisitTemplates(); return templates.ConvertAll((m) => { return new SiteExplorerNodeViewModel(m); }); }); _materialTemplatesRoot = CreateTemplateNode("Material Templates", @"images\Material.png", () => { var templates = service.GetMaterialTemplates(); return templates.ConvertAll((m) => { return new SiteExplorerNodeViewModel(m); }); }); }
private void LoadSummary() { var service = new MaterialService(User); String rtf = service.GetMaterialSummary(Material.Model); txtSummary.RTF = rtf; IsPopulated = true; }
public override bool Validate(List<string> messages) { var material = new List<RDEMaterialViewModel>(grpMaterial.Items.Select(vm => vm as RDEMaterialViewModel)); if (Preferences.AccessionNumberIsMandatory.Value) { foreach (RDEMaterialViewModel m in material) { if (String.IsNullOrWhiteSpace(m.AccessionNo)) { messages.Add("At least one piece of material is missing an Accession Number. Please review and provide an Accession number for each piece of material. (See Tools -> Settings -> Preferences to turn off mandatory accession numbers)"); break; } } } if (Preferences.UniqueAccessionNumbers.Value) { if (MaterialControl != null) { if (material.Count() > 0) { var service = new MaterialService(User); var accessionNumbers = new List<String>(); foreach (RDEMaterialViewModel m in material) { // Check only new material if (m.MaterialID < 0 && !string.IsNullOrWhiteSpace(m.AccessionNo)) { if (accessionNumbers.Contains(m.AccessionNo)) { messages.Add("Some of the material you are adding share the same accession number (" + m.AccessionNo + ")"); } var candidateIds = service.GetMaterialIdsByAccessionNo(m.AccessionNo); if (candidateIds.Count > 0) { messages.Add("There is already material in the database with Accession number " + m.AccessionNo + " (Material ID " + candidateIds[0] + ")"); } accessionNumbers.Add(m.AccessionNo); } } } } } return messages.Count == 0; }