Changeset 19727

Show
Ignore:
Timestamp:
09/22/08 17:49:20 (5 years ago)
Author:
poolmmjp
Message:

exeと同じ場所にfilters.txtを作っておくと、プリセットのフィルタ定義として使えるようにした。

Location:
lang/csharp/MMMMB/MMMMB
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • lang/csharp/MMMMB/MMMMB/MainForm.cs

    r13980 r19727  
    3535            // account 
    3636            string[] accounts = LoadAccounts(); 
     37            string[] filters = File.Exists("filters.txt") ? File.ReadAllLines("filters.txt") : new string[]{}; 
    3738            foreach (string account in accounts) 
    3839            { 
     
    4950                view.Logger = logger; 
    5051                view.Notify += new MiniBlogView.NotifyEventHandler(view_Notify); 
     52                view.FilterTemplate = filters; 
    5153                view.Reload(); 
    5254 
  • lang/csharp/MMMMB/MMMMB/MiniBlogView.Designer.cs

    r13977 r19727  
    3939            this.browserPanel = new System.Windows.Forms.Panel(); 
    4040            this.filterPanel = new System.Windows.Forms.Panel(); 
    41             this.notifyInput = new System.Windows.Forms.TextBox(); 
    42             this.allowInput = new System.Windows.Forms.TextBox(); 
    43             this.denyInput = new System.Windows.Forms.TextBox(); 
    4441            this.notifyInputLabel = new System.Windows.Forms.Label(); 
    4542            this.allowInputLabel = new System.Windows.Forms.Label(); 
     
    4744            this.filterCheck = new System.Windows.Forms.CheckBox(); 
    4845            this.panel = new System.Windows.Forms.Panel(); 
     46            this.denyInput = new System.Windows.Forms.ComboBox(); 
     47            this.allowInput = new System.Windows.Forms.ComboBox(); 
     48            this.notifyInput = new System.Windows.Forms.ComboBox(); 
    4949            this.browserPanel.SuspendLayout(); 
    5050            this.filterPanel.SuspendLayout(); 
     
    148148            this.filterPanel.TabIndex = 0; 
    149149            //  
    150             // notifyInput 
    151             //  
    152             this.notifyInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    153                         | System.Windows.Forms.AnchorStyles.Right))); 
    154             this.notifyInput.Location = new System.Drawing.Point(56, 75); 
    155             this.notifyInput.Name = "notifyInput"; 
    156             this.notifyInput.Size = new System.Drawing.Size(318, 19); 
    157             this.notifyInput.TabIndex = 6; 
    158             //  
    159             // allowInput 
    160             //  
    161             this.allowInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    162                         | System.Windows.Forms.AnchorStyles.Right))); 
    163             this.allowInput.Location = new System.Drawing.Point(56, 50); 
    164             this.allowInput.Name = "allowInput"; 
    165             this.allowInput.Size = new System.Drawing.Size(318, 19); 
    166             this.allowInput.TabIndex = 4; 
    167             this.allowInput.TextChanged += new System.EventHandler(this.filterInput_TextChanged); 
    168             //  
    169             // denyInput 
    170             //  
    171             this.denyInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    172                         | System.Windows.Forms.AnchorStyles.Right))); 
    173             this.denyInput.Location = new System.Drawing.Point(56, 25); 
    174             this.denyInput.Name = "denyInput"; 
    175             this.denyInput.Size = new System.Drawing.Size(318, 19); 
    176             this.denyInput.TabIndex = 2; 
    177             this.denyInput.TextChanged += new System.EventHandler(this.filterInput_TextChanged); 
    178             //  
    179150            // notifyInputLabel 
    180151            //  
    181152            this.notifyInputLabel.AutoSize = true; 
    182             this.notifyInputLabel.Location = new System.Drawing.Point(3, 78); 
     153            this.notifyInputLabel.Location = new System.Drawing.Point(3, 80); 
    183154            this.notifyInputLabel.Name = "notifyInputLabel"; 
    184155            this.notifyInputLabel.Size = new System.Drawing.Size(47, 12); 
     
    189160            //  
    190161            this.allowInputLabel.AutoSize = true; 
    191             this.allowInputLabel.Location = new System.Drawing.Point(3, 53); 
     162            this.allowInputLabel.Location = new System.Drawing.Point(3, 54); 
    192163            this.allowInputLabel.Name = "allowInputLabel"; 
    193164            this.allowInputLabel.Size = new System.Drawing.Size(47, 12); 
     
    226197            this.panel.Size = new System.Drawing.Size(381, 303); 
    227198            this.panel.TabIndex = 8; 
     199            //  
     200            // denyInput 
     201            //  
     202            this.denyInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     203                        | System.Windows.Forms.AnchorStyles.Right))); 
     204            this.denyInput.FormattingEnabled = true; 
     205            this.denyInput.Location = new System.Drawing.Point(56, 25); 
     206            this.denyInput.Name = "denyInput"; 
     207            this.denyInput.Size = new System.Drawing.Size(318, 20); 
     208            this.denyInput.TabIndex = 2; 
     209            this.denyInput.TextChanged += new System.EventHandler(this.filterInput_TextChanged); 
     210            //  
     211            // allowInput 
     212            //  
     213            this.allowInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     214                        | System.Windows.Forms.AnchorStyles.Right))); 
     215            this.allowInput.FormattingEnabled = true; 
     216            this.allowInput.Location = new System.Drawing.Point(56, 51); 
     217            this.allowInput.Name = "allowInput"; 
     218            this.allowInput.Size = new System.Drawing.Size(318, 20); 
     219            this.allowInput.TabIndex = 4; 
     220            this.allowInput.TextChanged += new System.EventHandler(this.filterInput_TextChanged); 
     221            //  
     222            // notifyInput 
     223            //  
     224            this.notifyInput.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     225                        | System.Windows.Forms.AnchorStyles.Right))); 
     226            this.notifyInput.FormattingEnabled = true; 
     227            this.notifyInput.Location = new System.Drawing.Point(56, 77); 
     228            this.notifyInput.Name = "notifyInput"; 
     229            this.notifyInput.Size = new System.Drawing.Size(318, 20); 
     230            this.notifyInput.TabIndex = 6; 
     231            this.notifyInput.TextChanged += new System.EventHandler(this.filterInput_TextChanged); 
    228232            //  
    229233            // MiniBlogView 
     
    261265        private System.Windows.Forms.CheckBox filterCheck; 
    262266        private System.Windows.Forms.Panel panel; 
    263         private System.Windows.Forms.TextBox denyInput; 
    264267        private System.Windows.Forms.Label denyInputLabel; 
    265         private System.Windows.Forms.TextBox notifyInput; 
    266         private System.Windows.Forms.TextBox allowInput; 
    267268        private System.Windows.Forms.Label notifyInputLabel; 
    268269        private System.Windows.Forms.Label allowInputLabel; 
     270        private System.Windows.Forms.ComboBox denyInput; 
     271        private System.Windows.Forms.ComboBox notifyInput; 
     272        private System.Windows.Forms.ComboBox allowInput; 
    269273    } 
    270274} 
  • lang/csharp/MMMMB/MMMMB/MiniBlogView.cs

    r18564 r19727  
    9191        } 
    9292 
     93        public string[] FilterTemplate 
     94        { 
     95            set 
     96            { 
     97                ComboBox[] combos = { denyInput, allowInput, notifyInput }; 
     98                foreach (ComboBox combo in combos) 
     99                { 
     100                    combo.Items.Clear(); 
     101                    combo.Items.Add(""); 
     102                    combo.Items.AddRange(value); 
     103                } 
     104            } 
     105        } 
     106 
    93107        public MiniBlogView() 
    94108        { 
     
    108122                try 
    109123                { 
    110                     Filter notify = Filter.Parse(filterCheck.Checked ? notifyInput.Text : ""); 
     124                    Filter notify = Filter.Parse(filterCheck.Checked ? InvokeComboText(notifyInput) : ""); 
    111125                    List<Entry> notifyEntryList = new List<Entry>(); 
    112126                    int before = entryList.Count; 
     
    164178        { 
    165179            // filter 
    166             Filter deny = Filter.Parse(filterCheck.Checked ? denyInput.Text : ""); 
    167             Filter allow = Filter.Parse(filterCheck.Checked ? allowInput.Text : ""); 
     180            Filter deny = Filter.Parse(filterCheck.Checked ? InvokeComboText(denyInput) : ""); 
     181            Filter allow = Filter.Parse(filterCheck.Checked ? InvokeComboText(allowInput) : ""); 
    168182            StringBuilder sb = new StringBuilder(); 
    169183            int count = 0; 
     
    171185            { 
    172186                Entry e = entryList[i]; 
    173                 bool ok = true; 
    174                 if (0 < allow.Items.Length) ok = allow.IsMatchAny(e); 
    175                 if (0 < deny.Items.Length) ok = !deny.IsMatchAny(e); 
    176                 if (!ok) continue; 
     187                bool ok_allow = true; 
     188                bool ok_deny = true; 
     189                if (0 < allow.Items.Length) ok_allow = allow.IsMatchAny(e); 
     190                if (0 < deny.Items.Length) ok_deny = !deny.IsMatchAny(e); 
     191                if (!(ok_allow && ok_deny)) continue; 
    177192                if (500 <= count++) break; 
    178193 
     
    214229                    browser.DocumentText = html; 
    215230                } 
     231            })); 
     232        } 
     233 
     234        private delegate string StringMethodInvoker(); 
     235        private string InvokeComboText(ComboBox combo) 
     236        { 
     237            return (string)this.Invoke(new StringMethodInvoker(delegate() 
     238            { 
     239                return combo.Text; 
    216240            })); 
    217241        }