Exemple #1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            addButton = new UIBarButtonItem(UIBarButtonSystemItem.Add, (s, e) => {
                var task = new TodoItem()
                {
                    Title = "<new task>"
                };
                // Save to Azure
                var added = AzureWebService.AddTodo(task);
                tasks.Add(added);
                Reload();                  // show the new task
            });
            NavigationItem.RightBarButtonItem = addButton;

            // UIBarButtonSystemItem.Refresh or http://barrow.io/posts/iphone-emoji/
            refreshButton = new UIBarButtonItem('\uE049'.ToString()
                                                , UIBarButtonItemStyle.Plain
                                                , (s, e) => {
                tasks = AzureWebService.LoadTodos(Reload);
            });
            NavigationItem.LeftBarButtonItem = refreshButton;

            tasks = AzureWebService.LoadTodos(Reload);
        }
        protected override void OnResume()
        {
            base.OnResume();

            // yep, we go to the network on every resume... this is just a demo after all
            tasks = AzureWebService.LoadTodos(Reload);
        }
Exemple #3
0
        protected void CancelDelete()
        {
            if (task.Id >= 0)
            {
                AzureWebService.DeleteTodo(task);
            }

            Finish();
        }
Exemple #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            #region color the titlebar
            View titleView = Window.FindViewById(Android.Resource.Id.Title);
            if (titleView != null)
            {
                IViewParent parent = titleView.Parent;
                if (parent != null && (parent is View))
                {
                    View parentView = (View)parent;
                    parentView.SetBackgroundColor(Color.Rgb(0x26, 0x75, 0xFF));         //38, 117 ,255
                }
            }
            #endregion

            // set our layout to be the details screen
            SetContentView(Resource.Layout.TaskDetails);

            int taskID = Intent.GetIntExtra("TaskID", -1);
            if (taskID >= 0)
            {
                task = AzureWebService.GetTodo(taskID); // from Azure
            }
            else
            {
                task = new Task();
            }

            nameTextEdit = FindViewById <EditText>(Resource.Id.txtName);
            //notesTextEdit = FindViewById<EditText>(Resource.Id.txtNotes);
            saveButton   = FindViewById <Button>(Resource.Id.btnSave);
            doneCheckbox = FindViewById <CheckBox>(Resource.Id.chkDone);

            // find all our controls
            cancelDeleteButton = FindViewById <Button>(Resource.Id.btnCancelDelete);

            // set the cancel delete based on whether or not it's an existing task
            cancelDeleteButton.Text = (task.Id < 0 ? "Cancel" : "Delete");

            // name
            nameTextEdit.Text = task.Title;

            // notes
            //notesTextEdit.Text = task.Notes;

            doneCheckbox.Checked = task.IsDone;

            // button clicks
            cancelDeleteButton.Click += (sender, e) => { CancelDelete(); };
            saveButton.Click         += (sender, e) => { Save(); };
        }
Exemple #5
0
        protected void Save()
        {
            task.Title = nameTextEdit.Text;
            //task.Notes = notesTextEdit.Text;
            task.IsDone = doneCheckbox.Checked;
            if (task.Id >= 0)
            {
                AzureWebService.UpdateTodo(task);
            }
            else
            {
                AzureWebService.AddTodo(task);
            }

            Finish();
        }
Exemple #6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            #region UI Controls (you could do this in XIB if you want)
            saveButton       = UIButton.FromType(UIButtonType.RoundedRect);
            saveButton.Frame = new RectangleF(10, 10, 145, 40);
            saveButton.SetTitle("Save", UIControlState.Normal);
            saveButton.SetTitle("waiting...", UIControlState.Disabled);
            saveButton.Enabled = false;

            deleteButton       = UIButton.FromType(UIButtonType.RoundedRect);
            deleteButton.Frame = new RectangleF(10, 150, 145, 40);
            deleteButton.SetTitle("Delete", UIControlState.Normal);
            deleteButton.Enabled = false;

            doneSwitch         = new UISwitch();
            doneSwitch.Frame   = new RectangleF(185, 30, 145, 50);
            doneSwitch.Enabled = false;
            doneLabel          = new UILabel();
            doneLabel.Frame    = new RectangleF(200, 10, 145, 15);
            doneLabel.Text     = "Done?";

            titleText = new UITextView(new RectangleF(10, 70, 300, 40));
            titleText.BackgroundColor = UIColor.FromRGB(240, 240, 240);
            titleText.Editable        = true;
            titleText.BackgroundColor = UIColor.FromRGB(240, 240, 240);

            descriptionText = new UITextView(new RectangleF(10, 130, 300, 180));
            descriptionText.BackgroundColor  = UIColor.FromRGB(240, 240, 240);
            descriptionText.Editable         = true;
            descriptionText.ScrollEnabled    = true;
            descriptionText.AutoresizingMask = UIViewAutoresizing.FlexibleHeight;

            // Add the controls to the view
            this.Add(saveButton);
            this.Add(deleteButton);
            this.Add(doneLabel);
            this.Add(doneSwitch);
            //this.Add(descriptionText);   // disabled for Azure demo (for now...)
            this.Add(titleText);
            #endregion

            LoadData();

            saveButton.TouchUpInside += (sender, e) => {
                task.Title       = titleText.Text;
                task.Description = descriptionText.Text;
                task.IsDone      = doneSwitch.On;

                // save to Azure
                AzureWebService.UpdateTodo(task);

                descriptionText.ResignFirstResponder();                                         // hide keyboard
                titleText.ResignFirstResponder();

                NavigationController.PopToRootViewController(true);
            };

            deleteButton.TouchUpInside += (sender, e) => {
                // save to Azure
                AzureWebService.DeleteTodo(task);

                descriptionText.ResignFirstResponder();                                         // hide keyboard
                titleText.ResignFirstResponder();

                NavigationController.PopToRootViewController(true);                  // doesn't reflect deletion yet
            };
        }