コード例 #1
0
        public static void Play()
        {
            var e1 = new TagsWereAddedToFiles { FileNames = new[] { "file1", "file2" }, TagsThatWereAdded = new[] { "tag1", "tag2" } };
            var e2 = new TagsWereAddedToFiles { FileNames = new[] { "file1", "file2" }, TagsThatWereAdded = new[] { "tag11", "tag22" } };
            var e3 = new TagsWereAddedToFiles { FileNames = new[] { "file1", "file3" }, TagsThatWereAdded = new[] { "tag3", "tag4" } };
            var e4 = new TagsWereAddedToFiles { FileNames = new[] { "file4", "file5" }, TagsThatWereAdded = new[] { "tag1", "tag4" } };
            var e5 = new TagRenamed { OldValue = "tag1", NewValue = "tag10" };
            var e6 = new TagsWereRemovedFromFiles { FileNames = new[] { "file1", "file2" }, TagsThatWereRemoved = new[] { "tag2" } };
            var e7 = new FileRenamed { OldValue = "file1", NewValue = "file10" };

            Event[] events = { e1, e2, e3, e4, e5, e6 };
            foreach (var ev in events)
            {
                var processor = ev as IEventProcessor;
                processor.ProcessEvent();
            }

            var state = State.Populate(TaggedFile.Repository.GetFilesList());


            var filter = new TagsIntersectionCondition(
                new TagsUnionCondition(InversableTag.GetTag("tag10"), InversableTag.GetTag("tag2")),
                new TagsUnionCondition(InversableTag.GetTag("tag11"), InversableTag.GetTag("tag4"))
                );

            var newState = State.Populate(filter.Apply(state.GetFiles()));

            filter = new TagsIntersectionCondition(
                new TagsUnionCondition(InversableTag.GetInverseTag("tag10"))
                );

            newState = State.Populate(filter.Apply(state.GetFiles()));
        }
コード例 #2
0
        public void Update(TagsIntersectionCondition newTagsCombination)
        {            
            int leftLocation = 0;
            int correction = 0;
            string OrString = "|";
            string AndString = "&&";

            Button btn;
            Label lbl;

            // First, clear old controls
            this.Controls.Clear();

            // Now, paint each control according with the new tags combination
            foreach (TagsUnionCondition tagsUnion in newTagsCombination.UnionConditions)
            {
                // Paint '('
                if (tagsUnion.Count > 1)
                {                    
                    lbl = this.CreateLabel("(", 16, 0);
                    lbl.Left = leftLocation;
                    this.Controls.Add(lbl);                    
                    leftLocation = lbl.Right - correction;
                }

                foreach (InversableTag invTag in tagsUnion.InversableTags)
                {
                    // Paint the button for the tag
                    btn = new Button();
                    btn.Click += new EventHandler(this.btn_Click);
                    btn.MouseUp += new MouseEventHandler(this.btn_MouseUp);
                    btn.Tag = new TagsCombinationViewerEventArgs(invTag);
                    btn.Left = leftLocation;
                    btn.Top = 3;
                    btn.AutoSizeMode = AutoSizeMode.GrowAndShrink;
                    btn.AutoSize = true;
                    btn.Text = invTag.Inverse ? "Not " + invTag.Tag.Value : invTag.Tag.Value;
                    this.Controls.Add(btn);
                    btn.BringToFront();
                    leftLocation = btn.Right;

                    // Paint OR char: '|'
                    if (invTag != tagsUnion.InversableTags.Last())
                    {
                        lbl = this.CreateLabel(OrString, 8, 7);
                        lbl.Left = leftLocation;
                        this.Controls.Add(lbl);
                        leftLocation = lbl.Right;
                    }
                }

                // Paint ')'
                bool closeBracesExists = false;
                if (tagsUnion.Count > 1)
                {
                    lbl = this.CreateLabel(")", 16, 0);
                    lbl.Left = leftLocation - correction;
                    this.Controls.Add(lbl);                    
                    leftLocation = lbl.Right - correction;
                    closeBracesExists = true;
                }

                // Paint AND char: '&'
                if (tagsUnion != newTagsCombination.UnionConditions.Last())
                {
                    lbl = this.CreateLabel(AndString, 16, 0);
                    if (closeBracesExists)
                        lbl.Left = leftLocation;
                    else
                        lbl.Left = leftLocation - correction;
                                        
                    this.Controls.Add(lbl);                    
                    leftLocation = lbl.Right - correction;
                }
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: yaronthurm/TagFolders
 private void button1_Click(object sender, EventArgs e)
 {
     _filter = new TagsIntersectionCondition();
     this.ApplyFilter();
 }