Пример #1
0
        /// <summary>
        /// 적용 버튼
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void btnAdapt_Click(object sender, EventArgs e)
        {
            bool bIsLangChanged = false;

            mSettingStruct.ThemeType = (Const.ThemeType)cboxMainTheme.SelectedIndex;
            mSettingStruct.StyleType = (Const.StyleType)cboxSubStyle.SelectedIndex;
            if (mSettingStruct.LanguageType != (Const.LanguageType)cboxLanguage.SelectedIndex)
            {
                mSettingStruct.LanguageType = (Const.LanguageType)cboxLanguage.SelectedIndex;
                bIsLangChanged = true;
            }

            AppConfigMgr.SetAppConfig(Const.APP_SETTING_THEME, (int)mSettingStruct.ThemeType);
            AppConfigMgr.SetAppConfig(Const.APP_SETTING_STYLE, (int)mSettingStruct.StyleType);
            AppConfigMgr.SetAppConfig(Const.APP_SETTING_LANGUAGE, (int)mSettingStruct.LanguageType);
            if (toggleTrayIcon.Checked)
            {
                AppConfigMgr.SetAppConfig(Const.APP_SETTING_TRAYICON, Const.STRING_TRUE);
            }
            else
            {
                AppConfigMgr.SetAppConfig(Const.APP_SETTING_TRAYICON, Const.STRING_FALSE);
            }
            mSettingStruct.TrayIconEnable = toggleTrayIcon.Checked;

            if (bIsLangChanged)
            {
                DialogResult result = MessageBox.Show("언어가 변경되었습니다. 재시작 하시겠습니까?", "언어 변경", MessageBoxButtons.YesNo);
                if (result == DialogResult.Yes)
                {
                    Application.Restart();
                }
                else
                {
                    MessageBox.Show("언어는 재시작 이후에 적용됩니다.");
                    this.DialogResult = DialogResult.OK;
                    Close();
                }
            }
            else
            {
                this.DialogResult = DialogResult.OK;
                Close();
            }
        }
Пример #2
0
        /// <summary>
        /// 설정값 불러오기
        /// </summary>
        private void InitSettings()
        {
            #region 버튼간 Margin 값
            try
            {
                mSettingStruct.Margin = int.Parse(AppConfigMgr.GetAppConfig(Const.APP_SETTING_MARGIN));
                if (mSettingStruct.Margin < 0)
                {
                    mSettingStruct.Margin = Const.DEFAULT_MARGIN;
                }
            }
            catch (ArgumentNullException)
            {
                mSettingStruct.Margin = Const.DEFAULT_MARGIN;
            }
            #endregion

            #region 언어 설정값
            try
            {
                int nLangType = int.Parse(AppConfigMgr.GetAppConfig(Const.APP_SETTING_LANGUAGE));
                if (nLangType > (int)Const.LanguageType.Max)
                {
                    mSettingStruct.LanguageType = Const.DEFAULT_LANGUAGE;
                }
                else
                {
                    mSettingStruct.LanguageType = (Const.LanguageType)nLangType;
                }
            }
            catch (ArgumentNullException)
            {
                mSettingStruct.LanguageType = Const.DEFAULT_LANGUAGE;
            }

            switch (mSettingStruct.LanguageType)
            {
            case Const.LanguageType.English:
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
                break;

            case Const.LanguageType.Korean:
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("ko-KR");
                break;

            default:
                Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
                break;
            }
            #endregion

            #region 테마 설정값
            try
            {
                int nThemeType = int.Parse(AppConfigMgr.GetAppConfig(Const.APP_SETTING_THEME));
                if (nThemeType > (int)Const.ThemeType.Max)
                {
                    mSettingStruct.ThemeType = Const.DEFAULT_THEME;
                }
                else
                {
                    mSettingStruct.ThemeType = (Const.ThemeType)nThemeType;
                }
            }
            catch (ArgumentNullException)
            {
                mSettingStruct.ThemeType = Const.DEFAULT_THEME;
            }
            #endregion

            #region 스타일 설정값
            try
            {
                int nStyleType = int.Parse(AppConfigMgr.GetAppConfig(Const.APP_SETTING_STYLE));
                if (nStyleType > (int)Const.StyleType.Max)
                {
                    mSettingStruct.StyleType = Const.DEFAULT_STYLE;
                }
                else
                {
                    mSettingStruct.StyleType = (Const.StyleType)nStyleType;
                }
            }
            catch (ArgumentNullException)
            {
                mSettingStruct.StyleType = Const.DEFAULT_STYLE;
            }
            #endregion

            #region 트레이 아이콘 사용 유무
            try
            {
                string strTrue = AppConfigMgr.GetAppConfig(Const.APP_SETTING_TRAYICON);
                if (strTrue != null)
                {
                    if (strTrue.Equals(Const.STRING_TRUE))
                    {
                        mSettingStruct.TrayIconEnable = true;
                    }
                    else
                    {
                        mSettingStruct.TrayIconEnable = false;
                    }
                }
                else
                {
                    mSettingStruct.TrayIconEnable = false;
                }
            }
            catch (ArgumentNullException)
            {
                mSettingStruct.TrayIconEnable = false;
            }
            #endregion
        }