예제 #1
0
        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (DateTimePicker != null)
                {
                    UnmonitorControl(DateTimePicker);
                    DateTimePicker.Dispose();
                    DateTimePicker = null;
                }
            }

            base.Dispose(disposing);
        }
예제 #2
0
        private void cmb_repeatfor_SelectedIndexChanged(object sender, EventArgs e)
        {
            Label    lbl_duration  = Controls.Find("lbl_repeatduration", true).FirstOrDefault() as Label;
            ComboBox cmb_repeatfor = Controls.Find("cmb_repeatfor", true).FirstOrDefault() as ComboBox;

            TextBox        txt_duration = Controls.Find("txt_duration", true).FirstOrDefault() as TextBox;
            DateTimePicker dtp_duration = Controls.Find("dtp_duration", true).FirstOrDefault() as DateTimePicker;

            if (lbl_duration != null)
            {
                lbl_duration.Dispose();
            }

            if (txt_duration != null)
            {
                txt_duration.Dispose();
            }

            if (dtp_duration != null)
            {
                dtp_duration.Dispose();
            }

            if (!cmb_repeatfor.Text.Equals("") && !cmb_repeatfor.Text.Equals("None") && !cmb_repeatfor.Text.Equals("Forever"))
            {
                Label label = new Label()
                {
                    Name      = "lbl_repeatduration",
                    Text      = "Duration",
                    Location  = new Point(333, this.cmb_repeattype.Location.Y + 30),
                    ForeColor = System.Drawing.Color.White,
                };

                Controls.Add(label);
            }

            if (cmb_repeatfor.Text.Equals("Specific Number Of Times"))
            {
                TextBox text = new TextBox()
                {
                    Name      = "txt_duration",
                    Location  = new Point(333, cmb_repeatfor.Location.Y),
                    ForeColor = System.Drawing.Color.White,
                    BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(31)))), ((int)(((byte)(31)))), ((int)(((byte)(31))))),
                    Font      = new System.Drawing.Font("Microsoft Sans Serif", 11.25F),
                    Text      = (userEvent.RepeatCount + 1).ToString(),
                };
                Controls.Add(text);
            }

            if (cmb_repeatfor.Text.Equals("Until"))
            {
                DateTimePicker text = new DateTimePicker()
                {
                    Name      = "dtp_duration",
                    Location  = new Point(333, cmb_repeatfor.Location.Y),
                    ForeColor = System.Drawing.Color.White,
                    Value     = userEvent.RepeatTill == DateTime.MaxValue ? DateTime.Now : userEvent.RepeatTill,
                };
                Controls.Add(text);
            }
        }
예제 #3
0
 /// <summary>
 /// Dispose function. Release unmanaged resources.
 /// </summary>
 protected virtual void ReleaseUnmanagedResources()
 {
     //Release managed resources
     picker.Dispose();
     picker = null;
 }
예제 #4
0
 private void Dtp_CloseUp(object sender, EventArgs e)
 {
     dtp.Visible = false;
     dtp.Dispose();
 }
        private void dataPro_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            DateTime datefrom = new DateTime(2000, 7, 26);

            try
            {
                if (this.dataPro.Columns[e.ColumnIndex].DataPropertyName == nameof(Project.fromdate))
                {
                    dtp         = new DateTimePicker();
                    dtp.Format  = DateTimePickerFormat.Short;
                    dtp.Visible = true;
                    Rectangle rect = this.dataPro.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
                    dtp.Location = new Point(rect.X, rect.Y);
                    dtp.Size     = new Size(rect.Width, rect.Height);
                    try
                    {
                        dtp.Value = DateTime.Parse(this.dataPro.CurrentCell.Value.ToString());
                    }
                    catch
                    {
                        dtp.Visible = false;
                        dtp.Dispose();
                        dataPro.CurrentCell.Value = datefrom.ToString();
                    }
                    dtp.CloseUp     += Dtp_Closeup;
                    dtp.TextChanged += Dtp_TextChanged;
                    this.dataPro.Controls.Add(dtp);
                }
            }

            catch (Exception s)
            {
                Console.WriteLine(s);
            }
            DateTime dateto = new DateTime(2000, 7, 26);

            try
            {
                if (this.dataPro.Columns[e.ColumnIndex].DataPropertyName == nameof(Project.todate))
                {
                    dtp1         = new DateTimePicker();
                    dtp1.Format  = DateTimePickerFormat.Short;
                    dtp1.Visible = true;
                    Rectangle rect = this.dataPro.GetCellDisplayRectangle(e.ColumnIndex, e.RowIndex, true);
                    dtp1.Location = new Point(rect.X, rect.Y);
                    dtp1.Size     = new Size(rect.Width, rect.Height);
                    try
                    {
                        dtp1.Value = DateTime.Parse(this.dataPro.CurrentCell.Value.ToString());
                    }
                    catch
                    {
                        dtp1.Visible = false;
                        dtp1.Dispose();
                        dataPro.CurrentCell.Value = dateto.ToString();
                    }
                    dtp1.CloseUp     += Dtp_Closeup1;
                    dtp1.TextChanged += Dtp_TextChanged1;
                    this.dataPro.Controls.Add(dtp1);
                }
            }
            catch (Exception s)
            {
                Console.WriteLine(s);
            }
        }