Exemplo n.º 1
0
        /*  public static Cache[] CacheListFilter(Cache[] cacheList)
        {
            List<Cache> clist = new List<Cache>();

            foreach (Cache c in cacheList)
            {
                if (!CacheFilter(c)) clist.Add(c);
            }

            return clist.ToArray();
        }

        private static bool CacheFilter(Cache cache)
        {
            var flist = Settings.Default._filterList.Where(n => n.Effect == true).ToArray();
            if (flist.Length == 0) return false;

            bool? flag = null;

            foreach (Filter f in flist)
            {
                // ファイル名の比較
                if (f.Name.Trim() != "")
                {
                    if (flag == null) flag = true;

                    if (f.Name.Contains("\""))
                    {
                        foreach (Match m in Regex.Matches(f.Name, "\"(.*?)\""))
                        {
                            string mat = m.Value.Trim('\"');
                            flag &= ((!mat.StartsWith("-") && cache.Name.Contains(mat)) || (mat.StartsWith("-") && !cache.Name.Contains(mat.Substring(1))));
                        }
                    }
                    else
                    {
                        flag &= cache.Name.Contains(f.Name);
                    }
                }

                // カテゴリの比較
                if (f.Category != null)
                {
                    if (flag == null) flag = true;

                    foreach (string ss in f.Category)
                    {
                        if (ss != null && ss.Trim() != "")
                        {
                            flag &= cache.Category.Any(n => n != null && n.ToLower() == ss.ToLower());
                        }
                    }
                }

                // IDの比較
                if (f.ID != null && f.ID.Trim() != "")
                {
                    if (flag == null) flag = true;

                    flag &= f.ID == Convert.ToBase64String(HashFunction.HashCreate(cache.PublicKey));
                }

                // ハッシュの比較
                if (f.Hash != null && f.Hash.Length != 0)
                {
                    if (flag == null) flag = true;

                    flag &= BinaryEditor.ArrayEquals(f.Hash, cache.Hash);
                }

                // サイズ上限
                if (f.LimitSize != 0)
                {
                    if (flag == null) flag = true;

                    flag &= f.LimitSize > cache.Size;
                }

                // サイズ下限
                if (f.LowerSize != 0)
                {
                    if (flag == null) flag = true;

                    flag &= f.LowerSize < cache.Size;
                }
            }

            return flag == true ? true : false;
        }*/
        private void 追加_J_Click(object sender, RoutedEventArgs e)
        {
            using (FilterSettingWindow filterSettingWindow = new FilterSettingWindow())
            {
                filterSettingWindow.ShowDialog();
            }
        }
Exemplo n.º 2
0
        private void 編集_E_Click(object sender, RoutedEventArgs e)
        {
            var item = FilterListView.SelectedItem as Filter;

            if (item != null)
            {
                using (FilterSettingWindow filterSettingWindow = new FilterSettingWindow())
                {
                    filterSettingWindow.SetFilter(item);
                    filterSettingWindow.ShowDialog();

                    if (filterSettingWindow.DialogResult == true)
                        Settings.Default._filterList.Remove(item);
                }
            }
        }