示例#1
0
        private void tagClickedFunc(Object sender, EventArgs e)
        {
            TagProvider tp = new TagProvider();
            Dictionary <string, string> d = tp.getAllTag();
            int tagCount = tp.getNum();
            var tagGroup = new List <IconDescBind>();

            foreach (string key in d.Keys)
            {
                tagGroup.Add(new IconDescBind {
                    path = key, tagDesc = d[key]
                });
            }
            DataTemplate dt = new DataTemplate(() =>
            {
                var icon = new Image()
                {
                    HorizontalOptions = LayoutOptions.End
                };
                var tagDescLable = new Label()
                {
                    HorizontalTextAlignment = TextAlignment.Center
                };
                //var space = new Label() { Text = "    " };
                icon.SetBinding(Image.SourceProperty, "path");
                tagDescLable.SetBinding(Label.TextProperty, "tagDesc");
                StackLayout sl = new StackLayout()
                {
                    Orientation       = StackOrientation.Horizontal,
                    HorizontalOptions = LayoutOptions.Center,
                    Children          = { icon, tagDescLable, }
                };
                return(new ViewCell {
                    View = sl
                });
            });
            CircleListView clv = new CircleListView
            {
                ItemsSource       = tagGroup,
                ItemTemplate      = dt,
                HorizontalOptions = LayoutOptions.Center,
            };

            clv.ItemTapped += TagTapped;
            cp              = new CirclePage()
            {
                Content = clv
            };
            //np.PushAsync(cp);
            Navigation.PushModalAsync(cp);
        }
示例#2
0
        public Dictionary <string, double> readWeeklyTagAmount(int year, int weekNum)
        {
            TagProvider tp = new TagProvider();
            Dictionary <string, string> tags = tp.getAllTag();
            Dictionary <string, double> ret  = new Dictionary <string, double>();

            //initialize the return dict
            foreach (var item in tags)
            {
                ret.Add(item.Value, 0);
            }
            //calculate by date
            DateTime Jan1         = new DateTime(year, 1, 1);
            DateTime firstWeekDay = Jan1.AddDays(7 - (int)Jan1.DayOfWeek + 1);
            DateTime weekStart    = firstWeekDay.AddDays((weekNum - 1) * 7);

            //Toast.DisplayText(weekStart.ToString("yyyy-MM-dd"));
            for (int i = 0; i < 7; i++)
            {
                //DateTime weekStart = weekStartX;
                string qDate = weekStart.ToString("yyyy-MM-dd");
                var    qRes  = dbConnection.Query <Item>("select * from Item where date = '" + qDate + "'");
                if (qRes.Count != 0)
                {
                    foreach (Item it in qRes)
                    {
                        double adder;
                        if (it.amount.Contains("+"))
                        {
                            adder = Convert.ToDouble(it.amount.Substring(1));
                        }
                        else
                        {
                            adder = Convert.ToDouble(it.amount);
                        }
                        //Toast.DisplayText(adder.ToString());
                        ret[tags[it.tagDesc]] += adder;
                        //Toast.DisplayText(ret[tags[it.tagDesc]].ToString());
                    }
                }
                weekStart = weekStart.AddDays(1);
            }
            //Toast.DisplayText(ret["电子产品"].ToString());
            return(ret);
        }