Ejemplo n.º 1
0
        /// <summary>
        /// フィルタクラスタを新しいクラスタに結合します。(AND結合)
        /// </summary>
        public static FilterCluster Restrict(this FilterCluster original, params FilterCluster[] append)
        {
            var cluster = new FilterCluster();

            cluster.ConcatenateAnd = true;
            cluster.Filters        = new[] { original }.Concat(append).ToArray();
            return(cluster.Optimize());
        }
Ejemplo n.º 2
0
        public FilterCluster GetOnlyForUserFilter()
        {
            var nfc = new FilterCluster();

            nfc.ConcatenateAnd = this.ConcatenateAnd;
            nfc.Negate         = this.Negate;
            nfc.Filters        = _filters
                                 .OfType <IUserFilter>()
                                 .Select(f => f is FilterCluster ? ((FilterCluster)f).GetOnlyForUserFilter() : f)
                                 .ToArray();
            return(nfc);
        }
Ejemplo n.º 3
0
 public static FilterCluster GetParent(this IFilter filterObject, FilterCluster root)
 {
     if (root.Filters.Contains(filterObject))
     {
         return(root);
     }
     else
     {
         return(root.Filters
                .OfType <FilterCluster>()
                .Select(f => GetParent(f, root))
                .Where(f => f != null)
                .FirstOrDefault());
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// フィルタクラスタにフィルタを結合します。
        /// </summary>
        public static FilterCluster Join(this FilterCluster cluster, FilterBase filter, bool concatAnd = false)
        {
            var newCluster = new FilterCluster();

            if (cluster != null)
            {
                newCluster.Filters = new IFilter[] { cluster, filter }
            }
            ;
            else
            {
                newCluster.Filters = new IFilter[] { filter }
            };

            newCluster.ConcatenateAnd = concatAnd;

            return(newCluster.Optimize());
        }
Ejemplo n.º 5
0
 private void ClickUserIcon()
 {
     var user = TwitterHelper.GetSuggestedUser(this.Tweet);
     if (Keyboard.Modifiers.HasFlag(ModifierKeys.Alt))
     {
         var cluster = new FilterCluster(){
             ConcatenateAnd = false,
             Negate = false,
             Filters = this.Parent.TabProperty.TweetSources.ToArray()};
         this.Parent.TabProperty.TweetSources = new[]{ cluster.Restrict(new FilterCluster(){ ConcatenateAnd = false, Negate = true, Filters = new[]{ new FilterUserId(user.NumericId) }}).Optimize()}.ToArray();
         Task.Factory.StartNew(() => this.Parent.BaseTimeline.CoreViewModel.InvalidateCache());
     }
     else
     {
         var filter = new[] { new FilterUserId(user.NumericId) };
         var desc = "@" + user.ScreenName;
         switch (Setting.Instance.TimelineExperienceProperty.UserExtractTransition)
         {
             case TransitionMethod.ViewStack:
                 this.Parent.AddTopTimeline(filter);
                 break;
             case TransitionMethod.AddTab:
                 this.Parent.Parent.AddTab(new Configuration.Tabs.TabProperty() { Name = desc, TweetSources = filter });
                 break;
             case TransitionMethod.AddColumn:
                 var column = this.Parent.Parent.Parent.CreateColumn();
                 column.AddTab(new Configuration.Tabs.TabProperty() { Name = desc, TweetSources = filter });
                 break;
         }
     }
 }
Ejemplo n.º 6
0
 public FilterCluster GetOnlyForUserFilter()
 {
     var nfc = new FilterCluster();
     nfc.ConcatenateAnd = this.ConcatenateAnd;
     nfc.Negate = this.Negate;
     nfc.Filters = _filters
         .OfType<IUserFilter>()
         .Select(f => f is FilterCluster ? ((FilterCluster)f).GetOnlyForUserFilter() : f)
         .ToArray();
     return nfc;
 }
Ejemplo n.º 7
0
 public static FilterCluster Copy(this FilterCluster cluster)
 {
     return(QueryCompiler.ToFilter(cluster.ToQuery()));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// フィルタを簡易化します。
 /// </summary>
 public static FilterCluster Optimize(this FilterCluster cluster)
 {
     return(QueryCompiler.Optimize(cluster));
 }