public Program(ProgramSwitch[] program1, ProgramSwitch[] program2, int activeProgram) { Program1 = program1; Program2 = program2; ActiveProgram = activeProgram; }
//private void DrawProgramDial(PaintEventArgs e) //{ // if (_currentStatus.UserMode == UserModes.Clock) // { // Pen whitePen = new Pen(Color.White, 16 * Settings.Default.scale); // Pen whitePenSmall = new Pen(Color.White, 4 * Settings.Default.scale); // for (int i = 0; i < 12; i++) // { // e.Graphics.DrawArc(whitePen, 135 * Settings.Default.scale, 144 * Settings.Default.scale, 362 * Settings.Default.scale, 362 * Settings.Default.scale, 271 + (i * 29) + i, 28); // } // if (_currentProgram != null) // { // DateTime now = DateTime.Now; // Pen bluePen = new Pen(_blueColor, 4 * Settings.Default.scale); // Pen lightBluePen = new Pen(_lightBlueColor, 4 * Settings.Default.scale); // Pen redPen = new Pen(_redColor, 4 * Settings.Default.scale); // Pen lightRedPen = new Pen(_lightRedColor, 4 * Settings.Default.scale); // double average = 0; // int numSwitchPoints = 0; // for (int j = 0; j < _currentProgram.Length; j++) // { // int i = 0; // while(i<12) // { // int hour = i; // while (hour < now.Hour) // { // hour += 12; // } // DateTime switchPointToDraw = DateTime.Today.AddHours(hour); // if (_currentProgram[j].Timestamp <= switchPointToDraw && _currentProgram[(j + 1) % _currentProgram.Length].Timestamp > switchPointToDraw) // { // numSwitchPoints++; // average += _currentProgram[j].Temperature; // break; // } // i++; // } // } // average /= numSwitchPoints; // ProgramSwitch previousSwitchPoint =null; // for (int i = 0; i < 12; i++) // { // int hour = i; // while (hour < now.Hour) // { // hour += 12; // } // DateTime switchPointToDraw = DateTime.Today.AddHours(hour); // int segments = 1; // if (switchPointToDraw.Hour == now.Hour) // { // //exception situation // segments = 28; // } // for (int j = 0; j < _currentProgram.Length; j++) // { // if (switchPointToDraw <= _currentProgram[j].Timestamp && switchPointToDraw.AddMinutes(59) >= _currentProgram[j].Timestamp) // { // segments = 28;///(( _currentProgram[j].Timestamp.Minute*28)/60); // break; // } // } // for (int q = 0; q < segments; q++) // { // DateTime tmpSwitchPoint = switchPointToDraw.AddMinutes(Math.Round(2.14*q*(28/segments))); // if (tmpSwitchPoint.Hour == now.Hour && tmpSwitchPoint.Minute < now.Minute) // { // tmpSwitchPoint = tmpSwitchPoint.AddHours(12); // } // ProgramSwitch swi = null; // for (int j = 0; j < _currentProgram.Length; j++) // { // if (_currentProgram[j].Timestamp <= tmpSwitchPoint && _currentProgram[(j + 1)%_currentProgram.Length].Timestamp > tmpSwitchPoint) // { // swi = _currentProgram[j]; // break; // } // } // if (swi != null) // { // Pen p; // if (swi.Timestamp <= now && _currentScreenMode == ScreenMode.SetpointScreen) // { // p = whitePenSmall; // } // else if (swi.Temperature >= average) // { // if (previousSwitchPoint != null && previousSwitchPoint != swi && previousSwitchPoint.Temperature >= average) // { // p = lightRedPen; // } // else // { // p = redPen; // } // } // else // { // if (previousSwitchPoint != null && previousSwitchPoint != swi && previousSwitchPoint.Temperature < average) // { // p = lightBluePen; // } // else // { // p = bluePen; // } // } // e.Graphics.DrawArc(p, 147*Settings.Default.scale, 156*Settings.Default.scale, 338*Settings.Default.scale, 338*Settings.Default.scale, 271 + (i*29) + i + ((28F/segments)*q), 28/segments); // } // previousSwitchPoint = swi; // } // } // CurrentTimeIndicator(e); // } // } // else // { // e.Graphics.DrawArc(new Pen(Color.FromArgb(128, 128, 128), 16 * Settings.Default.scale), 135 * Settings.Default.scale, 144 * Settings.Default.scale, 362 * Settings.Default.scale, 362 * Settings.Default.scale, 0, 360); // } //} private void DrawProgramDial(PaintEventArgs e) { if (_currentStatus.UserMode == UserModes.Clock) { Pen whitePen = new Pen(Color.White, 16 * Settings.Default.scale); Pen whitePenSmall = new Pen(Color.White, 4 * Settings.Default.scale); for (int i = 0; i < 12; i++) { e.Graphics.DrawArc(whitePen, 135 * Settings.Default.scale, 144 * Settings.Default.scale, 362 * Settings.Default.scale, 362 * Settings.Default.scale, 271 + (i * 29) + i, 28); } if (_currentProgram != null) { DateTime now = DateTime.Now; Pen bluePen = new Pen(_blueColor, 4 * Settings.Default.scale); Pen lightBluePen = new Pen(_lightBlueColor, 4 * Settings.Default.scale); Pen redPen = new Pen(_redColor, 4 * Settings.Default.scale); Pen lightRedPen = new Pen(_lightRedColor, 4 * Settings.Default.scale); double average = 0; List <ProgramSwitch> switchpoints = new List <ProgramSwitch>(); for (int j = 0; j < _currentProgram.Length; j++) { int i = 0; while (i < 12) { int hour = i; while (hour < now.Hour) { hour += 12; } DateTime switchPointToDraw = DateTime.Today.AddHours(hour); // if (_currentProgram[j].Timestamp <= switchPointToDraw && _currentProgram[(j + 1) % _currentProgram.Length].Timestamp > switchPointToDraw) if (_currentProgram[j].Timestamp.Date == DateTime.Today.Date) { switchpoints.Add(_currentProgram[j]); average += _currentProgram[j].Temperature; break; } i++; } } average /= switchpoints.Count; ProgramSwitch previousSwitchPoint = null; Pen previousPen = null; for (int i = 0; i < 12; i++) { DateTime switchPointToDraw = DateTime.Today.AddHours(i + DateTime.Now.Hour); int segments = 1; if (i == 0) { segments = 28; } for (int j = 0; j < _currentProgram.Length; j++) { if (switchPointToDraw <= _currentProgram[j].Timestamp && switchPointToDraw.AddMinutes(59) >= _currentProgram[j].Timestamp) { segments = 28;///(( _currentProgram[j].Timestamp.Minute*28)/60); break; } } for (int q = 0; q < segments; q++) { DateTime tmpSwitchPoint = switchPointToDraw.AddMinutes(Math.Round(2.14 * q * (28 / segments))); if (i == 0 && tmpSwitchPoint.Minute < now.Minute) { tmpSwitchPoint = tmpSwitchPoint.AddHours(12); } ProgramSwitch swi = null; for (int j = 0; j < _currentProgram.Length; j++) { if (_currentProgram[j].Timestamp <= tmpSwitchPoint && _currentProgram[(j + 1) % _currentProgram.Length].Timestamp > tmpSwitchPoint) { swi = _currentProgram[j]; break; } } if (swi != null) { Pen p; if (swi.Timestamp <= now && _currentScreenMode == ScreenMode.SetpointScreen) { p = whitePenSmall; } else if (swi == previousSwitchPoint) { p = previousPen; } else if (swi.Temperature >= average) { if (previousSwitchPoint != null && previousSwitchPoint != swi && previousSwitchPoint.Temperature >= average) { p = redPen; } else { p = redPen; } } else { if (previousSwitchPoint != null && previousSwitchPoint != swi && previousSwitchPoint.Temperature < average) { p = bluePen; } else { p = bluePen; } } e.Graphics.DrawArc(p, 147 * Settings.Default.scale, 156 * Settings.Default.scale, 338 * Settings.Default.scale, 338 * Settings.Default.scale, 271 + ((tmpSwitchPoint.Hour % 12) * 29) + (tmpSwitchPoint.Hour % 12) + ((28F / segments) * q), 28 / segments); if (i > 0 || tmpSwitchPoint.Hour - DateTime.Now.Hour < 1) { previousPen = p; } } if (i > 0 || tmpSwitchPoint.Hour - DateTime.Now.Hour < 1) { previousSwitchPoint = swi; } } } CurrentTimeIndicator(e); } } else { e.Graphics.DrawArc(new Pen(Color.FromArgb(128, 128, 128), 16 * Settings.Default.scale), 135 * Settings.Default.scale, 144 * Settings.Default.scale, 362 * Settings.Default.scale, 362 * Settings.Default.scale, 0, 360); } }