public void start() { btn_Report_HTML.Enabled = btn_Report_Txt.Enabled = true; times = new obj_Times(); TimeSpan addTime = new TimeSpan(); TimeSpan remTime = new TimeSpan(); if (num_CorrH.Value + num_CorrM.Value > 0) { addTime += new TimeSpan((int)num_CorrH.Value, (int)num_CorrM.Value, 0); remTime += new TimeSpan((int)num_CorrH.Value * -1, (int)num_CorrM.Value * -1, 0); } lv_Results_01.Items.Clear(); lv_Results_02.Items.Clear(); DateTime arr = new DateTime(); DateTime dep = new DateTime(); DateTime n = DateTime.Now; TimeSpan time = new TimeSpan(); TimeSpan dif = new TimeSpan(); TimeSpan tDiff = new TimeSpan(0, 0, 0); TimeSpan tWork = new TimeSpan(0, 0, 0); int numOfDays = 0; List <String> lines = new List <string>(); if (rtb_Report_01.Text != "" && rtb_Report_02.Text == rtb_Report_01.Text) { tc1.SelectedIndex = 1; foreach (String s in rtb_Report_01.Lines) { foreach (String ss in Properties.Settings.Default.s_dayNames.Split(',')) { if (s.ToLower().StartsWith(ss.ToLower())) { lines.Add(s); } } } } Regex r_proper = new Regex(regx_proper); Regex r_daysOff = new Regex(regx_daysoff); Regex r_vacsic = new Regex(regx_vacsic); Regex r_nothing = new Regex(regx_nothing); MatchCollection mc = null; CaptureCollection cc = null; try { assumedUserName = rtb_Report_01.Lines[Properties.Settings.Default.s_UseLine]; } catch { assumedUserName = "******"; } if (forceUserName && userName != "") { Text = "WolfPaw WorkTime Calculator 2 - " + userName; } else if (forceUserName && userName == "") { Text = "WolfPaw WorkTime Calculator 2 - Unknown user"; } else { Text = "WolfPaw WorkTime Calculator 2 - " + assumedUserName; } foreach (String s in lines) { ListViewItem lvi = new ListViewItem(); ListViewItem.ListViewSubItem lvsi1 = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem lvsi2 = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem lvsi3 = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem lvsi4 = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem lvsi5 = new ListViewItem.ListViewSubItem(); ListViewItem.ListViewSubItem lvsi6 = new ListViewItem.ListViewSubItem(); if (r_daysOff.IsMatch(s)) { mc = r_daysOff.Matches(s); cc = mc[0].Captures; lvi.Text = mc[0].Groups[2].Value; lvsi1.Text = mc[0].Groups[1].Value; lvsi6.Text = "Munkaszüneti Nap"; lvi.BackColor = Color.LightGray; } else if (r_vacsic.IsMatch(s)) { mc = r_vacsic.Matches(s); cc = mc[0].Captures; lvi.Text = mc[0].Groups[2].Value; lvsi1.Text = mc[0].Groups[1].Value; lvsi6.Text = "Szabadság / Betegség"; lvi.BackColor = Color.LightGreen; } else if (r_nothing.IsMatch(s)) { mc = r_nothing.Matches(s); cc = mc[0].Captures; lvi.Text = mc[0].Groups[2].Value; lvsi1.Text = mc[0].Groups[1].Value; lvsi6.Text = " - "; lvi.BackColor = Color.LightYellow; } else if (r_proper.IsMatch(s)) { lvi.UseItemStyleForSubItems = false; lvsi1.BackColor = lvsi2.BackColor = lvsi3.BackColor = lvsi4.BackColor = lvsi5.BackColor = lvsi6.BackColor = Color.LightYellow; lvsi1.Font = lvsi2.Font = lvsi3.Font = lvsi4.Font = lvsi5.Font = lvsi6.Font = Properties.Settings.Default.s_lvFont; numOfDays++; int ah = 0, am = 0, dh = 0, dm = 0; mc = r_proper.Matches(s); cc = mc[0].Captures; lvi.Text = mc[0].Groups[2].Value; lvsi1.Text = mc[0].Groups[1].Value; lvsi2.Text = mc[0].Groups[3].Value; lvsi3.Text = mc[0].Groups[4].Value; ah = Convert.ToInt32(lvsi2.Text.Split(':')[0]); am = Convert.ToInt32(lvsi2.Text.Split(':')[1]); //lvsi4.Text = mc[0].Groups[5].Value; dh = Convert.ToInt32(lvsi3.Text.Split(':')[0]); dm = Convert.ToInt32(lvsi3.Text.Split(':')[1]); arr = new DateTime(n.Year, n.Month, n.Day, ah, am, 0); dep = new DateTime(n.Year, n.Month, n.Day, dh, dm, 0); time = dep.TimeOfDay - arr.TimeOfDay; lvsi4.Text = time.Hours.ToString().PadLeft(2, '0') + ":" + time.Minutes.ToString().PadLeft(2, '0'); dif = time - daily; String tme = ""; tme = dif.ToString().Substring(0, dif.ToString().Length - 3); lvsi5.Text = tme; if (dif.TotalMinutes > 0) { lvsi5.Text = " " + lvsi5.Text; lvsi5.Text += " ↑"; lvsi5.BackColor = Color.Green; } else if (dif.TotalMinutes < 0) { lvsi5.Text += " ↓"; lvsi5.BackColor = Color.LightPink; if (dif.TotalMinutes <= -30) { lvsi5.BackColor = Color.OrangeRed; } if (dif.TotalMinutes <= -60) { lvsi5.BackColor = Color.Red; } } else { lvsi5.Text += " ="; } lvsi6.Text = ""; lvi.BackColor = Color.LightYellow; tDiff += dif; tWork += time; times.addItem(numOfDays, Convert.ToDateTime(mc[0].Groups[2].Value), Convert.ToDateTime(mc[0].Groups[3].Value), Convert.ToDateTime(mc[0].Groups[4].Value), time); } if (lvsi1.Text.ToLower() == "hétfo") { lvsi1.Text = lvsi1.Text.Replace("o", "ő"); } lvi.SubItems.Add(lvsi1); lvi.SubItems.Add(lvsi2); lvi.SubItems.Add(lvsi3); lvi.SubItems.Add(lvsi4); lvi.SubItems.Add(lvsi5); lvi.SubItems.Add(lvsi6); if (!lockView) { lv_Results_02.Items.Add(lvi); } ListViewItem lvi2 = (ListViewItem)lvi.Clone(); lvi2.Font = Properties.Settings.Default.s_lvFont; lv_Results_01.Items.Add(lvi2); } if (!lockView) { ch_Arrival_02.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_AtWork_02.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_Date_02.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_DayOfWeek_02.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_DayType_02.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_Departure_02.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_Diff_02.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); } ch_Arrival_01.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_AtWork_01.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_Date_01.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_DayOfWeek_01.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_DayType_01.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_Departure_01.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); ch_Diff_01.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); lv_Results_01.Font = Properties.Settings.Default.s_lvFont; lv_Results_02.Font = Properties.Settings.Default.s_lvFont; if (num_CorrH.Value + num_CorrM.Value > 0) { if (pm_minus) { tDiff += remTime; tWork += remTime; } else { tDiff += addTime; tWork += addTime; } } try { tb_Diff.Text = tDiff.ToString().Substring(0, tDiff.ToString().Length - 3); tb_Mean.Text = new TimeSpan(0, ((int)tWork.TotalMinutes / numOfDays), 0).ToString(); tb_Days.Text = numOfDays + ""; } catch { } if (tDiff.TotalMinutes < 0) { tb_Diff.BackColor = Color.LightPink; tb_Diff.Text += " ↓"; } else if (tDiff.TotalMinutes > 0) { tb_Diff.BackColor = Color.LightGreen; tb_Diff.Text += " ↑"; } else { tb_Diff.BackColor = Color.LightYellow; tb_Diff.Text += " ="; } }
public String getColor(String txt) { int times = 1; string ret = ""; ret = txt; if (txt != "") { txt = txt.Replace("↑", "").Replace("↓", "").Replace("=", ""); txt = txt.Trim(); if (txt.StartsWith("-")) { txt = txt.Replace("-", ""); times = -1; } TimeSpan spn = new TimeSpan(Convert.ToInt32(txt.Split(':')[0]), Convert.ToInt32(txt.Split(':')[1]), 0); if (times == -1) { spn = spn.Negate(); } if (times > 0) { ret = "<td•class='green'>" + ret; } else { //MessageBox.Show(spn.TotalMinutes.ToString()); if (spn.TotalMinutes <= -60) { ret = "<td•class='red'>" + ret; } else if (spn.TotalMinutes <= -30) { ret = "<td•class='lightred'>" + ret; } else if (spn.TotalMinutes < 0) { ret = "<td•class='pink'>" + ret; } else if (spn.TotalMinutes == 0) { ret = "<td•class='yellow'>" + ret; } } //MessageBox.Show(spn.ToString()); } else { return("<td>"); } return(ret); }