public void BT_Start_Stop_Clicked(object sender, EventArgs e) { if (!Counting) { Counting = true; foreach (ListViewItem lvItem in View.lv_items.Items) { if (lvItem.Selected) { Current_TI = new TrackedItem(lvItem.Text, lvItem.SubItems[1].Text); timer.Start(); break; } } View.bt_start_stop.Text = "Stop"; } else { Counting = false; if (Current_TI != null) { timer.Stop(); ConfigHandler.UpdateItem(Current_TI); Current_LVI.SubItems[1].Text = Current_TI.Time.ToString(); } View.bt_start_stop.Text = "Start"; } }
public void AddItem(TrackedItem item) { XmlNode newItem = trackedItemsDoc.CreateElement(item.Name); newItem.InnerText = item.Time.ToString(); RootNode_Tracked.AppendChild(newItem); trackedItemsDoc.Save(TrackedItems_Path + TrackedItems_FileName); }
public void DeleteItem(TrackedItem item) { var toDel = GetItem(item); if (toDel != null) { RootNode_Tracked.RemoveChild(toDel); trackedItemsDoc.Save(TrackedItems_FileName); } }
public void UpdateItem(TrackedItem item) { var toUpd = GetItem(item); if (toUpd != null) { toUpd.InnerText = item.Time.ToString(); trackedItemsDoc.Save(TrackedItems_Path + TrackedItems_FileName); } }
//PRIVATE public XmlNode GetItem(TrackedItem item) { foreach (XmlNode node in RootNode_Tracked.ChildNodes) { if (node.Name == item.Name) { return(node); } } return(null); }
//PRIVATE private void AddListViewItem(TrackedItem trackedItem) { ListViewItem lvItem = new ListViewItem() { Text = trackedItem.Name, }; lvItem.SubItems.Add(trackedItem.Time.ToString()); View.lv_items.Items.Add(lvItem); View.lv_items.Columns[0].AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); }
public void TB_NewItemInput_EnterPressed(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Enter) { string itemName = View.tb_new_item_input.Text; if (!string.IsNullOrWhiteSpace(itemName)) { itemName = itemName.Replace(' ', '_'); TrackedItem trackedItem = new TrackedItem(itemName); if (ConfigHandler.GetItem(trackedItem) == null) { ConfigHandler.AddItem(trackedItem); AddListViewItem(trackedItem); } } View.tb_new_item_input.Text = ""; } }