} // Trick to show previous month (default ist actual and future month); reset to default 31.12.9998 later private void TimerRunOnce_Tick(object sender, EventArgs e) { // Schreibt etwas zeitverzögert die Feiertage in die BoldedDates-Eigenschaft (Workaround) timerRunOnce.Stop(); //tooltipFixDays = annualFixDays.ToDictionary(x => new DateTime(currentYear, x.Key.Month, x.Key.Day), x => x.Value); tooltipFixDays = ClsBoldedDays.GetAnnualDays(currentYear); Dictionary <DateTime, string> boldedMobileDays = ClsBoldedDays.GetMobileDays(currentYear, varTooltipText); tooltipDays = ClsBoldedDays.MergeBoldedDays(tooltipFixDays, boldedMobileDays); monthCalendar.BoldedDates = boldedMobileDays.Keys.ToArray(); // diese Zeile den Fehler, wenn BoldedDates bei DateChanged neu geschrieben werden sollen monthCalendar.Focus(); monthCalendar.MaxDate = new DateTime(9998, 12, 31); // to show previous month (default ist actual and future month); reset to default 31.12.9998 after Load per Timer }
} // disable visual styles for this control private void FrmCalendar_Load(object sender, EventArgs e) { SetColors(); if (!string.IsNullOrEmpty(varGoogleCalendar) && varGoogleCalendar.Substring(varGoogleCalendar.Length - 4).Equals(".ics")) { string localFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Kalender.ics"); WebClient webClient = new WebClient(); try { webClient.DownloadFile(varGoogleCalendar, localFile); } // vorhandene Datei wird überschrieben catch (ArgumentNullException ae) { MessageBox.Show(ae.Message, appName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); } catch (WebException we) { MessageBox.Show(we.Message, appName, MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (NotSupportedException se) { MessageBox.Show(se.Message, appName, MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { webClient.Dispose(); } } Rectangle screen = Screen.PrimaryScreen.WorkingArea; string[] coords = varFormLocation.Split(','); Point point = new Point(int.Parse(coords[0]), int.Parse(coords[1])); if (point.IsEmpty) {// CenterOnSreen wenn keine gespeicherten Werte vorhanden sind Location = new Point((screen.Height / 2) - (Height / 2), (screen.Width / 2) - (Width / 2)); } else {// Form komplett innerhalb der WorkingArea angezeigt werden int xPos = point.X; int yPos = point.Y; xPos = xPos <0 ? 0 : xPos + Width> screen.Width ? screen.Width - Width : xPos; yPos = yPos <0 ? 0 : yPos + Height> screen.Height ? screen.Height - Height : yPos; Location = new Point(xPos, yPos); } lblHorizontalLine.Location = new Point(lblHorizontalLine.Location.X, lblInfo.Location.Y); // if currentView = 3 if (varTrayModus && varHotkeyLetter >= 'A' && varHotkeyLetter <= 'Z') { if (NativeMethods.RegisterHotKey(Handle, NativeMethods.HOTKEY_ID, (uint)(NativeMethods.Modifiers.Control | NativeMethods.Modifiers.Win), (uint)(Keys)varHotkeyLetter) == false) { MessageBox.Show("Fehler beim Registrieren des Hotkey!\nDer Hotkey wird wahrscheinlich bereits\nvon einem anderen Programm benutzt.", appName, MessageBoxButtons.OK, MessageBoxIcon.Information); varHotkeyLetter = '-'; } else { anzeigenToolStripMenuItem.ShortcutKeyDisplayString = "Strg+Win+" + Char.ToUpper(varHotkeyLetter); } } monthCalendar.AnnuallyBoldedDates = ClsBoldedDays.GetAnnualDays().Keys.ToArray(); // muss vor MaxDate-Zeile stehen! if (varCurrentView == 3) { monthCalendar.MaxDate = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)).AddMonths(1); } } // Trick to show previous month (default ist actual and future month); reset to default 31.12.9998 later