Пример #1
0
 /// <summary>
 /// 动态添加病虫害
 /// 异常只能添加一次
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void btnAddPestTab_Tap(object sender, System.Windows.Input.GestureEventArgs e)
 {
     string tabTitle = txtPestTitle.Text;
     var selectedPestType = (ExpanderSelectorDataSource)esPest.Seleted;
     int pestType = ((ListPickerItem)lpPestType.SelectedItem).TabIndex;
     switch (pestType)
     {
         case (1):
             {
                 _pestIndex1++;
                 var index = _pestIndex2 + _pestIndex1;
                 var result = new CollectionTaskResultDisease();
                 result.TabID = index;
                 result.PestID = int.Parse(selectedPestType.ID);
                 result.TaskId = _taskId;
                 var content = new DiseasePestTab(selectedPestType.Name, result);
                 tabList.Items.Insert(index, new PivotItem()
                 {
                     Header = tabTitle,
                     Content = content,
                 });
                 _diseaseList.Add(result);
                 _imageDataDic.Add(int.Parse(selectedPestType.ID), content.ImgDataContext);
                 tabList.SelectedIndex = index;
                 content.EventForMoveToGalleryPage += new EventHandler(SubTab_NavigateToPageEvent);
                 break;
             }
         //虫害
         case (0):
             {
                 _pestIndex2++;
                 var result = new CollectionTaskResultPest();
                 result.TabID = _pestIndex2;
                 result.PestID = int.Parse(selectedPestType.ID);
                 result.TaskId = _taskId;
                 var content = new InsectPestTab(selectedPestType.Name, result);
                 tabList.Items.Insert(_pestIndex2, new PivotItem()
                 {
                     Header = tabTitle,
                     Content = content,
                 });
                 _pestList.Add(result);
                 _imageDataDic.Add(int.Parse(selectedPestType.ID), content.ImgDataContext);
                 tabList.SelectedIndex = _pestIndex2;
                 content.EventForMoveToGalleryPage += new EventHandler(SubTab_NavigateToPageEvent);
                 break;
             }
         //草害
         case (2):
             {
                 _pestIndex3++;
                 var index = _pestIndex2 + _pestIndex1 + _pestIndex3;
                 var result = new CollectionTaskResultWeed();
                 result.TabID = index;
                 result.PestID = int.Parse(selectedPestType.ID);
                 result.TaskId = _taskId;
                 var content = new WeedPestTab(selectedPestType.Name, result);
                 tabList.Items.Insert(index, new PivotItem()
                 {
                     Header = tabTitle,
                     Content = content,
                 });
                 _weedList.Add(result);
                 _imageDataDic.Add(int.Parse(selectedPestType.ID), content.ImgDataContext);
                 tabList.SelectedIndex = index;
                 content.EventForMoveToGalleryPage += new EventHandler(SubTab_NavigateToPageEvent);
                 break;
             }
         //异常
         case (3):
             {
                 if (!_taskException.ExceptionID.HasValue)
                 {
                     _pestIndex4++;
                     var index = _pestIndex2 + _pestIndex1 + _pestIndex3 + _pestIndex4;
                     _taskException.ExceptionID = 0;
                     var content = new ExceptionPestTab(_taskException);
                     tabList.Items.Insert(index, new PivotItem()
                     {
                         Header = tabTitle,
                         Content = content,
                     });
                     _imageDataDic.Add(_taskException.ExceptionID.Value, content.ImgDataContext);
                     tabList.SelectedIndex = index;
                     content.EventForMoveToGalleryPage += new EventHandler(SubTab_NavigateToPageEvent);
                 }
                 break;
             }
     }
     txtPestTitle.Text = String.Empty;
     esPest.DefaultValue = "请选择";
     caPestType.Visibility = Visibility.Collapsed;
     btnAddPestType.Background = new System.Windows.Media.SolidColorBrush(Color.FromArgb(255, 0, 128, 0));
 }
Пример #2
0
 /// <summary>
 /// 初始化病虫草害采集Tab
 /// </summary>
 /// <param name="list"></param>
 private void initTaskPestTypeDetail(List<CollectionTaskPestView> list)
 {
     for (int i = 0; i < list.Count; i++)
     {
         var item = list[i];
         string itemTitle = String.Empty;
         //病害
         if (item.PestType == 1)
         {
             _pestIndex1++;
             var result = new CollectionTaskResultDisease();
             result.TabID = _pestIndex2;
             result.PestID = item.PestID;
             result.TaskId = _taskId;
             itemTitle = "病害" + _pestIndex1;
             var content = new DiseasePestTab(item.PestName, result);
             tabList.Items.Add(new PivotItem()
             {
                 Header = itemTitle,
                 Content = content,
             });
             _diseaseList.Add(result);
             _imageDataDic.Add(item.PestID, content.ImgDataContext);
             content.EventForMoveToGalleryPage += new EventHandler(SubTab_NavigateToPageEvent);
         }
         //虫害
         else if (item.PestType == 0)
         {
             _pestIndex2++;
             itemTitle = "虫害" + _pestIndex2;
             var result = new CollectionTaskResultPest();
             result.TabID = _pestIndex2;
             result.PestID = item.PestID;
             result.TaskId = _taskId;
             var content = new InsectPestTab(item.PestName, result);
             tabList.Items.Add(new PivotItem()
             {
                 Header = itemTitle,
                 Content = content,
             });
             _pestList.Add(result);
             _imageDataDic.Add(item.PestID, content.ImgDataContext);
             content.EventForMoveToGalleryPage += new EventHandler(SubTab_NavigateToPageEvent);
         }
         //草害
         else if (item.PestType == 2)
         {
             _pestIndex3++;
             var result = new CollectionTaskResultWeed();
             result.TabID = _pestIndex3;
             result.PestID = item.PestID;
             result.TaskId = _taskId;
             itemTitle = "草害" + _pestIndex3;
             var content = new WeedPestTab(item.PestName, result);
             tabList.Items.Add(new PivotItem()
             {
                 Header = itemTitle,
                 Content = content,
             });
             _weedList.Add(result);
             _imageDataDic.Add(item.PestID, content.ImgDataContext);
             content.EventForMoveToGalleryPage += new EventHandler(SubTab_NavigateToPageEvent);
         }
         //异常
         else
         {
             _pestIndex4++;
             itemTitle = "异常" + _pestIndex4;
             _taskException.ExceptionID = 0;
             var content = new ExceptionPestTab(_taskException);
             tabList.Items.Add(new PivotItem()
             {
                 Header = itemTitle,
                 Content = content,
             });
             _imageDataDic.Add(_taskException.ExceptionID.Value, content.ImgDataContext);
             content.EventForMoveToGalleryPage += new EventHandler(SubTab_NavigateToPageEvent);
         }
     }
 }