Ejemplo n.º 1
0
        private void AddMemo(string pText, string pDateTime = null)
        {
            Panel tPn = new Panel();

            tPn.Size        = new Size(300, 80);
            tPn.BackColor   = Color.Transparent;
            tPn.BorderStyle = BorderStyle.None;
            tPn.Region      = System.Drawing.Region.FromHrgn(Classes.RoundRectRgn.CreateRoundRectRgn(0, 0, tPn.Width, tPn.Height, 10, 15));

            string tDateTime = pDateTime == null?DateTime.Now.ToString("yyyy.MM.dd") : pDateTime;

            MemoPanelFrm frm = new MemoPanelFrm(pText, tDateTime)
            {
                Dock     = DockStyle.Fill,
                TopLevel = false,
                TopMost  = true,
                Parent   = tPn
            };

            frm.mEditEvent += (data) =>
            {
                Invoke(new Action(() =>
                {
                    textBox1.Text = data;
                }));
            };

            tPn.Controls.Add(frm);
            frm.Show();

            textBox1.Clear();
            textBox1.Focus();

            flowLayoutPanel1.Controls.Add(tPn);
        }
Ejemplo n.º 2
0
        private void SaveMemo(string pPath)
        {
            FileInfo fi = new FileInfo(pPath);

            if (!fi.Directory.Exists)
            {
                fi.Directory.Create();
            }
            if (!fi.Exists)
            {
                File.Delete(pPath);
            }

            if (flowLayoutPanel1.Controls.Count == 0)
            {
                FileStream f = File.Create(fi.FullName);
                f.Close();

                return;
            }

            List <string> labelTextList = new List <string>();

            foreach (Panel pan in flowLayoutPanel1.Controls)
            {
                MemoPanelFrm frm = (MemoPanelFrm)pan.Controls[0];
                labelTextList.Add(string.Format($"{frm.LabelText},{frm.LabelDateTime}"));
            }

            File.WriteAllLines(fi.FullName, labelTextList);
        }