Example #1
0
 private void btnAdd_Click(object sender, EventArgs e)
 {
     _cropDataContext.GetAllCrops((data) =>
     {
         _cropData = data;
         _cropTabIndex++;
         string headerTxt = "作物" + _cropTabIndex;
         var fieldCrop = new FieldCrop();
         var content = new FieldCropTab(_cropData, fieldCrop);
         bodyPiv.Items.Add(new PivotItem
         {
             Header = headerTxt,
             Content = content,
         });
         _fieldCropList.Add(fieldCrop);
         bodyPiv.SelectedIndex = _cropTabIndex;
     });
 }
Example #2
0
        protected override void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            ((PivotItem)bodyPiv.Items[0]).Header = "基本信息";

            if (e.NavigationMode == NavigationMode.New)
            {
                _fieldId = int.Parse(NavigationContext.QueryString["fid"].ToString());
                _field = _fieldDataAccessLayer.Get(_fieldId);
                _fieldCropList = _field.Plantings;
                _fieldSuveryResult.FieldPoints = GeoHelper.ParsePointsFromString(_field.Geo, ';', ',');

                int plantingCount = _fieldCropList.Count;
                esRegion.DefaultValue = _field.RegionName;
                
                _regionDataContext.GetAllRegions((regionData) =>
                {
                    _regionData = regionData;
                    esRegion.DataContext = new ExpanderSelectorDataContext(_regionData.ToList<object>());
                    _cropDataContext.GetAllCrops((cropData) =>
                   {
                       _cropData = cropData;
                       for (_cropTabIndex = 0; _cropTabIndex < plantingCount; _cropTabIndex++)
                       {
                           int index = _cropTabIndex + 1;
                           string headerTxt = "作物" + index;
                           var content = new NyAppWP.Controls.FieldCropTab(_cropData, _fieldCropList[_cropTabIndex], false);
                           bodyPiv.Items.Add(new PivotItem()
                           {
                               Header = headerTxt,
                               Content = content,
                           });
                       }
                       txtFieldArea.Text = _field.Area.ToString("f2", CultureInfo.InvariantCulture);
                       txtFieldName.Text = _field.FarmlandName;
                   });
                });
            }
            //PhoneApplicationService.Current.State.Add("fieldSurveyResult", fsRst);
            //if (PhoneApplicationService.Current.State.ContainsKey("fieldSurveyResult"))
            //{
            //    Object obj;
            //    PhoneApplicationService.Current.State.TryGetValue("fieldSurveyResult", out obj);
            //    FieldSurveyResult fr = (FieldSurveyResult)obj;
            //    if (fr.FieldID == _guid.ToString())
            //    {
            //        var ptList = fr.FieldPoints.ToList();
            //        System.Text.StringBuilder sb = new System.Text.StringBuilder();
            //        foreach (GeoCoordinate coor in ptList)
            //        {
            //            sb.Append(coor.Longitude.ToString("#0.000000")).Append(",").Append(coor.Latitude.ToString("#0.000000")).Append(";");
            //        }

            //        this._fieldGPSPoints = sb.ToString();
            //        this._area = fr.FieldArea;
            //    }
            //}
        }