public void RefreshCustomers()
        {
            this.Root.Clear();

            this.Root.Add(new Section("")
            {
                new StringElement("Refresh", RefreshCustomers)
            });

            var json = NSUserDefaults.StandardUserDefaults.StringForKey("customers");

            if (string.IsNullOrWhiteSpace(json) == false)
            {
                Customers = JsonSerializer.DeserializeFromString <IEnumerable <Customer> >(json).ToList();
            }

            if (Customers.Any())
            {
                var section = new Section("Customers");

                foreach (var customer in Customers)
                {
                    var desc = string.Format("Customer Name: {0} -- Address: {1}", customer.Name, customer.Address);
                    section.Add(new StringElement(desc));
                }

                this.Root.Add(section);
            }

            using (var pool = new NSAutoreleasePool()) {
                pool.BeginInvokeOnMainThread(() => {
                    this.ReloadData();
                });
            }
        }
        private void FinishedDownloadingImage(string path)
        {
            if (File.Exists(path))
            {
                using (var pool = new NSAutoreleasePool()) {
                    pool.BeginInvokeOnMainThread(() => {
                        var drugImageView   = new UIImageView(UIImage.FromFile(path));
                        drugImageView.Frame = new RectangleF(0, 0, 448, 320);
                        _DrugScrollView.AddSubview(drugImageView);
                    });
                }
            }
            else
            {
                using (var pool = new NSAutoreleasePool()) {
                    pool.BeginInvokeOnMainThread(() => {
                        var alert            = new UIAlertView("", "No Image Found", null, "OK");
                        alert.AlertViewStyle = UIAlertViewStyle.Default;

                        alert.Dismissed += delegate {
                            // do something, go back maybe.
                        };
                        alert.Show();
                    });
                }
            }
        }
 public void HideSearchingView()
 {
     using(var pool = new NSAutoreleasePool()) {
         pool.BeginInvokeOnMainThread(() => {
             IsSearching = false;
             _SearchingView.Hidden = true;
         });
     }
 }
Beispiel #4
0
 public void HideSearchingView()
 {
     using (var pool = new NSAutoreleasePool()) {
         pool.BeginInvokeOnMainThread(() => {
             IsSearching           = false;
             _SearchingView.Hidden = true;
         });
     }
 }
 private void UsageFetchError(string errorMessage)
 {
     using (var pool = new NSAutoreleasePool())
     {
         pool.BeginInvokeOnMainThread(() =>
         {
             var alert        = NSAlert.WithMessage("Error", "OK", null, null, "Could not get usage information: " + errorMessage);
             alert.AlertStyle = NSAlertStyle.Warning;
             alert.RunModal();
         });
     }
 }
 void Handle_RetreivedResultAction(bool result)
 {
     if (result)
     {
         feeds = new FeedsController();
         using (var pool = new NSAutoreleasePool())
         {
             pool.BeginInvokeOnMainThread(() => {
                 PushViewController(feeds, true);
             });
         }
     }
 }
Beispiel #7
0
 public void SetResultElementValue(string @value)
 {
     using (var pool = new NSAutoreleasePool()) {
         pool.BeginInvokeOnMainThread(() => {
             var e = Root[2][0] as StringElement;
             if (e != null)
             {
                 e.Caption = value;
                 this.TableView.ReloadData();
             }
         });
     }
 }
Beispiel #8
0
        private void UpdateMap(PlaceMark from, PlaceMark to)
        {
            using (var pool = new NSAutoreleasePool())
            {
                pool.BeginInvokeOnMainThread(() =>
                {
                    _MapView.AddAnnotation(new MKAnnotation[] { from, to });
                    _MapView.SetRegion(new MKCoordinateRegion(from.Coordinate, new MKCoordinateSpan(0.2, 0.2)), true);

                    UpdateRouteView();
                    CenterMap();
                });
            }
        }
        public override void LoadView()
        {
            base.LoadView();

            this.View.BackgroundColor = UIColor.White;

            _ResponseLabel           = new UILabel();
            _ResponseLabel.Text      = "Click to send Request";
            _ResponseLabel.Frame     = new System.Drawing.RectangleF(25, 300, View.Frame.Width - 50, 55);
            _ResponseLabel.TextColor = UIColor.Black;

            this.View.AddSubview(_ResponseLabel);

            var button = UIButton.FromType(UIButtonType.RoundedRect);

            button.Frame = new System.Drawing.RectangleF(25, 150, View.Frame.Width - 50, 55);
            button.SetTitle("Add Customer!", UIControlState.Normal);


            button.TouchUpInside += delegate {
                try {
                    var req = new RestRequest("", Method.PUT);
                    req.Timeout = (int)TimeSpan.FromSeconds(5).TotalMilliseconds;

                    var customer = new Customer {
                        Id      = _Random.Next(1, 100),
                        Name    = Names[_Random.Next(0, 8)],
                        Address = string.Format(@"{0} FARFLUFFLE on {1} STREET", _Random.Next(1, 1000), _Random.Next(1, 100)),
                    };
                    var body = JsonSerializer.SerializeToString <Customer>(customer);
                    Console.WriteLine(body);
                    req.AddParameter("body", body, ParameterType.RequestBody);

                    var response = _Client.Execute(req);
                    Console.WriteLine("Response -- Code: {0} -- Content: {1} -- Error: {2}", response.StatusCode, response.Content, response.ErrorMessage);


                    using (var pool = new NSAutoreleasePool()) {
                        pool.BeginInvokeOnMainThread(() => {
                            _ResponseLabel.Text = response.StatusCode == System.Net.HttpStatusCode.OK ? response.Content : "No Response from Server...";
                        });
                    }
                } catch (Exception ex) {
                    Console.WriteLine(ex);
                }
            };

            this.View.AddSubview(button);
        }
		void Handle_RetreivedResultAction(bool result)
		{
			if(result)
			{
				feeds = new FeedsController();
				using(var pool = new NSAutoreleasePool())
				{
					pool.BeginInvokeOnMainThread(()=>{
						PushViewController(feeds, true);
					});
				}
				
				
			}
		}
		public static void PresentFromRect(RectangleF rect, UIView inView, UIPopoverArrowDirection arrowDirection)
		{
			if(_Popover.ShouldDismiss == null) {
				_Popover.ShouldDismiss += (controller) => { return true; };
			}
			
			if(_Popover.DidDismiss == null) {
				_Popover.DidDismiss += (controller) => { Console.WriteLine("Popover Did Dismiss"); };
			}
			
			using(var pool = new NSAutoreleasePool()) {
			pool.BeginInvokeOnMainThread(()=> {
					_Popover.PresentPopover(rect, inView, arrowDirection, true);
				});
			}
		}
        void Handle_SubmitButtonClicked()
        {
            if (_WebView.IsLoading)
            {
                return;
            }

            using (var pool = new NSAutoreleasePool())
            {
                pool.BeginInvokeOnMainThread(() => {
                    _SubmitElement.Caption = "Processing...";
                    Root[0].Add(new ActivityElement());
                    this.TableView.ReloadData();
                });
            }


            _WebView.LoadHtmlString(Response.Content, new NSUrl(@"https://signin.crm.dynamics.com"));
        }
        private void FinishedGettingDrugConcept(RxTerm term)
        {
            var section = new Section();

            section.Add(new StringElement("Brand Name: ", term.BrandName));
            section.Add(new StringElement("Display Name: ", term.DisplayName));
            section.Add(new StringElement("Synonym: ", term.Synonym));
            section.Add(new StringElement("Full Name: ", term.FullName));
            section.Add(new StringElement("Full Generic Name: ", term.FullGenericName));
            section.Add(new StringElement("View Image!", () => { PushDrugImageView(term); }));

            using (var pool = new NSAutoreleasePool()) {
                pool.BeginInvokeOnMainThread(() => {
                    this.Root.Clear();
                    this.Root.Add(section);

                    this.TableView.ReloadData();
                });
            }
        }
        private void Handle_CustomViewViewWasTouched(object sender, EventArgs e)
        {
            var customView = sender as XMCustomView;

            if (customView == null)
            {
                return;
            }

            // Remember, the block of this method is called on a Background Thread...
            // In order to push a notification to the view we need to call within the scope of the main thread.

            using (var pool = new NSAutoreleasePool()) {
                pool.BeginInvokeOnMainThread(() => {
                    using (var alert = new UIAlertView("View Was Touched", "Our bound XMCustomView was Touched!", null, "OK, Cool!", null)) {
                        alert.Show();
                    }
                });
            }
        }
        public void RefreshCustomers()
        {
            this.Root.Clear();

            this.Root.Add(new Section("") {
                new StringElement("Refresh", RefreshCustomers)
            });

            var json = NSUserDefaults.StandardUserDefaults.StringForKey("customers");
            if(string.IsNullOrWhiteSpace(json) == false) {
                Customers = JsonSerializer.DeserializeFromString<IEnumerable<Customer>>(json).ToList();
            }

            if(Customers.Any()) {
                var section = new Section("Customers");

                foreach(var customer in Customers) {
                    var desc = string.Format("Customer Name: {0} -- Address: {1}", customer.Name, customer.Address);
                    section.Add(new StringElement(desc));
                }

                this.Root.Add(section);
            }

            using (var pool = new NSAutoreleasePool()) {
                pool.BeginInvokeOnMainThread(()=>{
                    this.ReloadData();
                });
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            //Call base
            base.ViewDidLoad();

            // Build a download manager
            downloadManager = new ACDownloadManager();

            //Wireup progress bar
            downloadManager.FileDownloadProgressPercent += delegate(float percentage) {
                //Update GUI
                using (var pool = new NSAutoreleasePool())
                {
                    pool.BeginInvokeOnMainThread(delegate {
                        //Set current percentage
                        DownloadingProgress.Progress = percentage;
                    });
                }
            };

            //Wireup completion handler
            downloadManager.AllDownloadsCompleted += delegate() {
                //Update GUI
                using (var pool = new NSAutoreleasePool())
                {
                    pool.BeginInvokeOnMainThread(delegate {
                        //Display Alert Dialog Box
                        ACAlert.ShowAlertOK("Download Manager", "All files have been downloaded.");

                        //Update GUI
                        DownloadingProgress.Hidden = true;
                        DownloadingActivity.StopAnimating();
                        DownloadButton.Enabled  = true;
                        CancelButton.Enabled    = false;
                        DownloadingLabel.Hidden = true;
                    });
                }
            };

            //Wireup download error event
            downloadManager.DownloadError += delegate(string message) {
                //Update GUI
                using (var pool = new NSAutoreleasePool())
                {
                    pool.BeginInvokeOnMainThread(delegate {
                        //Display Alert Dialog Box
                        ACAlert.ShowAlertOK("Download Error", message);

                        //Update GUI
                        DownloadingProgress.Hidden = true;
                        DownloadingActivity.StopAnimating();
                        DownloadButton.Enabled  = true;
                        CancelButton.Enabled    = false;
                        DownloadingLabel.Hidden = true;
                    });
                }
            };

            // Perform any additional setup after loading the view, typically from a nib.
            DownloadingProgress.Hidden = true;
            DownloadingActivity.StopAnimating();
            DownloadButton.Enabled = true;
            CancelButton.Enabled   = false;
        }
		public void SetResultElementValue(string @value)
		{	
			using(var pool = new NSAutoreleasePool()) {
				pool.BeginInvokeOnMainThread(() => {
					var e = Root[2][0] as StringElement;
					if(e != null) {
						e.Caption = value;
						this.TableView.ReloadData();
					}
				});
			}
		}
        public override void LoadView()
        {
            base.LoadView();

            this.View.BackgroundColor = UIColor.White;

            _ResponseLabel = new UILabel();
            _ResponseLabel.Text = "Click to send Request";
            _ResponseLabel.Frame = new System.Drawing.RectangleF(25, 300, View.Frame.Width - 50, 55);
            _ResponseLabel.TextColor = UIColor.Black;

            this.View.AddSubview(_ResponseLabel);

            var button = UIButton.FromType(UIButtonType.RoundedRect);
            button.Frame = new System.Drawing.RectangleF(25, 150, View.Frame.Width - 50, 55);
            button.SetTitle("Add Customer!", UIControlState.Normal);

            button.TouchUpInside += delegate {

                try {
                    var req = new RestRequest("", Method.PUT);
                    req.Timeout = (int)TimeSpan.FromSeconds(5).TotalMilliseconds;

                    var customer = new Customer {
                        Id = _Random.Next(1, 100),
                        Name = Names[_Random.Next(0, 8)],
                        Address = string.Format(@"{0} FARFLUFFLE on {1} STREET", _Random.Next(1, 1000), _Random.Next(1, 100)),
                    };
                    var body = JsonSerializer.SerializeToString<Customer>(customer);
                    Console.WriteLine(body);
                    req.AddParameter("body", body, ParameterType.RequestBody);

                    var response = _Client.Execute(req);
                    Console.WriteLine("Response -- Code: {0} -- Content: {1} -- Error: {2}", response.StatusCode, response.Content, response.ErrorMessage);

                    using(var pool = new NSAutoreleasePool()) {
                        pool.BeginInvokeOnMainThread(()=>{
                            _ResponseLabel.Text = response.StatusCode == System.Net.HttpStatusCode.OK ? response.Content : "No Response from Server...";
                        });
                    }

                } catch (Exception ex) {
                    Console.WriteLine(ex);
                }
            };

            this.View.AddSubview(button);
        }
        private void FinishedDownloadingImage(string path)
        {
            if(File.Exists(path)){
                using(var pool = new NSAutoreleasePool()) {
                    pool.BeginInvokeOnMainThread(() => {
                        var drugImageView = new UIImageView(UIImage.FromFile(path));
                        drugImageView.Frame = new RectangleF(0, 0, 448, 320);
                        _DrugScrollView.AddSubview(drugImageView);
                    });
                }
            }
            else {
                using(var pool = new NSAutoreleasePool()) {
                    pool.BeginInvokeOnMainThread(() => {

                        var alert = new UIAlertView ("", "No Image Found", null, "OK");
                        alert.AlertViewStyle = UIAlertViewStyle.Default;

                        alert.Dismissed += delegate {
                            // do something, go back maybe.
                        };
                        alert.Show();
                    });
                }
            }
        }
		private void Handle_CustomViewViewWasTouched (object sender, EventArgs e)
		{
			var customView =  sender as XMCustomView;
			
			if(customView == null) {
				return;
			}
			
			// Remember, the block of this method is called on a Background Thread...
			// In order to push a notification to the view we need to call within the scope of the main thread.
			
			using(var pool = new NSAutoreleasePool()) {
				pool.BeginInvokeOnMainThread(() => {
					using(var alert = new UIAlertView("View Was Touched", "Our bound XMCustomView was Touched!", null, "OK, Cool!", null)) {
						alert.Show();
					}
				});
			}
		}
Beispiel #21
0
        private void UpdateMap(PlaceMark from, PlaceMark to)
        {
            using(var pool = new NSAutoreleasePool())
            {

                pool.BeginInvokeOnMainThread(()=>
                {
                    _MapView.AddAnnotation(new MKAnnotation[] { from, to });
                    _MapView.SetRegion(new MKCoordinateRegion(from.Coordinate, new MKCoordinateSpan(0.2, 0.2)), true);

                    UpdateRouteView();
                    CenterMap();
                });
            }
        }
        private void UpdateResultElement(string result)
        {
            ResultElement.Value = result;

            using(var pool = new NSAutoreleasePool()) {
                pool.BeginInvokeOnMainThread(()=>{
                    this.ReloadData();
                });
            }
        }
		void Handle_SubmitButtonClicked()
		{
			if(_WebView.IsLoading)
				return;
			
			using(var pool = new NSAutoreleasePool())
			{
				pool.BeginInvokeOnMainThread(()=>{
					_SubmitElement.Caption = "Processing...";
					Root[0].Add(new ActivityElement());
					this.TableView.ReloadData();
				});
			}
			
			
			_WebView.LoadHtmlString(Response.Content, new NSUrl(@"https://signin.crm.dynamics.com"));
		}
		private void FinishedGettingDrugConcept(RxTerm term)
		{
			var section = new Section();
			
			section.Add(new StringElement("Brand Name: ", term.BrandName));
			section.Add(new StringElement("Display Name: ", term.DisplayName));
			section.Add(new StringElement("Synonym: ", term.Synonym));
			section.Add(new StringElement("Full Name: ", term.FullName));
			section.Add(new StringElement("Full Generic Name: ", term.FullGenericName));
			section.Add(new StringElement("View Image!", () => { PushDrugImageView(term); }));
			
			using(var pool = new NSAutoreleasePool()) {
				pool.BeginInvokeOnMainThread(()=>{
					this.Root.Clear();
					this.Root.Add(section);
					
					this.TableView.ReloadData();
				});
			}
		}