private bool IsTimePointTimeInUsing(List <TimePoint> timePoints, TimePoint currentTimePoint) { foreach (var time in timePoints) { if (time.Time == currentTimePoint.Time) { return(false); } } return(true); }
private void moveUpButton_Click(object sender, EventArgs e) { if (listBox.SelectedIndex > 0) { TimePoint timePoint = _timePoints[listBox.SelectedIndex]; _timePoints[listBox.SelectedIndex] = _timePoints[listBox.SelectedIndex - 1]; _timePoints[listBox.SelectedIndex - 1] = timePoint; UpdateListbox(); listBox.SelectedIndex--; } }
private void moveDownButton_Click(object sender, EventArgs e) { if (listBox.SelectedIndex < _timePoints.Count - 1) { TimePoint timePoint = _timePoints[listBox.SelectedIndex]; _timePoints[listBox.SelectedIndex] = _timePoints[listBox.SelectedIndex + 1]; _timePoints[listBox.SelectedIndex + 1] = timePoint; UpdateListbox(); listBox.SelectedIndex++; } }
public int CompareTo(object obj) { TimePoint point = (TimePoint)obj; if (this.Time > point.Time) { return(1); } if (this.Time < point.Time) { return(-1); } return(0); }
private void addButton_Click(object sender, EventArgs e) { string description = descriptionTextBox.Text.Trim(); if (description == "") { description = "Without Description"; } long timeToSeconds = TimeToSeconds((int)hrsNumeric.Value, (int)minNumeric.Value, (int)secNumeric.Value); Point point = new Point((int)xNumeric.Value, (int)yNumeric.Value); TimePoint timePoint = new TimePoint(new DateTime().AddSeconds(timeToSeconds), point, description); if (IsTimePointTimeInUsing(_timePoints, timePoint)) { _timePoints.Add(timePoint); UpdateListbox(); } }