コード例 #1
0
ファイル: ScanView.cs プロジェクト: saedaes/ProductFinder
            public override void DidManualSearch(SIOverlayController overlayController, string text)
            {
                this._loadPop = new LoadingOverlay(UIScreen.MainScreen.Bounds);
                this.presentingViewController.View.Add(this._loadPop);
                picker.StopScanning();
                presentingViewController.DismissViewController(true, null);

                Task.Factory.StartNew(
                    // tasks allow you to use the lambda syntax to pass work
                    () => {
                    System.Threading.Thread.Sleep(1 * 1000);
                }
                    // ContinueWith allows you to specify an action that runs after the previous thread
                    // completes
                    //
                    // By using TaskScheduler.FromCurrentSyncrhonizationContext, we can make sure that
                    // this task now runs on the original calling thread, in this case the UI thread
                    // so that any UI updates are safe. in this example, we want to hide our overlay,
                    // but we don't want to update the UI from a background thread.
                    ).ContinueWith(
                    t => {
                    nsrView = new NameSearchResultView();
                    nsrView.setProductName(text.Trim());
                    presentingViewController.NavigationController.PushViewController(nsrView, true);
                    this._loadPop.Hide();
                }, TaskScheduler.FromCurrentSynchronizationContext()
                    );
            }
コード例 #2
0
            public ProductsTableSourceIphone(List <ProductSearchService> items, NameSearchResultView controller, int user)
            {
                tableItems       = items;
                this.controller  = controller;
                this.user        = user;
                PlaceholderImage = MaxResizeImage(Images.sinImagen, 60, 60);

                foreach (ProductSearchService product in tableItems)
                {
                    UIButton addToList = new UIButton();
                    botones.Add(addToList);
                }

                controller.productImages.CollectionChanged += HandleCollectionChanged;
                // If either a download fails or the image we download is corrupt, ignore the problem.
                TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs e) => e.SetObserved();
            }
コード例 #3
0
ファイル: MainView.cs プロジェクト: saedaes/ProductFinder
        public override void DidManualSearch(SIOverlayController overlayController, string text)
        {
            this._loadPop = new LoadingOverlay(UIScreen.MainScreen.Bounds);
            this.presentingViewController.View.Add(this._loadPop);
            picker.StopScanning();
            presentingViewController.DismissViewController(true, null);

            Task.Factory.StartNew(
                () => {
                System.Threading.Thread.Sleep(1 * 1000);
            }
                ).ContinueWith(
                t => {
                nsrView = new NameSearchResultView();
                nsrView.setProductName(text);
                presentingViewController.NavigationController.PushViewController(nsrView, true);
                this._loadPop.Hide();
            }, TaskScheduler.FromCurrentSynchronizationContext()
                );
        }
コード例 #4
0
ファイル: MainView.cs プロジェクト: saedaes/ProductFinder
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			this.Add (faceBookView);
			this.Add (facebookView2);

			iPhoneLocationManager = new CLLocationManager ();
			iPhoneLocationManager.DesiredAccuracy = CLLocation.AccuracyNearestTenMeters;
			iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {

			};
				
			iPhoneLocationManager.RequestAlwaysAuthorization ();
			if (CLLocationManager.LocationServicesEnabled) {
				iPhoneLocationManager.StartUpdatingLocation ();
			}
			#region observadores del teclado
			// Keyboard popup
			NSNotificationCenter.DefaultCenter.AddObserver
			(UIKeyboard.DidShowNotification,KeyBoardUpNotification);

			// Keyboard Down
			NSNotificationCenter.DefaultCenter.AddObserver
			(UIKeyboard.WillHideNotification,KeyBoardDownNotification);
			#endregion

			#region declaracion de vista de Facebook
			// Create the Facebook LogIn View with the needed Permissions
			// https://developers.facebook.com/ios/login-ui-control/
			loginView = new FBLoginView (ExtendedPermissions) {
				Frame = new CGRect (0,0,45, 45)
			};

			// Create view that will display user's profile picture
			// https://developers.facebook.com/ios/profilepicture-ui-control/

			pictureView = new FBProfilePictureView () {
				Frame = new CGRect (0, 0, 45, 45)
			};
			pictureView.UserInteractionEnabled = true;
			// Hook up to FetchedUserInfo event, so you know when
			// you have the user information available
			loginView.FetchedUserInfo += (sender, e) => {
				user = e.User;
				pictureView.ProfileID = user.GetId ();
				MainView.isWithFacebook = true;
				loginView.Alpha = 0.1f;
				pictureView.Hidden = false;
			};

			// Clean user Picture and label when Logged Out
			loginView.ShowingLoggedOutUser += (sender, e) => {
				pictureView.ProfileID = null;
				pictureView.Hidden = true;
				lblUserName.Text = string.Empty;
				loginView.Alpha = 1f;
				MainView.isWithFacebook = false;
			};
		
			this.faceBookView.Add(pictureView);
			this.faceBookView.Add(loginView);
			#endregion

			var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
			_pathToDatabase = Path.Combine(documents, "db_sqlite-net.db");

			//Creamos la base de datos y la tabla de persona
			using (var conn= new SQLite.SQLiteConnection(_pathToDatabase))
			{
				conn.CreateTable<Person>();
				conn.CreateTable<State> ();
				conn.CreateTable<Terms> ();
				conn.CreateTable<PrivacyNotice> ();
			}

			using (var db = new SQLite.SQLiteConnection(_pathToDatabase ))
			{
				people = new List<Person> (from p in db.Table<Person> () select p);
				states = new List<State> (from s in db.Table<State> () select s);
				terms = new List<Terms> (from t in db.Table<Terms> ()select t);
				privacyNotices = new List<PrivacyNotice> (from pr in db.Table<PrivacyNotice> () select pr);
			}

			if(people.Count > 0){
				Person user = people.ElementAt(0);
				MainView.userId = user.ID;
				Console.WriteLine ("El Id de usuario es: "+ user.ID);
			}

			if(states.Count > 0){
				State estado = states.ElementAt(0);
				MainView.localityId = estado.localityId;
				Console.WriteLine ("El Id de localidad es: "+ estado.stateId);
			}
				
			//Boton para entrar al menu de la aplicacion.
			this.btnEntrar.TouchUpInside += (sender, e) => {
				scanView = new ScanView();
				this.NavigationController.PushViewController(scanView, true);
			};

			this.btnListas.TouchUpInside += (sender, e) => {
				using (var db = new SQLite.SQLiteConnection(_pathToDatabase ))
				{
					people = new List<Person> (from p in db.Table<Person> () select p);
				}
				if(people.Count > 0){
					MyListsView mylists = new MyListsView();
					this.NavigationController.PushViewController(mylists,true);
				}else{
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes iniciar sesion para acceder a tus listas"
					};
					alert.AddButton ("Aceptar");
					alert.Show ();
				}
			};

			//Boton para hacer busqueda por nombre de producto
			this.btnBuscar.TouchUpInside += (sender, e) => {
				if(this.cmpNombre.Text == ""){
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes ingresar el nombre del producto a buscar"
					};
					alert.AddButton ("Aceptar");
					alert.Show ();
				}
				else if (states.Count < 1){
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " +
							"Al menu de opciones para establecerla"
					};
					alert.AddButton ("Aceptar");
					alert.Clicked += (s, o) => {
						StatesView statesView = new StatesView();
						this.NavigationController.PushViewController(statesView, true);
					};
					alert.Show ();
				}
				else{
					this._loadPop = new LoadingOverlay (UIScreen.MainScreen.Bounds);
					this.View.Add ( this._loadPop );
					this.cmpNombre.ResignFirstResponder();
					Task.Factory.StartNew (
						() => {
							System.Threading.Thread.Sleep ( 1 * 1000 );
						}
					).ContinueWith ( 
						t => {
							nsr = new NameSearchResultView();
							nsr.setProductName(this.cmpNombre.Text.Trim());
							this.NavigationController.PushViewController(nsr,true);
							this._loadPop.Hide ();
						}, TaskScheduler.FromCurrentSynchronizationContext()
					);
				}
			};

			this.cmpNombre.ShouldReturn += (textField) => {
				if(this.cmpNombre.Text == ""){
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes ingresar el nombre del producto a buscar"
					};
					alert.AddButton ("Aceptar");
					alert.Show ();
				}
				else if (states.Count < 1){
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " +
							"Al menu de opciones para establecerla"
					};
					alert.AddButton ("Aceptar");
					alert.Clicked += (s, o) => {
						StatesView statesView = new StatesView();
						this.NavigationController.PushViewController(statesView, true);
					};
					alert.Show ();
				}
				else{
					this._loadPop = new LoadingOverlay (UIScreen.MainScreen.Bounds);
					this.View.Add ( this._loadPop );
					this.cmpNombre.ResignFirstResponder();
					Task.Factory.StartNew (
						() => {
							System.Threading.Thread.Sleep ( 1 * 1000 );
						}
					).ContinueWith ( 
						t => {
							nsr = new NameSearchResultView();
							nsr.setProductName(this.cmpNombre.Text.Trim());
							this.NavigationController.PushViewController(nsr,true);
							this._loadPop.Hide ();
						}, TaskScheduler.FromCurrentSynchronizationContext()
					);
				} 
				return true; 
			};

			//Boton para iniciar el escaner de codigo de barras
			this.btnCodigo.TouchUpInside += (sender, e) => {
				if(states.Count > 0){
					// Configurar el escaner de codigo de barras.
					picker = new ScanditSDKRotatingBarcodePicker (appKey);
					picker.OverlayController.Delegate = new overlayControllerDelegate(picker, this);
					picker.OverlayController.ShowToolBar(true);
					picker.OverlayController.ShowSearchBar(true);
					picker.OverlayController.SetToolBarButtonCaption("Cancelar");
					picker.OverlayController.SetSearchBarKeyboardType(UIKeyboardType.Default);
					picker.OverlayController.SetSearchBarPlaceholderText("Búsqueda por nombre de producto");
					picker.OverlayController.SetCameraSwitchVisibility(SICameraSwitchVisibility.OnTablet);
					picker.OverlayController.SetTextForInitializingCamera("Iniciando la camara");
					this.PresentViewController (picker, true, null);
					picker.StartScanning ();
				}else{
					UIAlertView alert = new UIAlertView () { 
						Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " +
							"Al menu de opciones para establecerla"
					};
					alert.AddButton ("Aceptar");
					alert.Clicked += (s, o) => {
						StatesView statesView = new StatesView();
						this.NavigationController.PushViewController(statesView, true);
					};
					alert.Show ();
				}
			};
		}
コード例 #5
0
ファイル: MainView.cs プロジェクト: saedaes/ProductFinder
		public override void DidManualSearch (SIOverlayController overlayController, string text) {
			this._loadPop = new LoadingOverlay (UIScreen.MainScreen.Bounds);
			this.presentingViewController.View.Add ( this._loadPop );
			picker.StopScanning ();
			presentingViewController.DismissViewController (true, null);

			Task.Factory.StartNew (
				() => {
					System.Threading.Thread.Sleep ( 1 * 1000 );
				}
			).ContinueWith ( 
				t => {
					nsrView = new NameSearchResultView();
					nsrView.setProductName (text);
					presentingViewController.NavigationController.PushViewController (nsrView, true);
					this._loadPop.Hide ();
				}, TaskScheduler.FromCurrentSynchronizationContext()
			);
		}
コード例 #6
0
 public AddToListsTableSource(List <ListsService> items, NameSearchResultView controller, String producto, int cantidad)
 {
     tableItems    = items;
     this.producto = producto;
     this.cantidad = cantidad;
 }
コード例 #7
0
ファイル: MainView.cs プロジェクト: saedaes/ProductFinder
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            this.Add(faceBookView);
            this.Add(facebookView2);

            iPhoneLocationManager = new CLLocationManager();
            iPhoneLocationManager.DesiredAccuracy   = CLLocation.AccuracyNearestTenMeters;
            iPhoneLocationManager.LocationsUpdated += (object sender, CLLocationsUpdatedEventArgs e) => {
            };

            iPhoneLocationManager.RequestAlwaysAuthorization();
            if (CLLocationManager.LocationServicesEnabled)
            {
                iPhoneLocationManager.StartUpdatingLocation();
            }
            #region observadores del teclado
            // Keyboard popup
            NSNotificationCenter.DefaultCenter.AddObserver
                (UIKeyboard.DidShowNotification, KeyBoardUpNotification);

            // Keyboard Down
            NSNotificationCenter.DefaultCenter.AddObserver
                (UIKeyboard.WillHideNotification, KeyBoardDownNotification);
            #endregion

            #region declaracion de vista de Facebook
            // Create the Facebook LogIn View with the needed Permissions
            // https://developers.facebook.com/ios/login-ui-control/
            loginView = new FBLoginView(ExtendedPermissions)
            {
                Frame = new CGRect(0, 0, 45, 45)
            };

            // Create view that will display user's profile picture
            // https://developers.facebook.com/ios/profilepicture-ui-control/

            pictureView = new FBProfilePictureView()
            {
                Frame = new CGRect(0, 0, 45, 45)
            };
            pictureView.UserInteractionEnabled = true;
            // Hook up to FetchedUserInfo event, so you know when
            // you have the user information available
            loginView.FetchedUserInfo += (sender, e) => {
                user = e.User;
                pictureView.ProfileID   = user.GetId();
                MainView.isWithFacebook = true;
                loginView.Alpha         = 0.1f;
                pictureView.Hidden      = false;
            };

            // Clean user Picture and label when Logged Out
            loginView.ShowingLoggedOutUser += (sender, e) => {
                pictureView.ProfileID   = null;
                pictureView.Hidden      = true;
                lblUserName.Text        = string.Empty;
                loginView.Alpha         = 1f;
                MainView.isWithFacebook = false;
            };

            this.faceBookView.Add(pictureView);
            this.faceBookView.Add(loginView);
            #endregion

            var documents = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
            _pathToDatabase = Path.Combine(documents, "db_sqlite-net.db");

            //Creamos la base de datos y la tabla de persona
            using (var conn = new SQLite.SQLiteConnection(_pathToDatabase))
            {
                conn.CreateTable <Person>();
                conn.CreateTable <State> ();
                conn.CreateTable <Terms> ();
                conn.CreateTable <PrivacyNotice> ();
            }

            using (var db = new SQLite.SQLiteConnection(_pathToDatabase))
            {
                people         = new List <Person> (from p in db.Table <Person> () select p);
                states         = new List <State> (from s in db.Table <State> () select s);
                terms          = new List <Terms> (from t in db.Table <Terms> () select t);
                privacyNotices = new List <PrivacyNotice> (from pr in db.Table <PrivacyNotice> () select pr);
            }

            if (people.Count > 0)
            {
                Person user = people.ElementAt(0);
                MainView.userId = user.ID;
                Console.WriteLine("El Id de usuario es: " + user.ID);
            }

            if (states.Count > 0)
            {
                State estado = states.ElementAt(0);
                MainView.localityId = estado.localityId;
                Console.WriteLine("El Id de localidad es: " + estado.stateId);
            }

            //Boton para entrar al menu de la aplicacion.
            this.btnEntrar.TouchUpInside += (sender, e) => {
                scanView = new ScanView();
                this.NavigationController.PushViewController(scanView, true);
            };

            this.btnListas.TouchUpInside += (sender, e) => {
                using (var db = new SQLite.SQLiteConnection(_pathToDatabase))
                {
                    people = new List <Person> (from p in db.Table <Person> () select p);
                }
                if (people.Count > 0)
                {
                    MyListsView mylists = new MyListsView();
                    this.NavigationController.PushViewController(mylists, true);
                }
                else
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Espera!", Message = "Debes iniciar sesion para acceder a tus listas"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            //Boton para hacer busqueda por nombre de producto
            this.btnBuscar.TouchUpInside += (sender, e) => {
                if (this.cmpNombre.Text == "")
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Espera!", Message = "Debes ingresar el nombre del producto a buscar"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
                else if (states.Count < 1)
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " +
                                                     "Al menu de opciones para establecerla"
                    };
                    alert.AddButton("Aceptar");
                    alert.Clicked += (s, o) => {
                        StatesView statesView = new StatesView();
                        this.NavigationController.PushViewController(statesView, true);
                    };
                    alert.Show();
                }
                else
                {
                    this._loadPop = new LoadingOverlay(UIScreen.MainScreen.Bounds);
                    this.View.Add(this._loadPop);
                    this.cmpNombre.ResignFirstResponder();
                    Task.Factory.StartNew(
                        () => {
                        System.Threading.Thread.Sleep(1 * 1000);
                    }
                        ).ContinueWith(
                        t => {
                        nsr = new NameSearchResultView();
                        nsr.setProductName(this.cmpNombre.Text.Trim());
                        this.NavigationController.PushViewController(nsr, true);
                        this._loadPop.Hide();
                    }, TaskScheduler.FromCurrentSynchronizationContext()
                        );
                }
            };

            this.cmpNombre.ShouldReturn += (textField) => {
                if (this.cmpNombre.Text == "")
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Espera!", Message = "Debes ingresar el nombre del producto a buscar"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
                else if (states.Count < 1)
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " +
                                                     "Al menu de opciones para establecerla"
                    };
                    alert.AddButton("Aceptar");
                    alert.Clicked += (s, o) => {
                        StatesView statesView = new StatesView();
                        this.NavigationController.PushViewController(statesView, true);
                    };
                    alert.Show();
                }
                else
                {
                    this._loadPop = new LoadingOverlay(UIScreen.MainScreen.Bounds);
                    this.View.Add(this._loadPop);
                    this.cmpNombre.ResignFirstResponder();
                    Task.Factory.StartNew(
                        () => {
                        System.Threading.Thread.Sleep(1 * 1000);
                    }
                        ).ContinueWith(
                        t => {
                        nsr = new NameSearchResultView();
                        nsr.setProductName(this.cmpNombre.Text.Trim());
                        this.NavigationController.PushViewController(nsr, true);
                        this._loadPop.Hide();
                    }, TaskScheduler.FromCurrentSynchronizationContext()
                        );
                }
                return(true);
            };

            //Boton para iniciar el escaner de codigo de barras
            this.btnCodigo.TouchUpInside += (sender, e) => {
                if (states.Count > 0)
                {
                    // Configurar el escaner de codigo de barras.
                    picker = new ScanditSDKRotatingBarcodePicker(appKey);
                    picker.OverlayController.Delegate = new overlayControllerDelegate(picker, this);
                    picker.OverlayController.ShowToolBar(true);
                    picker.OverlayController.ShowSearchBar(true);
                    picker.OverlayController.SetToolBarButtonCaption("Cancelar");
                    picker.OverlayController.SetSearchBarKeyboardType(UIKeyboardType.Default);
                    picker.OverlayController.SetSearchBarPlaceholderText("Búsqueda por nombre de producto");
                    picker.OverlayController.SetCameraSwitchVisibility(SICameraSwitchVisibility.OnTablet);
                    picker.OverlayController.SetTextForInitializingCamera("Iniciando la camara");
                    this.PresentViewController(picker, true, null);
                    picker.StartScanning();
                }
                else
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Espera!", Message = "Debes seleccionar tu ubicacion antes de comenzar a usar FixBuy, por favor ingresa " +
                                                     "Al menu de opciones para establecerla"
                    };
                    alert.AddButton("Aceptar");
                    alert.Clicked += (s, o) => {
                        StatesView statesView = new StatesView();
                        this.NavigationController.PushViewController(statesView, true);
                    };
                    alert.Show();
                }
            };
        }
コード例 #8
0
ファイル: ScanView.cs プロジェクト: saedaes/ProductFinder
			public override void DidManualSearch (SIOverlayController overlayController, string text) {
				this._loadPop = new LoadingOverlay (UIScreen.MainScreen.Bounds);
				this.presentingViewController.View.Add ( this._loadPop );
				picker.StopScanning ();
				presentingViewController.DismissViewController (true, null);

				Task.Factory.StartNew (
					// tasks allow you to use the lambda syntax to pass work
					() => {
						System.Threading.Thread.Sleep ( 1 * 1000 );
					}
					// ContinueWith allows you to specify an action that runs after the previous thread
					// completes
					// 
					// By using TaskScheduler.FromCurrentSyncrhonizationContext, we can make sure that 
					// this task now runs on the original calling thread, in this case the UI thread
					// so that any UI updates are safe. in this example, we want to hide our overlay, 
					// but we don't want to update the UI from a background thread.
				).ContinueWith ( 
					t => {
						nsrView = new NameSearchResultView();
						nsrView.setProductName (text.Trim());
						presentingViewController.NavigationController.PushViewController (nsrView, true);
						this._loadPop.Hide ();
					}, TaskScheduler.FromCurrentSynchronizationContext()
				);
			}
コード例 #9
0
			public AddToListsTableSource (List<ListsService> items, NameSearchResultView controller, String producto, int cantidad) 
			{
				tableItems = items;
				this.producto = producto;
				this.cantidad = cantidad;
			}
コード例 #10
0
			public ProductsTableSourceIphone (List<ProductSearchService> items, NameSearchResultView controller, int  user) 
			{
				tableItems = items;
				this.controller = controller;
				this.user = user;
				PlaceholderImage = MaxResizeImage (Images.sinImagen, 60, 60); 

				foreach (ProductSearchService product in tableItems){
					UIButton addToList = new UIButton ();
					botones.Add (addToList);
				}

				controller.productImages.CollectionChanged += HandleCollectionChanged;
				// If either a download fails or the image we download is corrupt, ignore the problem.
				TaskScheduler.UnobservedTaskException += (object sender, UnobservedTaskExceptionEventArgs e) => e.SetObserved ();
			}