Exemple #1
0
        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
        {
            if (pictureBox1.Image != null)
            {
                FlowLayoutPanel newPanel  = new FlowLayoutPanel();
                FlowLayoutPanel newPanel2 = new FlowLayoutPanel();
                Label           location  = new Label();
                TextBox         noteTB    = new TextBox();
                Button          delBtn    = new Button();

                noteTB.Size         = new System.Drawing.Size(noteFlowLayoutPanel.Width - 50, 20);
                noteTB.Multiline    = true;
                noteTB.TextChanged += new System.EventHandler(noteTB_TextChanged);

                location.Text   = "( " + e.X.ToString() + "," + e.Y.ToString() + " )";
                location.Margin = new System.Windows.Forms.Padding(0, 5, 0, 0);
                location.Size   = new System.Drawing.Size(noteFlowLayoutPanel.Width - 73, 23);

                delBtn.Text      = "X";
                delBtn.FlatStyle = FlatStyle.Popup;
                delBtn.Font      = new System.Drawing.Font("Segoe UI", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
                delBtn.ForeColor = Color.Red;
                delBtn.Margin    = new System.Windows.Forms.Padding(0);
                delBtn.Padding   = new System.Windows.Forms.Padding(0);
                delBtn.Size      = new System.Drawing.Size(23, 23);
                delBtn.Click    += new System.EventHandler(delBtn_Click);

                newPanel2.Size          = new System.Drawing.Size(noteFlowLayoutPanel.Width - 50, 23);
                newPanel2.FlowDirection = FlowDirection.LeftToRight;

                newPanel2.Controls.Add(location);
                newPanel2.Controls.Add(delBtn);

                newPanel.AutoSize      = true;
                newPanel.FlowDirection = FlowDirection.TopDown;
                newPanel.Padding       = new System.Windows.Forms.Padding(5, 0, 5, 5);

                newPanel.Controls.Add(newPanel2);
                newPanel.Controls.Add(noteTB);
                newPanel.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
                noteFlowLayoutPanel.Controls.Add(newPanel);
                //MessageBox.Show(newPanel.Width.ToString());

                DateTime date = DateTime.Now;
                tnOpen             = new TagNote();
                tnOpen.ID_TagNote  = ("TN" + date.ToShortDateString() + "_" + date.ToLongTimeString()).Replace("/", "-").Replace(":", "-");
                tnOpen.ID_DCupNote = dcnOpen.ID_DCupNote;
                tnOpen.LocationX   = e.X;
                tnOpen.LocationY   = e.Y;
                DDC.TagNotes.InsertOnSubmit(tnOpen);
                DDC.SubmitChanges();

                delBtn.Name = tnOpen.ID_TagNote;
                noteTB.Name = tnOpen.ID_TagNote;
            }
        }
Exemple #2
0
        private void deleteBtn_Click(object sender, EventArgs e)
        {
            try
            {
                if (dCupNoteDGV.CurrentRow != null)
                {
                    string selectedID = (string)dCupNoteDGV.CurrentRow.Cells[0].Value;

                    if (MessageBox.Show("Do you want to delete this D'Cup Note?", "Question [Delete]",
                                        MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
                    {
                        List <TagNote> listTN = (from tn in DDC.TagNotes
                                                 where tn.ID_DCupNote == selectedID
                                                 select tn).ToList();

                        if (listTN.Count > 0)
                        {
                            DDC.TagNotes.DeleteAllOnSubmit(listTN);
                        }

                        _dcn = (from d in DDC.DCupNotes
                                where d.ID_DCupNote == selectedID
                                select d).FirstOrDefault();

                        DDC.DCupNotes.DeleteOnSubmit(_dcn);
                        DDC.SubmitChanges();
                        UpdateDCupNoteDGV();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }