Beispiel #1
0
        private void TodoText_KeyPress(object sender, KeyPressEventArgs e)
        {
            MyAutoSizeTextbox tb = (MyAutoSizeTextbox)sender;
            Control           p  = base.Parent;
            int index            = p.Controls.IndexOf(this);

            if (e.KeyChar == (char)Keys.Enter)
            {
                content = TodoText.Text;
                updateTodo();

                MyTodoItem td = new MyTodoItem();
                e.Handled = true;
                p.Controls.Add(td);
                p.Controls.SetChildIndex(td, index + 1);
                td.TodoText.Focus();
            }
            else if (e.KeyChar == (char)Keys.Back && tb.Text == "")
            {
                if (index > 0)
                {
                    p.Controls[index - 1].Focus();
                }
                p.Controls.Remove(this);
                if (MainForm.Data.todoIs.ContainsKey(Id))
                {
                    MainForm.Data.todoIs.Remove(Id);
                }
            }
        }
        private void AddTodoItemToInnerPanel()
        {
            todoItem        = new Panel();
            todoItem.Margin = new Padding(0, 16, 3, 3);
            todoItem.Size   = new Size(426, 16);

            checkbox          = new PictureBox();
            checkbox.Size     = new Size(12, 12);
            checkbox.Location = new Point(19, 2);
            checkbox.Image    = MyImage.checkbox;

            Todocont             = new MyAutoSizeTextbox();
            Todocont.Location    = new Point(41, 0);
            Todocont.Font        = new Font("微软雅黑", 9f);
            Todocont.BorderStyle = BorderStyle.None;
            todocont.BackColor   = Color.White;

            Todocont.Text      = "New To-Do";
            Todocont.ForeColor = textGrey;

            todoItem.Controls.Add(checkbox);
            todoItem.Controls.Add(Todocont);

            innerPanel.Controls.Add(todoItem);
        }
Beispiel #3
0
        //bool lastOne;

        public MyTodoItem(string text = null, Image state = null, int _id = -1)
        {
            id  = _id;
            Due = MainForm.Data.initDate;

            Size   = new Size(392, 24);
            Margin = new Padding(18, 0, 3, 0);
            this.ContextMenuStrip = itemMenu;
            this.GotFocus        += TodoText_GotFocus;
            MyAnimation.SetListItemColor(this);

            /* editBtn = new PictureBox();
             * editBtn.Size = new Size(18, 12);
             * editBtn.Location = new Point(2, 6);
             * editBtn.Image = Properties.Resources.editbtn;*/

            CheckBox      = new PictureBox();
            CheckBox.Size = new Size(12, 13);
            if (state != null)
            {
                CheckBox.Image = state;
            }
            else
            {
                CheckBox.Image = MyImage.checkbox;
            }
            CheckBox.Location = new Point(4, 6);
            CheckBox.Click   += CheckBox_Click;

            TodoText          = new MyAutoSizeTextbox();
            TodoText.Location = new Point(24, 4);
            TodoText.Font     = new Font("微软雅黑", 9f);
            if (text != null)
            {
                TodoText.Text = text;
            }
            else
            {
                TodoText.Text = "New To-Do";
            }
            if (TodoText.Text == "New To-Do")
            {
                TodoText.ForeColor = Color.FromArgb(204, 202, 204);
            }
            TodoText.KeyPress  += TodoText_KeyPress;
            TodoText.KeyDown   += TodoText_KeyDown;
            TodoText.GotFocus  += TodoText_GotFocus;
            TodoText.LostFocus += TodoText_LostFocus;

            Content = TodoText.Text;
            Cstate  = CheckBox.Image;

            this.Controls.Add(CheckBox);
            this.Controls.Add(TodoText);
        }