Exemplo n.º 1
0
        private void AbleFlowLayout()
        {
            int          index    = 0;
            Ucl_NoteItem noteitem = null;

            foreach (Control c in this.flowLayoutPanel1.Controls)
            {
                c.Margin = new Padding(0);

                index++;
                noteitem = c as Ucl_NoteItem;
                if (noteitem != null)
                {
                    noteitem.SetSortIndex(index);
                }
            }

            if (this.flowLayoutPanel1.Controls.Count == 0)
            {
                this.flowLayoutPanel1.Visible = false;
            }
            else
            {
                this.flowLayoutPanel1.Visible = true;
            }
        }
Exemplo n.º 2
0
 private void textBox1_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter && this.textBox1.Text.Trim() != "")
     {
         Ucl_NoteItem item = new Ucl_NoteItem(Guid.NewGuid().ToString(), this.textBox1.Text.Trim(), 0, DateTime.Now, true);
         this.flowLayoutPanel1.Controls.Add(item);
         this.textBox1.Text = "";
     }
 }
Exemplo n.º 3
0
        private void flowLayoutPanel1_ControlAdded(object sender, ControlEventArgs e)
        {
            isAdding = true;

            Ucl_NoteItem noteitem = null;

            #region 保存到数据库
            if (Cache.GetCache("uid") != null)
            {
                string           id;
                string           title;
                int              types;
                DateTime         addTime;
                bool             isNew;
                DBUtil.Note_Main main = new DBUtil.Note_Main();
                noteitem = e.Control as Ucl_NoteItem;
                if (noteitem != null)
                {
                    id      = noteitem.ID;
                    title   = noteitem.Title;
                    types   = noteitem.Types;
                    addTime = noteitem.AddTime;
                    isNew   = noteitem.IsNew;


                    main.ID       = id;
                    main.AddRenID = Cache.GetCache("uid").ToString();
                    main.State    = types;
                    main.Content  = title;
                    main.AddTime  = addTime.ToString("yyyy-MM-dd HH:mm:ss");

                    if (isNew)
                    {
                        main.Add();
                    }
                }
            }
            #endregion

            AbleFlowLayout();

            if (layoutAdded != null)
            {
                layoutAdded(e.Control.Height);
            }

            isAdding = false;
        }
Exemplo n.º 4
0
 private void InitData()
 {
     if (Process.GetCurrentProcess().ProcessName != "devenv")
     {
         flowLayoutPanel1.ControlRemoved -= flowLayoutPanel1_ControlRemoved;
         flowLayoutPanel1.ControlAdded   -= flowLayoutPanel1_ControlAdded;
         this.flowLayoutPanel1.Controls.Clear();
         DBUtil.Note_Main main = new DBUtil.Note_Main();
         DataSet          ds   = main.GetList("State=0 order by addtime desc");
         if (ds != null && ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
         {
             for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
             {
                 Ucl_NoteItem item = new Ucl_NoteItem(ds.Tables[0].Rows[i]["ID"].ToString(), ds.Tables[0].Rows[i]["Content"].ToString(), Convert.ToInt32(ds.Tables[0].Rows[i]["State"]), Convert.ToDateTime(ds.Tables[0].Rows[i]["AddTime"]), false);
                 this.flowLayoutPanel1.Controls.Add(item);
             }
         }
         flowLayoutPanel1.ControlRemoved += flowLayoutPanel1_ControlRemoved;
         flowLayoutPanel1.ControlAdded   += flowLayoutPanel1_ControlAdded;
     }
 }
Exemplo n.º 5
0
        private void flowLayoutPanel1_ControlRemoved(object sender, ControlEventArgs e)
        {
            isRemoving = true;

            #region 保存到数据库
            DBUtil.Note_Main main     = new DBUtil.Note_Main();
            Ucl_NoteItem     noteitem = e.Control as Ucl_NoteItem;
            if (noteitem != null)
            {
                main.GetModel(noteitem.ID);
                if (main.ID == noteitem.ID)
                {
                    main.State = 2;
                    main.Update();
                }
            }
            #endregion

            AbleFlowLayout();

            isRemoving = false;
        }