public ActivityTime(LogTimeItem item) { InitializeComponent(); LogItem = item; timePickerAll.Time = LogItem.LoggedTime; Name = LogItem.ActivityID; }
public static void Remove(LogTimeItem item) { if (Cache != null) { lock(SyncRoot) { Cache.Data.Remove(item); } } }
public static void AddLogItem(LogTimeItem item) { CheckCache(); Cache.Data.Add(item); }
private void btnAddLogItem_Click(object sender, EventArgs e) { if(lvActivities.SelectedItems.Count == 1) { var selected = lvActivities.SelectedItems[0]; foreach (var item in flowPanel.Controls) { if (((ActivityTime)item).Name == selected.Text) { return; } } //flow panel doesn't contain such activity now //can add var logTime = new LogTimeItem(); logTime.ActivityID = selected.Text; logTime.DayOfLogging = dateTimePicker.Value.Date; LogItemsService.AddLogItem(logTime); var control = new ActivityTime(logTime); control.RemoveButtonClicked += control_RemoveButtonClicked; control.AddButtonClicked += control_AddButtonClicked; flowPanel.Controls.Add(control); FormChanged(); } }