コード例 #1
0
        private bool ValidateExit(bool Exit = false)
        {
            bool IsChanged = false;

            try
            {
                IsChanged = !(
                    CSIWebServerName == CSIWebServerEdit.Text &&
                    Configuration == ((string)ConfigurationSpinner.SelectedItem ?? string.Empty) &&
                    Theme == InterpretThemeValue(((string)ThemeSpinner.SelectedItem ?? string.Empty)) &&
                    SavedUser == UserEdit.Text &&
                    SavedPassword == PasswordEdit.Text &&
                    EnableHTTPS == EnableHTTPSSwitch.Checked &&
                    UseRESTForRequest == UseRESTForRequestSwitch.Checked &&
                    LoadPicture == LoadPictureSwitch.Checked &&
                    ForceAutoPost == ForceAutoPostSwitch.Checked &&
                    ShowSuccessMessage == ShowSuccessMessageSwitch.Checked &&
                    RecordCap == RecordCapEdit.Text &&
                    SaveUser == SaveUserSwitch.Checked &&
                    SavePassword == SavePasswordSwitch.Checked
                    );
                if (IsChanged)
                {
                    FragmentTransaction ft            = FragmentManager.BeginTransaction();
                    CSIMessageDialog    SignOutDialog = new CSIMessageDialog(GetString(Resource.String.app_name), GetString(Resource.String.SettingChanged), DialogTypes.YesNoCancle, this.BaseActivity);
                    SignOutDialog.YesHandler += (sender, args) =>
                    {
                        bool bChangeTheme = false;
                        if (CSISystemContext.CSIWebServerName != Theme)
                        {
                            bChangeTheme = true;
                        }
                        SaveConfiguration();
                        if (Exit)
                        {
                            Dismiss();
                            Dispose();
                            if (bChangeTheme)
                            {
                                Intent intent = new Intent(Application.Context, typeof(MainActivity));
                                Bundle bundle = BaseActivity.GetCSISystemContext().BuildBundle();
                                intent.PutExtra("CSISystemContext", bundle);
                                BaseActivity.StartActivity(intent);
                                BaseActivity.Finish();
                            }
                        }
                    };
                    SignOutDialog.NoHandler += (sender, args) =>
                    {
                        CSISystemContext.CSIWebServerName   = CSIWebServerName;
                        CSISystemContext.Theme              = Theme;
                        CSISystemContext.SavedUser          = SavedUser;
                        CSISystemContext.SavedPassword      = SavedPassword;
                        CSISystemContext.EnableHTTPS        = EnableHTTPS;
                        CSISystemContext.UseRESTForRequest  = UseRESTForRequest;
                        CSISystemContext.LoadPicture        = LoadPicture;
                        CSISystemContext.ForceAutoPost      = ForceAutoPost;
                        CSISystemContext.ShowSuccessMessage = ShowSuccessMessage;
                        CSISystemContext.RecordCap          = RecordCap;
                        CSISystemContext.SaveUser           = SaveUser;
                        CSISystemContext.SavePassword       = SavePassword;
                        if (Exit)
                        {
                            Dismiss();
                            Dispose();
                        }
                    };
                    SignOutDialog.CancelHandler += (sender, args) =>
                    {
                    };
                    SignOutDialog.Show(ft, "");
                }
                else
                {
                    Dismiss();
                    Dispose();
                }
            }
            catch (Exception Ex)
            {
                WriteErrorLog(Ex);
                return(false);
            }
            return(true);
        }