static void Main(string[] args)
        {
            dataStorage = new DataStorage();

            Console.ForegroundColor = ConsoleColor.Green;
            Console.WriteLine(dataStorage.GetHost().FirstName + " " + dataStorage.GetHost().LastName);
            Console.ResetColor();
            Console.WriteLine(dataStorage.GetHost().Description);
            Console.WriteLine();

            schedule = dataStorage.GenerateSchedule(DateTime.Now.AddDays(-5), DateTime.Now.AddDays(5));
            activeDate = DateTime.Now.Date;

            ShowSchedule();
            int todayIndex = schedule.FindIndex(p => p.Day.Date == DateTime.Now.Date);
            ShowAppointmentsFor(todayIndex);

            Console.WriteLine("Enter command 'app [index]' to see appointments.");
            Console.WriteLine("Enter command 'more' to load next 5 days.");
            Console.WriteLine("Enter command 'exit' to quit.");
            string command = string.Empty;
            while (command != "exit")
            {
                // 'app 3' or 'app 4'
                if (command.StartsWith("app "))
                {
                    try
                    {
                        string[] words = command.Split(' ');
                        int relativeIndex = int.Parse(words[1]);
                        int index = -1;

                        index = relativeIndex + todayIndex;

                        if (index >= 0)
                        {
                            activeDate = schedule[index].Day.Date;
                            ShowSchedule();

                            ShowAppointmentsFor(index);
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
                else if (command == "more")
                {
                    List<ScheduleItem> moreItems = dataStorage.GenerateSchedule(schedule[schedule.Count - 1].Day.AddDays(1), schedule[schedule.Count - 1].Day.AddDays(6));
                    schedule.AddRange(moreItems);
                    ShowSchedule();
                }

                command = Console.ReadLine();
            }
        }
Example #2
0
        protected override void OnCreate(Bundle bundle)
        {
            dataStorage = new DataStorage ();

            Window.AddFlags (WindowManagerFlags.Fullscreen);
            Window.ClearFlags (WindowManagerFlags.ForceNotFullscreen);
            this.Window.SetFlags (WindowManagerFlags.KeepScreenOn, WindowManagerFlags.KeepScreenOn);

            base.OnCreate (bundle);
            SetContentView (Resource.Layout.Main);

            FillHostSummary (dataStorage.GetHost());

            appointmentsListView = FindViewById<ListView> (Resource.Id.appointmentsListView);
            EndlessScrollView scrollView = FindViewById<EndlessScrollView> (Resource.Id.scroll);
            datesLayout = FindViewById<LinearLayout> (Resource.Id.datesLayout);

            schedule = dataStorage.GenerateSchedule (DateTime.Now.AddDays(0), DateTime.Now.AddDays (LOAD_NUMBER));

            scrollView.ScrollReachedRight += (sender, args) => {
                LoadMoreRight (LOAD_NUMBER);
            };

            for (var i = 0; i < schedule.Count; i++) {
                ScheduleItem item = schedule [i];

                View view = InflateScheduleItem (this, item);

                view.Click += (sender, e) => {
                    DateClick (sender, item.Appointments, item.Day.DayOfWeek);
                };

                datesLayout.AddView (view);
            }

            int todayIndex = FindTodayIndex();
            // Can't scroll right away, it needs time to render element first
            ScrollTo (todayIndex, scrollView);

            Button saveButton = FindViewById<Button> (Resource.Id.saveButton);

            saveButton.Click += (object sender, EventArgs e) => {
            };
            saveButton.Clickable = false;
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            nfloat h = 25.0f;
            nfloat w = 50.0f;
            nfloat padding = 10.0f;

            dataStorage = new DataStorage ();

            schedule = dataStorage.GenerateSchedule (DateTime.Now.AddDays(0), DateTime.Now.AddDays (LOAD_NUMBER));
            activeDate = DateTime.Now.Date;

            scrollView = new UIScrollView {
                Frame = new CGRect (0, 150, View.Frame.Width, h + 2 * padding),
                ContentSize = new CGSize ((w + padding) * LOAD_NUMBER, h),
                BackgroundColor = UIColor.White,
                AutoresizingMask = UIViewAutoresizing.FlexibleWidth
            };

              for (int i=0; i<schedule.Count; i++) {
             	var button = UIButton.FromType (UIButtonType.RoundedRect);
                ScheduleItem item = schedule [i];
                button.SetTitle (item.Day.ToString("dd ddd"), UIControlState.Normal);
                button.Frame = new CGRect (padding * (i + 1) + (i * w), padding, w, h);
                scrollView.AddSubview (button);
                buttons.Add (button);

                button.SetTitleColor(UIColor.Blue, UIControlState.Normal);
               if (item.Day.DayOfWeek == DayOfWeek.Saturday || item.Day.DayOfWeek == DayOfWeek.Sunday)
                {
                    button.SetTitleColor(UIColor.Red, UIControlState.Normal);
                }
                if (item.Day.Day == DateTime.Now.Day)
                {
                    button.SetTitleColor(UIColor.Green, UIControlState.Normal);
                }
            }
            View.AddSubview (scrollView);
        }