private void LoadConfig() { string configFile = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\Moe_config.ini"; //读取配置文件 if (System.IO.File.Exists(configFile)) { try { string[] lines = System.IO.File.ReadAllLines(configFile); downloadC.NumOnce = Int32.Parse(lines[0]); if (lines[1] != "." && System.IO.Directory.Exists(lines[1])) DownloadControl.SaveLocation = lines[1]; if (lines[2].Contains(';')) { string[] parts = lines[2].Split(';'); //itmJpg.IsChecked = parts[0].Equals("1"); addressType = (AddressType)Enum.Parse(typeof(AddressType), parts[0]); if (parts[1] == "1") { //GlassHelper.noBlur = false; } if (parts.Length > 2) { numOfLoading = Int32.Parse(parts[2]); if (numOfLoading < 4) numOfLoading = 5; } if (parts.Length > 3) { itmMaskViewed.IsChecked = parts[3].Equals("1"); } if (parts.Length > 4) { string[] words = parts[4].Split('|'); foreach (string word in words) { //if (word.Trim().Length > 0) //txtSearch.Items.Add(word); searchControl.AddUsedItem(word); } } //if (!txtSearch.Items.Contains("thighhighs")) //txtSearch.Items.Add("thighhighs"); if (parts.Length > 5) { Proxy = parts[5]; } if (parts.Length > 6) { bossKey = (System.Windows.Forms.Keys)Enum.Parse(typeof(System.Windows.Forms.Keys), parts[6]); } if (parts.Length > 7) { itmSmallPre.IsChecked = parts[7].Equals("1"); } if (parts.Length > 8) { ProxyType = (ProxyType)Enum.Parse(typeof(ProxyType), parts[8]); } if (parts.Length > 9) { try { //Size pos = Size.Parse(parts[9]); var posItem = parts[9].Split(','); Size pos = new Size(int.Parse(posItem[0]), int.Parse(posItem[1])); if (pos.Width > MinWidth && pos.Height > MinHeight) { //rememberPos = true; //Left = pos.X; //Top = pos.Y; //startPos.Width = pos.Width; //startPos.Height = pos.Height; Width = pos.Width; Height = pos.Height; } } catch { } } if (parts.Length > 10) { togglePram.IsChecked = parts[10].Equals("1"); if (togglePram.IsChecked.Value) { //grdParam.Width = 0; //grdParam.Opacity = 0; } else { grdParam.Width = 479; grdParam.Opacity = 1; } } if (parts.Length > 11) { PreFetcher.CachedImgCount = int.Parse(parts[11]); } if (parts.Length > 12) { downloadC.IsSepSave = parts[12].Equals("1"); } if (parts.Length > 13) { itmxExplicit.IsChecked = parts[13].Equals("1"); showExplicit = !itmxExplicit.IsChecked; } if (parts.Length > 14) { namePatter = parts[14]; } if (parts.Length > 15) { txtNum.Text = parts[15]; } if (parts.Length > 16) { bgSt = (System.Windows.Media.Stretch)Enum.Parse(typeof(System.Windows.Media.Stretch), parts[16]); } if (parts.Length > 17) { bgHe = (System.Windows.Media.AlignmentX)Enum.Parse(typeof(System.Windows.Media.AlignmentX), parts[17]); } if (parts.Length > 18) { bgVe = (System.Windows.Media.AlignmentY)Enum.Parse(typeof(System.Windows.Media.AlignmentY), parts[18]); } if (parts.Length > 19) { bgOp = double.Parse(parts[19]); } } //else itmJpg.IsChecked = lines[2].Trim().Equals("1"); else addressType = (AddressType)Enum.Parse(typeof(AddressType), lines[2].Trim()); for (int i = 3; i < lines.Length; i++) { if (lines[i].Trim().Length > 0) { if (lines[i].Contains(':')) { string[] parts = lines[i].Trim().Split(':'); viewedIds[parts[0]] = new ViewedID(); viewedIds[parts[0]].AddViewedRange(parts[1]); } else { //向前兼容 if (i - 3 >= SiteManager.Instance.Sites.Count) break; viewedIds[SiteManager.Instance.Sites[i - 3].ShortName] = new ViewedID(); viewedIds[SiteManager.Instance.Sites[i - 3].ShortName].AddViewedRange(lines[i].Trim()); } } } } catch (Exception ex) { MessageBox.Show(this, "读取配置文件失败\r\n" + ex.Message, "Moe Loader", MessageBoxButton.OK, MessageBoxImage.Warning); } } switch (addressType) { case AddressType.Ori: itmTypeOri.IsChecked = true; break; case AddressType.Jpg: itmTypeJpg.IsChecked = true; break; case AddressType.Pre: itmTypePreview.IsChecked = true; break; case AddressType.Small: itmTypeSmall.IsChecked = true; break; } //string logoPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location) + "\\logo.png"; //if (System.IO.File.Exists(logoPath)) //{ //image.Source = new BitmapImage(new Uri(logoPath, UriKind.Absolute)); //} //else image.Source = new BitmapImage(new Uri("Images/logo1.png", UriKind.Relative)); }
/// <summary> /// 图片过滤 /// </summary> /// <param name="imgs">图片集合</param> /// <param name="maskScore">屏蔽分数</param> /// <param name="maskRes">屏蔽分辨率</param> /// <param name="lastViewed">已浏览的图片id</param> /// <param name="maskViewed">屏蔽已浏览</param> /// <param name="showExplicit">屏蔽Explicit评级</param> /// <param name="updateViewed">更新已浏览列表</param> /// <returns></returns> public virtual List <Img> FilterImg(List <Img> imgs, int maskScore, int maskRes, ViewedID lastViewed, bool maskViewed, bool showExplicit, bool updateViewed) { List <Img> re = new List <Img>(); foreach (Img img in imgs) { //标记已阅 img.IsViewed = true; if (lastViewed != null && !lastViewed.IsViewed(img.Id)) { img.IsViewed = false; if (updateViewed) { lastViewed.AddViewingId(img.Id); } } else if (maskViewed) { continue; } int res = img.Width * img.Height; //score filter & resolution filter & explicit filter if (IsSupportScore && img.Score <= maskScore || IsSupportRes && res < maskRes || !showExplicit && img.IsExplicit) { continue; } else { re.Add(img); } } return(re); }
/// <summary> /// 图片过滤 /// </summary> /// <param name="imgs">图片集合</param> /// <param name="maskScore">屏蔽分数</param> /// <param name="maskRes">屏蔽分辨率</param> /// <param name="lastViewed">已浏览的图片id</param> /// <param name="maskViewed">屏蔽已浏览</param> /// <param name="showExplicit">屏蔽Explicit评级</param> /// <param name="updateViewed">更新已浏览列表</param> /// <returns></returns> public virtual List<Img> FilterImg(List<Img> imgs, int maskScore, int maskRes, ViewedID lastViewed, bool maskViewed, bool showExplicit, bool updateViewed) { List<Img> re = new List<Img>(); foreach (Img img in imgs) { //标记已阅 img.IsViewed = true; if (lastViewed != null && !lastViewed.IsViewed(img.Id)) { img.IsViewed = false; if (updateViewed) lastViewed.AddViewingId(img.Id); } else if (maskViewed) continue; int res = img.Width * img.Height; //score filter & resolution filter & explicit filter if (IsSupportScore && img.Score <= maskScore || IsSupportRes && res < maskRes || !showExplicit && img.IsExplicit) { continue; } else { re.Add(img); } } return re; }