Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            var content = textBox1.Text;
            var date    = dateTimePicker1.Value;

            _Parent.ListView.Add(content, date);
            _Parent.RedrawAll();
            _Parent.SaveTodoList();
            this.Close();
        }
Beispiel #2
0
        public Point RedrawItems()
        {
            void DrawItem(TodoItem item, int anchorX, int anchorY)
            {
                var baseAnchor    = new Point(anchorX, anchorY);
                var contentAnchor = baseAnchor + new Size(20, -11);
                var dateAnchor    = contentAnchor + new Size(327, 0);

                var removeLbl = new Label()
                {
                    ForeColor = MyColors.DefaultColor,
                    BackColor = Color.Transparent,
                    FlatStyle = FlatStyle.Flat,
                    Text      = "",
                    Height    = 20,
                    Width     = 20,
                    Tag       = item.ID,
                    Location  = baseAnchor
                };

                removeLbl.Font        = new Font(_Me.Fonts.Families[1], 8);
                removeLbl.MouseEnter += (s, e) =>
                {
                    (s as Label).Text = "";
                };
                removeLbl.MouseLeave += (s, e) =>
                {
                    (s as Label).Text = "";
                };
                removeLbl.MouseClick += (s, e) =>
                {
                    var rm = Items.Single(i => i.ID == (s as Label).Tag as string);
                    Items.Remove(rm);
                    _Me.SaveTodoList();
                    _Me.RedrawAll();
                };
                _Me.Controls.Add(removeLbl);
                _Controls.Add(removeLbl);

                var content = new Label()
                {
                    Text      = item.Content,
                    ForeColor = MyColors.DefaultColor,
                    BackColor = Color.Transparent,
                    FlatStyle = FlatStyle.Flat,
                    Height    = 35,
                    Tag       = item.ID,
                    AutoSize  = true,
                    Location  = contentAnchor
                };

                content.Font = new Font("Source Han Sans SC ExtraLight", 12);
                _Me.Controls.Add(content);
                _Controls.Add(content);

                var date = new Label()
                {
                    Text      = item.ToDateString(),
                    ForeColor = MyColors.DefaultColor,
                    BackColor = Color.Transparent,
                    FlatStyle = FlatStyle.Flat,
                    Height    = 35,
                    Tag       = item.ID,
                    Location  = dateAnchor
                };

                date.Font = new Font("Source Han Sans SC", 12);
                _Me.Controls.Add(date);
                _Controls.Add(date);
            }

            foreach (var c in _Controls)
            {
                _Me.Controls.Remove(c);
            }
            _Controls.Clear();

            int currentY = _Anchor.Y;

            foreach (var item in Items)
            {
                DrawItem(item, _Anchor.X, currentY);
                currentY += _ItemOffsetY;
            }

            return(new Point(_Anchor.X, currentY));
        }