示例#1
0
        public ShareSettingWindow(ShareSetting shareSetting)
        {
            ShareSetting = shareSetting;

            this.InitializeComponent();

            //为LbDisplayedSites添加项
            foreach (var site in Share.GetSortedSites())
            {
                if (site != Share.Sites.None)
                {
                    LbDisplayedSites.Items.Add(site);
                    if (ShareSetting.DisplayedSites.Contains(site))
                    {
                        LbDisplayedSites.SelectedItems.Add(site);
                    }
                }
            }

            //显示的分享网站有改变
            LbDisplayedSites.SelectionChanged += delegate
            {
                ShareSetting.DisplayedSites = new List <Share.Sites>();
                foreach (Share.Sites site in LbDisplayedSites.SelectedItems)
                {
                    ShareSetting.DisplayedSites.Add(site);
                }
                (Owner as DoubanFMWindow).ApplyShareSetting();
            };

            //为LbOneKeyShareSites添加项
            foreach (var site in Share.GetSortedSites())
            {
                LbOneKeyShareSites.Items.Add(site);
                if (ShareSetting.OneKeyShareSites.Contains(site))
                {
                    LbOneKeyShareSites.SelectedItems.Add(site);
                }
            }

            //一键分享网站有改变
            LbOneKeyShareSites.SelectionChanged += delegate
            {
                ShareSetting.OneKeyShareSites = new List <Share.Sites>();
                foreach (Share.Sites site in LbOneKeyShareSites.SelectedItems)
                {
                    ShareSetting.OneKeyShareSites.Add(site);
                }
                (Owner as DoubanFMWindow).ApplyShareSetting();
            };
        }
		public ShareSettingWindow(ShareSetting shareSetting)
		{
			ShareSetting = shareSetting;

			this.InitializeComponent();

			//为LbDisplayedSites添加项
			foreach (var site in Share.GetSortedSites())
			{
				if (site != Share.Sites.None)
				{
					LbDisplayedSites.Items.Add(site);
					if (ShareSetting.DisplayedSites.Contains(site))
						LbDisplayedSites.SelectedItems.Add(site);
				}
			}

			//显示的分享网站有改变
			LbDisplayedSites.SelectionChanged += delegate
			{
				ShareSetting.DisplayedSites = new List<Share.Sites>();
				foreach (Share.Sites site in LbDisplayedSites.SelectedItems)
				{
					ShareSetting.DisplayedSites.Add(site);
				}
				(Owner as DoubanFMWindow).ApplyShareSetting();
			};

			//为LbOneKeyShareSites添加项
			foreach (var site in Share.GetSortedSites())
			{
				LbOneKeyShareSites.Items.Add(site);
				if (ShareSetting.OneKeyShareSites.Contains(site))
					LbOneKeyShareSites.SelectedItems.Add(site);
			}

			//一键分享网站有改变
			LbOneKeyShareSites.SelectionChanged += delegate
			{
				ShareSetting.OneKeyShareSites = new List<Share.Sites>();
				foreach (Share.Sites site in LbOneKeyShareSites.SelectedItems)
				{
					ShareSetting.OneKeyShareSites.Add(site);
				}
				(Owner as DoubanFMWindow).ApplyShareSetting();
			};
		}
示例#3
0
		/// <summary>
		/// 加载设置
		/// </summary>
		internal static ShareSetting Load()
		{
			ShareSetting setting = null;
			try
			{
				using (FileStream stream = File.OpenRead(Path.Combine(_dataFolder, "ShareSetting.dat")))
				{
					BinaryFormatter formatter = new BinaryFormatter();
					setting = (ShareSetting)formatter.Deserialize(stream);
				}
			}
			catch
			{
				setting = new ShareSetting();
			}
			return setting;
		}
示例#4
0
        /// <summary>
        /// 加载设置
        /// </summary>
        internal static ShareSetting Load()
        {
            ShareSetting setting = null;

            try
            {
                using (FileStream stream = File.OpenRead(Path.Combine(_dataFolder, "ShareSetting.dat")))
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    setting = (ShareSetting)formatter.Deserialize(stream);
                }
            }
            catch
            {
                setting = new ShareSetting();
            }
            return(setting);
        }
示例#5
0
        protected ShareSetting(SerializationInfo info, StreamingContext context)
        {
            ShareSetting def = new ShareSetting();

            try { EnableOneKeyShare = info.GetBoolean("EnableOneKeyShare"); }
            catch { }

            #region 兼容1.7.4及更早版本的保存方式
            bool isOld = false;
            try
            {
                OneKeyShareSites = info.GetValue("OneKeyShareSites", typeof(List <Share.Sites>)) as List <Share.Sites>;
                isOld            = true;
            }
            catch
            {
                OneKeyShareSites = def.OneKeyShareSites;
            }
            try
            {
                DisplayedSites = info.GetValue("DisplayedSites", typeof(List <Share.Sites>)) as List <Share.Sites>;
                isOld          = true;
            }
            catch
            {
                DisplayedSites = def.DisplayedSites;
            }
            if (isOld)
            {
                foreach (var site in Share.GetSortedSites())
                {
                    //如果出现了1.7.4及之前版本中没出现的网站,则默认显示
                    //这里列出的是1.7.4版本中已定义的网站列表
                    if (site != Share.Sites.None &&
                        site != Share.Sites.Douban &&
                        site != Share.Sites.Weibo &&
                        site != Share.Sites.Msn &&
                        site != Share.Sites.Kaixin &&
                        site != Share.Sites.Renren &&
                        site != Share.Sites.TencentWeibo &&
                        site != Share.Sites.Fanfou &&
                        site != Share.Sites.Facebook &&
                        site != Share.Sites.Twitter)
                    {
                        DisplayedSites.Add(site);
                    }
                }
            }
            #endregion

            #region 1.7.5及更高版本的保存方式
            if (!isOld)
            {
                DisplayedSites   = new List <Share.Sites>();
                OneKeyShareSites = new List <Share.Sites>();
                foreach (var site in Share.GetSortedSites())
                {
                    try
                    {
                        bool value = info.GetBoolean("DisplayedSites_" + site);
                        if (value)
                        {
                            DisplayedSites.Add(site);
                        }
                    }
                    catch
                    {
                        //说明这是更新为新版本后新增加的网站
                        DisplayedSites.Add(site);
                    }

                    try
                    {
                        bool value = info.GetBoolean("OneKeyShareSites_" + site);
                        if (value)
                        {
                            OneKeyShareSites.Add(site);
                        }
                    }
                    catch
                    {
                        //新增加的网站默认不设置一键分享
                    }
                }
            }
            #endregion
        }
示例#6
0
		protected ShareSetting(SerializationInfo info, StreamingContext context)
		{
			ShareSetting def = new ShareSetting();

			try { EnableOneKeyShare = info.GetBoolean("EnableOneKeyShare"); }
			catch { }

			#region 兼容1.7.4及更早版本的保存方式
			bool isOld = false;
			try
			{
				OneKeyShareSites = info.GetValue("OneKeyShareSites", typeof(List<Share.Sites>)) as List<Share.Sites>;
				isOld = true;
			}
			catch
			{
				OneKeyShareSites = def.OneKeyShareSites;
			}
			try
			{
				DisplayedSites = info.GetValue("DisplayedSites", typeof(List<Share.Sites>)) as List<Share.Sites>;
				isOld = true;
			}
			catch
			{
				DisplayedSites = def.DisplayedSites;
			}
			if (isOld)
			{
				foreach (var site in Share.GetSortedSites())
				{
					//如果出现了1.7.4及之前版本中没出现的网站,则默认显示
					//这里列出的是1.7.4版本中已定义的网站列表
					if (site != Share.Sites.None
						&& site != Share.Sites.Douban
						&& site != Share.Sites.Weibo
						&& site != Share.Sites.Msn
						&& site != Share.Sites.Kaixin
						&& site != Share.Sites.Renren
						&& site != Share.Sites.TencentWeibo
						&& site != Share.Sites.Fanfou
						&& site != Share.Sites.Facebook
						&& site != Share.Sites.Twitter)
					{
						DisplayedSites.Add(site);
					}
				}
			}
			#endregion

			#region 1.7.5及更高版本的保存方式
			if (!isOld)
			{
				DisplayedSites = new List<Share.Sites>();
				OneKeyShareSites = new List<Share.Sites>();
				foreach (var site in Share.GetSortedSites())
				{
					try
					{
						bool value = info.GetBoolean("DisplayedSites_" + site);
						if (value)
						{
							DisplayedSites.Add(site);
						}
					}
					catch
					{
						//说明这是更新为新版本后新增加的网站
						DisplayedSites.Add(site);
					}

					try
					{
						bool value = info.GetBoolean("OneKeyShareSites_" + site);
						if (value)
						{
							OneKeyShareSites.Add(site);
						}
					}
					catch
					{
						//新增加的网站默认不设置一键分享
					}
				}
			}
			#endregion
		}