Beispiel #1
0
        private async void Btn_plus_time_Clicked(object sender, EventArgs e)
        {
            Time_pick.TextChanged -= Time_pick_TextChanged;
            var btn = (TagButton)sender;
            await btn.FadeTo(0, 10);

            TagButton tb = (TagButton)sender;

            if (Time_pick.Text == "")
            {
                Time_pick.Text = "00:00:00";
            }
            string val = Time_pick.Text;

            double[] form_val = new double[3];
            form_val[0] = Convert.ToDouble(val.Split(':')[0]);
            form_val[1] = Convert.ToDouble(val.Split(':')[1]);
            form_val[2] = Convert.ToDouble(val.Split(':')[2]);
            Time_r tm = new Time_r(form_val[0], form_val[1], form_val[2]);

            switch (tb.Tag)
            {
            case "++":
                tm.Min += 10;
                break;

            case "--":
                if (tm.Min < 10)
                {
                    tm.Min = 0;
                }
                else
                {
                    tm.Min -= 10;
                }
                break;

            case "+":
                tm.Sec += 10;
                break;

            case "-":
                if (tm.Sec < 10)
                {
                    tm.Sec = 0;
                }
                else
                {
                    tm.Sec -= 10;
                }
                break;
            }
            if (tm.Sec >= 359999)
            {
                tm.Sec = 359999;
            }
            Time_pick.Text         = tm.ToString();
            Time_pick.TextChanged += Time_pick_TextChanged;
            await btn.FadeTo(1, 100);
        }
Beispiel #2
0
        private void Time_pick_TextChanged(object sender, TextChangedEventArgs e)
        {
            string val = Time_pick.Text;

            double[] form_val = new double[3];
            form_val[0] = Convert.ToDouble(val.Split(':')[0]);
            form_val[1] = Convert.ToDouble(val.Split(':')[1]);
            form_val[2] = Convert.ToDouble(val.Split(':')[2]);
            Time_r tm = new Time_r(form_val[0], form_val[1], form_val[2]);

            if (tm.Sec >= 359999)
            {
                tm.Sec = 359999;
            }
            val            = tm.ToString();
            Time_pick.Text = val;
        }
        //private static Dictionary<string, int> counter = new Dictionary<string, int>();
        //private static void GetTaskList(string value)
        //{
        //    List<string> vs = new List<string>();
        //    if (value == "")
        //    {
        //        value = "Другие";
        //    }
        //    if (Options.opt.ActiveType == 6)
        //    {
        //        vs = value.Split(',').ToList();
        //        foreach (string item in vs)
        //        {
        //            if (counter.ContainsKey(item))
        //                counter[item]++;
        //            else
        //                counter.Add(item, 1);
        //        }
        //    }
        //    else
        //    {
        //        if (counter.ContainsKey(value))
        //            counter[value]++;
        //        else
        //            counter.Add(value, 1);
        //    }
        //}
        /// <summary>
        /// Для одного года
        /// </summary>
        /// <param name="vlr"></param>
        public static string GetBar(Dictionary <string, ValueRange> vlr, string year = null)
        {
            //counter.Clear();
            //Microcharts.Chart chtr = new Microcharts.BarChart();
            //месяц лист(число знаечние)
            string name_bk = "";
            //Dictionary<string, Dictionary<string, double>> approx = new Dictionary<string, Dictionary<string, double>>();
            List <ValueDate> valueDates = new List <ValueDate>();
            List <string>    YL         = new List <string>();

            YL = vlr.Keys.ToList();
            if (year != null)
            {
                YL = YL.Where(t => t == year).ToList();
            }

            foreach (string item in YL)
            {
                foreach (var cell in vlr[item].Values)
                {
                    string mount_nm = cell[0].ToString();
                    if (mount_nm == "")
                    {
                        mount_nm = name_bk;
                    }
                    else
                    {
                        name_bk = mount_nm;
                    }
                    if (cell[0].ToString() != "Мес")
                    {
                        if (cell.Count > 1)
                        {
                            DateTime dtt    = new DateTime(1899, 12, 30, new GregorianCalendar());
                            int      daybuf = Convert.ToInt32(cell[1].ToString());
                            dtt = dtt.AddDays(daybuf);
                            string dt = dtt.ToString("D", CultureInfo.GetCultureInfo("ru-RU"));
                            //DateTime dt = Convert.ToDateTime(cell[1].ToString());
                            object db  = new object();
                            double dbd = 0;
                            if (Options.opt.ActiveType == 2)
                            {
                                double val = Convert.ToDouble(cell[Options.opt.ActiveType]);
                                // *24*60
                                //Time_r tm = new Time_r(form_val[0], form_val[1], form_val[2]);
                                db = new Time_r(val * 24 * 60 * 60).Min;
                            }
                            else if (Options.opt.ActiveType == 5)
                            {
                                db = GetIntFromVal(cell[Options.opt.ActiveType].ToString());
                            }
                            else if (Options.opt.ActiveType != 6 && Options.opt.ActiveType != 10)
                            {
                                if (!double.TryParse(cell[Options.opt.ActiveType].ToString(), out dbd))
                                {
                                    db = 0;
                                }
                                else
                                {
                                    db = dbd;
                                }
                            }
                            else if (Options.opt.ActiveType == 10)
                            {
                                if (cell.Count < 11)
                                {
                                    db = "";
                                }
                                else
                                {
                                    db = cell[Options.opt.ActiveType].ToString();
                                }
                            }
                            else if (Options.opt.ActiveType == 6)
                            {
                                db = cell[Options.opt.ActiveType].ToString();
                            }
                            valueDates.Add(new ValueDate(dtt, db));
                        }
                    }
                }
            }
            if (YL.Count > 1)
            {
                return(imgChartBuilder.FormerPost(valueDates, vlr.Keys.ToList()));
            }
            else
            {
                return(imgChartBuilder.FormerPost_year(valueDates));
            }

            /*
             * if (approx.ContainsKey(mount_nm))
             * {
             *  if (approx[mount_nm].ContainsKey(dt))
             *      approx[mount_nm][dt] += db;
             *  else
             *      approx[mount_nm].Add(dt, db);
             * }
             * else
             * {
             *  approx.Add(mount_nm, new Dictionary<string, double>());
             *  approx[mount_nm].Add(dt, db);
             * }
             * //chtr.Entries = PlotBar(approx, true);
             * }
             * else
             * {
             * approx.Add(mount_nm, new Dictionary<string, double>());
             * approx[mount_nm].Add(mount_nm, 0);
             * }
             *
             * }
             *
             * }
             * if (Options.opt.ActiveType != 6 && Options.opt.ActiveType != 10)
             * Debug.Write("Место для формирования графика");
             * //chtr.Entries = PlotBar(approx, true);
             * else
             * {
             * List<Microcharts.Entry> CHARTlist = new List<Microcharts.Entry>();
             * Random rnd = new Random();
             * foreach (string item in counter.Keys)
             * {
             * //Debug.WriteLine(item + "  " + counter[item]);
             * //string color = String.Format("#{0:X6}", rnd.Next(0x1000000));
             * //CHARTlist.Add(new Microcharts.Entry((float)counter[item]) { Color = SkiaSharp.SKColor.Parse(color), ValueLabel = item });
             * }
             * chtr.Entries = CHARTlist;
             * }
             * return chtr;
             * //approx.OrderBy(key => key.Value);
             */
        }