private void loadFromSettings() { listView1.Items.Clear(); foreach (KeyValuePair <string, Settings.ColorSet> entry in this.settings.colors) { string k = entry.Key; Settings.ColorSet cs = entry.Value; if (cs.tracked == "1") { k = k + "*"; } ListViewItem lvi = new ListViewItem(); lvi.Text = k; lvi.ForeColor = this.getColorFromString(cs.fgColor); lvi.BackColor = this.getColorFromString(cs.bgColor); listView1.Items.Add(lvi); } }
private void loadButtons() { this.clearButtons(); this.settings = new Settings(); foreach (KeyValuePair <string, Settings.ButtonSpec> entry in this.settings.buttons) { string l = entry.Value.buttonLabel; string t = entry.Value.buttonType; string m = entry.Value.buttonMessage; Button btn = new Button(); btn.AutoSize = true; btn.Text = l; Settings.ColorSet cs = this.settings.getColorSet(t); btn.ForeColor = this.getColorFromString(cs.fgColor); btn.BackColor = this.getColorFromString(cs.bgColor); btn.Click += new EventHandler(button_Click); buttonFlp.Controls.Add(btn); } }
private void button1_Click(object sender, EventArgs e) { // save this.settings.clearColors(); foreach (ListViewItem lvi in listView1.Items) { string lbl = lvi.Text; string tracked = "0"; if (lbl.Substring(lbl.Length - 1, 1) == "*") { tracked = "1"; lbl = lbl.Substring(0, lbl.Length - 1); } string fgs = this.getStringFromColor(lvi.ForeColor); string bgs = this.getStringFromColor(lvi.BackColor); Settings.ColorSet cs = new Settings.ColorSet(lbl, fgs, bgs, tracked); this.settings.addColor(cs); } this.settings.save(); }
private void addRow(Settings.ButtonSpec bs) { int r; Settings.ColorSet cs = this.settings.getColorSet(bs.buttonType); Color fg = this.getColorFromString(cs.fgColor); Color bg = this.getColorFromString(cs.bgColor); List <string> ls = new List <string>(); ls.Add(this.getTime()); ls.Add(bs.buttonType); ls.Add(bs.buttonMessage); r = dataGridView1.Rows.Add(ls.ToArray()); DataGridViewRow row = dataGridView1.Rows[r]; for (int i = 0; i < row.Cells.Count; i++) { row.Cells[i].Style.ForeColor = fg; row.Cells[i].Style.BackColor = bg; } }
private void saveBtn_Click(object sender, EventArgs e) { SaveFileDialog sfd = new SaveFileDialog(); sfd.Filter = "Text File|*.txt"; sfd.Title = "Save the data"; sfd.FileName = this.saveFileName + ".txt"; DialogResult res = sfd.ShowDialog(); if (res == DialogResult.OK) { List <string> ls = new List <string>(); string prevMsg = ""; int prevHMS = 0; Dictionary <string, int> durations = new Dictionary <string, int>(); foreach (DataGridViewRow obj in dataGridView1.Rows) { if (!obj.IsNewRow) { string ts = obj.Cells[0].Value.ToString(); string bty = obj.Cells[1].Value.ToString(); string msg = obj.Cells[2].Value.ToString(); string s = ts + "\t" + bty + "\t" + msg; ls.Add(s); // see if this is a trackble event Settings.ColorSet cs = this.settings.getColorSet(bty); if ((cs.tracked == "1") || (bty == "STOP")) { int hms = this.hms_to_seconds(ts); if ((prevMsg != "") && (prevMsg != msg)) { int dur = hms - prevHMS; if (!durations.ContainsKey(prevMsg)) { durations.Add(prevMsg, 0); } durations[prevMsg] += dur; prevHMS = hms; prevMsg = msg; } else if (prevMsg == "") { prevHMS = hms; prevMsg = msg; } } } } ls.Add(""); ls.Add("Durations"); ls.Add(""); foreach (KeyValuePair <string, int> entry in durations) { ls.Add(entry.Key + "\t" + this.seconds_to_hms(entry.Value)); } File.WriteAllLines(sfd.FileName, ls.ToArray()); } this.needToSave = false; }