Пример #1
0
        private async void All_Clicked()
        {
            Plot thispolt = null;

            thispolt = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(pickPlotOne.SelectedIndex);
            List <DetailsGraph2> Detail = new List <DetailsGraph2>();
            ObservableCollection <DetailsGraph2> DetailSort = new ObservableCollection <DetailsGraph2>();
            double totalv = 0;
            double totalp = 0;

            for (int x = 0; x < plotTog.Count; x++)
            {
                if (plotTog.ElementAt(x).Selected)
                {
                    Calculator calc = new Calculator();

                    if (thispolt != null && PickPrice.SelectedIndex != -1)
                    {
                        calc.SetPrices(((List <PriceRange>)Application.Current.Properties["Prices"]).ElementAt(PickPrice.SelectedIndex));
                        double[,] result;

                        result = calc.Calcs(thispolt.getTrees().ElementAt(x).Diameter, thispolt.getTrees().ElementAt(x).Merch, thispolt.getTrees().ElementAt(x).ActualMerchHeight);
                        string resText0 = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("LogClass") + "\n";
                        string resText1 = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Price") + "\n";
                        string resText2 = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Volume") + "\n";
                        SortedList <double, double> brack = calc.GetPrices().GetBrack();
                        string[] unitcm = { "cm" };
                        string[] unitm  = { "m" };
                        string[] unitm3 = { "m3" };
                        for (int i = 0; i < result.GetLength(0); i++)
                        {
                            totalv += result[i, 2];
                            totalp += result[i, 1] * (((int)Application.Current.Properties["Currenselect"] == -1 ? 1 : ((List <(string, double)>)Application.Current.Properties["Currenlist"]).ElementAt((int)Application.Current.Properties["Currenselect"]).Item2));
                            DetailsGraph2 answer = new DetailsGraph2 {
                                volume = Math.Round(result[i, 2], 4), price = Math.Round(result[i, 1] * (((int)Application.Current.Properties["Currenselect"] == -1 ? 1 : ((List <(string, double)>)Application.Current.Properties["Currenlist"]).ElementAt((int)Application.Current.Properties["Currenselect"]).Item2)), 2), result = result, brack = brack, resultrow = i
                            };
                            if (result[i, 0] == -1)
                            {
                                answer.label = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("TooSmall");
                            }
                            else if (result[i, 0] == brack.Count - 1)
                            {
                                answer.label = (Math.Round(brack.ElementAt((int)result[i, 0]).Key *(GirthDBH2.IsToggled ? 1 / Math.PI : 1), 2) + unitcm[0] + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("OrLarger"));
                            }
                            else
                            {
                                answer.label = Math.Round(brack.ElementAt((int)result[i, 0]).Key *(GirthDBH2.IsToggled ? 1 / Math.PI : 1), 2) + "-" + Math.Round(brack.ElementAt((int)result[i, 0] + 1).Key *(GirthDBH2.IsToggled ? 1 / Math.PI : 1), 2) + unitcm[0];
                            }
                            Detail.Add(answer);
                        }
                    }
                }
            }
            DetailsGraph2 answer2 = new DetailsGraph2 {
                volume = Math.Round(totalv, 4), price = Math.Round(totalp, 2), label = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Totals")
            };

            Detail.Add(answer2);
            await PopupNavigation.Instance.PushAsync(MeasureResult.GetInstance(Detail));
        }
Пример #2
0
        public async void RunCalc()
        {
            Calculator calc     = new Calculator();
            Plot       thispolt = null;

            if (pickPlotOne.SelectedIndex > -1)
            {
                thispolt = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(pickPlotOne.SelectedIndex);
            }
            else
            {
                try { thispolt = ((List <Plot>)Application.Current.Properties["Plots"]).ElementAt(pickPlot.SelectedIndex); }
                catch { }
            }
            if (PickPrice.SelectedIndex > -1)
            {
                double totalv = 0;
                double totalp = 0;
                List <DetailsGraph2> Detail = new List <DetailsGraph2>();
                calc.SetPrices(((List <PriceRange>)Application.Current.Properties["Prices"]).ElementAt(PickPrice.SelectedIndex));
                double[,] result;
                if (calc.GetPrices() == null)
                {
                    Device.BeginInvokeOnMainThread(async() =>
                    {
                        bool reslut = await DisplayAlert(AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("PSPrice"), AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("PSPrice"), "OK", "Add Price Scheme");
                        if (!reslut)
                        {
                            await Navigation.PushAsync(new CreatePricing());
                        }
                    });
                    return;
                }
                if (Double.TryParse(merchheight.Text, out double ans) && ans > 0 && girth.Text != null && height.Text != null)
                {
                    result = calc.Calcs(double.Parse(girth.Text) * (GirthDBH.IsToggled ? Math.PI : 1), double.Parse(height.Text), ans);
                }
                else if (girth.Text != null && height.Text != null)
                {
                    result = calc.Calcs(double.Parse(girth.Text) * (GirthDBH.IsToggled ? Math.PI : 1), double.Parse(height.Text));
                }
                else
                {
                    return;
                }
                string resText0 = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("LogClass") + "\n";
                string resText1 = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Price") + "\n";
                string resText2 = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Volume") + "\n";
                SortedList <double, double> brack = calc.GetPrices().GetBrack();
                string[] unitcm = { "cm" };
                string[] unitm  = { "m" };
                string[] unitm3 = { "m\xB3" };

                for (int i = 0; i < result.GetLength(0); i++)
                {
                    totalv += result[i, 2];
                    totalp += result[i, 1] * (((int)Application.Current.Properties["Currenselect"] == -1 ? 1 : ((List <(string, double)>)Application.Current.Properties["Currenlist"]).ElementAt((int)Application.Current.Properties["Currenselect"]).Item2));
                    DetailsGraph2 answer = new DetailsGraph2 {
                        volume = Math.Round(result[i, 2], 4), price = Math.Round(result[i, 1] * (((int)Application.Current.Properties["Currenselect"] == -1 ? 1 : ((List <(string, double)>)Application.Current.Properties["Currenlist"]).ElementAt((int)Application.Current.Properties["Currenselect"]).Item2)), 2), result = result, brack = brack, resultrow = i
                    };
                    if (result[i, 0] == -1)
                    {
                        answer.label = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("TooSmall");
                    }
                    else if (result[i, 0] == brack.Count - 1)
                    {
                        answer.label = (Math.Round(brack.ElementAt((int)result[i, 0]).Key *(GirthDBH2.IsToggled ? 1 / Math.PI : 1), 2) + unitcm[0] + AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("OrLarger"));
                    }
                    else
                    {
                        answer.label = (Math.Round(brack.ElementAt((int)result[i, 0]).Key *(GirthDBH2.IsToggled ? 1 / Math.PI : 1), 2)) + "-" + Math.Round(brack.ElementAt((int)result[i, 0] + 1).Key *(GirthDBH2.IsToggled ? 1 / Math.PI : 1), 2) + unitcm[0];
                    }
                    Detail.Add(answer);
                }
                DetailsGraph2 answer2 = new DetailsGraph2 {
                    volume = Math.Round(totalv, 4), price = Math.Round(totalp, 2), label = AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("Totals")
                };
                Detail.Add(answer2);
                await PopupNavigation.Instance.PushAsync(MeasureResult.GetInstance(Detail));

                // LogList.ItemsSource = Detail;
                //LogList.IsVisible = true;
            }
            else
            {
                Device.BeginInvokeOnMainThread(async() =>
                {
                    bool result = await DisplayAlert(AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("PSPrice"), AppResource.ResourceManager.GetResourceSet(Thread.CurrentThread.CurrentCulture, true, true).GetString("PSPrice"), "OK", "( Price Scheme");
                    if (!result)
                    {
                        await Navigation.PushAsync(new CreatePricing());
                    }
                });
            }
        }