Example #1
0
        public SidebarPage(ShieldPageViewModel vm)
        {
            InitializeComponent();
            menuList = new List <SidebarItem>();
            NavigationPage.SetHasNavigationBar(this, false);

            ViewModel = vm;

            var page1 = new SidebarItem()
            {
                Id = "profile", Title = "Profile", Icon = "ic_user.png"
            };
            var page2 = new SidebarItem()
            {
                Id = "device", Title = "Device", Icon = "ic_settings.png"
            };
            var page3 = new SidebarItem()
            {
                Id = "chart", Title = "Chart", Icon = "ic_chart.png"
            };
            var page4 = new SidebarItem()
            {
                Id = "about", Title = "About", Icon = "ic_help.png"
            };


            // Adding menu items to menuList
            menuList.Add(page1);
            menuList.Add(page2);
            menuList.Add(page3);
            menuList.Add(page4);

            lst.ItemsSource = menuList;
        }
Example #2
0
        public ChartPage(ShieldPageViewModel vm)
        {
            InitializeComponent();

            int total = 0;

            try
            {
                List <Microcharts.Entry> entries = new List <Microcharts.Entry>();

                var      labels  = new List <string>();
                DateTime history = DateTime.Now.AddHours(-24);
                Random   random  = new Random(DateTime.Now.Second);

                for (int i = 0; i < 24; i++)
                {
                    string date = history.AddHours(i).ToString();

                    int hour = history.AddHours(i).Hour;

                    int sum = vm.DeviceList.Count(x => x.DateCreated.Year.Equals(history.AddHours(i).Year) &&
                                                  x.DateCreated.Month.Equals(history.AddHours(i).Month) &&
                                                  x.DateCreated.Day.Equals(history.AddHours(i).Day) &&
                                                  x.DateCreated.Hour.Equals(history.AddHours(i).Hour));

                    //uncomment for test data
                    //if (hour == 8 || hour == 9 || hour == 12 || hour == 18 || hour == 19)
                    //    sum = 10 + random.Next(50);

                    //total += sum;
                    entries.Add(new Microcharts.Entry(sum)
                    {
                        Label = i.ToString(), ValueLabel = sum.ToString(), Color = SKColor.Parse("#092ABB")
                    });
                    string when = history.AddHours(i).ToString("htt");  //hour < 12 ? "am" : "pm";
                    labels.Add(when);
                }

                chart.Chart = new BarChart()
                {
                    Entries       = entries,
                    LabelTextSize = 20
                };
            }
            catch (Exception ex)
            {
            }

            if (total == 0)
            {
                lblStatus.IsVisible = true;
                chart.IsVisible     = false;
            }
        }