protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            locationManager = (LocationManager)GetSystemService(Context.LocationService);
            SetContentView(Resource.Layout.activity_location);
            location_TxtView_Header      = FindViewById <TextView>(Resource.Id.location_TxtView_Header);
            location_TxtView_Header.Text = "تعیین موقعیت";
            location_Button_SetLocation  = FindViewById <Button>(Resource.Id.location_Button_SetLocation);
            MapFragment mapFragment = (MapFragment)FragmentManager.FindFragmentById(Resource.Id.Locatin_Fragment_map);
            MapIsActive Isactive    = new MapIsActive(this);

            location_Button_SetLocation.Click += delegate {
                //تعیین موقعیت توسط گوگل
                locationManager.RequestLocationUpdates(LocationManager.GpsProvider, 1000, 1, this);
                mapFragment.GetMapAsync(this);
            };


            Criteria locationCriteria = new Criteria();

            locationCriteria.Accuracy         = Accuracy.Coarse;
            locationCriteria.PowerRequirement = Power.Medium;


            var locationProvider = locationManager.GetBestProvider(locationCriteria, true);

            if (locationProvider != null)
            {
                locationManager.RequestLocationUpdates(locationProvider, 2000, 1, this);
                if (Isactive.IsGooglePlayServicesInstalled())
                {
                    mapFragment.GetMapAsync(this);
                }
                else
                {
                    Snackbar snackBar = Snackbar.Make(location_Button_SetLocation, "اجرای سرویس گوگل پلی به مشکل خورده است", Snackbar.LengthIndefinite).SetAction("تایید", (v) =>
                    {
                        Finish();
                    });

                    //set  action button text color
                    snackBar.SetActionTextColor(Android.Graphics.Color.Green);

                    snackBar.Show();
                }
            }
            else
            {
                // Log.Info(tag, "No location providers available");
                Snackbar snackBar = Snackbar.Make(location_Button_SetLocation, "مکان باب دستگاه مکانی را پیدا نکرد", Snackbar.LengthIndefinite).SetAction("تایید", (v) =>
                {
                    Finish();
                });

                //set  action button text color
                snackBar.SetActionTextColor(Android.Graphics.Color.Green);

                snackBar.Show();
            }
        }
Exemple #2
0
        async void ShowGPSMessage(bool dontShowSnackBar = true)
        {
            await Task.Delay(250);              // For smother animation on startup

            if (dontShowSnackBar == false && Util.Util.isGpsPositionEnabled())
            {
                //Snackbar.Make (_snackBarView, "Hämtar de närmaste hållplatserna!", Snackbar.LengthLong).Show ();
            }
            else if (dontShowSnackBar == false)
            {
                _GPSSnackbar = Snackbar.Make(_snackBarView, "Slå på GPS:en (Lågenergi-läge används!)", Snackbar.LengthIndefinite)
                               .SetAction("GPS-inställningar", (view) => {
                    _currentLocation     = null;
                    _useLastKnowLocation = true;
                    StartActivity(new Intent(Settings.ActionLocationSourceSettings));
                });


                _GPSSnackbar.SetActionTextColor(Color.ParseColor("#2B9CF5"));

                _GPSSnackbar.Show();

                DismissSnackbar();
            }
        }
        private void ShowSnackbar(int position)
        {
            try
            {
                string undoMsg = _activity.GetString(Resource.String.undoDelet);
                string undo    = _activity.GetString(Resource.String.undo);
                //https://blog.xamarin.com/add-beautiful-material-design-with-the-android-support-design-library/
                Snackbar snackbar = Snackbar.Make(_view, undoMsg, Snackbar.LengthLong)
                                    .SetAction(undo, (v) =>
                {
                    if (_deletedCard != null)
                    {
                        _cards.Insert(position, _deletedCard);
                        _adapter.NotifyItemInserted(position);
                    }
                });

                snackbar.SetActionTextColor(Color.Yellow);

                // Button snackViewButton = dd.View.FindViewById<Button>(Resource.Id.snackbar_action);
                TextView snackViewText = snackbar.View.FindViewById <TextView>(Resource.Id.snackbar_text);
                //snackViewText.Gravity = GravityFlags.Center;
                snackViewText.SetTextColor(Color.White);
                snackbar.Show();
            }
            catch (Exception ex)
            {
                Log.Error("CartItemTouchHelperCallback ", ex.Message);
            }
        }
Exemple #4
0
        private async void bntRecoverClick(object sender, EventArgs e)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(email.Text) || string.IsNullOrEmpty(email.Text))
                {
                    Snackbar bar = Snackbar.Make(parentForgot, Html.FromHtml("<font color=\"#000000\">Fill email</font>"), Snackbar.LengthLong);
                    Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout)bar.View;
                    layout.SetMinimumHeight(100);
                    layout.SetBackgroundColor(Android.Graphics.Color.White);
                    layout.TextAlignment = TextAlignment.Center;
                    layout.ScrollBarSize = 16;
                    bar.SetActionTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Red));
                    bar.SetDuration(Snackbar.LengthLong);
                    bar.SetAction("Ok", (v) => { });
                    bar.Show();
                }
                else
                {
                    string txtEmailForgot = email.Text;
                    var    httpClient     = new HttpClient();
                    var    content        = new StringContent(JsonConvert.SerializeObject(new { Email = txtEmailForgot }), Encoding.UTF8, "application/json");
                    var    result         = await httpClient.PostAsync("UrlApi" + "api/account/forgotpassword", content);

                    var response = await result.Content.ReadAsStringAsync();

                    Toast.MakeText(this, "Check your email please.", ToastLength.Long).Show();
                    StartActivity(typeof(LogIn));
                }
            }
            catch (HttpRequestException httpEx)
            {
                Snackbar bar = Snackbar.Make(parentForgot, Html.FromHtml("<font color=\"#000000\">Check your internet connection</font>"), Snackbar.LengthLong);
                Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout)bar.View;
                layout.SetMinimumHeight(100);
                layout.SetBackgroundColor(Android.Graphics.Color.White);
                layout.TextAlignment = TextAlignment.Center;
                layout.ScrollBarSize = 16;
                bar.SetActionTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Red));
                bar.SetDuration(Snackbar.LengthIndefinite);
                bar.SetAction("Ok", (v) => { });
                bar.Show();
            }
            catch (Exception ex)
            {
                Snackbar bar = Snackbar.Make(parentForgot, Html.FromHtml("<font color=\"#000000\">Error: " + ex + "</font>"), Snackbar.LengthLong);
                Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout)bar.View;
                layout.SetMinimumHeight(100);
                layout.SetBackgroundColor(Android.Graphics.Color.White);
                layout.TextAlignment = TextAlignment.Center;
                layout.ScrollBarSize = 16;
                bar.SetActionTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Red));
                bar.SetDuration(Snackbar.LengthIndefinite);
                bar.SetAction("Ok", (v) => { });
                bar.Show();
            }
        }
        protected virtual IDisposable ToastAppCompat(AppCompatActivity activity, ToastConfig cfg)
        {
            Snackbar snackBar = null;

            activity.SafeRunOnUi(() =>
            {
                var view = activity.Window.DecorView.RootView.FindViewById(Android.Resource.Id.Content);
                var msg  = this.GetSnackbarText(cfg);

                snackBar = Snackbar.Make(
                    view,
                    msg,
                    (int)cfg.Duration.TotalMilliseconds
                    );
                if (cfg.BackgroundColor != null)
                {
                    snackBar.View.SetBackgroundColor(cfg.BackgroundColor.Value.ToNative());
                }

                if (cfg.Position == ToastPosition.Top)
                {
                    // watch for this to change in future support lib versions
                    var layoutParams = snackBar.View.LayoutParameters as FrameLayout.LayoutParams;
                    if (layoutParams != null)
                    {
                        layoutParams.Gravity = GravityFlags.Top;
                        layoutParams.SetMargins(0, 80, 0, 0);
                        snackBar.View.LayoutParameters = layoutParams;
                    }
                }
                if (cfg.Action != null)
                {
                    snackBar.SetAction(cfg.Action.Text, x =>
                    {
                        cfg.Action?.Action?.Invoke();
                        snackBar.Dismiss();
                    });
                    var color = cfg.Action.TextColor;
                    if (color != null)
                    {
                        snackBar.SetActionTextColor(color.Value.ToNative());
                    }
                }

                snackBar.Show();
            });
            return(new DisposableAction(() =>
            {
                if (snackBar.IsShown)
                {
                    activity.SafeRunOnUi(snackBar.Dismiss);
                }
            }));
        }
        internal static void ShowSnackBar_WithOKButtonToClose(Context context, View view, int iResourceStringID)
        {
            Snackbar bar = Snackbar.Make(view, iResourceStringID, Snackbar.LengthIndefinite);

            bar.View.SetBackgroundColor(new Android.Graphics.Color(ContextCompat.GetColor(context, Resource.Color.primary_dark)));

            bar.SetAction(Resource.String.snackbar_OK, (v) => { });
            bar.SetActionTextColor(new Android.Graphics.Color(ContextCompat.GetColor(context, Resource.Color.primary_light)));

            bar.Show();
        }
        protected virtual IDisposable ToastAppCompat(AppCompatActivity activity, ToastConfig cfg)
        {
            Snackbar snackBar = null;

            activity.RunOnUiThread(() =>
            {
                var view = activity.Window.DecorView.RootView.FindViewById(Android.Resource.Id.Content);
                var msg  = this.GetSnackbarText(cfg);

                snackBar = Snackbar.Make(
                    view,
                    msg,
                    (int)cfg.Duration.TotalMilliseconds
                    );
                if (cfg.BackgroundColor != null)
                {
                    snackBar.View.SetBackgroundColor(cfg.BackgroundColor.Value.ToNative());
                }

                if (cfg.Action != null)
                {
                    snackBar.SetAction(cfg.Action.Text, x =>
                    {
                        cfg.Action?.Action?.Invoke();
                        snackBar.Dismiss();
                    });
                    var color = cfg.Action.TextColor;
                    if (color != null)
                    {
                        snackBar.SetActionTextColor(color.Value.ToNative());
                    }
                }

                snackBar.Show();
            });
            return(new DisposableAction(() =>
            {
                if (snackBar.IsShown)
                {
                    activity.RunOnUiThread(() =>
                    {
                        try
                        {
                            snackBar.Dismiss();
                        }
                        catch
                        {
                            // catch and swallow
                        }
                    });
                }
            }));
        }
Exemple #8
0
        private void displaySnackBar(string text)
        {
            Snackbar bar = Snackbar.Make(view, Html.FromHtml("<font color=\"#000000\">" + text + "</font>"), Snackbar.LengthLong);

            Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout)bar.View;
            layout.SetMinimumHeight(100);
            layout.SetBackgroundColor(Android.Graphics.Color.White);
            layout.TextAlignment = TextAlignment.Center;
            layout.ScrollBarSize = 20;
            bar.SetActionTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Red));
            bar.SetDuration(Snackbar.LengthIndefinite);
            bar.SetAction("Ok", (v) => { });
            bar.Show();
        }
Exemple #9
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            var          dlg       = inflater.Inflate(Resource.Layout.layoutStatuseDelete, container, false);
            var          font      = Typeface.CreateFromAsset(ctx.Assets, "Estedad.ttf");
            LinearLayout lnaboutus = dlg.FindViewById <LinearLayout>(Resource.Id.statusedeltelinearlayout);

            lnaboutus.SetBackgroundResource(Resource.Drawable.dialog_fragment_round);

            statusedeletetxtviewcaption          = dlg.FindViewById <TextView>(Resource.Id.statusedeletetxtviewcaption);
            statusedeletetxtviewcaption.Typeface = font;
            statusedelterchkboxnotevent          = dlg.FindViewById <CheckBox>(Resource.Id.statusedelterchkboxnotevent);
            statusedelterchkboxnotevent.Typeface = font;
            statusedelterchkboxnotevent.Click   += delegate
            {
                statusedeletechknotokeyevent.Checked = false;
                statusedeletechkcancell.Checked      = false;
            };

            statusedeletechknotokeyevent          = dlg.FindViewById <CheckBox>(Resource.Id.statusedeletechknotokeyevent);
            statusedeletechknotokeyevent.Typeface = font;
            statusedeletechknotokeyevent.Click   += delegate
            {
                statusedelterchkboxnotevent.Checked = false;
                statusedeletechkcancell.Checked     = false;
            };
            statusedeletechkcancell          = dlg.FindViewById <CheckBox>(Resource.Id.statusedeletechkcancell);
            statusedeletechkcancell.Typeface = font;
            statusedeletechkcancell.Click   += delegate {
                statusedelterchkboxnotevent.Checked  = false;
                statusedeletechknotokeyevent.Checked = false;
            };
            Button statusedeletebuttonenter = dlg.FindViewById <Button>(Resource.Id.statusedeletebuttonenter);

            statusedeletebuttonenter.Typeface = font;
            statusedeletebuttonenter.Click   += delegate
            {
                Snackbar snackBar = Snackbar.Make(statusedeletebuttonenter, "حذف رویداد با موفقیت انجام شد", Snackbar.LengthIndefinite).SetAction("باشه", (v) =>
                {
                    Dismiss();
                });
                snackBar.SetActionTextColor(Android.Graphics.Color.Green);

                snackBar.Show();
            };

            return(dlg);
        }
Exemple #10
0
        public static void SingleButtonSnackBar(string strText, string actionText, bool isLengthIndefinite, View view)
        {
            Snackbar SnackBar = Snackbar.Make(view, strText, isLengthIndefinite ? Snackbar.LengthIndefinite : Snackbar.LengthShort).SetAction(actionText, (v) =>
            {
                //set action for action button
                //TODO: Action for SnackBar
            });

            //set action button text color and size
            SnackBar.SetActionTextColor(Android.Graphics.Color.Yellow);
            var txtAction = SnackBar.View.FindViewById <TextView>(Resource.Id.snackbar_action);

            txtAction.SetTextSize(Android.Util.ComplexUnitType.Dip, 14);

            //set message text color and size
            var txtMessage = SnackBar.View.FindViewById <TextView>(Resource.Id.snackbar_text);

            txtMessage.SetTextColor(Android.Graphics.Color.White);
            txtMessage.SetTextSize(Android.Util.ComplexUnitType.Dip, 13);
            SnackBar.Show();
        }
Exemple #11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            CalligraphyConfig.InitDefault(new CalligraphyConfig.Builder()
                                          .SetDefaultFontPath("Estedad.ttf").Build());
            SetContentView(Resource.Layout.layoutEditMyEvent);
            var font = Typeface.CreateFromAsset(Assets, "Estedad.ttf");

            editmyeventtxtviewCaptionCost          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewCaptionCost);
            editmyeventtxtviewCaptionCost.Typeface = font;
            editmyeventimgviewback        = FindViewById <ImageView>(Resource.Id.editmyeventimgviewback);
            editmyeventimgviewback.Click += delegate { Finish(); };

            editmyeventButtonBack          = FindViewById <Button>(Resource.Id.editmyeventButtonBack);
            editmyeventButtonBack.Typeface = font;
            editmyeventButtonBack.Click   += delegate { Finish(); };

            editmyeventbuttoncaption          = FindViewById <Button>(Resource.Id.editmyeventbuttoncaption);
            editmyeventbuttoncaption.Typeface = font;
            editmyeventbuttoncaption.Click   += delegate {
                Controller.Fragment.Captionvent fdlg = new Fragment.Captionvent(this);
                fdlg.Show(this.FragmentManager, "ebrahimeditfragment1");
                fdlg.OnGetCurrentItem += Fdlg_OnGetCurrentItem;
            };

            editmyeventtxtviewcaption          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewcaption);
            editmyeventtxtviewcaption.Typeface = font;


            editeventedittextHelpCaption = FindViewById <TextView>(Resource.Id.editmyeventtxtviewcaptionevent);

            editeventedittextHelpCaption.Click += delegate {
                ValueToast = "تیتر اصلی رویداد خود را شفاف و جذاب درج کنید";

                Controller.Fragment.ShowWarning fdlg = new Fragment.ShowWarning(this, ValueToast);
                fdlg.Show(this.FragmentManager, "ebrahimfragment1");
            };

            editmyeventeditTextCaption          = FindViewById <EditText>(Resource.Id.editmyeventeditTextCaption);
            editmyeventeditTextCaption.Typeface = font;

            //   editmyeventeditTextCaption.RequestFocus();

            editmyeventtxtviewcaptionevent          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewcaptionevent);
            editmyeventtxtviewcaptionevent.Typeface = font;

            editmyeventbuttonLocal          = FindViewById <Button>(Resource.Id.editmyeventbuttonLocal);
            editmyeventbuttonLocal.Typeface = font;

            editmyeventbuttonLocal.Click += delegate {
                Fragment.EnterPlace fdlg = new Fragment.EnterPlace(this);
                fdlg.ShowsDialog = true;
                fdlg.Show(this.FragmentManager, "ebrahimfragmentfdlg");
                fdlg.OnGetPlaceEvent += delegate(object sender, GetPlaceEvent e)
                {
                    if (e.GetPlace.Count > 1)
                    {
                        ValueToast   = "بیشتر از یک مکان برای رویداد انتخاب شده است";
                        view         = LayoutInflater.Inflate(Resource.Layout.layoutToast, null);
                        txt          = view.FindViewById <TextView>(Resource.Id.toasttxtviewtoast);
                        txt.Typeface = font;
                        txt.Text     = ValueToast;
                        toast        = new Toast(this)
                        {
                            Duration = ToastLength.Long,

                            View = view
                        };
                        toast.SetGravity(GravityFlags.Center, 0, 0);
                        toast.Show();
                        return;
                    }
                    else
                    {
                        if (e.GetPlace.Count == 0)
                        {
                            return;
                        }

                        editmyeventbuttonLocal.Text = "";
                        foreach (var item in e.GetPlace)
                        {
                            editmyeventbuttonLocal.Text += item.itemplace;
                        }
                        //  editmyeventbuttonshiraz.Visibility = ViewStates.Invisible;
                    }
                };
            };
            editmyeventbuttonshiraz          = FindViewById <Button>(Resource.Id.editmyeventbuttonshiraz);
            editmyeventbuttonshiraz.Typeface = font;


            editmyeventtxtviewplace          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewplace);
            editmyeventtxtviewplace.Typeface = font;


            editmyeventedittextHelpAddress        = FindViewById <EditText>(Resource.Id.editmyeventedittextHelpAddress);
            editmyeventedittextHelpAddress.Click += delegate
            {
                ValueToast = "می توانید آدرس  محل رویداد خود را در اینجا بنویسید";
                Controller.Fragment.ShowWarning fdlg = new Fragment.ShowWarning(this, ValueToast);
                fdlg.Show(this.FragmentManager, "ebrahimfragment1");
            };



            FindViewById <EditText>(Resource.Id.editmyeventeditexthelpcost).Click += delegate {
                Drawable errorIcon = Resources.GetDrawable(Resource.Drawable.academicblack32);



                FindViewById <EditText>(Resource.Id.editmyeventeditexthelpcost).SetError(Android.Text.Html.FromHtml("<font color='White'>منظور از هزینه رویداد میزان هرینه ای است که از مخاطب بابت شرکت در رویداد خود دریافت می نمایید یکی از گزینه های درج شده را انتخاب نمایید</font>"), errorIcon);
            };



            editmyeventeditTextAddres          = FindViewById <EditText>(Resource.Id.editmyeventeditTextAddres);
            editmyeventeditTextAddres.Typeface = font;

            string editTextAddres     = editmyeventeditTextAddres.Hint;
            string numberdigittAddres = editTextAddres.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            editmyeventeditTextAddres.Hint = numberdigittAddres;

            string editTextAddresText     = editmyeventeditTextAddres.Text;
            string numberdigittAddresText = editTextAddresText.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            editmyeventeditTextAddres.Text = numberdigittAddresText;


            editmyeventtxtviewaddres          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewaddres);
            editmyeventtxtviewaddres.Typeface = font;

            editmyeventeditexthelpTime        = FindViewById <EditText>(Resource.Id.editmyeventeditexthelpTime);
            editmyeventeditexthelpTime.Click += delegate
            {
                ValueToast = "بازه زمان برگزاری رویداد خود را مشخص کنید در صورتی که رویداد شما یک روزه است تاریخ شروع و پایان را یکسان انتخاب نمایید";
                Controller.Fragment.ShowWarning fdlg = new Fragment.ShowWarning(this, ValueToast);
                fdlg.Show(this.FragmentManager, "ebrahimfragment1");
            };


            editmyeventbuttotnTo          = FindViewById <Button>(Resource.Id.editmyeventbuttotnTo);
            editmyeventbuttotnTo.Typeface = font;

            string buttotnTo        = editmyeventbuttotnTo.Text;
            string myeventbuttotnTo = buttotnTo.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            editmyeventbuttotnTo.Text = myeventbuttotnTo;



            editmyeventbuttotnTo.Click += delegate {
                a = 2;

                Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog p = new Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog();
                Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog d = Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog.NewInstance(this, p.SelectedDay.Year, p.SelectedDay.Month, p.SelectedDay.Day);
                d.Show(FragmentManager, "ebrahimeditfragmnetto");
            };
            editmyeventtxtviewto          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewto);
            editmyeventtxtviewto.Typeface = font;

            editmyeventbuttonFrom          = FindViewById <Button>(Resource.Id.editmyeventbuttonFrom);
            editmyeventbuttonFrom.Typeface = font;

            string buttonFrom        = editmyeventbuttonFrom.Text;
            string myeventbuttonFrom = buttonFrom.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            editmyeventbuttonFrom.Text = myeventbuttonFrom;



            editmyeventbuttonFrom.Click += delegate {
                // a = 1;
                Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog p = new Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog();
                Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog d = Com.Mohamadamin.Persianmaterialdatetimepicker.Date.DatePickerDialog.NewInstance(this, p.SelectedDay.Year, p.SelectedDay.Month, p.SelectedDay.Day);
                d.Show(FragmentManager, "ebrahimeditfragmentdate");
            };
            editmyeventtxtviewfrom          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewfrom);
            editmyeventtxtviewfrom.Typeface = font;


            editmyeventtxtviewtime          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewtime);
            editmyeventtxtviewtime.Typeface = font;


            editmyeventbuttoncost        = FindViewById <Button>(Resource.Id.editmyeventbuttoncost);
            editmyeventbuttoncost.Click += delegate
            {
                PanelCostFragment Pcost = new PanelCostFragment(this);
                Pcost.Show(this.FragmentManager, "ebrahimeditfragmentcost");
                Pcost.OnGetCurrentcost += delegate(object sender, GetAllItemCheckd e)
                {
                    if (e.GetCost != string.Empty)
                    {
                        editmyeventbuttoncost.Text = e.GetCost;
                    }
                };
            };

            editmyeventtxtviewCaptionCost.Click += delegate {
                if (editmyeventtxtviewCaptionCost.Text == string.Empty)
                {
                    return;
                }
                else
                {
                    Entercost fdialog = new Entercost(this);
                    fdialog.Show(this.FragmentManager, "ebrahimfragment3");


                    fdialog.OnGetCurrentItem += delegate(object sende1r, GetCostItem getcost)
                    {
                        this.Window.SetSoftInputMode(SoftInput.StateAlwaysHidden);
                        int    valuenumber = Convert.ToInt32(getcost.GetCost);
                        string num         = valuenumber.ToString("N0");


                        string digitpersiannumber = num.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

                        editmyeventtxtviewCaptionCost.Text = digitpersiannumber + "تومان";

                        editmyeventtxtviewCaptionCost.SetTextColor(Android.Graphics.Color.ParseColor("#311b92"));
                        editmyeventtxtviewCaptionCost.Typeface = font;
                        editmyeventtxtviewCaptionCost.Gravity  = GravityFlags.Center;
                        editmyeventtxtviewCaptionCost.RequestFocus();
                    };
                }
            };

            editmyeventtxtviewcost          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewcost);
            editmyeventtxtviewcost.Typeface = font;

            editmyeventedittexthelptel        = FindViewById <EditText>(Resource.Id.enteteventedittexthelptel);
            editmyeventedittexthelptel.Click += delegate {
                ValueToast = ".شماره همراه جهت پاسخگویی به مخاطبین رویداد را درج نمایید.  پس از  ثبت رویداد در ایونتو پیامکی حاوی کد تایید به این شماره ارسال خواهد شد";
                Controller.Fragment.ShowWarning fdlg = new Fragment.ShowWarning(this, ValueToast);
                fdlg.Show(this.FragmentManager, "ebrahimfragment1");
            };
            EditText editmteventedittextHelpCaption;

            editmteventedittextHelpCaption = FindViewById <EditText>(Resource.Id.editmteventedittextHelpCaption);

            editmteventedittextHelpCaption        = FindViewById <EditText>(Resource.Id.editmteventedittextHelpCaption);
            editmteventedittextHelpCaption.Click += delegate {
                ValueToast = "تیتر اصلی رویداد خود را شفاف و جذاب درج کنید";

                Controller.Fragment.ShowWarning fdlg = new Fragment.ShowWarning(this, ValueToast);
                fdlg.Show(this.FragmentManager, "ebrahimfragment1");
            };


            editmyeventeditTextTel          = FindViewById <EditText>(Resource.Id.editmyeventeditTextTel);
            editmyeventeditTextTel.Typeface = font;

            string editTextTel    = editmyeventeditTextTel.Hint;
            string numberdigitTel = editTextTel.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            editmyeventeditTextTel.Hint = numberdigitTel;

            string editTextTelText    = editmyeventeditTextTel.Text;
            string numberdigitTelText = editTextTelText.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            editmyeventeditTextTel.Text = numberdigitTelText;



            editmyeventtxtviewtel          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewtel);
            editmyeventtxtviewtel.Typeface = font;

            editmyeventeditexthelpurl = FindViewById <EditText>(Resource.Id.editmyeventeditexthelpurl);

            editmyeventeditexthelpurl.Click += delegate {
                ValueToast = "در این قسمت میتوانید آدرس وب سایت یا شبکه های اجتماعی خود را درج نمایید";
                Controller.Fragment.ShowWarning fdlg = new Fragment.ShowWarning(this, ValueToast);
                fdlg.Show(this.FragmentManager, "ebrahimfragment1");
            };



            editmyeventeditTextUrl          = FindViewById <EditText>(Resource.Id.editmyeventeditTextUrl);
            editmyeventeditTextUrl.Typeface = font;

            editmyeventtxtviewurl          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewurl);
            editmyeventtxtviewurl.Typeface = font;


            editmyeventeditexthelpdescription        = FindViewById <EditText>(Resource.Id.editmyeventeditexthelpdescription);
            editmyeventeditexthelpdescription.Click += delegate {
                ValueToast = "اطلاعات تکمیلی رویداد خود از جمله شرایط هزینه را بطور کامل و شفاف ارایه دهید از درج هر گونه آدرس اینترنتی در این قسمت خودداری نمایید";
                Controller.Fragment.ShowWarning fdlg = new Fragment.ShowWarning(this, ValueToast);
                fdlg.Show(this.FragmentManager, "ebrahimfragment1");
            };


            editmyeventeditexthelpdescription = FindViewById <EditText>(Resource.Id.editmyeventeditexthelpdescription);


            FindViewById <EditText>(Resource.Id.editmyeventedttexthelpcamera).Click += delegate {
                ValueToast = "  تصاویر مرتیط با رویداد خود را بار گذاری کنید.تصاویر مناسب باعث بیشتر دیده شدن رویداد شما خواهد شد" + ".";

                Controller.Fragment.ShowWarning fdlg = new Fragment.ShowWarning(this, ValueToast);
                fdlg.Show(this.FragmentManager, "ebrahimfragment1");
            };
            //



            editmyeventeditTextdesc          = FindViewById <EditText>(Resource.Id.editmyeventeditTextdesc);
            editmyeventeditTextdesc.Typeface = font;

            editmyeventtxtviewdescription          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewdescription);
            editmyeventtxtviewdescription.Typeface = font;



            editmyeventbuttoncamera          = FindViewById <Button>(Resource.Id.editmyeventbuttoncamera);
            editmyeventbuttoncamera.Typeface = font;
            editmyeventbuttoncamera.Click   += delegate {
                var intentbrowserimage = new Intent();
                intentbrowserimage.SetAction(Intent.ActionGetContent);
                intentbrowserimage.SetType("image/*");
                StartActivityForResult(intentbrowserimage, 100);
            };

            editmyeventtxtviewphoto          = FindViewById <TextView>(Resource.Id.editmyeventtxtviewphoto);
            editmyeventtxtviewphoto.Typeface = font;


            editmyeventlinearLayoutcamera = FindViewById <LinearLayout>(Resource.Id.editmyeventlinearLayoutcamera);


            editmyeventimageviewSend        = FindViewById <ImageView>(Resource.Id.editmyeventimageviewSend);
            editmyeventimageviewSend.Click += delegate {
                if (editmyeventbuttoncaption.Text == "انتخاب شود")
                {
                    ValueToast = "موضوع رویداد اجباری می باشد";



                    editmyeventbuttoncaption.Error = ValueToast;



                    return;
                }
                if (editmyeventeditTextCaption.Text == string.Empty)
                {
                    ValueToast = "عنوان رویداد اجباری می باشد";

                    editmyeventeditTextCaption.Error = ValueToast;
                    return;
                }
                if (editmyeventbuttonLocal.Text == "محله")
                {
                    ValueToast = "  انتخاب محله اجباری می باشد";

                    editmyeventbuttonLocal.Error = ValueToast;



                    return;
                }
                if (editmyeventeditTextAddres.Text == string.Empty)
                {
                    ValueToast = "آدرس رویداد اجباری می باشد";
                    //Drawable icon = Resources.GetDrawable(Resource.Drawable.warning32);
                    //if (icon != null)
                    //{
                    //    icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);
                    //}
                    editmyeventeditTextAddres.Error = ValueToast;
                    return;
                }
                if (editmyeventbuttonFrom.Text == "تاریخ شروع")
                {
                    ValueToast = "تاریخ شروع اجباری می باشد";

                    editmyeventbuttonFrom.Error = ValueToast;
                    return;
                }
                if (editmyeventbuttotnTo.Text == "تاریخ پایان")
                {
                    ValueToast = "تاریخ پایان اجباری می باشد";

                    editmyeventbuttotnTo.Error = ValueToast;
                    return;
                }
                if (editmyeventeditTextTel.Text == "تلفن تماس")
                {
                    ValueToast = "تلفن تماس اجباری می باشد";

                    editmyeventeditTextTel.Error = ValueToast;
                    return;
                }
                if (editmyeventeditTextdesc.Text.Length > 400)
                {
                    ValueToast = "توضیحات باید کمتر از 400 کاراکتر باشد";
                    //Drawable icon = Resources.GetDrawable(Resource.Drawable.warning32);
                    //if (icon != null)
                    //{
                    //    icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);
                    //}
                    editmyeventeditTextdesc.Error = ValueToast;
                    return;
                }



                else
                {
                    ValueToast = "تغییرات رویداد با موفقیت انجام شد";


                    Snackbar snackBar = Snackbar.Make(editmyeventbuttonSend, ValueToast, Snackbar.LengthIndefinite).SetAction("تایید", (v) =>
                    {
                        Finish();
                    });

                    //set  action button text color
                    snackBar.SetActionTextColor(Android.Graphics.Color.Green);

                    snackBar.Show();
                    //Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);


                    //alert.SetTitle("تایید رویداد");
                    //alert.SetIcon(Resource.Drawable.alert24);
                    //alert.SetMessage(ValueToast);
                    //alert.SetPositiveButton("باشه", (senderAlert, args) => {
                    //    Finish();

                    //});



                    //Dialog dialog = alert.Create();
                    //dialog.Show();
                }
            };
            editmyeventbuttonSend          = FindViewById <Button>(Resource.Id.editmyeventbuttonSend);
            editmyeventbuttonSend.Typeface = font;
            editmyeventbuttonSend.Click   += delegate {
                if (editmyeventbuttoncaption.Text == "انتخاب شود")
                {
                    ValueToast = "موضوع رویداد اجباری می باشد";



                    editmyeventbuttoncaption.Error = ValueToast;



                    return;
                }
                if (editmyeventeditTextCaption.Text == string.Empty)
                {
                    ValueToast = "عنوان رویداد اجباری می باشد";

                    editmyeventeditTextCaption.Error = ValueToast;
                    return;
                }
                if (editmyeventbuttonLocal.Text == "محله")
                {
                    ValueToast = "  انتخاب محله اجباری می باشد";

                    editmyeventbuttonLocal.Error = ValueToast;



                    return;
                }
                if (editmyeventeditTextAddres.Text == string.Empty)
                {
                    ValueToast = "آدرس رویداد اجباری می باشد";
                    //Drawable icon = Resources.GetDrawable(Resource.Drawable.warning32);
                    //if (icon != null)
                    //{
                    //    icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);
                    //}
                    editmyeventeditTextAddres.Error = ValueToast;
                    return;
                }
                if (editmyeventbuttonFrom.Text == "تاریخ شروع")
                {
                    ValueToast = "تاریخ شروع اجباری می باشد";

                    editmyeventbuttonFrom.Error = ValueToast;
                    return;
                }
                if (editmyeventbuttotnTo.Text == "تاریخ پایان")
                {
                    ValueToast = "تاریخ پایان اجباری می باشد";

                    editmyeventbuttotnTo.Error = ValueToast;
                    return;
                }
                if (editmyeventeditTextTel.Text == "تلفن تماس")
                {
                    ValueToast = "تلفن تماس اجباری می باشد";

                    editmyeventeditTextTel.Error = ValueToast;
                    return;
                }
                if (editmyeventeditTextdesc.Text.Length > 400)
                {
                    ValueToast = "توضیحات باید کمتر از 400 کاراکتر باشد";
                    //Drawable icon = Resources.GetDrawable(Resource.Drawable.warning32);
                    //if (icon != null)
                    //{
                    //    icon.SetBounds(0, 0, icon.IntrinsicWidth, icon.IntrinsicHeight);
                    //}
                    editmyeventeditTextdesc.Error = ValueToast;
                    return;
                }



                else
                {
                    ValueToast = "تغییرات رویداد با موفقیت انجام شد";


                    Snackbar snackBar = Snackbar.Make(editmyeventbuttonSend, ValueToast, Snackbar.LengthIndefinite).SetAction("تایید", (v) =>
                    {
                        Finish();
                    });

                    //set  action button text color
                    snackBar.SetActionTextColor(Android.Graphics.Color.Green);

                    snackBar.Show();
                    //Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);


                    //alert.SetTitle("تایید رویداد");
                    //alert.SetIcon(Resource.Drawable.alert24);
                    //alert.SetMessage(ValueToast);
                    //alert.SetPositiveButton("باشه", (senderAlert, args) => {
                    //    Finish();

                    //});



                    //Dialog dialog = alert.Create();
                    //dialog.Show();
                }
            };

            editmyeventbuttondelete          = FindViewById <Button>(Resource.Id.editmyeventbuttondelete);
            editmyeventbuttondelete.Typeface = font;

            editmyeventbuttondelete.Text   = "صرف نظر";
            editmyeventbuttondelete.Click += delegate {
                Finish();
            };



            editmyeventimageviewclose        = FindViewById <ImageView>(Resource.Id.editmyeventimageviewclose);
            editmyeventimageviewclose.Click += delegate {
                Finish();
            };
        }
        public static void ShowSnackbar(Activity activity, SnackbarConfig config)
        {
            var view = activity.Window.DecorView.RootView.FindViewById(global::Android.Resource.Id.Content);

            if (_snackbar == null)
            {
                _snackbar = Snackbar.Make(view, config.Message, (int)config.Duration.TotalMilliseconds);
            }

            if (_snackbar.IsShownOrQueued)
            {
                _snackbar = Snackbar.Make(view, config.Message, (int)config.Duration.TotalMilliseconds);
            }

            _snackbar.SetDuration((int)config.Duration.TotalMilliseconds);
            _snackbar.SetText(config.Message);

            if (!string.IsNullOrWhiteSpace(config.ActionText))
            {
                _snackbar.SetAction(config.ActionText, (v) =>
                {
                    config.Action?.Invoke();

                    _snackbar.Dismiss();
                });

                if (config.ActionTextColor.HasValue)
                {
                    _snackbar.SetActionTextColor(config.ActionTextColor.Value.ToNativeColor());
                }
            }

            if (config.TextColor.HasValue)
            {
                //TextView textView = _snackbar.View.FindViewById<TextView>(Resource.Id.snackbar_text);
                //textView.SetTextColor(config.TextColor.Value.ToNativeColor());

                // TODO
            }

            if (config.BackgroundColor.HasValue)
            {
                //TextView textView = _snackbar.View.FindViewById<TextView>(Resource.Id.snackbar_text);
                //textView.SetBackgroundColor(config.BackgroundColor.Value.ToNativeColor());

                // TODO
            }

            //if (config.Position != ToastPosition.Default)
            //{
            //    // watch for this to change in future support lib versions
            //    var layoutParams = _snackbar.View.LayoutParameters as FrameLayout.LayoutParams;
            //    if (layoutParams != null)
            //    {
            //        if (config.Position == ToastPosition.Top)
            //        {
            //            layoutParams.Gravity = GravityFlags.Top;
            //            layoutParams.SetMargins(0, 80, 0, 0);
            //        }
            //        else if (config.Position == ToastPosition.Center)
            //        {
            //            layoutParams.Gravity = GravityFlags.Center;
            //        }
            //        else if (config.Position == ToastPosition.Bottom)
            //        {
            //            layoutParams.Gravity = GravityFlags.Bottom;
            //            layoutParams.SetMargins(0, 0, 0, 30);
            //        }

            //        _snackbar.View.LayoutParameters = layoutParams;
            //    }
            //}

            _snackbar.Show();
        }
Exemple #13
0
        private async void clickBtnLogIn(object sender, EventArgs e)
        {
            if (string.IsNullOrWhiteSpace(username.Text) || string.IsNullOrEmpty(username.Text))
            {
                Snackbar bar = Snackbar.Make(parentLayout, "Fill username", Snackbar.LengthLong);
                bar.SetText(Html.FromHtml("<font color=\"#000000\">Fill username</font>"));
                Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout)bar.View;
                layout.SetMinimumHeight(100);
                layout.SetBackgroundColor(Android.Graphics.Color.White);
                layout.TextAlignment = TextAlignment.Center;
                layout.ScrollBarSize = 16;
                bar.SetActionTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Red));
                bar.SetDuration(Snackbar.LengthLong);
                bar.SetAction("Ok", (v) => { });
                bar.Show();
            }
            else if (string.IsNullOrWhiteSpace(password.Text) || string.IsNullOrEmpty(password.Text))
            {
                Snackbar bar = Snackbar.Make(parentLayout, Html.FromHtml("<font color=\"#000000\">Fill password</font>"), Snackbar.LengthLong);
                Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout)bar.View;
                layout.SetMinimumHeight(100);
                layout.SetBackgroundColor(Android.Graphics.Color.White);
                layout.TextAlignment = TextAlignment.Center;
                layout.ScrollBarSize = 16;
                bar.SetActionTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Red));
                bar.SetDuration(Snackbar.LengthLong);
                bar.SetAction("Ok", (v) => { });
                bar.Show();
            }
            else
            {
                var progressDialog = new ProgressDialog(this);
                try
                {
                    progressDialog.SetIcon(2130968582);
                    progressDialog.SetCancelable(true);
                    progressDialog.SetMessage("Please wait!");
                    progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
                    progressDialog.Show();

                    var client        = new HttpClient();
                    var keyValueLogIn = new List <KeyValuePair <string, string> >
                    {
                        new KeyValuePair <string, string>("username", username.Text),
                        new KeyValuePair <string, string>("password", password.Text),
                        new KeyValuePair <string, string>("grant_type", "password")
                    };
                    var request = new HttpRequestMessage(HttpMethod.Post, "UrlApiToken");
                    request.Content = new FormUrlEncodedContent(keyValueLogIn);
                    var response = await client.SendAsync(request);

                    var content = await response.Content.ReadAsStringAsync();

                    if (response.IsSuccessStatusCode)
                    {
                        TokenModel tokenFromServer = JsonConvert.DeserializeObject <TokenModel>(content);
                        var        jsonContent     = JsonConvert.SerializeObject(username.Text);
                        var        LogIncontent    = new StringContent(jsonContent, Encoding.ASCII, "application/json");

                        client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", tokenFromServer.access_token);

                        response = await client.PostAsync("UrlApi" + "api/Account/userdata", LogIncontent);

                        var userData = await response.Content.ReadAsStringAsync();

                        User user = JsonConvert.DeserializeObject <User>(userData);

                        var userSession = new UserSession
                        {
                            FirstName  = user.FirstName,
                            LastName   = user.LastName,
                            userId     = user.userId,
                            Token      = tokenFromServer.access_token,
                            user_image = user.user_image
                        };
                        con.Insert(userSession);
                        progressDialog.Cancel();
                        StartActivity(typeof(MainActivity));
                    }
                    else
                    {
                        LogInError logInError      = JsonConvert.DeserializeObject <LogInError>(content);
                        var        alertLogInError = new Android.App.AlertDialog.Builder(this);
                        alertLogInError.SetTitle(logInError.error);
                        alertLogInError.SetMessage(logInError.error_description);
                        username.Text = "";
                        password.Text = "";

                        Snackbar bar = Snackbar.Make(parentLayout, Html.FromHtml("<font color=\"#000000\">" + logInError.error + " - " + logInError.error_description + "</font>"), Snackbar.LengthLong);
                        Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout)bar.View;
                        layout.SetMinimumHeight(100);
                        layout.SetBackgroundColor(Android.Graphics.Color.White);
                        layout.TextAlignment = TextAlignment.Center;
                        layout.ScrollBarSize = 16;
                        bar.SetActionTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Red));
                        bar.SetDuration(Snackbar.LengthLong);
                        bar.SetAction("Ok", (v) => { });
                        bar.Show();

                        progressDialog.Cancel();
                    }
                }
                catch (HttpRequestException httpEx)
                {
                    Snackbar bar = Snackbar.Make(parentLayout, Html.FromHtml("<font color=\"#000000\">Please check your internet connection!</font>"), Snackbar.LengthLong);
                    Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout)bar.View;
                    layout.SetMinimumHeight(100);
                    layout.SetBackgroundColor(Android.Graphics.Color.White);
                    layout.TextAlignment = TextAlignment.Center;
                    layout.ScrollBarSize = 16;
                    bar.SetActionTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Red));
                    bar.SetDuration(Snackbar.LengthIndefinite);
                    bar.SetAction("Ok", (v) => { });
                    bar.Show();
                    progressDialog.Cancel();
                }
                catch (Exception ex)
                {
                    Snackbar bar = Snackbar.Make(parentLayout, Html.FromHtml("<font color=\"#000000\">Error: " + ex + "</font>"), Snackbar.LengthLong);
                    Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout)bar.View;
                    layout.SetMinimumHeight(100);
                    layout.SetBackgroundColor(Android.Graphics.Color.White);
                    layout.TextAlignment = TextAlignment.Center;
                    layout.ScrollBarSize = 16;
                    bar.SetActionTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Red));
                    bar.SetDuration(Snackbar.LengthIndefinite);
                    bar.SetAction("Ok", (v) => { });
                    bar.Show();
                    progressDialog.Cancel();
                }
            }
        }
Exemple #14
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_addaccount);
            AddAccount_TextView_Telhamrah = FindViewById <TextView>(Resource.Id.AddAccount_TextView_Telhamrah);
            AddAccount_EditText_Telhamrah = FindViewById <EditText>(Resource.Id.AddAccount_EditText_Telhamrah);



            AddAccount_TextView_FamilyName   = FindViewById <TextView>(Resource.Id.AddAccount_TextView_FamilyName);
            AddAccount_EditText_FamilyName   = FindViewById <EditText>(Resource.Id.AddAccount_EditText_FamilyName);
            AddAccount_TextView_NationalCode = FindViewById <TextView>(Resource.Id.AddAccount_TextView_NationalCode);
            AddAccount_EditText_NationalCode = FindViewById <EditText>(Resource.Id.AddAccount_EditText_NationalCode);
            AddAccount_TextView_BirthDay     = FindViewById <TextView>(Resource.Id.AddAccount_TextView_BirthDay);
            AddAccount_EditText_BirthDay     = FindViewById <EditText>(Resource.Id.AddAccount_EditText_BirthDay);
            AddAccount_CheckBox_Male         = FindViewById <CheckBox>(Resource.Id.AddAccount_CheckBox_Male);
            AddAcount_checkBox_Female        = FindViewById <CheckBox>(Resource.Id.AddAcount_checkBox_Female);
            //AddAccount_CheckBox_Male.Click += delegate { };
            AddAccount_CheckBox_Male.CheckedChange += delegate {
                if (AddAcount_checkBox_Female.Checked)
                {
                    AddAccount_CheckBox_Male.Checked = false;
                }
            };

            AddAcount_checkBox_Female.CheckedChange += delegate {
                if (AddAccount_CheckBox_Male.Checked)
                {
                    AddAcount_checkBox_Female.Checked = false;
                }
            };
            AddAccount_TxtView_Header        = FindViewById <TextView>(Resource.Id.AddAccount_TxtView_Header);
            AddAccount_Button_Account        = FindViewById <Button>(Resource.Id.AddAccount_Button_Account);
            AddAccount_Button_Account.Click += delegate {
                //حساب
                Intent oi = new Intent(this, typeof(Account_Activity));
                StartActivity(oi);
            };


            AddAccount_Button_Message        = FindViewById <Button>(Resource.Id.AddAccount_Button_Message);
            AddAccount_Button_Message.Click += delegate {
                //پیام
                Intent oi = new Intent(this, typeof(Message_Activity));
                StartActivity(oi);
            };
            AddAccount_Button_Basket        = FindViewById <Button>(Resource.Id.AddAccount_Button_Basket);
            AddAccount_Button_Basket.Click += delegate {
                //سبد
                Intent oi = new Intent(this, typeof(Basket_activity));
                StartActivity(oi);
            };
            AddAccount_Button_Home        = FindViewById <Button>(Resource.Id.AddAccount_Button_Home);
            AddAccount_Button_Home.Click += delegate {   //خانه
                Intent oi = new Intent(this, typeof(MainActivity));
                StartActivity(oi);
            };
            AddAccount_TextView_FullName = FindViewById <TextView>(Resource.Id.AddAccount_TextView_FullName);
            AddAccount_EditText_FullName = FindViewById <EditText>(Resource.Id.AddAccount_EditText_FullName);
            AddAccount_TextView_Tel      = FindViewById <TextView>(Resource.Id.AddAccount_TextView_Tel);
            AddAccount_EditText_Tel      = FindViewById <EditText>(Resource.Id.AddAccount_EditText_Tel);
            AddAccount_TextView_Adress   = FindViewById <TextView>(Resource.Id.AddAccount_TextView_Adress);
            AddAccount_EditText_Address  = FindViewById <EditText>(Resource.Id.AddAccount_EditText_Address);

            AddAccount_Button_Save        = FindViewById <Button>(Resource.Id.AddAccount_Button_Save);
            AddAccount_Button_Save.Click += delegate {
                Snackbar snackBar = Snackbar.Make(AddAccount_Button_Save, "عملیات مورد نظر با موفقیت انجام شد", Snackbar.LengthIndefinite).SetAction("تایید", (v) =>
                {
                    Finish();
                });

                //set  action button text color
                snackBar.SetActionTextColor(Android.Graphics.Color.Green);

                snackBar.Show();
            };
        }
Exemple #15
0
        private async void clickBtnRegister(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Email.Text) || string.IsNullOrWhiteSpace(Email.Text))
            {
                displaySnackBar("Fill Email!");
            }
            else if (string.IsNullOrEmpty(Username.Text) || string.IsNullOrWhiteSpace(Username.Text))
            {
                displaySnackBar("Fill username!");
            }
            else if (string.IsNullOrEmpty(Password.Text) || string.IsNullOrWhiteSpace(Password.Text))
            {
                displaySnackBar("Fill password!");
            }
            else if (string.IsNullOrEmpty(ConfirmPassword.Text) || string.IsNullOrWhiteSpace(ConfirmPassword.Text))
            {
                displaySnackBar("Fill column confirm password!");
            }
            else if (string.IsNullOrEmpty(FirstName.Text) || string.IsNullOrWhiteSpace(FirstName.Text))
            {
                displaySnackBar("Fill First name!");
            }
            else if (string.IsNullOrEmpty(LastName.Text) || string.IsNullOrWhiteSpace(LastName.Text))
            {
                displaySnackBar("Fill Last name!");
            }
            else if (Password.Text != ConfirmPassword.Text)
            {
                displaySnackBar("Confirm password do not match with password. Please check them.");
            }
            else
            {
                var progressDialog = new ProgressDialog(this);
                progressDialog.SetCancelable(true);
                progressDialog.SetMessage("Please wait!");
                progressDialog.SetProgressStyle(ProgressDialogStyle.Spinner);
                progressDialog.Show();

                string email           = Email.Text;
                string username        = Username.Text;
                string password        = Password.Text;
                string confirmPassword = ConfirmPassword.Text;
                string fistName        = FirstName.Text;
                string lastName        = LastName.Text;
                string phoneNumber     = PhoneNumber.Text;

                httpClient = new HttpClient();

                var resultForUsername = await httpClient.PostAsync("UrlApiapi/account/checkUsername", new StringContent(JsonConvert.SerializeObject(username), Encoding.UTF8, "application/json"));

                var responseForUsername = await resultForUsername.Content.ReadAsStringAsync();

                var resultForEmail = await httpClient.PostAsync("UrlApiapi/account/checkEmail", new StringContent(JsonConvert.SerializeObject(email), Encoding.UTF8, "application/json"));

                var responseForEmail = await resultForEmail.Content.ReadAsStringAsync();

                if (responseForUsername == "true")
                {
                    displaySnackBar("There exist user with this username.");
                    progressDialog.Hide();
                }
                else if (responseForEmail == "true")
                {
                    displaySnackBar("There exisit new user with this mail.");
                    progressDialog.Hide();
                }
                else
                {
                    string base64Image = "";
                    try
                    {
                        UserImage.BuildDrawingCache(true);
                        BitmapDrawable bd     = (BitmapDrawable)UserImage.Drawable;
                        Bitmap         bitmap = bd.Bitmap;
                        byte[]         imageData;
                        using (MemoryStream stream = new MemoryStream())
                        {
                            bitmap.Compress(Bitmap.CompressFormat.Png, 0, stream);
                            imageData = stream.ToArray();
                        }
                        base64Image = Convert.ToBase64String(imageData);
                    }
                    catch (Exception ex) { }

                    try
                    {
                        var signUp = new SignUp
                        {
                            Email           = email,
                            UserName        = username,
                            FirstName       = fistName,
                            LastName        = lastName,
                            BirthDate       = DateTime.Now.ToString(),
                            Password        = password,
                            PhoneNumber     = phoneNumber,
                            user_image      = base64Image,
                            ConfirmPassword = confirmPassword,
                            Gender          = "M"
                        };

                        var httpClient  = new HttpClient();
                        var jsonContent = JsonConvert.SerializeObject(signUp);
                        var content     = new StringContent(jsonContent, Encoding.UTF8, "application/json");
                        var response    = await httpClient.PostAsync("UrlApiapi/account/Register", content);

                        var responseString = await response.Content.ReadAsStringAsync();

                        Toast.MakeText(this, "Check your email for further details.", ToastLength.Long).Show();
                        progressDialog.Cancel();
                        StartActivity(typeof(LogIn));
                    }
                    catch (HttpRequestException httpEx)
                    {
                        Snackbar bar = Snackbar.Make(linearLayout2, "Please check your internet connection!", Snackbar.LengthLong);
                        Snackbar.SnackbarLayout layout = (Snackbar.SnackbarLayout)bar.View;
                        layout.SetMinimumHeight(100);
                        layout.SetBackgroundColor(Android.Graphics.Color.White);
                        layout.TextAlignment = TextAlignment.Center;
                        layout.ScrollBarSize = 16;
                        bar.SetActionTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Red));
                        bar.SetDuration(Snackbar.LengthIndefinite);
                        bar.SetAction("Ok", (v) => { });
                        bar.Show();
                        progressDialog.Cancel();
                    }
                    catch (Exception ex)
                    {
                        progressDialog.Cancel();
                        Toast.MakeText(this, "Error: " + ex, ToastLength.Long).Show();
                    }
                }
            }
        }
Exemple #16
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            CalligraphyConfig.InitDefault(new CalligraphyConfig.Builder()
                                          .SetDefaultFontPath("Estedad.ttf")

                                          .Build()
                                          );
            string StrId = Intent.GetStringExtra("Id");

            int id = int.Parse(StrId);


            SetContentView(Resource.Layout.layoutSelectEvent);


            using (HttpClient client = new HttpClient())
            {
                client.BaseAddress = new Uri(WebAddress.MyAddress);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                string json                  = JsonConvert.SerializeObject(StrId, Formatting.Indented);
                var    httpContent           = new StringContent(json);
                HttpResponseMessage response = client.PostAsync("api/FindEventsItem/" + id, httpContent).Result;
                //var response = await client.PostAsync("api/FindEventsItem/", content);
                if (response.IsSuccessStatusCode)
                {
                    response.EnsureSuccessStatusCode();
                    var responseJsonString = await response.Content.ReadAsStringAsync();

                    var result = JsonConvert.DeserializeObject(responseJsonString);

                    objr = JsonConvert.DeserializeObject <Event>(result.ToString());
                }
            }

            var font = Typeface.CreateFromAsset(Assets, "Estedad.ttf");

            selecteventxtviewaddress          = FindViewById <TextView>(Resource.Id.selecteventxtviewaddress);
            selecteventxtviewaddress.Typeface = font;
            string txtviewaddress = selecteventxtviewaddress.Text;
            string numberdigit    = txtviewaddress.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            selecteventxtviewaddress.Text = numberdigit;

            selecteventtxtviewcaptionaddress          = FindViewById <TextView>(Resource.Id.selecteventtxtviewcaptionaddress);
            selecteventtxtviewcaptionaddress.Typeface = font;
            string txtviewcaptionaddress = selecteventtxtviewcaptionaddress.Text;
            string numberdigittwo        = txtviewcaptionaddress.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            selecteventtxtviewcaptionaddress.Text = numberdigittwo;

            selecteventxtviewurl          = FindViewById <TextView>(Resource.Id.selecteventxtviewurl);
            selecteventxtviewurl.Typeface = font;
            string txtviewurl       = selecteventxtviewurl.Text;
            string numberdigitthree = txtviewurl.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            selecteventxtviewurl.Text = numberdigitthree;

            selecteventtxtviewcaptionurl          = FindViewById <TextView>(Resource.Id.selecteventtxtviewcaptionurl);
            selecteventtxtviewcaptionurl.Typeface = font;
            string tviewcaptionurl = selecteventtxtviewcaptionurl.Text;
            string numberdigitfor  = tviewcaptionurl.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            selecteventtxtviewcaptionurl.Text = numberdigitfor;

            selecteventtxtviewcaptiongroup                = FindViewById <TextView>(Resource.Id.selecteventtxtviewcaptiongroup);
            selecteventtxtviewcaptiongroup.Typeface       = font;
            selecteventtxtviewcaptionplace                = FindViewById <TextView>(Resource.Id.selecteventtxtviewcaptionplace);
            selecteventtxtviewcaptionplace.Typeface       = font;
            selecteventtxtviewcaptiontime                 = FindViewById <TextView>(Resource.Id.selecteventtxtviewcaptiontime);
            selecteventtxtviewcaptiontime.Typeface        = font;
            selecteventtxtviewcaptioncost                 = FindViewById <TextView>(Resource.Id.selecteventtxtviewcaptioncost);
            selecteventtxtviewcaptioncost.Typeface        = font;
            selecteventtxtviewcaptiondescription          = FindViewById <TextView>(Resource.Id.selecteventtxtviewcaptiondescription);
            selecteventtxtviewcaptiondescription.Typeface = font;


            selecteventxtviecaunt          = FindViewById <TextView>(Resource.Id.selecteventxtviecaunt);
            selecteventxtviecaunt.Typeface = font;
            selecteventvpagerslider        = FindViewById <ViewPager>(Resource.Id.selecteventvpagerslider);

            selecteventvpagerslider.Adapter = new SelectImageImageAdapter(this, objr.Image);
            //    (this);
            var dots = FindViewById <TabLayout>(Resource.Id.selecteventtablayoutdots);

            dots.SetupWithViewPager(selecteventvpagerslider, true);

            btncobtactus          = FindViewById <Button>(Resource.Id.button);
            btncobtactus.Typeface = font;

            btncobtactus.Click += delegate {
                //اطلاعات تماس
                ContentTelFragment fdlg = new ContentTelFragment(this, id);
                fdlg.Show(this.FragmentManager, "ContenttellFragmentShow");
            };
            selecteventtxtviewcaption          = FindViewById <TextView>(Resource.Id.selecteventtxtviewcaption);
            selecteventtxtviewcaption.Typeface = font;
            selecteventtxtviewcaption.Text     = objr.CaptionEvent;
            selecteventbtnenterevent           = FindViewById <Button>(Resource.Id.selecteventbtnenterevent);

            //var fontenterevent = Typeface.CreateFromAsset(Assets, "titr.ttf");
            selecteventbtnenterevent.Typeface = font;
            selecteventbtnenterevent.Click   += delegate { StartActivity(typeof(EnterEvent)); };

            selecteventtxtviewcaptionfgfg          = FindViewById <TextView>(Resource.Id.selecteventtxtviewcaption);
            selecteventtxtviewcaptionfgfg.Typeface = font;
            selecteventimgbtnlogo = FindViewById <ImageButton>(Resource.Id.selecteventimgbtnlogo);

            selecteventimgbtnlogo.Click += delegate { StartActivity(typeof(MainActivity)); };



            selecteventtxtviewmajor          = FindViewById <TextView>(Resource.Id.selecteventtxtviewmajor);
            selecteventtxtviewmajor.Typeface = font;

            selecteventtxtviewsport          = FindViewById <TextView>(Resource.Id.selecteventtxtviewsport);
            selecteventtxtviewsport.Typeface = font;
            // selecteventtxtviewsport.Text = "dfdfd;";
            if (objr.Type == Event.TypeEvent.ClassLearn)
            {
                selecteventtxtviewsport.Text = "کلاس های آموزشی";
            }
            if (objr.Type == Event.TypeEvent.Cultrual)
            {
                selecteventtxtviewsport.Text = "فرهنگی هنری";
            }
            if (objr.Type == Event.TypeEvent.Food)
            {
                selecteventtxtviewsport.Text = "خوراکی";
            }
            if (objr.Type == Event.TypeEvent.Health)
            {
                selecteventtxtviewsport.Text = "سلامتی و زیبایی";
            }
            if (objr.Type == Event.TypeEvent.Public)
            {
                selecteventtxtviewsport.Text = "داوطلبانه و مردمی;";
            }
            if (objr.Type == Event.TypeEvent.Religuse)
            {
                selecteventtxtviewsport.Text = "خوراکی";
            }
            if (objr.Type == Event.TypeEvent.Sciences)
            {
                selecteventtxtviewsport.Text = "علمی و تخصصی";
            }
            if (objr.Type == Event.TypeEvent.Sport)
            {
                selecteventtxtviewsport.Text = "ورزشی";
            }
            if (objr.Type == Event.TypeEvent.Toursm)
            {
                selecteventtxtviewsport.Text = "گردشگری";
            }

            selecteventtxtviewplace          = FindViewById <TextView>(Resource.Id.selecteventtxtviewplace);
            selecteventtxtviewplace.Typeface = font;
            if (objr.Address != null)
            {
                foreach (var item in objr.Address)
                {
                    selecteventtxtviewplace.Text = item.AddressTwo;
                }
            }



            selecteventtxtviewdate          = FindViewById <TextView>(Resource.Id.selecteventtxtviewdate);
            selecteventtxtviewdate.Typeface = font;
            // "22اردیبهشت تا 25شهریور"


            string ttxtviewdate    = selecteventtxtviewdate.Text = objr.ToDate + "تا" + objr.FromDate;
            string numberdigitdate = ttxtviewdate.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            selecteventtxtviewdate.Text = numberdigitdate;



            selecteventtxtviewmajor          = FindViewById <TextView>(Resource.Id.selecteventtxtviewmajor);
            selecteventtxtviewmajor.Typeface = font;
            selecteventtxtviewmajor.Text     = objr.CaptionEvent;

            selecteventtxtviewprice          = FindViewById <TextView>(Resource.Id.selecteventtxtviewprice);
            selecteventtxtviewprice.Typeface = font;
            string txtviewrice;

            if (objr.Payed == Event.Cost.AddCost)
            {
                selecteventtxtviewprice.Text = "تومان" + objr.Price;
            }
            if (objr.Payed == Event.Cost.Free)
            {
                selecteventtxtviewprice.Text = "رایگان";
            }
            if (objr.Payed == Event.Cost.NotCost)
            {
                selecteventtxtviewprice.Text = "هزینه درج نشود";
            }


            txtviewrice = selecteventtxtviewprice.Text = "تومان" + objr.Price;
            string numberdigitprice = txtviewrice.Replace("0", "٠").Replace("1", "١").Replace("2", "٢").Replace("3", "٣").Replace("4", "٤").Replace("5", "٥").Replace("6", "٦").Replace("7", "٧").Replace("8", "٨").Replace("9", "٩");

            selecteventtxtviewprice.Text = numberdigitprice;



            selecteventxtviewdescription          = FindViewById <TextView>(Resource.Id.selecteventxtviewdescription);
            selecteventxtviewdescription.Typeface = font;
            selecteventxtviewdescription.Text     = objr.Description;

            selecteventbtnreport          = FindViewById <Button>(Resource.Id.selecteventbtnreport);
            selecteventbtnreport.Typeface = font;
            selecteventbtnreport.Click   += delegate {
                Controller.Fragment.Reportevent fdlg = new Controller.Fragment.Reportevent(this);
                fdlg.Show(this.FragmentManager, "ebrahimfragmentreportevent");
            };



            selecteventbtncomment          = FindViewById <Button>(Resource.Id.selecteventbtncomment);
            selecteventbtncomment.Typeface = font;
            selecteventbtncomment.Click   += delegate {
                //نظرات رویداد
                Intent oi = new Intent(this, typeof(CustomActivity.Comment_Activity));
                StartActivity(oi);
            };

            selecteventbtnshare          = FindViewById <Button>(Resource.Id.selecteventbtnshare);
            selecteventbtnshare.Typeface = font;
            selecteventbtnshare.Click   += delegate
            {
                Intent sharingIntent = new Intent(Android.Content.Intent.ActionSend);
                //در خط زیر نوع داده ای که قراره به اشتراک گذاشته بشه رو تعیین میکنیم که تو این کد یه متن تعریف شده
                sharingIntent.SetType("text/plain");
                sharingIntent.PutExtra(Android.Content.Intent.ExtraSubject, "اشتراک");
                string text = selecteventtxtviewmajor.Text + string.Empty + selecteventtxtviewsport.Text + string.Empty + selecteventtxtviewplace.Text + string.Empty + selecteventtxtviewdate.Text + string.Empty + selecteventtxtviewprice.Text + string.Empty + selecteventxtviewdescription.Text;
                sharingIntent.PutExtra(Android.Content.Intent.ExtraText, text);
                StartActivity(Intent.CreateChooser(sharingIntent, "اشتراک با"));
            };

            selecteventbtnbookmark          = FindViewById <Button>(Resource.Id.selecteventbtnbookmark);
            selecteventbtnbookmark.Typeface = font;
            selecteventbtnbookmark.Click   += delegate {
                Snackbar snackBar = Snackbar.Make(selecteventbtnbookmark, "رویداد مورد نظر ذخیره شد", Snackbar.LengthIndefinite).SetAction("باشه", (v) =>
                {
                });

                //set  action button text color
                snackBar.SetActionTextColor(Android.Graphics.Color.Green);

                snackBar.Show();
            };
        }