Ejemplo n.º 1
0
        public double[,] Calcs(double breastGirth, double TotalHeight)
        {
            LOGLEN = prices.GetLength();
            SortedList <double, double> brack = prices.GetBrack();
            int noLogs = (int)Math.Floor((TotalHeight) / LOGLEN);

            double[,] totals = new double[noLogs, 5];
            double taper          = 0;
            double rH             = 0;
            double rL             = 0;
            double breastDiameter = breastGirth / (Math.PI);

            BARK = 0.0266 * breastDiameter + 0.2399;
            double value     = 0;
            double height    = 0;
            double sizeClass = 0;

            height = STUMP;
            for (int i = 0; i < noLogs; i++)
            {
                height += LOGLEN;
                rH      = (TotalHeight - height) * ((A2 * TotalHeight * (Math.Pow(B2, 2)) * (BHEIGHT - height)) / ((1 + B2 * (height)) * (1 + B2 * BHEIGHT) * (1 + B2 * TotalHeight)) + ((0.77715 / TotalHeight + 0.01239 * ((breastDiameter - BARK) / 10) + -0.0027653 * Math.Pow(((breastDiameter - BARK) / 10), 2)) * (height - BHEIGHT)) + ((breastDiameter - BARK) / (TotalHeight - BHEIGHT)));
                rH      = rH / 2;

                value     = 0;
                sizeClass = -1;
                for (int a = 0; a < brack.Count; a++)
                {
                    if (2 * rH > brack.ElementAt(a).Key)
                    {
                        value     = brack.ElementAt(a).Value;
                        sizeClass = a;
                    }
                }
                totals[i, 0] = sizeClass;
                totals[i, 1] = LOGLEN * Math.PI * Math.Pow(rH / 100, 2) * value;
                totals[i, 2] = LOGLEN * Math.PI * Math.Pow(rH / 100, 2);
                totals[i, 3] = 2 * rH;
                totals[i, 4] = taper;

                rL = rH;
            }
            return(totals);
        }
Ejemplo n.º 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);
            }
        }
Ejemplo n.º 3
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);
     }
 }