protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Create your application here SetContentView(Resource.Layout.Configure); // ボタン取得 _Save = FindViewById <Button>(Resource.Id.buttonSave); _ToMain = FindViewById <Button>(Resource.Id.buttonMain); // テキストエディット取得 _EditIPAdress = FindViewById <EditText>(Resource.Id.editTextIPAdress); _EditFolderName = FindViewById <EditText>(Resource.Id.editTextFolderName); _EditUser = FindViewById <EditText>(Resource.Id.editTextUserName); _EditPassword = FindViewById <EditText>(Resource.Id.editTextPassword); _EditDomain = FindViewById <EditText>(Resource.Id.editTextDomain); // ローカルストレージインスタンス作成 DAO.LocalStorage LocalStorage = new DAO.LocalStorage(); // コンフィグファイル読み込み Entity.Configure EntityConfig = new Entity.Configure(); EntityConfig = LocalStorage.Read(); _EditIPAdress.SetText(EntityConfig.UriAdress, BufferType.Normal); _EditFolderName.SetText(EntityConfig.FolderName, BufferType.Normal); _EditUser.SetText(EntityConfig.User, BufferType.Normal); _EditPassword.SetText(EntityConfig.Password, BufferType.Normal); _EditDomain.SetText(EntityConfig.Domain, BufferType.Normal); _Save.Click += delegate { //Save_onClick(); EntityConfig.User = _EditUser.Text; EntityConfig.Password = _EditPassword.Text; EntityConfig.UriAdress = _EditIPAdress.Text; EntityConfig.FolderName = _EditFolderName.Text; EntityConfig.Domain = _EditDomain.Text; try { LocalStorage.Write(EntityConfig); Toast.MakeText(this, "設定を保存しました。", ToastLength.Short).Show(); }catch (Exception e) { Toast.MakeText(this, "エラーが発生しました。" + e, ToastLength.Short).Show(); } }; _ToMain.Click += delegate { ToMain_onClick(); }; }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // メイン画面からそれぞれのボタンを取得します。 _SpinnerUserLists = FindViewById <Spinner>(Resource.Id.spinnerUserLists); _TimeStamp = FindViewById <Button>(Resource.Id.buttonStamp); _ToggleAttendance = FindViewById <ToggleButton>(Resource.Id.toggleAttendance); _ToConfig = FindViewById <Button>(Resource.Id.buttonToConfig); // コンフィグファイルを読み取ります。 _EntityConfig = _ConfigLocalStorage.Read(); // ユーザーリスト取得インスタンスです。 try { _UserList = new DAO.CsvToUserList(_EntityConfig); // 取得したユーザーリストをユーザーセレクトボックスに設定します。 ArrayAdapter <string> adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerItem, _UserList.GetUserLists()); adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem); _SpinnerUserLists.Adapter = adapter; } catch (SmbException e) { _TimeStamp.Enabled = false; Utility.LocalIPAddress LocalIPAddress = new Utility.LocalIPAddress(); System.Collections.Generic.List <System.Net.IPAddress> localadr = LocalIPAddress.GetLocalIPAddress(); string localIP = localadr[0].ToString(); Toast.MakeText(this, localIP, ToastLength.Long).Show(); //Toast.MakeText(this, "サーバー接続エラーが発生しました。\n エラー内容:" + e, ToastLength.Long).Show(); var dlg = new AlertDialog.Builder(this); dlg.SetTitle("エラー"); dlg.SetMessage("サーバー接続エラーが発生しました。\n エラー内容:" + e.StackTrace.ToString()); dlg.SetPositiveButton( //OKボタンの処理 "OK", (s, a) => Toast.MakeText(this, "OK", ToastLength.Short).Show()); dlg.SetNegativeButton( //Cancelボタンの処理 "Cancel", (s, a) => Toast.MakeText(this, "Cancel", ToastLength.Short).Show()); dlg.Create().Show(); } // 打刻ボタンクリック時の挙動です。 _TimeStamp.Click += delegate { TimeStamp_onClick(); }; _ToConfig.Click += delegate { ToConfig_onClick(); }; }