private void ButtonTaskOnClick(object sender, System.EventArgs e)
        {
            LayoutInflater layoutInflater = LayoutInflater.From(this);
            View           promptView     = layoutInflater.Inflate(Resource.Layout.taakLayout, null);

            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
            alertDialogBuilder.SetView(promptView);

            EditText titel        = (EditText)promptView.FindViewById(Resource.Id.edittextTitel);
            EditText omschrijving = (EditText)promptView.FindViewById(Resource.Id.edittextOmschrijving);
            EditText plaats       = (EditText)promptView.FindViewById(Resource.Id.edittextPlaats);

            TimePicker begin = (TimePicker)promptView.FindViewById(Resource.Id.timePickerBegin);

            begin.SetIs24HourView(Java.Lang.Boolean.True);
            TimePicker einde = (TimePicker)promptView.FindViewById(Resource.Id.timePickerEind);

            einde.SetIs24HourView(Java.Lang.Boolean.True);
            int      uurBegin = 0, minutenBegin = 0;
            int      uurEinde, minutenEinde = 0;
            TimeSpan beginuur, einduur;

            alertDialogBuilder.SetTitle("Taak toevoegen");
            alertDialogBuilder.SetPositiveButton("OK", (senderAlert, args) =>
            {
                begin.ClearFocus();
                einde.ClearFocus();
                uurBegin     = Convert.ToInt32(begin.CurrentHour);
                minutenBegin = Convert.ToInt32(begin.CurrentMinute);
                uurEinde     = Convert.ToInt32(einde.CurrentHour);
                minutenEinde = Convert.ToInt32(einde.CurrentMinute);
                beginuur     = new TimeSpan(uurBegin, minutenBegin, 0);
                einduur      = new TimeSpan(uurEinde, minutenEinde, 0);
                // calendar.addTaak(titel.Text, omschrijving.Text, plaats.Text, beginuur, einduur);
                database.addToTable(datum, titel.Text, plaats.Text, omschrijving.Text, beginuur, einduur);
                ListView taskList    = FindViewById <ListView>(Resource.Id.listView1);
                List <string> taken  = database.getFromTable(datum);
                ArrayAdapter adapter = new ArrayAdapter <String>(this, Resource.Layout.TextViewItem, taken);
                taskList.Adapter     = adapter;
            });
            alertDialogBuilder.SetNegativeButton("Annuleer", (senderAlert, args) =>
            {
            });
            AlertDialog alert = alertDialogBuilder.Create();


            alert.Show();



            alert.GetButton((int)DialogButtonType.Positive).Enabled = false;
            titel.TextChanged += (object sendere, Android.Text.TextChangedEventArgs tekst) =>
            {
                if (tekst.Text.ToString() == "")
                {
                    alert.GetButton((int)DialogButtonType.Positive).Enabled = false;
                }
                else
                {
                    alert.GetButton((int)DialogButtonType.Positive).Enabled = true;
                }
            };
        }
            public override View GetView(int position, View convertView, ViewGroup parent)
            {
                try
                {
                    convertView = LayoutInflater.From(context).Inflate(Resource.Layout.overview, parent, false);

                    //  convertView.FindViewById<TextView>(Resource.Id.ovt1).Typeface = typeface;
                    //  convertView.FindViewById<TextView>(Resource.Id.ovt1b).Typeface = typeface;
                    convertView.FindViewById <TextView>(Resource.Id.ovt2).Typeface = typeface;
                    convertView.FindViewById <TextView>(Resource.Id.ovt3).Typeface = typeface;

                    if (action == "overview" && filtered != null)
                    {
                        TextView tv1 = convertView.FindViewById <TextView>(Resource.Id.ovt1);
                        tv1.Text = filtered[position].Currency;
                        convertView.FindViewById <TextView>(Resource.Id.ovt2).Text        = filtered[position].Balance;
                        convertView.FindViewById <TextView>(Resource.Id.ovt3).Text        = filtered[position].USD;
                        convertView.FindViewById <TextView>(Resource.Id.ovt1b).Visibility = ViewStates.Gone;
                        convertView.FindViewById <TextView>(Resource.Id.ovt2).Visibility  = ViewStates.Visible;
                        convertView.FindViewById <TextView>(Resource.Id.ovt3).Visibility  = ViewStates.Visible;

                        if (position == 0)
                        {
                            //              convertView.FindViewById<TextView>(Resource.Id.ovt1b).SetTextColor(new Color(Resource.Color.black_overlay));
                            convertView.FindViewById <TextView>(Resource.Id.ovt1b).Text = "[refresh]";
                            convertView.FindViewById <TextView>(Resource.Id.ovt1b).SetTypeface(Typeface.Monospace, TypefaceStyle.Italic);
                            convertView.FindViewById <TextView>(Resource.Id.ovt1b).SetTextSize(Android.Util.ComplexUnitType.Sp, 13);
                            convertView.FindViewById <TextView>(Resource.Id.ovt1b).Visibility = ViewStates.Visible;
                            convertView.FindViewById <TextView>(Resource.Id.ovt3).Visibility  = ViewStates.Gone;
                            convertView.FindViewById <TextView>(Resource.Id.ovt2).Visibility  = ViewStates.Gone;
                        }

                        convertView.FindViewById <TextView>(Resource.Id.ovt1b).Click += delegate {
                            if (position == 0)
                            {
                                convertView.FindViewById <TextView>(Resource.Id.ovt1b).Enabled = false;
                                convertView.FindViewById <TextView>(Resource.Id.ovt1).Enabled  = false;
                                activity.Recreate();
                            }
                        };

                        convertView.FindViewById <TextView>(Resource.Id.ovt1).Click += delegate {
                            if (position == 0)
                            {
                                convertView.FindViewById <TextView>(Resource.Id.ovt1b).Enabled = false;
                                convertView.FindViewById <TextView>(Resource.Id.ovt1).Enabled  = false;
                                activity.Recreate();
                            }
                        };
                    }

                    if (action == "accounts" && NWSfiltered != null)
                    {
                        TextView tv1 = convertView.FindViewById <TextView>(Resource.Id.ovt1);
                        tv1.Visibility = ViewStates.Gone;
                        convertView.FindViewById <TextView>(Resource.Id.ovt2).Text = NWSfiltered[position].BlkNet.ToUpper();
                        convertView.FindViewById <TextView>(Resource.Id.ovt3).Text = NWSfiltered[position].BTCAddress;
                        convertView.FindViewById <TextView>(Resource.Id.ovt2).SetTextSize(Android.Util.ComplexUnitType.Sp, 16);
                        convertView.FindViewById <TextView>(Resource.Id.ovt3).SetTextSize(Android.Util.ComplexUnitType.Sp, 13);

                        if (position == 0)
                        {
                            //  convertView.FindViewById<TextView>(Resource.Id.ovt1b).SetTextColor(new Color(Resource.Color.black_overlay));
                            convertView.FindViewById <TextView>(Resource.Id.ovt1b).Text = "[balances]";
                            convertView.FindViewById <TextView>(Resource.Id.ovt1b).SetTypeface(Typeface.Monospace, TypefaceStyle.Italic);
                            convertView.FindViewById <TextView>(Resource.Id.ovt1b).SetTextSize(Android.Util.ComplexUnitType.Sp, 12);
                            convertView.FindViewById <TextView>(Resource.Id.ovt1b).Visibility = ViewStates.Visible;
                            convertView.FindViewById <TextView>(Resource.Id.ovt3).Visibility  = ViewStates.Gone;
                            convertView.FindViewById <TextView>(Resource.Id.ovt2).Visibility  = ViewStates.Gone;
                            tv1.Visibility = ViewStates.Visible;
                            tv1.Text       = NWSfiltered[position].ViewKey;
                        }
                        convertView.FindViewById <TextView>(Resource.Id.ovt1b).Click += delegate {
                            if (position == 0)
                            {
                                action = "overview";
                                activity.Recreate();
                            }
                        };

                        convertView.FindViewById(Resource.Id.ovinf).Click += delegate {
                            if (position > 0)
                            {
                                ImageView image = new ImageView(context);
                                image.SetImageBitmap(ConvertQr(NWSfiltered[position].BTCAddress, NWSfiltered[position].BlkNet));

                                AlertDialog.Builder builder = new AlertDialog.Builder(context).SetTitle(NWSfiltered[position].BlkNet.ToUpper()).SetMessage(NWSfiltered[position].BTCAddress).SetCancelable(true).SetPositiveButton("CLOSE", (EventHandler <DialogClickEventArgs>)null);
                                AlertDialog         alert   = builder.Create();
                                alert.SetView(image);
                                alert.Show();

                                var okBtn = alert.GetButton((int)DialogButtonType.Positive);

                                okBtn.Click += (asender, args) =>
                                {
                                    alert.Dismiss();
                                };
                            }
                        };
                    }
                }
                catch (Exception)
                {
                }
                return(convertView);
            }
        private void EditTask(int index, String titel, String omschrijving, String plaats, TimeSpan beginUur, TimeSpan eindUur)
        {
            int            item           = database.getId(index);
            LayoutInflater layoutInflater = LayoutInflater.From(this);
            View           promptView     = layoutInflater.Inflate(Resource.Layout.taakLayout, null);

            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
            alertDialogBuilder.SetView(promptView);
            alertDialogBuilder.SetTitle("Wijzigen van de taak");

            EditText toonTitel        = (EditText)promptView.FindViewById(Resource.Id.edittextTitel);
            EditText toonOmschrijving = (EditText)promptView.FindViewById(Resource.Id.edittextOmschrijving);
            EditText toonPlaats       = (EditText)promptView.FindViewById(Resource.Id.edittextPlaats);

            TimePicker toonBegin = (TimePicker)promptView.FindViewById(Resource.Id.timePickerBegin);

            toonBegin.SetIs24HourView(Java.Lang.Boolean.True);
            TimePicker toonEinde = (TimePicker)promptView.FindViewById(Resource.Id.timePickerEind);

            toonEinde.SetIs24HourView(Java.Lang.Boolean.True);

            toonTitel.Text        = titel;
            toonOmschrijving.Text = omschrijving;
            toonPlaats.Text       = plaats;

            toonBegin.CurrentHour   = (Java.Lang.Integer)(beginUur.Hours);
            toonBegin.CurrentMinute = (Java.Lang.Integer)(beginUur.Minutes);

            toonEinde.CurrentHour   = (Java.Lang.Integer)(eindUur.Hours);
            toonEinde.CurrentMinute = (Java.Lang.Integer)(eindUur.Minutes);


            alertDialogBuilder.SetPositiveButton("Opslaan", (senderAlert, args) =>
            {
                toonBegin.ClearFocus();
                toonEinde.ClearFocus();
                TimeSpan beginuur = new TimeSpan(Convert.ToInt32(toonBegin.CurrentHour), Convert.ToInt32(toonBegin.CurrentMinute), 0);
                TimeSpan einduur  = new TimeSpan(Convert.ToInt32(toonEinde.CurrentHour), Convert.ToInt32(toonEinde.CurrentMinute), 0);
                database.ChangeToTable(item, datum, toonTitel.Text, toonPlaats.Text, toonOmschrijving.Text, beginuur, einduur);
                ListView taskList    = FindViewById <ListView>(Resource.Id.listView1);
                List <string> taken  = database.getFromTable(datum);
                ArrayAdapter adapter = new ArrayAdapter <String>(this, Resource.Layout.TextViewItem, taken);
                taskList.Adapter     = adapter;
            });

            alertDialogBuilder.SetNegativeButton("Annuleren", (senderAlert, args) =>
            {
            });

            AlertDialog alert = alertDialogBuilder.Create();

            alert.Show();
            toonTitel.TextChanged += (object sendere, Android.Text.TextChangedEventArgs tekst) =>
            {
                if (tekst.Text.ToString() == "")
                {
                    alert.GetButton((int)DialogButtonType.Positive).Enabled = false;
                }
                else
                {
                    alert.GetButton((int)DialogButtonType.Positive).Enabled = true;
                }
            };
        }
        void listView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            Object listObj = _msgAdapter[e.Position];

            if (listObj is RpcLogMessage)
            {
                LayoutInflater requestJSON = (LayoutInflater)this.Activity.GetSystemService(Context.LayoutInflaterService);
                View           jsonLayout  = requestJSON.Inflate(Resource.Layout.consolelogpreview, null);
                EditText       jsonText    = (EditText)jsonLayout.FindViewById(Resource.Id.consoleLogPreview_jsonContent);

                RpcMessage          message = ((RpcLogMessage)listObj).getMessage();
                AlertDialog.Builder builder = new AlertDialog.Builder(this.Activity);

                string rawJSON    = "";
                int    corrId     = -1;
                string methodName = "";

                jsonText.Focusable = false;

                if (message is RpcRequest)
                {
                    corrId     = ((RpcRequest)message).getId();
                    methodName = ((RpcRequest)message).method;
                }
                else if (message is RpcResponse)
                {
                    corrId     = ((RpcResponse)message).getId();
                    methodName = ((HmiApiLib.Base.Result)((RpcResponse)message).result).method;
                }
                else if (message is RpcNotification)
                {
                    methodName = ((RpcNotification)message).method;
                }
                else if (message is RequestNotifyMessage)
                {
                    methodName = ((RequestNotifyMessage)message).method;
                }

                try
                {
                    rawJSON = JsonConvert.SerializeObject(message, Formatting.Indented);
                    builder.SetTitle("Raw JSON" + (corrId != -1 ? " (Corr ID " + corrId + ")" : ""));
                }
                catch (Exception ex)
                {
                    try
                    {
                        rawJSON = methodName +
                                  " (" + message.getRpcMessageFlow().ToString().ToLower() + " " + message.getRpcMessageType().ToString().ToLower() + ")";
                    }
                    catch (Exception e1)
                    {
                        rawJSON = "Undefined";
                    }
                }

                string finalJSON = rawJSON;

                jsonText.Text = finalJSON;

                builder.SetView(jsonLayout);

                builder.SetPositiveButton("Getters", (senderAlert, args) =>
                {
                    string sInfo = RpcMessageGetterInfo.viewDetails(message, false, 0);
                    Boolean isRpcResendAllowed = false;

                    if (message.rpcMessageFlow == HmiApiLib.Common.Enums.RpcMessageFlow.OUTGOING)
                    {
                        isRpcResendAllowed = true;
                    }

                    showDialogWithBack("GetterInfo", sInfo, isRpcResendAllowed, builder, jsonLayout);
                });

                builder.SetNeutralButton("Resend", (senderAlert, args) =>
                {
                    AppInstanceManager.Instance.sendRpc(message);
                });

                builder.SetNegativeButton("Cancel", (senderAlert, args) =>
                {
                    builder.Dispose();
                });

                AlertDialog ad = builder.Create();
                ad.Show();

                Button resendRpc = ad.GetButton((int)DialogButtonType.Neutral);
                if (message.rpcMessageFlow == HmiApiLib.Common.Enums.RpcMessageFlow.OUTGOING)
                {
                    resendRpc.Enabled = true;
                }
                else
                {
                    resendRpc.Enabled = false;
                }
            }
            else if (listObj is StringLogMessage)
            {
                AlertDialog.Builder builder = new AlertDialog.Builder(this.Activity);
                string sMessageText         = ((StringLogMessage)listObj).getData();
                if (sMessageText == "")
                {
                    sMessageText = ((StringLogMessage)listObj).getMessage();
                }
                builder.SetMessage(sMessageText);
                builder.SetPositiveButton("OK", (senderAlert, args) =>
                {
                    builder.Dispose();
                });
                AlertDialog ad = builder.Create();
                ad.Show();
            }
        }
        private void ProfilePopup()
        {
            var menu = new PopupMenu(this, search);

            menu.Inflate(Resource.Menu.Popup);
            int count = 0;

            foreach (Profiel p in _appController.DistinctProfielen)
            {
                menu.Menu.Add(0, count, count, p.name);
                count++;
            }

            menu.Menu.Add(0, count, count, "Nieuw profiel");

            menu.MenuItemClick += (s1, arg1) => {
                if (arg1.Item.ItemId == count)
                {
                    var alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Nieuw profiel");
                    var input = new EditText(this);
                    input.InputType = InputTypes.TextFlagCapWords;
                    input.Hint      = "Naam";
                    KeyboardHelper.ShowKeyboard(this, input);
                    alert.SetView(input);
                    alert.SetPositiveButton("Ok", (s, args) => {
                        string value = input.Text;
                        if (value.Replace("'", "").Replace(" ", "").Equals(""))
                        {
                            mToastShort.SetText("Ongeldige naam");
                            mToastShort.Show();
                        }
                        else if (_appController.GetProfielNamen().Contains(value))
                        {
                            input.Text = "";
                            mToastShort.SetText("Profiel " + value + " bestaat al");
                            mToastShort.Show();
                        }
                        else
                        {
                            _appController.AddProfile(value);
                            _appController.AddOrUpdateEigenschappenSer(value, JsonSerializer.SerializeToString(_appController.Eigenschappen));
                            mToastShort.SetText("Selectie opgeslagen voor profiel " + value);
                            mToastShort.Show();
                        }
                    });

                    AlertDialog d1 = alert.Create();

                    //add profile when enter is clicked
                    input.EditorAction += (s2, e) => {
                        if (e.ActionId == ImeAction.Done)
                        {
                            d1.GetButton(-1).PerformClick();
                        }
                        else
                        {
                            e.Handled = false;
                        }
                    };

                    RunOnUiThread(d1.Show);
                }
                else
                {
                    _appController.AddOrUpdateEigenschappenSer(arg1.Item.TitleFormatted.ToString(), JsonSerializer.SerializeToString(_appController.Eigenschappen));
                    mToastShort.SetText("Selectie opgeslagen voor profiel " + arg1.Item.TitleFormatted);
                    mToastShort.Show();
                }
            };

            menu.Show();
        }
Exemple #6
0
 void handllerNotingButton(object sender, DialogClickEventArgs e)
 {
     AlertDialog objAlertDialog = sender as AlertDialog;
     Button      btnClicked     = objAlertDialog.GetButton(e.Which);
     // Toast.MakeText(this, "you clicked on " + btnClicked.Text, ToastLength.Long).Show();
 }
 private void okButton_Handle(object sender, DialogClickEventArgs e)
 {
     AlertDialog objAlertDialog = sender as AlertDialog;
     Button      btnClicked     = objAlertDialog.GetButton(e.Which);
 }
        private void ButtonTaskOnClick(object sender, System.EventArgs e)
        {
            LayoutInflater layoutInflater = LayoutInflater.From(this);
            View           promptView     = layoutInflater.Inflate(Resource.Layout.taakLayout, null);

            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
            alertDialogBuilder.SetView(promptView);

            EditText titel        = (EditText)promptView.FindViewById(Resource.Id.edittextTitel);
            EditText omschrijving = (EditText)promptView.FindViewById(Resource.Id.edittextOmschrijving);
            EditText plaats       = (EditText)promptView.FindViewById(Resource.Id.edittextPlaats);

            TimePicker begin = (TimePicker)promptView.FindViewById(Resource.Id.timePickerBegin);

            begin.SetIs24HourView(Java.Lang.Boolean.True);
            TimePicker einde = (TimePicker)promptView.FindViewById(Resource.Id.timePickerEind);

            einde.SetIs24HourView(Java.Lang.Boolean.True);
            int      uurBegin = 0, minutenBegin = 0;
            int      uurEinde, minutenEinde = 0;
            TimeSpan beginuur, einduur;

            alertDialogBuilder.SetTitle("Taak toevoegen");
            alertDialogBuilder.SetPositiveButton("OK", (senderAlert, args) =>
            {
                begin.ClearFocus();
                einde.ClearFocus();
                uurBegin     = Convert.ToInt32(begin.CurrentHour);
                minutenBegin = Convert.ToInt32(begin.CurrentMinute);
                uurEinde     = Convert.ToInt32(einde.CurrentHour);
                minutenEinde = Convert.ToInt32(einde.CurrentMinute);
                beginuur     = new TimeSpan(uurBegin, minutenBegin, 0);
                einduur      = new TimeSpan(uurEinde, minutenEinde, 0);
                // calendar.addTaak(titel.Text, omschrijving.Text, plaats.Text, beginuur, einduur);

                /* string taak = " " + titel.Text + " " + omschrijving.Text + " " + plaats.Text + " " + "van: " + beginuur + " " + "tot: " + einduur;
                 * myItems[uurBegin] = myItems[uurBegin] + taak;*/
                database.addToTable(datum, titel.Text, plaats.Text, omschrijving.Text, beginuur, einduur);
                myItems = ResetAndFillUpList(myItems);
                taken   = database.getFromTable(datum);
                int i   = 0;
                foreach (string item in taken)
                {
                    int index      = Convert.ToInt32(database.getBeginuren(i).Hours);
                    myItems[index] = item;
                    i++;
                }
                ArrayAdapter <string> adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, myItems);
                myListView.Adapter            = adapter;
            });
            alertDialogBuilder.SetNegativeButton("Annuleer", (senderAlert, args) =>
            {
            });
            AlertDialog alert = alertDialogBuilder.Create();


            alert.Show();



            alert.GetButton((int)DialogButtonType.Positive).Enabled = false;
            titel.TextChanged += (object sendere, Android.Text.TextChangedEventArgs tekst) =>
            {
                if (tekst.Text.ToString() == "")
                {
                    alert.GetButton((int)DialogButtonType.Positive).Enabled = false;
                }
                else
                {
                    alert.GetButton((int)DialogButtonType.Positive).Enabled = true;
                }
            };
        }
Exemple #9
0
 private static void ShowDialog()
 {
     if (appInfo.data.dialog_style == 0 || appInfo.data.dialog_style == 1)
     {
         RelativeLayout relativeLayout = new RelativeLayout(Base);
         relativeLayout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
         EditText Card = new EditText(Base);
         Card.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
         relativeLayout.SetPadding(30, 0, 30, 0);
         relativeLayout.AddView(Card);
         if (appInfo.data.dialog_style == 1)
         {
             Card.SetTextColor(Color.White);
         }
         auth = new AlertDialog.Builder(Base, appInfo.data.dialog_style == 0 ? 5 : 4)
                .SetTitle(appInfo.data.title)
                .SetMessage(appInfo.data.notice)
                .SetCancelable(false)
                .SetView(relativeLayout)
                .SetNegativeButton(string.IsNullOrEmpty(appInfo.data.weburl) ? "取消" : "购卡", delegate { })
                .SetPositiveButton("验证", delegate { })
                .SetNeutralButton(appInfo.data.try_count > 0 ? "试用" : "查码", delegate { })
                .Show();
         auth.GetButton((int)DialogButtonType.Positive).Click += delegate
         {
             string card = Card.Text.Trim();
             if (string.Empty == card)
             {
                 return;
             }
             if (string.Empty == mac.GetMac())
             {
                 new AlertDialog.Builder(Base)
                 .SetTitle("请确认你的权限是否打开")
                 .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助")
                 .SetPositiveButton("去开启", (s, e) =>
                 {
                     Intent intent       = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
                     Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null);
                     intent.SetData(uri);
                     Base.StartActivity(intent);
                 })
                 .Show();
                 return;
             }
             Loading.Show(Base);
             mCard = card;
             HttpApi.loginAsync(mResult, card, mac.GetMac());
         };
         auth.GetButton((int)DialogButtonType.Negative).Click += delegate
         {
             if (string.IsNullOrEmpty(appInfo.data.weburl))
             {
                 System.Environment.Exit(0);
             }
             else
             {
                 if (appInfo.data.weburl.StartsWith("https://www.kuaifaka.com/purchasing?link="))
                 {
                     Loading.Show(Base);
                     HttpApi.GetPage_data(mResult, appInfo.data.weburl);
                 }
                 else
                 {
                     Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.weburl));
                     Base.StartActivity(browserIntent);
                 }
             }
         };
         auth.GetButton((int)DialogButtonType.Neutral).Click += delegate
         {
             if (appInfo.data.try_count > 0)
             {
                 if (string.Empty == mac.GetMac())
                 {
                     new AlertDialog.Builder(Base)
                     .SetTitle("请确认你的权限是否打开")
                     .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助")
                     .SetPositiveButton("去开启", (s, e) =>
                     {
                         Intent intent       = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
                         Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null);
                         intent.SetData(uri);
                         Base.StartActivity(intent);
                     })
                     .Show();
                     return;
                 }
                 Loading.Show(Base);
                 HttpApi.trialAsync(mResult, mac.GetMac());
             }
             else
             {
                 string card = Card.Text.Trim();
                 if (string.Empty == card)
                 {
                     return;
                 }
                 HttpApi.QueryAsync(mResult, card);
             }
         };
     }
     else if (appInfo.data.dialog_style == 2)
     {
         RelativeLayout relativeLayout = new RelativeLayout(Base);
         view = LayoutInflater.From(Base).Inflate(Base.Assets.OpenXmlResourceParser("res/layout/xamarin_auth.xml"), relativeLayout);
         CardView cardView = (CardView)view.FindViewWithTag("cardview");
         cardView.Radius               = 45;
         cardView.Elevation            = 1;
         cardView.PreventCornerOverlap = false;
         RoundImageView v = (RoundImageView)view.FindViewWithTag("image");
         v.SetImageBitmap(BitmapFactory.DecodeStream(Base.Assets.Open("bj.png")));
         auth = new AlertDialog.Builder(Base, 4)
                .SetView(relativeLayout)
                .SetCancelable(false)
                .Show();
         auth.Window.SetBackgroundDrawableResource(Android.Resource.Color.Transparent);
         EditText Card = (EditText)view.FindViewWithTag("et");
         ((TextView)view.FindViewWithTag("title")).SetText(appInfo.data.title, BufferType.Normal);
         ((TextView)view.FindViewWithTag("msg")).SetText(appInfo.data.notice, BufferType.Normal);
         if (string.Empty != appInfo.data.weburl)
         {
             ((Button)view.FindViewWithTag("bt2")).Visibility = ViewStates.Visible;
         }
         if (appInfo.data.try_count > 0)
         {
             ((Button)view.FindViewWithTag("bt1")).SetText("试用", BufferType.Normal);
         }
         else
         {
             ((Button)view.FindViewWithTag("bt1")).SetText("查码", BufferType.Normal);
         }
         view.FindViewWithTag("bt1").Click += delegate
         {
             if (appInfo.data.try_count > 0)
             {
                 if (string.Empty == mac.GetMac())
                 {
                     new AlertDialog.Builder(Base)
                     .SetTitle("请确认你的权限是否打开")
                     .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助")
                     .SetPositiveButton("去开启", (s, e) =>
                     {
                         Intent intent       = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
                         Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null);
                         intent.SetData(uri);
                         Base.StartActivity(intent);
                     })
                     .Show();
                     return;
                 }
                 Loading.Show(Base);
                 HttpApi.trialAsync(mResult, mac.GetMac());
             }
             else
             {
                 string card = Card.Text.Trim();
                 if (string.Empty == card)
                 {
                     return;
                 }
                 HttpApi.QueryAsync(mResult, card);
             }
         };
         view.FindViewWithTag("bt2").Click += delegate
         {
             if (appInfo.data.weburl.StartsWith("https://www.kuaifaka.com/purchasing?link="))
             {
                 Loading.Show(Base);
                 HttpApi.GetPage_data(mResult, appInfo.data.weburl);
             }
             else
             {
                 Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.weburl));
                 Base.StartActivity(browserIntent);
             }
         };
         view.FindViewWithTag("bt3").Click += delegate
         {
             string card = Card.Text.Trim();
             if (string.Empty == card)
             {
                 return;
             }
             if (string.Empty == mac.GetMac())
             {
                 new AlertDialog.Builder(Base)
                 .SetTitle("请确认你的权限是否打开")
                 .SetMessage("请在权限管理里(找到" + Base.PackageManager.GetApplicationLabel(Base.PackageManager.GetApplicationInfo(Base.PackageName, 0)) + ")打开-读取手机信息权限,如果依旧没有解决请联系客服进行协助")
                 .SetPositiveButton("去开启", (s, e) =>
                 {
                     Intent intent       = new Intent("android.settings.APPLICATION_DETAILS_SETTINGS");
                     Android.Net.Uri uri = Android.Net.Uri.FromParts("package", Base.PackageName, null);
                     intent.SetData(uri);
                     Base.StartActivity(intent);
                 })
                 .Show();
                 return;
             }
             Loading.Show(Base);
             mCard = card;
             HttpApi.loginAsync(mResult, card, mac.GetMac());
         };
     }
     if (appInfo.data.version > Convert.ToInt32(Properties.GetProperty("Ver")))
     {
         new AlertDialog.Builder(Base)
         .SetTitle(appInfo.data.title)
         .SetMessage(appInfo.data.update_msg)
         .SetCancelable(appInfo.data.updatemode == 0 ? false : true)
         .SetPositiveButton("更新", (s, e) =>
         {
             Intent browserIntent = new Intent(Intent.ActionDefault, Android.Net.Uri.Parse(appInfo.data.update_url));
             Base.StartActivity(browserIntent);
         }).Show();
     }
 }
        private static void UpdateEnabledChanged(AlertDialog alertDialog, DialogButtonType dialogButtonType, bool isEnabled)
        {
            var button = alertDialog.GetButton((int)dialogButtonType);

            button.Enabled = isEnabled;
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.NewUserRegistration);

            EditText username       = FindViewById <EditText>(Resource.Id.newusername);
            EditText password       = FindViewById <EditText>(Resource.Id.newpassword);
            Button   registerButton = FindViewById <Button>(Resource.Id.registerButton);

            registerButton.Click += delegate
            {
                string u_name       = username.Text.ToString();
                string new_passowrd = password.Text.ToString();
                if (!(String.IsNullOrWhiteSpace(u_name) || String.IsNullOrWhiteSpace(new_passowrd)))
                {
                    var data     = Encoding.ASCII.GetBytes(new_passowrd);
                    var sha1     = new SHA1CryptoServiceProvider();
                    var sha1data = sha1.ComputeHash(data);

                    LoginService service = new LoginService();
                    User         user    = new User();
                    user.Username = u_name;
                    user.Password = sha1data;
                    bool ret = service.SaveNewUserDetails(user);
                    if (ret)
                    {
                        //set alert for executing the task
                        AlertDialog.Builder alert = new AlertDialog.Builder(this);
                        alert.SetPositiveButton("Okay", (EventHandler <DialogClickEventArgs>)null);
                        AlertDialog alertDialog = alert.Create();
                        alertDialog.SetTitle("Registration Successfull!");
                        alertDialog.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                        alertDialog.SetMessage("New user added successfully");
                        alertDialog.Show();
                        // Get the buttons.
                        var okButton = alertDialog.GetButton((int)DialogButtonType.Positive);

                        // Assign our handlers.
                        okButton.Click += (sender, args) =>
                        {
                            StartActivity(typeof(NewMemberRegisterActivity));
                        };
                    }
                }
                else
                {
                    //set alert for executing the task
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetPositiveButton("Okay", (EventHandler <DialogClickEventArgs>)null);
                    alert.SetNegativeButton("Cancel", (EventHandler <DialogClickEventArgs>)null);
                    AlertDialog alertDialog = alert.Create();
                    alertDialog.SetTitle("Registration Error!");
                    alertDialog.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                    alertDialog.SetMessage("Could not register, please try again!");
                    alertDialog.Show();
                    var okButton     = alertDialog.GetButton((int)DialogButtonType.Positive);
                    var cancelButton = alertDialog.GetButton((int)DialogButtonType.Negative);

                    // Assign our handlers.
                    okButton.Click += (sender, args) =>
                    {
                        StartActivity(typeof(NewUserRegistration));
                    };
                    cancelButton.Click += (sender, args) =>
                    {
                        StartActivity(typeof(MainActivity));
                    };
                }
            };
        }
Exemple #12
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.PatientRegister);

            // Create your application here
            EditText firstName        = FindViewById <EditText>(Resource.Id.firstNameText);
            EditText lastName         = FindViewById <EditText>(Resource.Id.lastNameText);
            EditText address          = FindViewById <EditText>(Resource.Id.addressText);
            EditText zipcode          = FindViewById <EditText>(Resource.Id.zipcodeText);
            EditText contactNumber    = FindViewById <EditText>(Resource.Id.contactText);
            EditText emergencyContact = FindViewById <EditText>(Resource.Id.emergencyContactText);
            EditText dob               = FindViewById <EditText>(Resource.Id.dobText);
            EditText ageInYears        = FindViewById <EditText>(Resource.Id.ageText);
            EditText gender            = FindViewById <EditText>(Resource.Id.genderText);
            EditText insuranceID       = FindViewById <EditText>(Resource.Id.insuranceIDText);
            EditText insuranceProvider = FindViewById <EditText>(Resource.Id.insuranceProviderText);
            EditText pastAilments      = FindViewById <EditText>(Resource.Id.pastAilmentsText);
            EditText disability        = FindViewById <EditText>(Resource.Id.disabilityText);
            Button   registerButton    = FindViewById <Button>(Resource.Id.register);

            registerButton.Click += async delegate
            {
                Patient patient = new Patient();
                patient.FirstName = firstName.Text.ToString();
                patient.LastName  = lastName.Text.ToString();
                patient.Address   = address.Text.ToString();
                int zip, contact, emergencyNumber, DOB, age, insurance;
                int.TryParse(zipcode.Text.ToString(), out zip);
                patient.Zipcode = zip;
                int.TryParse(contactNumber.Text.ToString(), out contact);
                patient.ContactNumber = contact;
                int.TryParse(emergencyContact.Text.ToString(), out emergencyNumber);
                patient.EmergencyContact = emergencyNumber;
                int.TryParse(dob.Text.ToString(), out DOB);
                patient.DateOfBirth = DOB;
                int.TryParse(ageInYears.Text.ToString(), out age);
                patient.Age    = age;
                patient.Gender = Char.Parse(gender.Text.ToString());
                int.TryParse(insuranceID.Text.ToString(), out insurance);
                patient.InsuranceID       = insurance;
                patient.InsuranceProvider = insuranceProvider.Text.ToString();
                patient.PastAilments      = pastAilments.Text.ToString();
                patient.Disability        = disability.Text.ToString();

                patient.PatientID = 1;

                PatientLibrary patientLibrary = new PatientLibrary();
                try
                {
                    Task <int> patientId = patientLibrary.AddPatient(patient);
                    int        id        = await patientId;

                    //set alert for executing the task
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    // Create empty event handlers, we will override them manually instead of letting the builder handling the clicks.
                    alert.SetPositiveButton("Okay", (EventHandler <DialogClickEventArgs>)null);
                    // alert.SetNegativeButton("Cancel", (EventHandler<DialogClickEventArgs>)null);
                    AlertDialog alertDialog = alert.Create();
                    alertDialog.SetTitle("Registration Successfull");
                    alertDialog.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                    alertDialog.SetMessage("Patient registered successfully. Your Patient ID is " + id.ToString());
                    alertDialog.Show();
                    // Get the buttons.
                    var okButton = alertDialog.GetButton((int)DialogButtonType.Positive);


                    // Assign our handlers.
                    okButton.Click += (sender, args) =>
                    {
                        StartActivity(typeof(PatientLoginActivity));
                    };
                }
                catch (Java.Lang.Exception e)
                {
                    //set alert for executing the task
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    // Create empty event handlers, we will override them manually instead of letting the builder handling the clicks.
                    alert.SetPositiveButton("Okay", (EventHandler <DialogClickEventArgs>)null);
                    alert.SetNegativeButton("Cancel", (EventHandler <DialogClickEventArgs>)null);
                    AlertDialog alertDialog = alert.Create();
                    alertDialog.SetTitle("Registration Error!");
                    alertDialog.SetIcon(Android.Resource.Drawable.IcDialogAlert);
                    alertDialog.SetMessage("Patient not registered. Please try again.");
                    alertDialog.Show();
                    // Get the buttons.
                    var okButton     = alertDialog.GetButton((int)DialogButtonType.Positive);
                    var cancelButton = alertDialog.GetButton((int)DialogButtonType.Negative);

                    // Assign our handlers.
                    okButton.Click += (sender, args) =>
                    {
                        StartActivity(typeof(PatientRegisterActivity));
                    };
                    cancelButton.Click += (sender, args) =>
                    {
                        StartActivity(typeof(NewMemberRegisterActivity));
                    };
                }
            };
        }