public Dictionary <int, string> initSpinner(COMPANY_TYPE company, Spinner spinner, List <string> list) { var dictionary = SecurityWebService.getListCompanies(Configuration.securityToken, (int)company); foreach (KeyValuePair <int, string> w in dictionary) { list.Add(w.Value); } // Configuration du Spinner et de son Adapter par rapport à une liste de produit var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, list); spinner.Adapter = adapter; return(dictionary); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState, Resource.Layout.frmLogin); translateScreen(); //Obtient le chemin jusqu'au dossier "fichiers", où l'on peut écrire et lire des fichiers var documentsPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); //Si l'utilisateur a deja sauvegardé une autre URL que celle de base, alors on lit le fichier la contenant; sinon, on crée ce dernier avec une URL de base var filePath = System.IO.Path.Combine(documentsPath, "WebServiceURL.txt"); if (System.IO.File.Exists(filePath)) { Configuration.webServiceURL = System.IO.File.ReadAllText(filePath); } else { System.IO.File.WriteAllText(filePath, Configuration.webServiceURL); } //On récupère le contenu des champs EditText username = FindViewById <EditText>(Resource.Id.tfName); EditText password = FindViewById <EditText>(Resource.Id.tfPass); clearTextOnClick(FindViewById <ImageButton>(Resource.Id.imClear), username); clearTextOnClick(FindViewById <ImageButton>(Resource.Id.imClear2), password); FindViewById <RadioButton>(Resource.Id.rbFrench).Click += async(sender, e) => { Configuration.currentLanguage = CR_TTLangue.French_Canada; Recreate(); }; FindViewById <RadioButton>(Resource.Id.rbEnglish).Click += async(sender, e) => { Configuration.currentLanguage = CR_TTLangue.English; Recreate(); }; //Si l'utilisateur appuie sur le bouton connecter FindViewById <Button>(Resource.Id.btnConnect).Click += async(sender, e) => { //L'application est occupée IsBusy = true; await Task.Delay(50); //On essaye de se connecter au WebService if (SecurityWebService.doLogin(username.Text, password.Text)) { //Si la connection s'est bien passé on est envoyé vers la page d'accueil StartActivity(new Intent(this, typeof(HomeActivity))); } else { switch (Configuration.currentLanguage) { case CR_TTLangue.French_Canada: { Toast.MakeText(this, "Erreur à la connexion", ToastLength.Short).Show(); break; } case CR_TTLangue.English: { Toast.MakeText(this, "Connection error", ToastLength.Short).Show(); break; } } } //La ressource n'est plus occupée IsBusy = false; }; //Si l'utilisateur appuie sur Logout FindViewById <ImageButton>(Resource.Id.imLogout).Click += (sender, e) => { StartActivity(new Intent(this, typeof(LogoutActivity))); }; //Si l'utilisateur appuie sur Config FindViewById <ImageButton>(Resource.Id.imConfig).Click += (sender, e) => { StartActivity(new Intent(this, typeof(ConfigActivity))); }; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState, Resource.Layout.frmHome); translateScreen(); //On stocke les boutons et les transitions dans un dictionnaire Dictionary <int, Intent> buttons = new Dictionary <int, Intent>() { { Resource.Id.btnRelocation, new Intent(this, typeof(RelocationActivity)) }, { Resource.Id.btnConsolidate, new Intent(this, typeof(ConsolidationActivity)) }, { Resource.Id.btnRecieve, new Intent(this, typeof(ReceivingActivity)) }, { Resource.Id.btnPicking, new Intent(this, typeof(PickingListActivity)) }, { Resource.Id.btnInfo, new Intent(this, typeof(InformationActivity)) }, { Resource.Id.btnExit, new Intent(this, typeof(MyCeritar)) }, // {Resource.Id.btnProduction, new Intent(this, typeof(ProductionMenuActivity))} }; //{Resource.Id.btnInterWarehouse, new Intent(this, typeof(WarehouseListActivity)) } var dictionary = SecurityWebService.getListWarehouses(Configuration.securityToken); // Creation liste de nom produit pour le spinner List <string> warehouses = new List <string>(); foreach (KeyValuePair <int, string> w in dictionary) { warehouses.Add(w.Value); } // Configuration du Spinner et de son Adapter par rapport à une liste de produit spinner = FindViewById <Spinner>(Resource.Id.spnWarehouse); var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, warehouses); spinner.Adapter = adapter; foreach (KeyValuePair <int, string> w in dictionary) { if (Configuration.userInfos.warehouseNRI == w.Key) { int spinnerPosition = adapter.GetPosition(w.Value); spinner.SetSelection(spinnerPosition); } } spinner.ItemSelected += (parent, args) => { Configuration.userInfos.warehouseNRI = dictionary.FirstOrDefault(x => x.Value == warehouses[args.Position]).Key; }; //Pour chaque bouton on créer un évènement avec l'intention correspondante foreach (KeyValuePair <int, Intent> entry in buttons) { FindViewById <Button>(entry.Key).Click += async(sender, e) => { IsBusy = true; await Task.Delay(50); StartActivity(entry.Value); IsBusy = false; }; } }