Beispiel #1
0
 public async void DelTree()
 {
     if (pickPlot.SelectedIndex > -1 && ToolDelete.Text != "")
     {
         MessagingCenter.Unsubscribe <DeleteConfirm>(this, "Delete");
         MessagingCenter.Subscribe <DeleteConfirm>(this, "Delete", async(sender) => {
             string trees;
             int selec = ((List <DetailsGraph2>)DetailsList.ItemsSource).IndexOf((DetailsGraph2)DetailsList.SelectedItem);
             ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(pickPlot.SelectedIndex).getTrees().RemoveAt(selec);
             Plot ThisPlot        = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(pickPlot.SelectedIndex);
             trees                = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Name") + ": " + ThisPlot.GetName() + " " + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Area") + ": " + Math.Round(ThisPlot.GetArea(), 2) + "km2";
             List <Tree> TreeList = ThisPlot.getTrees();
             Tree ThisTree;
             for (int x = 0; x < TreeList.Count; x++)
             {
                 ThisTree = TreeList.ElementAt(x);
             }
             int storen             = pickPlot.SelectedIndex;
             pickPlot.SelectedIndex = -1;
             pickPlot.SelectedIndex = storen;
             Titlename.Text         = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("ManagePlots") + ": saving";
             SaveAll.GetInstance().SaveTrees2();
             Titlename.Text = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("ManagePlots") + ": saved";
             await Task.Delay(5000);
             Titlename.Text  = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("ManagePlots");
             ToolDelete.Text = "";
         });
         await PopupNavigation.Instance.PushAsync(DeleteConfirm.GetInstance());
     }
 }