Fetch() public method

public Fetch ( ) : void
return void
Exemplo n.º 1
0
        public void Building()
        {
            if (building == null){

                building = new Building () {
                    AccountEnabled = true,
                    ListOfString = new List<string> () { "One", "Two", "Three" }
                };
            }
            var bc = new BindingContext (null, building, "Building");

            var dv = new DialogViewController (bc.Root, true);

            // When the view goes out of screen, we fetch the data.
            dv.ViewDisappearing += delegate {
                // This reflects the data back to the object instance
                bc.Fetch ();

                // Manly way of dumping the data.
                Console.WriteLine ("Current status:");
                Console.WriteLine (
                    "Name:      	  {0}\n" +
                    "IEnumerable idx: {1}",
                    building.Name,
                    building.selected);
            };
            navigation.PushViewController (dv, true);
        }
Exemplo n.º 2
0
        public EditAccount(IAccountContainer container, TwitterAccount account, bool pushing)
        {
            var info = new AccountInfo ();
            bool newAccount = account == null;

            if (newAccount)
                account = new TwitterAccount ();
            else {
                info.Login = account.Username;
                //info.Password = account.Password;
            }

            var bc = new BindingContext (this, info, Locale.GetText ("Edit Account"));
            var dvc = new DialogViewController (bc.Root, true);
            PushViewController (dvc, false);
            UIBarButtonItem done = null;
            done = new UIBarButtonItem (UIBarButtonSystemItem.Done, delegate {
                bc.Fetch ();

                done.Enabled = false;
                CheckCredentials (info, delegate (string errorMessage) {
                    Util.PopNetworkActive ();
                    done.Enabled = true;

                    if (errorMessage == null){
                        account.Username = info.Login;
                        //account.Password = info.Password;

                        lock (Database.Main){
                            if (newAccount)
                                Database.Main.Insert (account);
                            else
                                Database.Main.Update (account);
                        }

                        account.SetDefaultAccount ();
                        DismissModalViewControllerAnimated (true);
                        container.Account = account;
                    } else {
                        dlg = new UIAlertView (Locale.GetText ("Login error"), errorMessage, null, Locale.GetText ("Close"));
                        dlg.Show ();
                    }
                });
            });

            dvc.NavigationItem.SetRightBarButtonItem (done, false);
        }
		//using the reflection api to edit a single bank
		void EditBank(Bank bank)
		{
			var context = new BindingContext (this, bank, "Edit " + bank.Name);
			
			//make a dialog view controller (UITableView descendant)
			var dvc = new DialogViewController (context.Root, true);
			
			//setup a button, so we can have a save function
			dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Save, (o,e) => {
				context.Fetch();
				NavigationController.PopViewControllerAnimated(true);
				ReloadData();

			});

			NavigationController.PushViewController (dvc, true);
		}
Exemplo n.º 4
0
		public override bool FinishedLaunching (UIApplication app, NSDictionary options)
		{
			window = new UIWindow (UIScreen.MainScreen.Bounds);


			//create our model
			var account = new AccountInfoModel ();

			//we could also do this
			//account.Login = "******";
			//account.Password = "******";

			//create a context. passing (in order)
			// account: this is where OnTap callbacks go to. This could be any other class, it doesn't have to be the same one
			// account: this is the model we are going to be populating
			// "...": the title of the list
			var context = new BindingContext (account, account, "Account");

			//make a dialog view controller (UITableView descendant)
			var dvc = new DialogViewController (context.Root, false);
		 	
			//setup a button, so we can have a save function
			dvc.NavigationItem.RightBarButtonItem = new UIBarButtonItem (UIBarButtonSystemItem.Save, (o,e) => {
				context.Fetch();

				var alert = new UIAlertView ("Thanks!", string.Format ("Thanks {0}. Your secret handshake is {1}.\nHave a nice flight in the {2}",
				                                                       account.Login, account.Password, account.Preference.ToString ()),
				                             null, "Ok");
				
				alert.Show ();

			});

			//wrap it all up in a UINavigationController
			window.RootViewController = new UINavigationController (dvc);
			window.MakeKeyAndVisible ();
			
			return true;
		}
Exemplo n.º 5
0
        public static void ShowCredentialDetails(Credential credential, UIViewController controller, UITableView tableView)
        {
            bool isNew = credential.Id == 0;

            var binding = new BindingContext(null, credential, isNew ? "Add Credential" : credential.Name);
            var dialogViewController = new DialogViewController(binding.Root);

            if ( controller is UINavigationController )
            {
                var navController = (controller as UINavigationController);

                navController.PushViewController(dialogViewController, true);
                navController.NavigationBarHidden = false;

                UIBarButtonItem addButton = new UIBarButtonItem (UIBarButtonSystemItem.Save);
                dialogViewController.NavigationItem.HidesBackButton = false;
                dialogViewController.NavigationItem.RightBarButtonItem = addButton;

                addButton.Clicked += (sender, e) =>
                {
                    binding.Fetch();
                    binding.Root.Caption = credential.Name;

                    if (ClientInterface.SaveCredential(credential)
                        && tableView != null)
                    {
                        tableView.ReloadData();
                    }

                    navController.PopViewControllerAnimated(true);
                };
            }
            else
            {
                controller.PresentModalViewController(dialogViewController, true);
            }
        }
Exemplo n.º 6
0
Arquivo: Main.cs Projeto: karasko/csla
    // This method is invoked when the application has loaded its UI and its ready to run
    public override bool FinishedLaunching (UIApplication app, NSDictionary options)
    {

      window.AddSubview (navigationController.View);
      
      Library.CustomerEdit.BeginNewCustomer (Csla.DataPortal.ProxyModes.LocalOnly, (o, e) =>
      {
        if (e.Error == null) {
          var customer = e.Object;
          // Now make sure we invoke on the main thread the updates
          navigationController.InvokeOnMainThread (delegate {
            var context = new BindingContext (this, customer, "Simple App");
            customerViewController = new DialogViewController (context.Root, true);
            // When the view goes out of screen, we fetch the data.
            customerViewController.ViewDissapearing += delegate {
              // This reflects the data back to the object instance
              context.Fetch ();
              Console.WriteLine ("Customer Name: {0}", customer.Name);
              Console.WriteLine ("Date of Birth: {0}", customer.BirthDate);
              Console.WriteLine ("Status: {0}", customer.Status);
            };
            navigationController.PushViewController (customerViewController, true);
          });
          
        }

        
        else {
          throw e.Error;
        }
        
      });
      
      window.MakeKeyAndVisible ();
      
      return true;
    }
		public void DemoReflectionApi ()
		{	
			if (s == null){
				s = new Settings () {
					AccountEnabled = true,
					Login = "******",
					Appointment = DateTime.Now,
					Birthday = new DateTime (1980, 6, 24),
					Alarm = new DateTime (2000, 1, 1, 7, 30, 0, 0),
					FavoriteType = TypeCode.Int32
				};
			}
			var bc = new BindingContext (s, "Settings");
			
			var dv = new DialogViewController (bc.Root, true);
			
			// When the view goes out of screen, we fetch the data.
			dv.ViewDissapearing += delegate {
				// This reflects the data back to the object instance
				bc.Fetch ();
				
				// Manly way of dumping the data.
				Console.WriteLine ("Current status:");
				Console.WriteLine (
				    "AccountEnabled: {0}\n" +
				    "Login:          {1}\n" +
				    "Password:       {2}\n" +
				    "Appointment:    {3}\n" +
				    "Birthday:       {4}\n" +
				    "Alarm:          {5}\n" +
				    "Favorite Type:  {6}\n", 
				    s.AccountEnabled, s.Login, s.Password, 
				    s.Appointment, s.Birthday, s.Alarm, s.FavoriteType);
			};
			navigation.PushViewController (dv, true);	
		}
		public void DemoReflectionApi ()
		{	
			if (settings == null){
				var image = UIImage.FromFile ("monodevelop-32.png");
				
				settings = new Settings () {
					AccountEnabled = true,
					Login = "******",
					TimeSamples = new TimeSettings () {
						Appointment = DateTime.Now,
						Birthday = new DateTime (1980, 6, 24),
						Alarm = new DateTime (2000, 1, 1, 7, 30, 0, 0)
					},
					FavoriteType = TypeCode.Int32,
					Top = image,
					Middle = image,
					Bottom = image,
					ListOfString = new List<string> () { "One", "Two", "Three" }
				};
			}

			var cb = new Callbacks();
			var bc = new BindingContext (cb, settings, "Settings");
			cb.Initalize(bc);

			var dv = new DialogViewController (bc.Root, true);
			
			// When the view goes out of screen, we fetch the data.
			dv.ViewDisappearing += delegate {
				// This reflects the data back to the object instance
				bc.Fetch ();
				
				// Manly way of dumping the data.
				Console.WriteLine ("Current status:");
				Console.WriteLine (
				    "AccountEnabled:   {0}\n" +
				    "Login:            {1}\n" +
				    "Password:         {2}\n" +
					"Name:      	   {3}\n" +
				    "Appointment:      {4}\n" +
				    "Birthday:         {5}\n" +
				    "Alarm:            {6}\n" +
				    "Favorite Type:    {7}\n" + 
				    "IEnumerable idx:  {8}\n" +
					"I like ice cream: {9}\n" +
					"I like veggies:   {10}\n" +
					"Animal kinds:     {11}\n" +
					"Animal sizes:     {12}",
				    settings.AccountEnabled, settings.Login, settings.Password, settings.Name,
				    settings.TimeSamples.Appointment, settings.TimeSamples.Birthday, 
				    settings.TimeSamples.Alarm, settings.FavoriteType,
				    settings.selected, 
					settings.LikeIceCream, settings.LikeVegetables,
					settings.Kinds, settings.Sizes);
			};
			navigation.PushViewController (dv, true);	
		}