예제 #1
0
        public void SavePlots()
        {
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                excelEngine.Excel.DefaultVersion = ExcelVersion.Excel2013;
                IWorkbook workbook = excelEngine.Excel.Workbooks.Create(1);
                workbook.Version = ExcelVersion.Excel97to2003;

                for (int y = 0; y < ((List <Plot>)Application.Current.Properties["Plots"]).Count(); y++)
                {
                    Plot thisPlot = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(y);
                    workbook.Worksheets.Create(thisPlot.GetName());
                    IWorksheet worksheet = workbook.Worksheets[y + 1];


                    worksheet.SetValue(1, 1, "Name");
                    worksheet.SetValue(2, 1, "Co-ordinates");
                    worksheet.SetValue(1, 4, "Owner");
                    worksheet.SetValue(2, 4, "Location");
                    worksheet.SetValue(3, 4, "Year Planted");
                    worksheet.SetValue(4, 4, "Comments");
                    if (thisPlot.Owner != null)
                    {
                        worksheet.SetValue(1, 5, thisPlot.Owner);
                    }
                    if (thisPlot.NearestTown != null)
                    {
                        worksheet.SetValue(2, 5, thisPlot.NearestTown);
                    }
                    if (thisPlot.Describe != null)
                    {
                        worksheet.SetValue(4, 5, thisPlot.Describe);
                    }
                    worksheet.SetValue(3, 5, thisPlot.YearPlanted.ToString());
                    worksheet.SetValue(1, 2, thisPlot.GetName());
                    worksheet.SetValue(2, 2, thisPlot.GetTag()[0].ToString());
                    worksheet.SetValue(2, 3, thisPlot.GetTag()[1].ToString());
                    worksheet.SetValue(3, 1, "Pricing Name");
                    //  if (thisPlot.GetRange() != null){
                    //    worksheet.SetValue(3, 2, thisPlot.GetRange().GetName());
                    // }
                    worksheet.SetValue(3, 3, thisPlot.GetPolygon().Count.ToString());

                    worksheet.SetValue(4, 1, "Border Co-ordinates");
                    worksheet.Range["$A$4:$B$4"].Merge();
                    for (int x = 0; x < thisPlot.GetPolygon().Count; x++)
                    {
                        worksheet.SetValue(5 + x, 1, thisPlot.GetPolygon().ElementAt(x).Latitude.ToString());
                        worksheet.SetValue(5 + x, 2, thisPlot.GetPolygon().ElementAt(x).Longitude.ToString());
                    }
                }

                workbook.Worksheets[0].Remove();
                MemoryStream stream = new MemoryStream();
                workbook.SaveAs(stream);
                workbook.Close();
                Xamarin.Forms.DependencyService.Get <ISave>().Save("Plots.xls", "application/msexcel", stream);
            }
        }
예제 #2
0
        protected override void  OnAppearing()
        {
            base.OnAppearing();
            plotty = new ObservableCollection <PlotContainer>();
            List <string> pickplotlist = new List <string>();

            if (Application.Current.Properties["Language"] != null)
            {
                Thread.CurrentThread.CurrentCulture = (CultureInfo)Application.Current.Properties["Language"];
            }
            PlotList1.Text = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Name");
            PlotList2.Text = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Trees");
            PlotList3.Text = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("DateMade");
            DunLLoadin();
            GraphNo = -1;
            DetailsList.IsVisible = false;
            year = DateTime.Now.Year;
            //pickPlot.Items.Clear();
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("MTY4MzVAMzEzNjJlMzIyZTMwZmMzUTBVc2x2STVZNG4rTm1mdXlXQ1czR09UQ1p0QzB2SmNjWFFtZ2RmOD0=");
            ((List <Plot>)Application.Current.Properties["Plots"]).Count();
            for (int x = 0; x < ((List <Plot>)Application.Current.Properties["Plots"]).Count(); x++)
            {
                Plot thisPlot = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(x);
                plotty.Add(new PlotContainer(thisPlot.GetName(), thisPlot.getTrees().Count, thisPlot.YearPlanted));
                pickplotlist.Add(((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(x).GetName());
            }
            pickPlot.ItemsSource   = pickplotlist;
            PlotList.ItemsSource   = plotty;
            pickPlot.SelectedIndex = -1;
            PlotList.IsVisible     = true;
            Girtdswitch.IsVisible  = false;
            Girtdlab.IsVisible     = false;
        }
예제 #3
0
 private PlotPopupEdit()
 {
     InitializeComponent();
     if (Application.Current.Properties["Language"] != null)
     {
         Thread.CurrentThread.CurrentCulture = (CultureInfo)Application.Current.Properties["Language"];
     }
     EditPlot         = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt((int)Application.Current.Properties["ThisPlot"]);
     Latent.IsVisible = true;
     //Longent.IsVisible = true;
     PlotName.Text = EditPlot.GetName();
     Comments.Text = EditPlot.Describe;
     Location.Text = EditPlot.NearestTown;
     PlotYear.Text = EditPlot.YearPlanted.ToString();
     double[] geo = EditPlot.GetTag();
     Latent.Text = geo[0].ToString() + ", " + geo[1].ToString();
     //Longent.Text = geo[1].ToString();
     Owner.Text = EditPlot.Owner;
 }
예제 #4
0
        public void Kamel()
        {
            string output = "<?xml version =\"1.0\" encoding=\"UTF-8\"?>\n<kml xmlns=\"http://www.opengis.net/kml/2.2\">\n<Document>";

            for (int x = 0; x < ((List <Plot>)Application.Current.Properties["Plots"]).Count; x++)
            {
                Plot ThisPlot = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(x);
                output += "\n<Placemark>\n<name>" + ThisPlot.GetName() + "</name>\n";
                double[] tag = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(x).GetTag();
                output += "<description>\n";
                if (ThisPlot.YearPlanted > 0)
                {
                    output += AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("YPlant") + ": " + ThisPlot.YearPlanted.ToString() + "\n";
                }

                List <Tree> TreeList = ThisPlot.getTrees();
                int         year     = DateTime.Now.Year;

                output += "</description>";
                output += "<Point>\n<coordinates>" + tag[1].ToString() + "," + tag[0].ToString() + "</coordinates>\n </Point>\n";
                if (ThisPlot.GetPolygon().Count > 0)
                {
                    output += "<Polygon><outerBoundaryIs><LinearRing><coordinates>\n";
                    for (int y = 0; y < ThisPlot.GetPolygon().Count; y++)
                    {
                        output += ThisPlot.GetPolygon().ElementAt(y).Longitude.ToString() + ", " + ThisPlot.GetPolygon().ElementAt(y).Latitude + ", 0.\n";
                    }
                    output += "  </coordinates></LinearRing></outerBoundaryIs></Polygon>\n<Style><PolyStyle><color>#a00000ff</color><outline>0</outline></PolyStyle></Style>\n</Placemark>";
                }
                else
                {
                    output += "</Placemark>";
                }
            }

            output += "\n</Document>\n</kml>";

            byte[]       byteArray = Encoding.UTF8.GetBytes(output);
            MemoryStream stream    = new MemoryStream(byteArray);

            Xamarin.Forms.DependencyService.Get <ISave>().Save("map.kml", "text/plain", stream);
        }
예제 #5
0
 protected override void OnAppearing()
 {
     Find.IsVisible = false;
     if (Application.Current.Properties["Language"] != null)
     {
         Thread.CurrentThread.CurrentCulture = (CultureInfo)Application.Current.Properties["Language"];
     }
     EditPlot         = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt((int)Application.Current.Properties["ThisPlot"]);
     Latent.IsVisible = true;
     //Longent.IsVisible = true;
     PlotName.Text = EditPlot.GetName();
     Comments.Text = EditPlot.Describe;
     Location.Text = EditPlot.NearestTown;
     PlotYear.Text = EditPlot.YearPlanted.ToString();
     double[] geo = EditPlot.GetTag();
     Latent.Text = geo[0].ToString() + ", " + geo[1].ToString();
     //Longent.Text = geo[1].ToString();
     Owner.Text = EditPlot.Owner;
     base.OnAppearing();
 }
예제 #6
0
        public void SaveTrees2()
        {
            int count = 0;

            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                excelEngine.Excel.DefaultVersion = ExcelVersion.Excel2013;
                IWorkbook workbook = excelEngine.Excel.Workbooks.Create(1);
                workbook.Version = ExcelVersion.Excel97to2003;
                IWorksheet worksheet = workbook.Worksheets[0];
                worksheet.SetValue(1, 1, "Tree ID");
                worksheet.SetValue(1, 2, "Plot");
                worksheet.SetValue(1, 3, "Date");
                worksheet.SetValue(1, 4, "Girth");
                worksheet.SetValue(1, 5, "Height");
                worksheet.SetValue(1, 6, "Merchantable Height");
                worksheet.SetValue(1, 14, "Currency");
                worksheet.SetValue(1, 15, "Rate vs USD");

                for (int x = 0; x < ((List <(string, double)>)Application.Current.Properties["Currenlist"]).Count(); x++)
                {
                    try
                    {
                        worksheet.SetValue(2 + x, 14, ((List <(string, double)>)Application.Current.Properties["Currenlist"]).ElementAt(x).Item1);
                        worksheet.SetValue(2 + x, 15, ((List <(string, double)>)Application.Current.Properties["Currenlist"]).ElementAt(x).Item2.ToString());
                    }
                    catch { worksheet.SetValue(2 + x, 15, "ErrorEventArgs"); }
                }

                for (int x = 0; x < ((List <Plot>)Application.Current.Properties["Plots"]).Count(); x++)
                {
                    int         minyear  = 0;
                    int         maxyear  = 0;
                    Plot        thisPlot = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(x);
                    List <Tree> TreeList = thisPlot.getTrees();
                    for (int y = 0; y < TreeList.Count; y++)
                    {
                        Tree thisTree = TreeList.ElementAt(y);
                        for (int z = 0; z < thisTree.GetHistory().Count; z++)
                        {
                            if (minyear == 0)
                            {
                                minyear = thisTree.GetHistory().ElementAt(z).Key.Year;
                            }
                            else
                            {
                                minyear = Math.Min(minyear, thisTree.GetHistory().ElementAt(z).Key.Year);
                            }
                            maxyear = Math.Max(maxyear, thisTree.GetHistory().ElementAt(z).Key.Year);
                            worksheet.SetValue(2 + count, 1, thisTree.ID.ToString());
                            worksheet.SetValue(2 + count, 2, thisPlot.GetName().ToString());
                            worksheet.SetValue(2 + count, 3, thisTree.GetHistory().ElementAt(z).Key.ToString());
                            worksheet.SetValue(2 + count, 4, thisTree.GetHistory().ElementAt(z).Value.Item1.ToString());
                            worksheet.SetValue(2 + count, 5, thisTree.GetHistory().ElementAt(z).Value.Item2.ToString());
                            worksheet.SetValue(2 + count, 6, thisTree.GetHistory().ElementAt(z).Value.Item3.ToString());
                            count++;
                        }
                    }
                }
                worksheet.SetValue(1, 11, count.ToString());
                MemoryStream stream = new MemoryStream();
                workbook.SaveAs(stream);
                workbook.Close();
                Xamarin.Forms.DependencyService.Get <ISave>().Save("trees.xls", "application/msexcel", stream);
            }
        }
예제 #7
0
        //activates when index is changed in the plot picker
        public void SelectPlot()
        {
            string trees = "";

            PlotList.IsVisible = false;
            ObservableCollection <Tree> TreeTails = new ObservableCollection <Tree>();
            string girths  = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Girth") + "\n";
            string heights = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Height") + "\n";

            if (pickPlot.SelectedIndex > -1)
            {
                ToolEdit.Text = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("EditPlot");
                Plot ThisPlot = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(pickPlot.SelectedIndex);
                trees = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Name") + ": " + ThisPlot.GetName();
                if (ThisPlot.Owner != null && ThisPlot.Owner != "")
                {
                    trees += AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Owner") + ": " + ThisPlot.Owner + "\n";
                }
                if (ThisPlot.NearestTown != null && ThisPlot.NearestTown != "")
                {
                    trees += AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Location") + ": " + ThisPlot.NearestTown + "\n";
                }
                if (ThisPlot.Describe != null && ThisPlot.Describe != "")
                {
                    trees += AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Comments") + ": " + ThisPlot.Describe + "\n";
                }
                List <Tree>          TreeList    = ThisPlot.getTrees();
                List <DetailsGraph2> Detailstree = new List <DetailsGraph2>();
                Tree ThisTree;
                for (int x = 0; x < TreeList.Count; x++)
                {
                    ThisTree = TreeList.ElementAt(x);
                    Detailstree.Add(new DetailsGraph2()
                    {
                        girth = Math.Round(ThisTree.Diameter * (Girtdswitch.IsToggled?1 / Math.PI : 1), 2), ID = ThisTree.Id, price = ThisTree.Merch, tree = ThisTree, label2 = (ThisTree.ActualMerchHeight > 0)? ThisTree.ActualMerchHeight.ToString():"?"
                    });
                    TreeTails.Add(ThisTree);
                }
                DetailsList.IsVisible     = true;
                ToolPricing.Text          = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("CPrice");
                DetailsList.ItemsSource   = Detailstree;
                DetailsList.HeightRequest = (40 * Math.Min(TreeTails.Count, 5)) + (10 * Math.Min(TreeTails.Count, 5)) + 60;
                PlotTitle.Text            = trees;

                ToolDelete.Text       = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("DeletePlot");
                ToolDeleteTree.Text   = "";
                Girtdswitch.IsVisible = true;
                Girtdlab.IsVisible    = true;
            }
            else
            {
                OnAppearing();
            }
        }
예제 #8
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());
     }
 }
예제 #9
0
        //activates when index is changed in the plot picker
        public async void SelectPlot()
        {
            string trees = "";

            if (pickTree.SelectedIndex != -1)
            {
                pickTree.SelectedIndex = -1;
                return;
            }
            SummList.IsVisible    = false;
            Girtdlab.IsVisible    = true;
            Girtdswitch.IsVisible = true;
            PlotList.IsVisible    = false;
            Listhadler            = 0;
            ShowGraph.IsVisible   = true;
            ObservableCollection <Tree> TreeTails = new ObservableCollection <Tree>();
            string girths  = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Girth") + "\n";
            string heights = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Height") + "\n";

            if (pickPlot.SelectedIndex == pickPlot.Items.Count - 1 && pickPlot.SelectedIndex > -1)
            {
                await Navigation.PushAsync(new NotPopup());

                return;
            }
            if (pickPlot.SelectedIndex > -1)
            {
                ShowGraph.IsVisible = true;
                Plot ThisPlot = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(pickPlot.SelectedIndex);
                trees = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Name") + ": " + ThisPlot.GetName() + " ";
                if (ThisPlot.Owner != null && ThisPlot.Owner != "")
                {
                    trees += AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Owner") + ": " + ThisPlot.Owner + "\n";
                }
                if (ThisPlot.NearestTown != null && ThisPlot.NearestTown != "")
                {
                    trees += AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Location") + ": " + ThisPlot.NearestTown + "\n";
                }
                if (ThisPlot.Describe != null && ThisPlot.Describe != "")
                {
                    trees += AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Comments") + ": " + ThisPlot.Describe + "\n";
                }
                List <string>        IDlis       = new List <string>();
                List <Tree>          TreeList    = ThisPlot.getTrees();
                List <DetailsGraph2> Detailstree = new List <DetailsGraph2>();
                Tree ThisTree;
                // pickTree.Items.Clear();
                for (int x = 0; x < TreeList.Count; x++)
                {
                    ThisTree = TreeList.ElementAt(x);
                    Detailstree.Add(new DetailsGraph2()
                    {
                        girth = Math.Round(ThisTree.Diameter * (Girtdswitch.IsToggled?1 / Math.PI : 1), 2), ID = ThisTree.Id, price = ThisTree.Merch, tree = ThisTree, label2 = (ThisTree.ActualMerchHeight > 0)? ThisTree.ActualMerchHeight.ToString():"?"
                    });
                    TreeTails.Add(ThisTree);
                    IDlis.Add(ThisTree.ID.ToString());
                }
                pickTree.ItemsSource      = IDlis;
                DetailsList.IsVisible     = true;
                LogClassList.IsVisible    = false;
                LogList.IsVisible         = false;
                ListOfTree.Text           = "";
                GirthOT.Text              = "";
                HeightOT.Text             = "";
                DetailsList.ItemsSource   = Detailstree;
                DetailsList.HeightRequest = (40 * Math.Min(TreeTails.Count, 5)) + (10 * Math.Min(TreeTails.Count, 5)) + 60;
                PlotTitle.Text            = trees;
                pickTree.IsVisible        = false;
            }
            else
            {
                base.OnAppearing();
            }
        }