Skip to content

Commit

Permalink
Fix printing
Browse files Browse the repository at this point in the history
  • Loading branch information
Olivier Rogier committed Sep 23, 2021
1 parent 3abfac0 commit f04b40b
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions Project/Dependencies/Calendar.NET/Calendar.cs
Original file line number Diff line number Diff line change
Expand Up @@ -928,6 +928,11 @@ private void RenderMonthCalendar(PaintEventArgs e)
{
if ( IsVisualStudioDesigner ) return;
if ( !Globals.IsReady ) return;
bool isPrinting = Globals.IsPrinting;
bool useColors = Program.Settings.UseColors;
bool useHoverEffect = Program.Settings.CalendarUseHoverEffect;
bool showSelectedox = Program.Settings.CalendarShowSelectedBox;
bool selectedBoxOnlyCurrent = Program.Settings.SelectedDayBoxColorOnlyCurrent;
_calendarDays.Clear();
_calendarEvents.Clear();
var bmp = new Bitmap(ClientSize.Width, ClientSize.Height);
Expand All @@ -938,11 +943,14 @@ private void RenderMonthCalendar(PaintEventArgs e)
// ORDISOFWTARE MODIF BEGIN
var today = DateTime.Today;
string monthText = _calendarDate.ToString("MMMM").Titleize();
if ( MainForm.Instance.CurrentDay != null )
MonthWithDayText = MainForm.Instance.CurrentDay.Date.Day + " " + monthText;
if ( isPrinting )
MonthWithDayText = monthText;
else
if ( !MainForm.Instance.PreferencesMutex )
MonthWithDayText = today.Day + " " + monthText;
if ( MainForm.Instance.CurrentDay != null )
MonthWithDayText = MainForm.Instance.CurrentDay.Date.Day + " " + monthText;
else
if ( !MainForm.Instance.PreferencesMutex )
MonthWithDayText = today.Day + " " + monthText;
int daysinmonth = DateTime.DaysInMonth(_calendarDate.Year, _calendarDate.Month);
SizeF monSize = sunSize;// g.MeasureString("Mon", _dayOfWeekFont);
SizeF tueSize = sunSize;// g.MeasureString("Tue", _dayOfWeekFont);
Expand Down Expand Up @@ -983,11 +991,6 @@ private void RenderMonthCalendar(PaintEventArgs e)
selectedMonth = today.Month;
selectedYear = today.Year;
}
bool printmutex = Globals.IsPrinting;
bool useColors = Program.Settings.UseColors;
bool useHoverEffect = Program.Settings.CalendarUseHoverEffect;
bool showSelectedox = Program.Settings.CalendarShowSelectedBox;
bool selectedBoxOnlyCurrent = Program.Settings.SelectedDayBoxColorOnlyCurrent;
bool CheckSelected(int day)
=> day == selectedDay && _calendarDate.Month == selectedMonth && _calendarDate.Year == selectedYear;
// ORDISOFWTARE MODIF END
Expand Down Expand Up @@ -1036,10 +1039,10 @@ bool CheckSelected(int day)
{
//ORDISOFTWARE MODIF BEGIN FIRST DAY OF MONTH ACTUAL DAY
SizeF stringSize = g.MeasureString(strCounter1, _todayFont);
if ( !printmutex )
if ( !isPrinting )
if ( useColors )
{
if ( CheckSelected(counter1) && !printmutex )
if ( CheckSelected(counter1) && !isPrinting )
{
isSelected = true;
g.FillRectangle(CurrentDayBackBrush, xStart + 5 - 1, yStart + 2 + 1, stringSize.Width + 4, stringSize.Height - 2);
Expand All @@ -1055,7 +1058,7 @@ bool CheckSelected(int day)
}
else
{
if ( CheckSelected(counter1) && !printmutex )
if ( CheckSelected(counter1) && !isPrinting )
{
isSelected = true;
g.FillRectangle(BrushBlack, xStart + 5, yStart + 2 + 1, stringSize.Width + 4, stringSize.Height - 2);
Expand All @@ -1074,7 +1077,7 @@ bool CheckSelected(int day)
else
{
//ORDISOFTWARE MODIF BEGIN FIRST DAY OF MONTH
if ( CheckSelected(counter1) && !printmutex )
if ( CheckSelected(counter1) && !isPrinting )
{
isSelected = true;
isSelectedNoToday = true;
Expand All @@ -1095,7 +1098,7 @@ bool CheckSelected(int day)
//ORDISOFTWARE MODIF BEGIN ACTUAL REAL DAY
string strCounter1 = counter1.ToString(CultureInfo.InvariantCulture);
SizeF stringSize = g.MeasureString(strCounter1, _todayFont);
if ( !printmutex )
if ( !isPrinting )
if ( useColors )
{
if ( CheckSelected(counter1) )
Expand All @@ -1113,7 +1116,7 @@ bool CheckSelected(int day)
}
else
{
if ( CheckSelected(counter1) && !printmutex )
if ( CheckSelected(counter1) && !isPrinting )
{
isSelected = true;
g.FillRectangle(BrushBlack, xStart + 5, yStart + 2 + 1, stringSize.Width + 1, stringSize.Height - 2);
Expand All @@ -1134,7 +1137,7 @@ bool CheckSelected(int day)
//ORDISOFTWARE MODIF BEGIN OTHER DAYS
string strCounter1 = counter1.ToString(CultureInfo.InvariantCulture);
SizeF stringSize = g.MeasureString(strCounter1, _daysFont);
if ( CheckSelected(counter1) && !printmutex )
if ( CheckSelected(counter1) && !isPrinting )
{
isSelected = true;
isSelectedNoToday = true;
Expand Down Expand Up @@ -1213,7 +1216,7 @@ bool CheckSelected(int day)
}

// ORDISOFWTARE MODIF BEGIN
if ( !printmutex )
if ( !isPrinting )
{
bool isactiveday = counter1 - 1 == _calendarDate.Day;
bool isMouseHover = false;
Expand Down

0 comments on commit f04b40b

Please sign in to comment.