public ToastViewModel(string ToastMessage, int ShowTime)
 {
     _closer                  = new DispatcherTimer();
     _closer.Interval         = new TimeSpan(0, 0, 0, 0, ShowTime);
     _closer.Tick            += _closer_Tick;
     _closer.IsEnabled        = true;
     this.ToastMessage        = ToastMessage;
     _toastWindow             = new ToastView();
     _toastWindow.DataContext = this;
     _toastWindow.Show();
     _closer.Start();
 }
Example #2
0
        private static void showToast(IInteraction interaction)
        {
            var call     = interaction as ICall;
            var cxScreen = Screen.PrimaryScreen;

            if (call.CallType == CallType.Outbound)
            {
                return;
            }
            if (Application.OpenForms.Count > 0)
            {
                cxScreen = Screen.FromHandle(Application.OpenForms[0].Handle);
            }
            else
            {
                cxScreen = Screen.FromHandle(findHandle());
            }


            var toast = new ToastView {
                Model = new ToastViewModel {
                    Interaction  = interaction,
                    LastActivity = DateTime.Now.AddSeconds(5),
                    Inactive     = true
                }
            };

            interaction.StateChanged += interaction_StateChanged;

            toast.Left        = (cxScreen.WorkingArea.X + cxScreen.WorkingArea.Width) - (toast.Width + 1);
            toast.Top         = (cxScreen.WorkingArea.Y + cxScreen.WorkingArea.Height) - (toast.Height + 1) - (_openToasts.Count * toast.Height);
            toast.MouseEnter += toast_MouseEnter;
            toast.MouseLeave += toast_MouseLeave;
            toast.Closed     += toast_Closed;
            _openToasts.Add(toast);
            toast.Show();

            if (_openToasts.Count == 1)
            {
                _timer.Change(5000, 1000);
            }
        }
        protected async Task ShowToast(string message = null)
        {
            if (RootGrid == null)
            {
                return;
            }
            if (_toast == null)
            {
                _toast = new ToastView
                {
                    Text = message ?? nameof(AppResources.SuccessToastMessage).Translate()
                };
                var columnSpan = RootGrid.ColumnDefinitions.Count == 0 ? 1 : RootGrid.ColumnDefinitions.Count;
                var rowSpan    = RootGrid.RowDefinitions.Count == 0 ? 1 : RootGrid.RowDefinitions.Count;

                Grid.SetColumnSpan(_toast, columnSpan);
                Grid.SetRowSpan(_toast, rowSpan);
                RootGrid.Children.Add(_toast);
            }

            await _toast.Show();
        }
Example #4
0
        public static Task <bool> Show(string message)
        {
            return(UIApplication.SharedApplication.InvokeOnMainThreadAsync(() =>
            {
                if (IsTopMostViewSplashScreen())
                {
                    return false;
                }

                //If we are displaying he splashscreen or extended splashscreen.
                if (IsTopMostViewSplashScreen())
                {
                    return false;
                }

                Toast = new ToastView(message);

                Toast.Show();

                return true;
            }));
        }
Example #5
0
        private static void ToastBase(string title, System.Drawing.Bitmap bitmap, Brush color, string msg = null, Action func = null)
        {
            IncrementToastCount();
            var toast = new ToastView();

            var desktopWorkingArea = System.Windows.SystemParameters.WorkArea;

            var toastHeight   = (int)(toast.Height + 10);
            var desktopHeight = (int)(desktopWorkingArea.Height / toastHeight);

            var XOffset = (ToastController.Instance.Offset / desktopHeight) + 1;
            var YOffset = XOffset > 1
                ? (ToastController.Instance.Offset % desktopHeight) + 1
                : (ToastController.Instance.Offset % desktopHeight);

            toast.Left = desktopWorkingArea.Right - XOffset * toast.Width;
            toast.Top  = desktopWorkingArea.Bottom - YOffset * toastHeight;

            toast.Image.Source        = BitmapSourceConverter.ConvertFromImage(bitmap);
            toast.bgColour.Background = color;
            toast.Title.Text          = title;
            if (msg == null)
            {
                toast.Message.Visibility = System.Windows.Visibility.Collapsed;
            }
            else
            {
                toast.Message.Text = msg;
            }

            if (func != null)
            {
                toast.OnClickEvent += new ToastView.OnClick(func);
            }

            toast.Show();
        }
Example #6
0
        /// <summary>
        /// Creates the toast notification.
        /// </summary>
        /// <param name="result">The result.</param>
        /// <param name="isForTest">if set to <c>true</c> [is for test].</param>
        /// <param name="toastOnActivated">The toast on activated.</param>
        internal static void CreateToastNotification(BuildResult result, bool isForTest, EventHandler <EventArgs> toastOnActivated)
        {
            var toastView  = new ToastView();
            var toastModel = new ToastViewModel(toastView)
            {
                Title        = result.Name,
                MessageLine1 = isForTest ? "Running build will fail" : result.Status.ToString(),
                MessageLine2 = isForTest ? result.RunningBuildRequestedBy : result.RequestedBy,
            };

            toastView.DataContext = toastModel;

            toastView.Left = SystemParameters.FullPrimaryScreenWidth - toastView.Width - 10;
            var top = SystemParameters.FullPrimaryScreenHeight - toastView.Height;

            while (DisplayedToastViewHeights.Contains(top))
            {
                top -= toastView.Height + 10;
            }

            toastView.Top = top;
            DisplayedToastViewHeights.Add(top);

            string image = null;

            switch (result.Status)
            {
            case BuildStatus.InProgress:
                image = "inprogress_128";
                break;

            case BuildStatus.Stopped:
                image = "stop_128";
                break;

            case BuildStatus.PartiallySucceeded:
                image = "orange_128";
                break;

            case BuildStatus.Failed:
                image = "red_128";
                break;
            }

            if (isForTest)
            {
                image = "build_128";
            }

            if (image != null)
            {
                var uri = new Uri("pack://application:,,,/BuildMonitorWpf;component/Images/" + image + ".png");
                toastModel.Image = new BitmapImage(uri);
            }

            System.Media.SystemSounds.Hand.Play();
            toastView.Closing += ToastViewClosing;
            if (toastOnActivated != null)
            {
                toastView.MouseDown += (o, e) => toastOnActivated(o, e);
            }

            toastView.Show();
        }
Example #7
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            this.Title = "Menú";


            //Ocultamos el boton de tiendas registradas temporalmente
            //btnTiendas.Hidden = true;
            //btnInfo2.Hidden = true;

            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, en caso de que ya exista no hace nada.
            using (var conn = new SQLite.SQLiteConnection(_pathToDatabase))
            {
                conn.CreateTable <Person>();
            }

            //Hacemos la conexion a la bd para buscar si hay un usuario registrado
            using (var db = new SQLite.SQLiteConnection(_pathToDatabase))
            {
                people = new List <Person> (from p in db.Table <Person> () select p);
            }

            //Establecemos las imagenes de los botones
            setButtonImages();

            //Eventos para los botones de informacion
            this.btnInfo1.TouchUpInside += (sender, e) => {
                ToastView view = new ToastView("Busca productos por código de barras o nombre", 3000);
                view.SetGravity(ToastGravity.Center, 0, 0);
                view.Show();
            };

            this.btnInfo2.TouchUpInside += (sender, e) => {
                ToastView view = new ToastView("Localiza todas las tiendas registradas en FIXBUY", 3000);
                view.SetGravity(ToastGravity.Center, 0, 0);
                view.Show();
            };

            this.btnInfo3.TouchUpInside += (sender, e) => {
                ToastView view = new ToastView("Administra tus listas y los productos en ellas", 3000);
                view.SetGravity(ToastGravity.Center, 0, 0);
                view.Show();
            };

            this.btnInfo4.TouchUpInside += (sender, e) => {
                ToastView view = new ToastView("Inicia Sesion en FIXBUY para poder acceder a tus listas y más!", 3000);
                view.SetGravity(ToastGravity.Center, 0, 0);
                view.Show();
            };

            this.btnInfo5.TouchUpInside += (sender, e) => {
                ToastView view = new ToastView("Establece tu ubicación para una busqueda mas eficaz!", 3000);
                view.SetGravity(ToastGravity.Center, 0, 0);
                view.Show();
            };

            this.btnInfo6.TouchUpInside += (sender, e) => {
                ToastView view = new ToastView("Consulta los servicios que ofrece FIXBUY", 3000);
                view.SetGravity(ToastGravity.Center, 0, 0);
                view.Show();
            };

            this.btnCerrarSesion.TouchUpInside += (sender, e) => {
                UIAlertView alert = new UIAlertView()
                {
                    Title = "Te vas? =(", Message = "Estas seguro que quieres cerrar la sesión?"
                };
                alert.AddButton("Aceptar");
                alert.AddButton("Cancelar");
                alert.Clicked += (s, o) => {
                    if (o.ButtonIndex == 0)
                    {
                        using (var conn = new SQLite.SQLiteConnection(_pathToDatabase))
                        {
                            conn.DropTable <Person>();
                            conn.CreateTable <Person>();
                        }
                        this.NavigationController.PopViewController(true);
                    }
                };
                alert.Show();
            };

            //Boton de buscar productos
            this.btnScan.TouchUpInside += (sender, e) => {
                // Configurar el escaner de codigo de barras.
                picker = new ScanditSDKRotatingBarcodePicker(MainView.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();
            };

            //Boton de tiendas Registradas
            this.btnTiendas.TouchUpInside += (sender, e) => {
                this._loadPop = new LoadingOverlay(UIScreen.MainScreen.Bounds);
                this.Add(this._loadPop);
                mvp = new MapViewController();
                Task.Factory.StartNew(
                    () => {
                    System.Threading.Thread.Sleep(1 * 1000);
                }
                    ).ContinueWith(
                    t => {
                    this._loadPop.Hide();
                    this.NavigationController.PushViewController(mvp, true);
                }, TaskScheduler.FromCurrentSynchronizationContext()
                    );
            };

            //Boton Mis listas
            this.btnListas.TouchUpInside += (sender, e) => {
                if (people.Count == 1)
                {
                    MyListsView myLists = new MyListsView();
                    this.NavigationController.PushViewController(myLists, true);
                }
                else
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Espera!", Message = "Debes iniciar sesión para acceder a tus listas"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
            };

            //Boton Iniciar Sesion
            this.btnSesion.TouchUpInside += (sender, e) => {
                if (people.Count == 1)
                {
                    UIAlertView alert = new UIAlertView()
                    {
                        Title = "Espera!", Message = "Ya has iniciado sesión"
                    };
                    alert.AddButton("Aceptar");
                    alert.Show();
                }
                else
                {
                    LoginView login = new LoginView();
                    this.NavigationController.PushViewController(login, true);
                }
            };

            //Boton Novedades
            this.btnNovedades.TouchUpInside += (sender, e) => {
                StatesView statesView = new StatesView();
                this.NavigationController.PushViewController(statesView, true);
            };

            //Boton Nuestros Servicios
            this.btnServicios.TouchUpInside += (sender, e) => {
                AboutUsView aboutUS = new AboutUsView();
                this.NavigationController.PushViewController(aboutUS, true);
            };

            // creacion de la barra de herramientas
            float toolbarHeight = 44;

            toolbar = new UIToolbar(new CGRect(0
                                               , this.View.Frame.Height - this.NavigationController.NavigationBar.Frame.Height
                                               , this.View.Frame.Width, toolbarHeight));
            toolbar.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth;
            toolbar.TintColor        = UIColor.FromRGB(7, 129, 181);

            // boton acerca de
            UIBarButtonItem btnacercaDe = new UIBarButtonItem(UIBarButtonSystemItem.Bookmarks);

            btnacercaDe.Clicked += (s, e) => {
                UIAlertView alert = new UIAlertView()
                {
                    Title = "Que deseas consultar? "
                };
                alert.AddButton("Terminos y Condiciones");
                alert.AddButton("Aviso de Privacidad");
                alert.Clicked += (sen, o) => {
                    if (o.ButtonIndex == 0)
                    {
                        TermsView termsView = new TermsView();
                        NavigationController.PushViewController(termsView, true);
                    }
                    else
                    {
                        PrivacyNoticeView privacyNoticeView = new PrivacyNoticeView();
                        NavigationController.PushViewController(privacyNoticeView, true);
                    }
                };
                alert.Show();
            };
            // fixed width
            //UIBarButtonItem fixedWidth = new UIBarButtonItem (UIBarButtonSystemItem.FixedSpace);
            //fixedWidth.Width = 35;

            // flexible width space
            UIBarButtonItem flexibleWidth1 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);

            // boton fixBuy
            UIBarButtonItem btnFixBuy = new UIBarButtonItem(UIBarButtonSystemItem.Search);

            btnFixBuy.Clicked += (s, e) => {
                NSUrl url = new NSUrl(@"http://fixbuy.mx");
                UIApplication.SharedApplication.OpenUrl(url);
            };

            // flexible width space
            UIBarButtonItem flexibleWidth2 = new UIBarButtonItem(UIBarButtonSystemItem.FlexibleSpace);

            // boton email
            UIBarButtonItem btnEmail = new UIBarButtonItem(UIBarButtonSystemItem.Compose);

            btnEmail.Clicked += (s, e) => {
                //Añadimos las configuraciones para la vista de email
                mailController = new MFMailComposeViewController();
                mailController.SetToRecipients(new string[] { "*****@*****.**" });
                mailController.SetSubject("Contacto");
                mailController.SetMessageBody("", false);
                mailController.Finished += (object o, MFComposeResultEventArgs args) => {
                    Console.WriteLine(args.Result.ToString());
                    args.Controller.DismissViewController(true, null);
                };

                this.PresentViewController(mailController, true, null);
            };

            // arreglo de botones para toolbar
            UIBarButtonItem[] items = new UIBarButtonItem[] {
                btnacercaDe, flexibleWidth1, btnFixBuy, flexibleWidth2, btnEmail
            };

            // agregar los botones a la toolbar
            toolbar.SetItems(items, false);

            // agregar la vista a la pantalla
            this.View.AddSubview(toolbar);
            try{
                //Leemos el servicio de los banners
                this.bannersService = new BannersService();
                banners             = bannersService.All();
            } catch (System.Net.WebException) {
                UIAlertView alert = new UIAlertView()
                {
                    Title = "UPS :S", Message = "Hubo un error al conectarse a internet la seccion de banners no puede mostrarse, por favor verifica tu conexión a internet"
                };
                alert.AddButton("Aceptar");
                alert.Show();
            }

            button = new UIButton(new CGRect(0, 0, bannerImage.Bounds.Width, bannerImage.Bounds.Height));
            bannerImage.Add(button);
            button.TouchUpInside += (sender, e) => {
                try{
                    if (bannerError == false)
                    {
                        if (element.imagen != "")
                        {
                            NSUrl url = new NSUrl(element.link);
                            UIApplication.SharedApplication.OpenUrl(url);
                        }
                    }
                }catch (Exception) {
                    //solo atrapamos la excepcion, no hacemos nada
                }
            };
        }