예제 #1
0
        public RemindForm(ReminderItem item)
        {
            InitializeComponent();
            Text = item.Title;
            textBox1.Text = item.Text;
            thisItem = item;

            FlashWindow(Handle, true);
        }
예제 #2
0
 static void ShowReminder(ReminderItem item)
 {
     new Thread(new ThreadStart(()=>
     {
         using (var form = new RemindForm(item))
         {
             form.Show();
             Application.Run(form);
         }
     })).Start();
 }
예제 #3
0
        public FormItem()
        {
            InitializeComponent();
            SetText("添加新");
            comboBox1.Items.AddRange(reminder.CategoryList.ToArray());
            comboBox1.SelectedIndex = 0;

            comboBox2.SelectedIndex = 1;

            state = StateEnum.New;

            oldItem = null;
        }
예제 #4
0
        public FormItem(ReminderItem item)
        {
            InitializeComponent();
            SetText("修改");

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

            comboBox2.SelectedIndex = (int)item.Importance;

            state = StateEnum.Modify;

            oldItem = item;
            textBox1.Text = oldItem.Title;
            textBox2.Text = oldItem.Text;
            dateTimePicker1.Value = oldItem.Time;
        }
예제 #5
0
        public ReminderItem ExpandOneItem()
        {
            if (IsEmpty())
            {
                var info = string.Format("事件发生器'{0}'已空,无法展开。", Title);
                throw new ArgumentOutOfRangeException(info);
            }
            var nextTime = TimeCache[0];

            var item = new ReminderItem
                           {
                               Title = Title,
                               Text = Text,
                               Category = Category,
                               Time = nextTime,
                               Importance = Importance
                           };

            BeginTime = nextTime;

            if (TimeCache.Length -1 < CacheSizeMin && !AllInCache)
                CacheMore();

            TimeCache = TimeCache.Skip(1).ToArray();

            return item;
        }
예제 #6
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);
                        }
                    }

                }
            }
        }
예제 #7
0
 public void ReplaceItem(ReminderItem oldItem, ReminderItem newItem)
 {
     lock (this)
     {
         int index = ItemList.IndexOf(oldItem);
         if(index != -1)
             ItemList[index] = newItem;
         SortItemList();
         ItemCreatorChangedHandler.BeginInvoke(null, null);
     }
 }
예제 #8
0
 public void RemoveItem(ReminderItem item)
 {
     lock (this)
     {
         ItemList.Remove(item);
         ItemCreatorChangedHandler.BeginInvoke(null, null);
     }
 }
예제 #9
0
        public void AddToOldItemList(ReminderItem item)
        {
            lock (this)
            {

            }
        }
예제 #10
0
 public void AddItem(ReminderItem item)
 {
     lock (this)
     {
         ItemList.Add(item);
         SortItemList();
         ItemCreatorChangedHandler.BeginInvoke(null, null);
     }
 }
예제 #11
0
 void reminder_RipeItemHandler(ReminderItem[] ripeItemList)
 {
     foreach (var item in ripeItemList)
         ShowReminder(item);
 }
예제 #12
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length == 0)
            {
                MessageBox.Show("标题不能为空。", Text, MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            var item = new ReminderItem()
            {
                Title = textBox1.Text,
                Category = comboBox1.SelectedItem.ToString(),
                Text = textBox2.Text,
                Time = dateTimePicker1.Value,
                Importance = (ReminderImportance)comboBox2.SelectedIndex
            };

            if (state == StateEnum.Modify)
                reminder.ReplaceItem(oldItem, item);
            else
                reminder.AddItem(item);

            Close();
        }