private void buttonOK_Click(object sender, System.EventArgs args)
        {
            if (!this.checkLockAfterTime.Checked)
            {
                this.originalConfig.LockWorkspace.LockAfterTime = 0;
            }
            else
            {
                this.originalConfig.LockWorkspace.LockAfterTime = (uint)this.numericLockAfterTime.Value;
            }

            if (!this.checkLockGlobalTime.Checked)
            {
                this.originalConfig.LockWorkspace.LockGlobalTime = 0;
            }
            else
            {
                this.originalConfig.LockWorkspace.LockGlobalTime = (uint)this.numericLockGlobalTime.Value;
            }

            var tmpRequested = this.checkAutoRun.Checked;
            var currentValue = NativeShellHelper.GetStartWithWindows(ApplicationDefines.AutoRunName);

            if (tmpRequested != currentValue)
            {
                var tmpExecutablePath = WindowsUtils.GetExecutablePath().Trim();
                if (tmpExecutablePath.StartsWith("\"") == false)
                {
                    tmpExecutablePath = "\"" + tmpExecutablePath + "\"";
                }

                NativeShellHelper.SetStartWithWindows(ApplicationDefines.AutoRunName, tmpExecutablePath, tmpRequested);
            }

            this.originalConfig.SecretRank.Rank0BackColor = this.colorComboRank0.Color;
            this.originalConfig.SecretRank.Rank1BackColor = this.colorComboRank1.Color;
            this.originalConfig.SecretRank.Rank2BackColor = this.colorComboRank2.Color;
            this.originalConfig.SecretRank.Rank3BackColor = this.colorComboRank3.Color;

            ApplicationConfigSerializer.SaveApplicationConfig(Program.Config);

            var tmpNewWorkDirectory = this.textWorkDirectory.Text;
            var tmpOldWorkDirectory = NativeShellHelper.GetWorkingDirectory();

            if (System.IO.Directory.Exists(tmpNewWorkDirectory))
            {
                if (tmpNewWorkDirectory != tmpOldWorkDirectory)
                {
                    MoveDirectoryTo(System.IO.Path.Combine(tmpOldWorkDirectory, "data"), tmpNewWorkDirectory);
                    MoveDirectoryTo(System.IO.Path.Combine(tmpOldWorkDirectory, "config"), tmpNewWorkDirectory);

                    Program.Config.WorkingDirectory = tmpNewWorkDirectory;
                    NativeShellHelper.SetWorkingDirectory(tmpNewWorkDirectory);
                    HuiruiSoft.Data.Configuration.DataBaseConfig.DataSource = System.IO.Path.Combine(Program.Config.WorkingDirectory, ApplicationDefines.SafePassDbFile);
                }
            }

            this.DialogResult = DialogResult.OK;
        }
        public static bool CheckApplicationReadied()
        {
            var tmpWorkDirectory = NativeShellHelper.GetWorkingDirectory();

            if (string.IsNullOrEmpty(tmpWorkDirectory))
            {
                return(false);
            }

            var tmpConfigFileName = System.IO.Path.Combine(tmpWorkDirectory, MainConfigFile);

            if (!System.IO.File.Exists(tmpConfigFileName))
            {
                return(false);
            }

            var tmpDataDirectory = System.IO.Path.Combine(tmpWorkDirectory, ApplicationDefines.SafePassDbFile);

            return(System.IO.File.Exists(tmpDataDirectory));
        }
        protected override void OnLoad(System.EventArgs args)
        {
            base.OnLoad(args);

            if (!base.DesignMode)
            {
                this.CancelButton               = this.buttonCancel;
                this.textPassword.MaxLength     = 50;
                this.textLoginName.MaxLength    = 30;
                this.textSafePassName.MaxLength = 50;
                this.textWorkDirectory.ReadOnly = true;
                this.textPassword.PasswordChar  = '*';
                this.textPassword.ImeMode       = ImeMode.Disable;
                this.textPwdRepeat.ImeMode      = ImeMode.Disable;
                this.textLoginName.ImeMode      = ImeMode.Disable;

                this.Icon                       = WindowsUtils.DefaultAppIcon;
                this.buttonOK.Text              = SafePassResource.ButtonOK;
                this.buttonCancel.Text          = SafePassResource.ButtonCancel;
                this.Text                       = SafePassResource.NewWizardWindowCaption;
                this.labelLoginName.Text        = SafePassResource.NewWizardWindowLabelLoginName;
                this.labelPassword.Text         = SafePassResource.NewWizardWindowLabelPassword;
                this.labelPwdRepeat.Text        = SafePassResource.NewWizardWindowLabelPwdRepeat;
                this.labelPwdQuality.Text       = SafePassResource.NewWizardWindowLabelPwdQuality;
                this.labelSafePassName.Text     = SafePassResource.NewWizardWindowLabelSafePassName;
                this.labelWorkDirectory.Text    = SafePassResource.NewWizardWindowLabelWorkDirectory;
                this.buttonSelectDirectory.Text = SafePassResource.NewWizardWindowButtonSelectDirectory;
                this.labelPromptRemember.Text   = SafePassResource.NewWizardWindowPromptRememberPassword;

                WindowsUtils.SetShowPasswordImage(this.buttonShowPassword, true);

                var tmpWorkDirectory = NativeShellHelper.GetWorkingDirectory();
                if (string.IsNullOrEmpty(tmpWorkDirectory))
                {
                    tmpWorkDirectory = System.IO.Path.Combine(NativeShellHelper.GetLocalDataDirectory(), @"HuiruiSoft\SafePass");
                }
                this.textWorkDirectory.Text = tmpWorkDirectory;
            }
        }