示例#1
0
        public static void Load()
        {
            Items = new List <FilterItem>();
            String      path = Path.Combine(Settings.DataPath, "filters.dat");
            List <byte> list = new List <byte>();

            byte[] buf;
            int    count;

            try
            {
                buf = File.ReadAllBytes(path);
                list.AddRange(buf);
            }
            catch { }

            while (list.Count(x => x == 0) >= 7)
            {
                FilterItem f = new FilterItem();
                count      = list.IndexOf(0);
                f.Argument = Encoding.UTF8.GetString(list.ToArray(), 0, count);
                list.RemoveRange(0, (count + 1));
                count       = list.IndexOf(0);
                f.Condition = Encoding.UTF8.GetString(list.ToArray(), 0, count);
                list.RemoveRange(0, (count + 1));
                count   = list.IndexOf(0);
                f.Event = Encoding.UTF8.GetString(list.ToArray(), 0, count);
                list.RemoveRange(0, (count + 1));
                count      = list.IndexOf(0);
                f.Property = Encoding.UTF8.GetString(list.ToArray(), 0, count);
                list.RemoveRange(0, (count + 1));
                count  = list.IndexOf(0);
                f.Room = Encoding.UTF8.GetString(list.ToArray(), 0, count);
                list.RemoveRange(0, (count + 1));
                count  = list.IndexOf(0);
                f.Task = Encoding.UTF8.GetString(list.ToArray(), 0, count);
                list.RemoveRange(0, (count + 1));
                count  = list.IndexOf(0);
                f.Text = Encoding.UTF8.GetString(list.ToArray(), 0, count);
                list.RemoveRange(0, (count + 1));
                Items.Add(f);
            }
        }
示例#2
0
        private void addToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.filter_dialog.ResetForm();
            this.filter_dialog.StartPosition = FormStartPosition.CenterParent;

            if (this.filter_dialog.ShowDialog() == DialogResult.OK)
            {
                FilterItem f = this.filter_dialog.Item;
                Filter.Items.Add(f);
                Filter.Update();
                this.dataGridView1.Rows.Add();
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[0].Value = f.Room;
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[1].Value = f.Event;
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[2].Value = f.Property;
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[3].Value = f.Condition;
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[4].Value = f.Argument;
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[5].Value = f.Task;
                this.dataGridView1.Rows[this.dataGridView1.Rows.Count - 1].Cells[6].Value = f.Text;
            }
        }