internal void AddHistory(string name, TaskRecord record) { RhinoApp.InvokeOnUiThread(new Action(() => { TaskHistory historyGroup = GetHistoryByID(record.TaskID); if (historyGroup == null) { historyGroup = new TaskHistory(name, record.TaskID); } int index = historyGroup.TaskRows.Items.Count + 1; // record.date.ToString("[MM/dd HH:mm:ss]") TaskRow taskRow = new TaskRow(index, record); taskRow.RestoreEvent += task => RestoreEvent(task); taskRow.StoreEvent += TaskRow_StoreEvent; taskRow.DeleteEvent += TaskRow_DeleteEvent; historyGroup.AddRow(taskRow); if (historyGroup.TaskRows.Items.Count == 1) { StackLayout.Items.Add(new StackLayoutItem(historyGroup)); } })); }
private void TaskRow_DeleteEvent(TaskRow taskRow) { TaskHistory historyGroup = GetHistoryByID(taskRow.TaskID); var items = historyGroup.TaskRows.Items; StackLayoutItem tobedel = null; foreach (var item in items) { if (!(item.Control is TaskRow row) || !Equals(row.HistoryID, taskRow.HistoryID)) { continue; } tobedel = item; } if (items.Count == 1) { MessageBox.Show("至少要留一个历史记录!"); return; } if (tobedel != null) { historyGroup.TaskRows.Items.Remove(tobedel); } DeleteEvent(taskRow); }
public void AddRow(TaskRow task) { TaskRows.Items.Add(task); Content = TaskRows; }
private void TaskRow_StoreEvent(TaskRow taskRow) { StoreEvent(taskRow); }