Exemplo n.º 1
0
 public string GetAppVersion()
 {
     if (!SettingHelper.CheckKeyExist(n_AppVersion))
     {
         return(null);
     }
     else
     {
         var value = SettingHelper.GetValue(n_AppVersion).ToString();
         return(value);
     }
 }
Exemplo n.º 2
0
        public void InitSettingData()
        {
            try
            {
                #region    //自动添加书架
                try
                {
                    if (!SettingHelper.CheckKeyExist(n_IfAutAddToShelf))
                    {
                        SettingHelper.SetValue(n_IfAutAddToShelf, true);
                        m_IfAutAddToShelf = true;
                    }
                    else
                    {
                        m_IfAutAddToShelf = (bool)SettingHelper.GetValue(n_IfAutAddToShelf);
                    }
                }
                catch (Exception)
                {
                    SettingHelper.SetValue(n_IfAutAddToShelf, true);
                    m_IfAutAddToShelf = true;
                }

                #endregion

                #region  //在流量下下载
                try
                {
                    if (!SettingHelper.CheckKeyExist(n_IfDownloadInWAAN))
                    {
                        SettingHelper.SetValue(n_IfDownloadInWAAN, false);
                        m_IfDownloadInWAAN = false;
                    }
                    else
                    {
                        m_IfDownloadInWAAN = (bool)SettingHelper.GetValue(n_IfDownloadInWAAN);
                    }
                }
                catch (Exception)
                {
                    SettingHelper.SetValue(n_IfDownloadInWAAN, false);
                    m_IfDownloadInWAAN = false;
                }

                #endregion

                #region  //正文字体大小
                try
                {
                    if (!SettingHelper.CheckKeyExist(n_TextFontSzie))
                    {
                        SettingHelper.SetValue(n_TextFontSzie, "20");
                        m_TextFontSzie = 20;
                    }
                    else
                    {
                        string value = SettingHelper.GetValue(n_TextFontSzie).ToString();
                        m_TextFontSzie = Convert.ToInt32(value);
                    }
                }
                catch (Exception)
                {
                    SettingHelper.SetValue(n_TextFontSzie, "20");
                    m_TextFontSzie = 20;
                }

                #endregion

                #region  //正文行间距
                try
                {
                    if (!SettingHelper.CheckKeyExist(n_LineHeight))
                    {
                        SettingHelper.SetValue(n_LineHeight, 35);
                        m_LineHeight = 35;
                    }
                    else
                    {
                        string value = SettingHelper.GetValue(n_LineHeight).ToString();
                        m_LineHeight = Convert.ToInt32(value);
                    }
                }
                catch (Exception)
                {
                    SettingHelper.SetValue(n_LineHeight, 35);
                    m_LineHeight = 35;
                }

                #endregion

                #region //设置夜间模式

                try
                {
                    if (!SettingHelper.CheckKeyExist(n_IsNightModel))
                    {
                        SettingHelper.SetValue(n_IsNightModel, false);
                        m_IsNightModel = false;
                    }
                    else
                    {
                        m_IsNightModel = (bool)SettingHelper.GetValue(n_IsNightModel);
                    }
                }
                catch (Exception)
                {
                    SettingHelper.SetValue(n_IsNightModel, false);
                    m_IsNightModel = false;
                }
                finally
                {
                    SetNightMode(m_IsNightModel);
                }

                #endregion

                #region   //设置横向模式
                try
                {
                    if (!SettingHelper.CheckKeyExist(n_IsLandscape))
                    {
                        SettingHelper.SetValue(n_IsLandscape, false);
                        m_IsLandscape = false;
                    }
                    else
                    {
                        var value = (bool)SettingHelper.GetValue(n_IsLandscape);
                        m_IsLandscape = value;
                    }
                }
                catch (Exception)
                {
                    SettingHelper.SetValue(n_IsLandscape, false);
                    m_IsLandscape = false;
                }
                finally
                {
                    SetLandscape(m_IsLandscape);
                }

                #endregion

                #region   //设置预读
                try
                {
                    if (!SettingHelper.CheckKeyExist(n_IsPreLoad))
                    {
                        SettingHelper.SetValue(n_IsPreLoad, true);
                        m_IsPreLoad = true;
                    }
                    else
                    {
                        var value = (bool)SettingHelper.GetValue(n_IsPreLoad);
                        m_IsPreLoad = value;
                    }
                }
                catch (Exception)
                {
                    SettingHelper.SetValue(n_IsPreLoad, true);
                    m_IsPreLoad = true;
                }
                #endregion

                #region   //设置阅读背景色
                try
                {
                    if (!SettingHelper.CheckKeyExist(n_ContentBackColor))
                    {
                        SettingHelper.SetValue(n_ContentBackColor, this.ColorList[0].Color.ToString());
                        m_ContentBackColor = this.ColorList[0];
                    }
                    else
                    {
                        var value = SettingHelper.GetValue(n_ContentBackColor);
                        m_ContentBackColor = this.ColorList.ToList().FirstOrDefault(p => p.Color.ToString().Equals(value)) ??
                                             this.ColorList[0];
                    }
                }
                catch (Exception)
                {
                    SettingHelper.SetValue(n_ContentBackColor, this.ColorList[0].Color.ToString());
                    m_ContentBackColor = this.ColorList[0];
                }
                #endregion

                #region //亮度
                try
                {
                    if (!SettingHelper.CheckKeyExist(n_LightValue))
                    {
                        SettingHelper.SetValue(n_LightValue, 100);
                        m_LightValue = 100;
                    }
                    else
                    {
                        string value = SettingHelper.GetValue(n_LightValue).ToString();
                        m_LightValue = Convert.ToDouble(value) < 20 ? 20 : Convert.ToDouble(value);
                    }
                }
                catch (Exception)
                {
                    SettingHelper.SetValue(n_LightValue, 100);
                    m_LightValue = 100;
                }
                #endregion

                #region  //是否分页阅读
                try
                {
                    if (!SettingHelper.CheckKeyExist(n_IsReadByPageMode))
                    {
                        SettingHelper.SetValue(n_IsReadByPageMode, true);
                        m_IsReadByPageMode = true;
                    }
                    else
                    {
                        var value = (bool)SettingHelper.GetValue(n_IsReadByPageMode);
                        m_IsReadByPageMode = value;
                    }
                }
                catch (Exception)
                {
                    SettingHelper.SetValue(n_IsReadByPageMode, true);
                    m_IsReadByPageMode = true;
                }

                #endregion

                #region  //是否开启切换动画
                try
                {
                    if (!SettingHelper.CheckKeyExist(n_SwitchAnimation))
                    {
                        SettingHelper.SetValue(n_SwitchAnimation, true);
                        m_SwitchAnimation = true;
                    }
                    else
                    {
                        var value = (bool)SettingHelper.GetValue(n_SwitchAnimation);
                        m_SwitchAnimation = value;
                    }
                }
                catch (Exception)
                {
                    SettingHelper.SetValue(n_SwitchAnimation, true);
                    m_SwitchAnimation = true;
                }

                #endregion
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                SetDefaultSetting();
            }
        }