ReloadData() public method

public ReloadData ( ) : void
return void
Esempio n. 1
0
        public void PushViewController()
        {
            // trace event
            TraceHelper.AddMessage("Item: PushViewController");

            try
            {
                folder = App.ViewModel.LoadFolder(ThisItem.FolderID);
            }
            catch (Exception)
            {
                folder = null;
                return;
            }

            // make a deep copy of the item which stores the previous values
            // the iphone implementation will make changes to the "live" copy
            ItemCopy = new Item(ThisItem);
            root = RenderViewItem(ThisItem);
            actionsViewController = new DialogViewController (root, true);

            // create an Edit button which pushes the edit view onto the nav stack
            actionsViewController.NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Edit, delegate {
                var editRoot = RenderEditItem(ThisItem, false);
                editViewController = new DialogViewController(editRoot, true);
                editViewController.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, delegate {
                    // save the item and trigger a sync with the service
                    SaveButton_Click(null, null);
                    // navigate back to the list page
                    TraceHelper.StartMessage("Item: Navigate back");
                    NavigateBack();
                });

                UIImage actionsBackButtonImage = UIImageCache.GetUIImage("Images/actions-back-button.png");
                UIImage actionsBackButtonImageSelected = UIImageCache.GetUIImage("Images/actions-back-button-selected.png");
                UIButton actionsBackButton = UIButton.FromType(UIButtonType.Custom);
                actionsBackButton.SetImage(actionsBackButtonImage, UIControlState.Normal);
                actionsBackButton.SetImage(actionsBackButtonImageSelected, UIControlState.Selected);
                actionsBackButton.SetImage(actionsBackButtonImageSelected, UIControlState.Highlighted);
                actionsBackButton.Frame = new System.Drawing.RectangleF(0, 0, actionsBackButtonImage.Size.Width, actionsBackButtonImage.Size.Height);
                actionsBackButton.TouchUpInside += delegate {
                    // save the item and trigger a sync with the service
                    SaveButton_Click(null, null);
                    // reload the Actions page
                    var oldroot = root;
                    root = RenderViewItem(ThisItem);
                    actionsViewController.Root = root;
                    actionsViewController.ReloadData();
                    oldroot.Dispose();
                    // pop back to actions page
                    controller.PopViewControllerAnimated(true);
                };
                UIBarButtonItem actionsBackBarItem = new UIBarButtonItem(actionsBackButton);
                editViewController.NavigationItem.LeftBarButtonItem = actionsBackBarItem;
                editViewController.TableView.BackgroundColor = UIColorHelper.FromString(App.ViewModel.Theme.PageBackground);
                controller.PushViewController(editViewController, true);
            });

            // if moving from the item page to its parent (e.g. the schedule tab), call ViewDidAppear on that controller
            actionsViewController.ViewDisappearing += (sender, e) =>
            {
                /*
                if (UIDevice.CurrentDevice.CheckSystemVersion(5, 0))
                {
                    // this property should be called "IsMovingToParentViewController" - it is a bug in the property naming,
                    // not a bug in the code
                    if (actionsViewController.IsMovingFromParentViewController)
                        controller.ViewDidAppear(false);
                }
                */
                // the IsMovingToParentViewController method is only available on iOS 5.0 so the code above doesn't work generally.
                // it does not appear to hurt anything to always call ViewDidAppear (even when pushing deeper into the nav stack)
                controller.ViewDidAppear(false);
            };

            // push the "view item" view onto the nav stack
            actionsViewController.TableView.BackgroundColor = UIColorHelper.FromString(App.ViewModel.Theme.PageBackground);
            controller.PushViewController(actionsViewController, true);
        }
Esempio n. 2
0
 /// <summary>
 /// For proper display when the user taps "Back" button.
 /// Resets rootSections' dropdowns (No of Styles, Style Category, SizeRange etc) to default values (i.e. 0)
 /// </summary>
 public void ResetSectionValues(DialogViewController dvc)
 {
     for (int i = 0; i < rootSections.Count; i++) {
         foreach (Element item in rootSections[i].Elements) {
             var rootElement = item as RootElement;
             if (rootElement != null)
                 rootElement.RadioSelected = 0;
         }
     }
     dvc.ReloadData ();
 }
		void AdvancedConfigEdit (DialogViewController dvc)
		{
			dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Edit, delegate {
				// Activate editing
				// Switch the root to editable elements		
				dvc.Root = CreateEditableRoot(dvc.Root, true);
				dvc.ReloadData();	
				// Activate row editing & deleting
				dvc.TableView.SetEditing (true, true);
				AdvancedConfigDone(dvc);				
			});
		}
        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            // Perform any additional setup after loading the view, typically from a nib.

            //DVC is the source one - the one we start with. Most of it's stuff is just setup

            dvc = new DialogViewController(null, false);

            var root = new RootElement("Hello there");
            var section = new Section();

            for(int i = 0; i < 10; i++)
            {
                //urgh, using lambas, so we need to capture a few things locally.
                //never sure if I have to do this with int's or not tho
                int locali = i;

                //make the local element, the one in the main list
                StyledStringElement localElement = null;
                localElement = new StyledStringElement("Hello " + i.ToString (), delegate {;

                    //when you tap on the item, make a new root,
                    // which is a radio list. Select item 1 (the second one) by default
                    // but only cos I want to, no real reason :)

                    RadioGroup radioGroup = new RadioGroup(1);

                    //create 3 elements. This is stupid code copy and paste, they all do the same thing
                    // I guess you'd make this from an array or database?
                    var childroot = new RootElement("child", radioGroup)
                    {
                        new Section()
                        {
                            // I've made a custom RadioElement (down the bottom)
                            // that, when selected, calls us back
                            new CheckedRadioElement("First", delegate(CheckedRadioElement cre) {
                                // .. and we dismiss the popover, grab the value out, and then tell the
                                // main dvc to reload/redisplay itself.
                                popOver.Dismiss(true);
                                localElement.Caption = cre.Caption;
                                dvc.ReloadData();
                            }),

                            // these 2 are the same - just other data. Use a database or an array :)
                            new CheckedRadioElement("Second", delegate(CheckedRadioElement cre) {
                                popOver.Dismiss(true);
                                localElement.Caption = cre.Caption;
                                dvc.ReloadData();
                            }),
                            new CheckedRadioElement("Third", delegate(CheckedRadioElement cre) {
                                popOver.Dismiss(true);
                                localElement.Caption = cre.Caption;
                                dvc.ReloadData();
                            })
                        }
                    };

                    //make the child DVC. This is the one which goes into the popover.
                    // false on the end, 'cos we are not pushing it into a UINavigationController
                    var childdvc = new DialogViewController(childroot, false);
                    childdvc.Style = UITableViewStyle.Plain;

                    //this does tho!
                    //get the rect of the last section
                    var newrootSize = childdvc.TableView.RectForSection (childroot.Count - 1);
                    //and make that the size. Or 700... which ever is smaller.
                    childdvc.ContentSizeForViewInPopover = new SizeF (300, Math.Min (newrootSize.Bottom, 700));

                    //make the popover and set its size
                    popOver = new UIPopoverController(childdvc);

                    //and show the popover. We ask the tableview for the rect of the item we selected.
                    // and in this case, we want to see it on the right (arrow == left)
                    popOver.PresentFromRect(dvc.TableView.RectForRowAtIndexPath(localElement.IndexPath), dvc.TableView, UIPopoverArrowDirection.Left, true);

                }) {
                    Accessory = UITableViewCellAccessory.DisclosureIndicator
                };

                section.Add (localElement);
            }

            root.Add (section);

            dvc.Root = root;

            //temp view is because a normal DVC wants to take over the whole screen, we I'm constraining it to a 300x300 area, which I think is about
            // what you had. Thats the only reason tho.
            var tempView = new UIView(new RectangleF(10,10,300,300));
            tempView.AddSubview(dvc.TableView);

            View.Add (tempView);
        }
		void AdvancedConfigDone (DialogViewController dvc)
		{
			dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Done, delegate {
				// Deactivate editing
				dvc.ReloadData();
				// Switch updated entry elements to StringElements
				dvc.Root = CreateEditableRoot(dvc.Root, false);
				dvc.TableView.SetEditing (false, true);
				AdvancedConfigEdit (dvc);
			});
		}