Пример #1
0
        private void SelectMaterialByUser()
        {
            var frm = new MaterialByUserWindow((items) => {
                foreach (LabelSetItem item in items)
                {
                    var vm = new LabelSetItemViewModel(item);
                    _itemModel.Add(vm);
                    item.SetID     = CurrentItemSetID;
                    item.NumCopies = 1;
                    Host.RegisterUniquePendingChange(new InsertLabelSetItemCommand(item, CurrentLabelSet.Model));
                }

                ReorderItems();
            });

            frm.Owner = this.FindParentWindow();
            frm.WindowStartupLocation = WindowStartupLocation.CenterOwner;
            frm.ShowDialog().ValueOrFalse();
        }
Пример #2
0
        public void AddItemFromPinnable(PinnableObject pinnable)
        {
            int maxOrder = 0;

            if (_itemModel.Count > 0)
            {
                maxOrder = _itemModel.Max((item) => {
                    return(item.PrintOrder);
                });
            }

            var newItem = new LabelSetItem {
                ItemID = pinnable.ObjectID, ItemType = pinnable.LookupType.ToString(), SetID = CurrentItemSetID, PrintOrder = maxOrder + 1, NumCopies = 1
            };
            var       service  = new MaterialService(User);
            Site      site     = null;
            SiteVisit visit    = null;
            Material  material = null;

            switch (pinnable.LookupType)
            {
            case LookupType.Material:
                material = service.GetMaterial(pinnable.ObjectID);
                visit    = service.GetSiteVisit(material.SiteVisitID);
                site     = service.GetSite(material.SiteID);
                break;

            case LookupType.SiteVisit:
                visit = service.GetSiteVisit(pinnable.ObjectID);
                site  = service.GetSite(visit.SiteID);
                break;

            case LookupType.Site:
                site = service.GetSite(pinnable.ObjectID);
                break;
            }

            if (material != null)
            {
                newItem.MaterialID   = material.MaterialID;
                newItem.TaxaFullName = material.TaxaDesc;
                newItem.AccessionNo  = material.AccessionNumber;
            }

            if (visit != null)
            {
                newItem.VisitID    = visit.SiteVisitID;
                newItem.Collectors = visit.Collector;
                newItem.DateType   = visit.DateType;
                newItem.CasualDate = visit.CasualTime;
                newItem.StartDate  = visit.DateStart;
                newItem.EndDate    = visit.DateEnd;
            }

            if (site != null)
            {
                if (site.PoliticalRegionID <= 0)
                {
                    ErrorMessage.Show("You cannot add this item as it does not belong to a political region (unplaced)");
                    return;
                }

                newItem.SiteID    = site.SiteID;
                newItem.Region    = site.PoliticalRegion;
                newItem.Local     = site.Locality;
                newItem.LocalType = site.LocalityType;
                newItem.Lat       = site.PosY1;
                newItem.Long      = site.PosX1;
                newItem.Lat2      = site.PosY2;
                newItem.Long2     = site.PosX2;
            }


            var vm = new LabelSetItemViewModel(newItem);

            vm.DataChanged += new DataChangedHandler((viewModel) => {
                Host.RegisterUniquePendingChange(new UpdateLabelSetItemCommand(newItem));
            });

            Host.RegisterUniquePendingChange(new InsertLabelSetItemCommand(newItem, CurrentLabelSet.Model));
            _itemModel.Add(vm);
        }
Пример #3
0
 public LabelSetItemTooltip(LabelSetItemViewModel viewModel) : base(viewModel.LabelItemID, viewModel)
 {
 }