Esempio n. 1
0
        public FormCreator(ReminderCreator creator)
        {
            InitializeComponent();
            SetText("修改");

            var CategoryList = reminder.CategoryList.ToArray();
            comboBox1.Items.AddRange(CategoryList);
            SetCategory(creator.Category);

            comboBox2.SelectedIndex = (int)creator.Importance;

            state = StateEnum.Modify;

            oldCreator = creator;
            textBox1.Text = oldCreator.Title;
            textBox2.Text = oldCreator.Text;
            textBox3.Text = oldCreator.TimeCode;

            timeList = oldCreator.TimeCache;

            var builder = new StringBuilder();
            foreach (var time in oldCreator.TimeCache)
            {
                builder.AppendLine(time.ToString("yyyy-MM-dd HH:mm:ss"));
            }
            if(oldCreator.AllInCache)
            {
                builder.AppendLine("END");
            }
            textBox4.Text = builder.ToString();
            TimeCodeValid = true;
        }
Esempio n. 2
0
        public FormCreator()
        {
            InitializeComponent();
            SetText("添加新");
            comboBox1.Items.AddRange(reminder.CategoryList.ToArray());
            comboBox1.SelectedIndex = 0;
            comboBox2.SelectedIndex = 1;

            state = StateEnum.New;

            oldCreator = null;
        }
Esempio n. 3
0
 void AddToEmptyCreatorList(ReminderCreator creator)
 {
 }
Esempio n. 4
0
        public void RestoreFromTextFile(string filename)
        {
            lock(this)
            {
                using(var fs = File.OpenText(filename))
                {
                    var firstLine = fs.ReadLine();
                    if (firstLine == "--itemList begin--")
                    {
                        while (true)
                        {
                            var line = fs.ReadLine();
                            if (line == "--itemList end--")
                                break;

                            var item = new ReminderItem();
                            item.Title = fs.ReadLine();
                            item.Category = fs.ReadLine();
                            item.Time = DateTime.Parse(fs.ReadLine());

                            fs.ReadLine();
                            var builder = new StringBuilder();

                            while(true)
                            {
                                var subline = fs.ReadLine();
                                if (subline == "--text end--")
                                    break;

                                builder.AppendLine(subline);
                            }
                            fs.ReadLine();
                            item.Text = builder.ToString();

                            ItemList.Add(item);
                        }
                    }

                    firstLine = fs.ReadLine();
                    if (firstLine == "--creatorList begin--")
                    {
                        while (true)
                        {
                            var line = fs.ReadLine();
                            if (line == "--creatorList end--")
                                break;

                            var item = new ReminderCreator();
                            item.Title = fs.ReadLine();
                            item.Category = fs.ReadLine();
                            item.BeginTime = DateTime.Parse(fs.ReadLine());
                            item.AllInCache = Boolean.Parse(fs.ReadLine());

                            fs.ReadLine();
                            var builder = new StringBuilder();
                            while (true)
                            {
                                var subline = fs.ReadLine();
                                if (subline == "--text end--")
                                    break;

                                builder.AppendLine(subline);
                            }
                            item.Text = builder.ToString();

                            fs.ReadLine();
                            builder = new StringBuilder();
                            while (true)
                            {
                                var subline = fs.ReadLine();
                                if (subline == "--timecode end--")
                                    break;

                                builder.AppendLine(subline);
                            }
                            item.TimeCode = builder.ToString();

                            fs.ReadLine();
                            var dtlist = new List<DateTime>();
                            while (true)
                            {
                                var subline = fs.ReadLine();
                                if (subline == "--timecache end--")
                                    break;

                                dtlist.Add(DateTime.Parse(subline));
                            }
                            item.TimeCache = dtlist.ToArray();

                            fs.ReadLine();

                            CreatorList.Add(item);
                        }
                    }

                }
            }
        }
Esempio n. 5
0
 public void ReplaceCreator(ReminderCreator oldCreator, ReminderCreator newCreator)
 {
     lock (this)
     {
         int index = CreatorList.IndexOf(oldCreator);
         if (index != -1)
             CreatorList[index] = newCreator;
         SortCreatorList();
         ItemCreatorChangedHandler.BeginInvoke(null, null);
     }
 }
Esempio n. 6
0
 public void RemoveCreator(ReminderCreator creator)
 {
     lock (this)
     {
         CreatorList.Remove(creator);
         ItemCreatorChangedHandler.BeginInvoke(null, null);
     }
 }
Esempio n. 7
0
        public void ExpandCreatorOneItem(ReminderCreator creator)
        {
            lock (this)
            {
                var newItem = creator.ExpandOneItem();

                if (creator.IsEmpty())
                {
                    CreatorList.Remove(creator);
                    AddToEmptyCreatorList(creator);
                }

                AddItem(newItem);
            }
        }
Esempio n. 8
0
        public void DropCreatorOneItem(ReminderCreator creator)
        {
            lock (this)
            {
                creator.ExpandOneItem();

                if (creator.IsEmpty())
                {
                    CreatorList.Remove(creator);
                    AddToEmptyCreatorList(creator);
                }

                ItemCreatorChangedHandler.BeginInvoke(null, null);
            }
        }
Esempio n. 9
0
 public void AddCreator(ReminderCreator creator)
 {
     lock (this)
     {
         CreatorList.Add(creator);
         SortCreatorList();
         ItemCreatorChangedHandler.BeginInvoke(null, null);
     }
 }
Esempio n. 10
0
        private void button2_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length == 0)
            {
                MessageBox.Show("标题不能为空。", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (!TimeCodeValid)
            {
                MessageBox.Show("TimeCode必须调试正确后才能添加。", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if(timeList.Length == 0)
            {
                MessageBox.Show("TimeList不能为空。", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            var creator = new ReminderCreator()
            {
                Title = textBox1.Text,
                Category = comboBox1.SelectedItem.ToString(),
                Text = textBox2.Text,
                TimeCode = textBox3.Text,
                BeginTime = DateTime.Now,
                TimeCache = timeList.Take(ReminderCreator.CacheSizeMax).ToArray(),
                AllInCache = timeList.Length < ReminderCreator.CacheSizeMax,
                Importance = (ReminderImportance)comboBox2.SelectedIndex
            };

            if (state == StateEnum.Modify)
                reminder.ReplaceCreator(oldCreator, creator);
            else
                reminder.AddCreator(creator);

            Close();
        }