Exemple #1
0
 private void PopList(int select)
 {
     //Fills list of prices
     if (select > -1)
     {
         List <string> ArrayList           = new List <string>();
         PriceRange    ThisPrice           = ((List <PriceRange>)Application.Current.Properties["Prices"]).ElementAt(select);
         SortedList <double, double> brack = ThisPrice.GetBrack();
         for (int x = 0; x < brack.Count(); x++)
         {
             if (x == brack.Count() - 1)
             {
                 ArrayList.Add(brack.ElementAt(x).Key + "cm " + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("OrLarger") + "\t\t\t\t" + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Price") + ": " + brack.ElementAt(x).Value + ((int)Application.Current.Properties["Currenselect"] == -1 ? "$" : ((List <(string, double)>)Application.Current.Properties["Currenlist"]).ElementAt((int)Application.Current.Properties["Currenselect"]).Item1) + "/m\xB3");
             }
             else
             {
                 ArrayList.Add(brack.ElementAt(x).Key + "cm to " + brack.ElementAt(x + 1).Key + "cm" + "\t\t\t\t" + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Price") + ": " + brack.ElementAt(x).Value + ((int)Application.Current.Properties["Currenselect"] == -1 ? "$" : ((List <(string, double)>)Application.Current.Properties["Currenlist"]).ElementAt((int)Application.Current.Properties["Currenselect"]).Item1) + "/m\xB3");
             }
         }
         NameOfPrices.Text       = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Name") + ": " + ThisPrice.GetName() + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("LogLength") + ": " + ThisPrice.GetLength().ToString() + "m";
         PriceArray              = ArrayList.ToArray();
         PriceList.ItemsSource   = PriceArray;
         PriceList.HeightRequest = (40 * PriceArray.Length) + (10 * PriceArray.Length);
     }
 }
Exemple #2
0
        public void SavePricing()
        {
            //Create an instance of ExcelEngine.
            using (ExcelEngine excelEngine = new ExcelEngine())
            {
                //Set the default application version as Excel 2013.
                excelEngine.Excel.DefaultVersion = ExcelVersion.Excel2013;

                //Create a workbook with a worksheet
                IWorkbook workbook = excelEngine.Excel.Workbooks.Create(1);
                workbook.Version = ExcelVersion.Excel97to2003;

                //Adding text to a cell
                for (int y = 0; y < ((List <PriceRange>)Application.Current.Properties["Prices"]).Count(); y++)
                {
                    PriceRange thisPrice = ((List <PriceRange>)Application.Current.Properties["Prices"]).ElementAt(y);
                    workbook.Worksheets.Create(thisPrice.GetName());
                    IWorksheet worksheet = workbook.Worksheets[y + 1];

                    worksheet.SetValue(1, 1, "Name");
                    worksheet.SetValue(2, 1, "Log Size");
                    worksheet.SetValue(1, 2, thisPrice.GetName());
                    worksheet.SetValue(2, 2, thisPrice.GetLength().ToString());
                    worksheet.SetValue(3, 1, "Size");
                    worksheet.SetValue(3, 2, "Price");
                    worksheet.SetValue(3, 3, thisPrice.GetBrack().Count.ToString());
                    for (int x = 0; x < thisPrice.GetBrack().Count; x++)
                    {
                        worksheet.SetValue(4 + x, 1, thisPrice.GetBrack().ElementAt(x).Key.ToString());
                        worksheet.SetValue(4 + x, 2, thisPrice.GetBrack().ElementAt(x).Value.ToString());
                    }
                    worksheet.Range["A1:A3"].CellStyle.Locked = true;
                    worksheet.Range[3, 2].CellStyle.Locked    = true;
                }
                workbook.Worksheets[0].Remove();
                //Save the workbook to stream in xlsx format.
                MemoryStream stream = new MemoryStream();
                workbook.SaveAs(stream);

                workbook.Close();

                //Save the stream as a file in the device and invoke it for viewing
                Xamarin.Forms.DependencyService.Get <ISave>().Save("Pricings.xls", "application/msexcel", stream);
            }
        }
Exemple #3
0
 public void SetPrices(PriceRange newprices)
 {
     prices = newprices;
 }
Exemple #4
0
        private void ShowGraphpick2()
        {
            SummList.IsVisible    = false;
            ListOfTree.IsVisible  = false;
            GirthOT.IsVisible     = false;
            Girtdlab.IsVisible    = true;
            Girtdswitch.IsVisible = true;
            if (ShowGraph.SelectedIndex > -1)
            {
            }
            else
            {
                brac = -1;
            }
            //show regular data for each tree
            if (ShowGraph.SelectedIndex == 0)
            {
                SelectPlot();
                Earlier.IsVisible        = false;
                Later.IsVisible          = false;
                ShowGraph.SelectedIndex -= 1;
            }
            // averages and data by log class
            else if (ShowGraph.SelectedIndex == 1 || ShowGraph.SelectedIndex == 2)
            {
                ObservableCollection <DetailsGraph> Detail = new ObservableCollection <DetailsGraph>();
                Plot ThisPlot = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(pickPlot.SelectedIndex);
                if (ThisPlot.getTrees().Count <= 0)
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        await DisplayAlert(AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("NoTrees"), "This plot contains no trees.", "OK");
                        return;
                    });
                }
                PriceRange thisRange = ((List <PriceRange>)Application.Current.Properties["Prices"]).ElementAt(PickPrice.SelectedIndex);
                Calculator Calc      = new Calculator();
                Calc.SetPrices(thisRange);

                double        total       = 0;
                List <string> Lablels     = new List <string>();
                List <string> ListLablels = new List <string>();

                for (int x = -1; x < thisRange.GetBrack().Count; x++)
                {
                    if (x == -1)
                    {
                        Lablels.Add("<" + Math.Round((thisRange.GetBrack().ElementAt(0).Key *(Girtdswitch.IsToggled ? 1 : Math.PI)), 2).ToString() + "cm");
                    }
                    else if (x == thisRange.GetBrack().Count - 1)
                    {
                        Lablels.Add(">" + Math.Round(thisRange.GetBrack().ElementAt(x).Key *(Girtdswitch.IsToggled ? 1 : Math.PI), 2) + "cm");
                    }
                    else
                    {
                        Lablels.Add(Math.Round(thisRange.GetBrack().ElementAt(x + 1).Key *(Girtdswitch.IsToggled ? 1 : Math.PI), 2) + "cm");
                    }
                }
                Lablels.Add(AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Totals"));

                int[]    logs      = new int[thisRange.GetBrack().Count + 1];
                int[]    logsmerch = new int[thisRange.GetBrack().Count + 1];
                double[] vols      = new double[thisRange.GetBrack().Count + 1];
                double[] volsmerch = new double[thisRange.GetBrack().Count + 1];
                double[] vals      = new double[thisRange.GetBrack().Count + 1];
                double   totalvol  = 0;
                double   totalvolM = 0;
                double   totalDia  = 0;
                double   absVol    = 0;
                double   totalTree = 0;
                int      count     = 0;
                int      tcount    = 0;
                for (int y = 0; y < ThisPlot.getTrees().Count; y++)
                {
                    Tree ThisTree = ThisPlot.getTrees().ElementAt(y);
                    SortedList <DateTime, (double, double, double)> Thistory = ThisTree.GetHistory();
                    try {
                        double[,] result = Calc.Calcs(ThisTree.GetDia(), ThisTree.Merch, ThisTree.ActualMerchHeight);
                        absVol          += (0.423 * Math.PI * Math.Pow((ThisTree.GetDia()), 2) * ThisTree.Merch) / 40000;
                        for (int x = 0; x < result.GetLength(0); x++)
                        {
                            logs[(int)result[x, 0] + 1]++;
                            logsmerch[(int)result[x, 0] + 1] += ((result[x, 1] <= 0) ? 0 : 1);
                            vols[(int)result[x, 0] + 1]      += result[x, 2];
                            volsmerch[(int)result[x, 0] + 1] += result[x, 2] * ((result[x, 1] <= 0) ? 0 : 1);
                            vals[(int)result[x, 0] + 1]      += result[x, 1];
                            totalvol  += result[x, 2];
                            totalvolM += ((result[x, 1] <= 0) ? 0 : 1) * result[x, 2];
                            total     += result[x, 1];
                            totalDia  += Math.Max(result[x, 3], 0) * ((result[x, 1] <= 0) ? 0 : 1);
                            count     += ((result[x, 1] <= 0) ? 0 : 1);
                        }
                    } catch { }
                    totalTree += ThisTree.GetDia() / Math.PI;
                    tcount++;
                }
                // data by log class
                if (ShowGraph.SelectedIndex == 1)
                {
                    GirthOT.Text = "";
                    if (((bool)Application.Current.Properties["Tutorial"]) && (bool)Application.Current.Properties["TLogs"])
                    {
                        Device.BeginInvokeOnMainThread(async() =>
                        {
                            await DisplayAlert("Logs", AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("SummaryTute"), AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Continue"));
                        });
                        Application.Current.Properties["TLogs"] = false;
                    }
                    Listhadler = 1;

                    for (int x = 1; x < thisRange.GetBrack().Count + 1; x++)
                    {
                        Detail.Add(new DetailsGraph {
                            label = Lablels.ElementAt(x), volume = Math.Round(vols[x], 4), price = Math.Round(vals[x] * (((int)Application.Current.Properties["Currenselect"] == -1 ? 1 : ((List <(string, double)>)Application.Current.Properties["Currenlist"]).ElementAt((int)Application.Current.Properties["Currenselect"]).Item2)), 2), logs = logsmerch[x]
                        });
Exemple #5
0
        //Renders tree informaition
        private void LatEar()
        {
            SummList.IsVisible = false;
            string trees     = "";
            string girthtext = "";
            string stuff     = "";
            double totVol    = 0;

            DetailsList.IsVisible  = false;
            LogClassList.IsVisible = false;
            LogList.IsVisible      = false;
            if (pickTree.SelectedIndex > -1 && pickPlot.SelectedIndex > -1)
            {
                Tree ThisTree = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(pickPlot.SelectedIndex).getTrees().ElementAt(pickTree.SelectedIndex);

                double girth = ThisTree.GetHistory().ElementAt(GraphNo).Value.Item1;
                double high  = ThisTree.GetHistory().ElementAt(GraphNo).Value.Item2;
                Application.Current.Properties["HCounter"] = GraphNo;


                if (PickPrice.SelectedIndex > -1)
                {
                    PriceRange thisRange = ((List <PriceRange>)Application.Current.Properties["Prices"]).ElementAt(PickPrice.SelectedIndex);
                    Calculator Calc      = new Calculator();
                    Calc.SetPrices(thisRange);
                    double[,] result;
                    if (ThisTree.ActualMerchHeight == -1)
                    {
                        result = Calc.Calcs(girth, high);
                    }
                    else
                    {
                        result = Calc.Calcs(girth, high, ThisTree.ActualMerchHeight);
                    }
                    double        total       = 0;
                    List <string> Lablels     = new List <string>();
                    List <string> ListLablels = new List <string>();

                    for (int x = -1; x < thisRange.GetBrack().Count; x++)
                    {
                        if (x == -1)
                        {
                            Lablels.Add("<" + Math.Round((thisRange.GetBrack().ElementAt(0).Key *(Girtdswitch.IsToggled ? 1 : Math.PI)), 2).ToString() + "cm");
                        }
                        else if (x == thisRange.GetBrack().Count - 1)
                        {
                            Lablels.Add(">" + Math.Round(thisRange.GetBrack().ElementAt(x).Key *(Girtdswitch.IsToggled ? 1 : Math.PI), 2) + "cm");
                        }
                        else
                        {
                            Lablels.Add(Math.Round(thisRange.GetBrack().ElementAt(x + 1).Key *(Girtdswitch.IsToggled ? 1 : Math.PI), 2) + "cm");
                        }
                    }
                    int[] logs = new int[thisRange.GetBrack().Count + 1];

                    for (int x = 0; x < result.GetLength(0); x++)
                    {
                        logs[(int)result[x, 0] + 1]++;
                        total   = +result[x, 1];
                        totVol += result[x, 2];
                    }

                    string title = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("TreeID") + ": " + ThisTree.ID.ToString() + " " + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Date") + ": " + ThisTree.GetHistory().ElementAt(GraphNo).Key.ToShortDateString();

                    if (GraphNo <= 0)
                    {
                        Earlier.IsVisible = false;
                    }

                    if (GraphNo >= ThisTree.GetHistory().Count - 1)
                    {
                        Later.IsVisible = false;
                    }
                    stuff           = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Girth") + ": " + Math.Round(girth, 2).ToString() + "\n" + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Height") + ": " + Math.Round(high, 2).ToString();
                    girthtext       = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("TotalLogs") + ": " + result.GetLength(0) + "\n" + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("TotalPrice") + ": " + Math.Round(total * (((int)Application.Current.Properties["Currenselect"] == -1 ? 1 : ((List <(string, double)>)Application.Current.Properties["Currenlist"]).ElementAt((int)Application.Current.Properties["Currenselect"]).Item2)), 2) + ((int)Application.Current.Properties["Currenselect"] == -1?"$": ((List <(string, double)>)Application.Current.Properties["Currenlist"]).ElementAt((int)Application.Current.Properties["Currenselect"]).Item1);
                    trees           = "Tree ID: " + ThisTree.ID.ToString() + "at the date" + ": " + ThisTree.GetHistory().ElementAt(GraphNo).Key.ToShortDateString();
                    GirthOT.Text    = girthtext;
                    ListOfTree.Text = stuff;
                    PlotTitle.Text  = trees;
                    HeightOT.Text   = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("TotalVol") + ": " + Math.Round(totVol, 4);
                }
            }
        }