private void okButton_Click(object sender, EventArgs e) { if (!contentTextBox.Text.Equals("")) { string planDate = dateTimePicker.Text; string startPlanDate = _planClassControl.planClassControlInitParameter.startTime; string endPlanDate = _planClassControl.planClassControlInitParameter.endTime; DateTimeFormatInfo format = new System.Globalization.DateTimeFormatInfo(); format.ShortDatePattern = DATE_PATTERN; DateTime planDateTime = Convert.ToDateTime(planDate, format); DateTime startPlanDateTime = Convert.ToDateTime(startPlanDate, format); DateTime endPlanDateTime = Convert.ToDateTime(endPlanDate, format); int compare1 = DateTime.Compare(planDateTime, endPlanDateTime); int compare2 = DateTime.Compare(planDateTime, startPlanDateTime); if (compare1 <= 0 && compare2 >= 0) { Label planL = new Label(); planL.Text = dateTimePicker.Text + ":" + contentTextBox.Text; int lengthOfLine = PlanClassControl.convertDateToLengthOfLine(planDate, _planClassControl.planClassControlInitParameter.endTime); planL.Location = new Point(_planClassControl.pPictureBox.Width / 2 - CENTER_OFFSET, lengthOfLine + POINT_HEIGHT_BASE); planL.ForeColor = NewPlanInitParameterForm.createRandomColor(); _planClassControl.pPictureBox.Controls.Add(planL); } else { DialogResult dr1 = MessageBox.Show(loadGlobalChineseCharacters.GlobalChineseCharactersDict["exception2"], loadGlobalChineseCharacters.GlobalChineseCharactersDict["exception"]); } } }
public AddPlanForm(int planIndex, PlanClassControl _planClassControl) { InitializeComponent(); loadGlobalChineseCharacters = LoadGlobalChineseCharacters.GetInstance(); this._planClassControl = _planClassControl; this.planIndex = planIndex; initUI(); }
private void createNewPlanClassControl(string planName, string startDate, string endDate) { Color color = createRandomColor(); PlanClassControlInitParameter planClassControlInitParameter = new PlanClassControlInitParameter(planName, startDate, endDate, color); PlanClassControl planClassControl = new PlanClassControl(main.panel.Controls.Count + 1, planClassControlInitParameter); planClassControl.Location = new Point(main.panel.Controls.Count * planClassControl.Width, 0); main.panel.Controls.Add(planClassControl); }