public FindBleViewModel (INavigation navigation, bool selMeuSkey) { fim = false; this.selMeuSkey = selMeuSkey; App.gateSkey = null; //sKey selecionada se for scan para gateDevice keySelecionada = null; //resultado da acao de click em item da lista de sKeys encontrados if (selMeuSkey || App.gateSkeys == null) devices = new ObservableCollection<BleDevice> (); else devices = new ObservableCollection<BleDevice> (App.gateSkeys); //Skeys do ultimo scan if (selMeuSkey && MySafetyDll.MySafety.isScanning) ((App)Application.Current).mysafetyDll.cancelScan (); ((App)Application.Current).mysafetyDll.Scan += mysafetyDll_Scan; _navigation = navigation; FindCommand = new Command ((key) => { findBleButton = (Button)key; scanSkeys (); }); // if (devices.Count () == 0) scanSkeys (); }
public SignatureImageViewModel() { _sigService = DependencyService.Get<ISignatureService> (); SignatureCommand = new Command(async (obj) => { Debug.WriteLine("Signature pad requested..."); var result = await _sigService.Request(new SignaturePadConfiguration() { StrokeColor = Color.Blue, StrokeWidth = Device.OnPlatform<int>(2, 4, 4), ClearTextColor = Color.Red, PromptTextColor = Color.Red, SignatureLineColor = Color.Red, CaptionText = "Rotate for larger signing area", CaptionTextColor = Color.Black }); if (result.Cancelled) await UserDialogs.Instance.AlertAsync("Signature Cancelled"); else { using (var sigStream = result.GetStream()) { sigStream.Position = 0; var ms = new MemoryStream(); sigStream.CopyTo(ms); byte[] sigBytes = ms.ToArray(); SignatureImage = sigBytes; } } }); }
public CalculatorVewModel() { _calculateLogic = new CalculateLogicService(); ChooseDigitCommand = new Command<string>(OnDigitChosen()); ChooseSymbolCommand = new Command<string>(OnSymbolChosen()); ChooseEqualCommand = new Command<string>(OnEqualsChosen()); ChooseCancelCommand = new Command<string>(OnCancelChosen()); }
public MainViewModel() { IsBusy = false; ConnectCommand = new Command ( async(nothing) => { Status = "Connecting..."; IsBusy = true; await Task.Delay(3000).ContinueWith(async(t) => { Device.BeginInvokeOnMainThread(() => { IsBusy = false; Status = "Connected";}); }); }, (nothing) => { return !IsBusy; }); }
// Repository<Mysafety_user> mySafetyUserRepository; // LogInViewModel login; public SignInViewModel(INavigation navigation, LogInViewModel login) { // this.login = login; enviarEnabled = true; _navigation = navigation; // mySafetyUserRepository = new Repository<Mysafety_user>(); SignInCommand = new Command (async (key) => { enviarEnabled = false; notificator.HideAll (); try { Console.WriteLine (" **Entrando em SignInCommand"); if (!Settings.email.Equals (email) || !Settings.password.Equals (password)) { login.cadastroEcommerce = string.Empty; login.comLicenca = false; login.userMySafetyExistente = false; } Settings.cadastrando = false; Settings.nome = nome; Settings.email = email; Settings.password = password; Settings.confirmaSenha = confirmaSenha; mensagem = testeDadosCadastro (); if (mensagem.Length > 0) { await notificator.Notify (ToastNotificationType.Error, "MySafety", mensagem, TimeSpan.FromSeconds (3)); return; } var x = await login.consultaTodosCadastros (false); if (x.Equals (false)) //Erro na consulta... return; if (login.cadastroEcommerce == "S4" || login.userMySafetyExistente) { var answer = await UserDialogs.Instance.ConfirmAsync ("Conta MySafety já existe\nFazer Login?", null, "Sim", "Não"); if (answer) { login.cadastroEcommerce = string.Empty; //forca nova consulta para conferir senha digitada ((App)Application.Current).MainPage = new NavigationPage (new LogInView (new LogInViewModel (_navigation))); } return; } Settings.cadastrando = true; /* *S0 – Usuário não consta no banco de dados do ecommerce *S1 – Usuário AINDA NÃO COMPLETOU O CADASTRO, PAROU NA TELA DO APLICATIVO *S2 – Usuário ESCOLHEU UM PLANO, MAS AINDA NÃO VERIFICOU O SEU EMAIL *S3 - Usuário ESCOLHEU O PLANO E JÁ VERIFICOU O SEU EMAIL *S4 - Usuário já cadastrado e senha nao confere com digitacao *S5 - Usuário já cadastrado e senha confere com digitacao */ if (login.cadastroEcommerce == "S0" || login.cadastroEcommerce == "S1") { var answer = await UserDialogs.Instance.ConfirmAsync ("Deseja fazer opcao de uso?\nReceberá um e-mail com o link para confirmar", null, "Ok", "Cancelar"); if (answer) login.linkCadastroEcommerce (true); //Joga usuario para o site Ecommerce } else if (login.cadastroEcommerce == "S2") { var answer = await UserDialogs.Instance.ConfirmAsync ("Acesse seu email e click no link de confirmação", null, "Ok", "Receber novo e-mail"); if (!answer) login.linkCadastroEcommerce (false); //Apenas faz site enviar novo email } else if (login.cadastroEcommerce == "S4") { await UserDialogs.Instance.AlertAsync ("Cadastro existente\nFaça login", null, "Ok"); } else if (login.cadastroEcommerce == "S3") login.loginUserMySafety ();//Cria o usuario } catch (Exception ex) { Console.WriteLine (" **Exception Erro 2:" + ex); enviarEnabled = true; await UserDialogs.Instance.AlertAsync ("Erro 2 ao criar conta\nTente mais tarde", null, "Ok"); } }); }
public GerenciarPortoesViewModel (INavigation navigation) { Navigation = navigation; Gates = App.Gates; gateUsers = null; #pragma warning disable CS4014 ((App)Application.Current).renovaMeusPortoes ().Wait (); if (SelectedGate != null) { //Sempre precisa tentar recompor tabela local, pois dados dos usuarios podem ter sido alterados // try // { // tableDevices.SyncAsync ("GD" + SelectedGate.Id, tableDevices.table.Where (gs => gs.GateLicId == SelectedGate.Id), true); // } // catch (Exception ex) // { // Console.WriteLine("Exception tableDevices.SyncAsync:" + ex.Message); // } // Monta lista de todos os usuarios do portao selecionado. gateUsers = new ObservableCollection<GateDevices> (tableDevices.GetAllAsync (). Result.Where (gs => gs.GateLicId == SelectedGate.Id).OrderBy (ho => ho.labelName)); } #pragma warning restore CS4014 Gates = App.Gates; if (gateUsers != null && gateUsers.Count () > 0) { App.gateSkeys = new ObservableCollection<BleDevice> (); foreach (var user in gateUsers) { //Skeys ja inseridos nao devem ser selecionados no Find if (!string.IsNullOrEmpty (user.SkeyBleId) && !user.SkeyBleId.Equals ("00:00:00:00:00:00")) { BleDevice naLista = new BleDevice (user.SkeyBleId, user.SKeyName); naLista.selecionado = true; //impede poder ser selecionado App.gateSkeys.Add (naLista); } if (!string.IsNullOrEmpty (user.Email)) { string Activationcode = MySafetyDll.MySafety.calculateAccessCode (SelectedGate.BleId, user.PhoneBleId, ((App)Application.Current).mysafetyDll.localBleAddress); if (!Activationcode.Equals (user.Code)) { user.Code = Activationcode; #pragma warning disable CS4014 tableDevices.UpdateAsync (user).Wait (); #pragma warning restore C } } } } GateOptionsCommand = new Command(async (key) => { await transferGateLicense(); }); //_hubProxy.On<string>("refreshGateRequests", async msg => //{ // string tst = msg; // msg += ""; //}); }