Skip to content

Commit

Permalink
Merge pull request #912 from Ordisoftware/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Ordisoftware authored Sep 23, 2021
2 parents 81e28d3 + f04b40b commit 190c249
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 53 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
80 changes: 45 additions & 35 deletions Project/Source/Forms/MainForm/MainForm.Initialize.Menus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,42 @@ public void CreateSystemInformationMenu()
/// </summary>
public void InitializeSpecialMenus()
{
CreateProvidersLinks();
CommonMenusControl.Instance.ActionViewStats.Enabled = Settings.UsageStatisticsEnabled;
CommonMenusControl.Instance.ActionViewLog.Enabled = DebugManager.TraceEnabled;
ActionWebLinks.Visible = Settings.WebLinksMenuEnabled;
if ( Settings.WebLinksMenuEnabled )
{
ActionWebLinks.InitializeFromWebLinks(InitializeSpecialMenus);
ActionWebLinks.DuplicateTo(MenuWebLinks);
}
MenuWebLinks.Visible = Settings.WebLinksMenuEnabled;
MenuWebLinks.Enabled = Settings.WebLinksMenuEnabled;
ActionLocalWeather.Visible = Settings.WeatherMenuItemsEnabled;
ActionOnlineWeather.Visible = Settings.WeatherMenuItemsEnabled;
SeparatorMenuWeather.Visible = Settings.WeatherMenuItemsEnabled;
ActionWebLinks.Enabled = Settings.WebLinksMenuEnabled;
ActionLocalWeather.Enabled = Settings.WeatherMenuItemsEnabled;
ActionOnlineWeather.Enabled = Settings.WeatherMenuItemsEnabled;
SeparatorMenuWeather.Enabled = Settings.WeatherMenuItemsEnabled;
var isVisible = Settings.WeatherMenuItemsEnabled ? (int?)null : int.MinValue;
ActionLocalWeather.Tag = isVisible;
ActionOnlineWeather.Tag = isVisible;
SeparatorMenuWeather.Tag = isVisible;
ActionTools.DuplicateTo(MenuTools);
ActionInformation.DuplicateTo(MenuInformation);
if ( !Settings.AllowSuspendReminder && ActionEnableReminder.Enabled )
ActionEnableReminder.PerformClick();
ActionDisableReminder.Enabled = Settings.AllowSuspendReminder;
MenuDisableReminder.Enabled = Settings.AllowSuspendReminder;
}

/// <summary>
/// Create providers links menu items.
/// </summary>
private void CreateProvidersLinks()
{
// Weekly parashah menu
ActionStudyOnline.InitializeFromProviders(HebrewGlobals.WebProvidersParashah, (sender, e) =>
{
var menuitem = (ToolStripMenuItem)sender;
Expand All @@ -55,6 +91,15 @@ public void InitializeSpecialMenus()
weekParashah.Factory,
weekParashah.Day.HasLinkedParashah);
});
ActionOpenVerseOnline.InitializeFromProviders(HebrewGlobals.WebProvidersBible, (sender, e) =>
{
var menuitem = (ToolStripMenuItem)sender;
var weekParashah = ApplicationDatabase.Instance.GetWeeklyParashah();
if ( weekParashah.Factory == null ) return;
string verse = $"{(int)weekParashah.Factory.Book}.{weekParashah.Factory.VerseBegin}";
HebrewTools.OpenBibleProvider((string)menuitem.Tag, verse);
});
// Visual month context menu
ContextMenuDayParashahStudy.InitializeFromProviders(HebrewGlobals.WebProvidersParashah, (sender, e) =>
{
var menuitem = (ToolStripMenuItem)sender;
Expand All @@ -64,14 +109,6 @@ public void InitializeSpecialMenus()
weekParashah,
ContextMenuDayCurrentEvent.HasLinkedParashah);
});
ActionOpenVerseOnline.InitializeFromProviders(HebrewGlobals.WebProvidersBible, (sender, e) =>
{
var menuitem = (ToolStripMenuItem)sender;
var weekParashah = ApplicationDatabase.Instance.GetWeeklyParashah();
if ( weekParashah.Factory == null ) return;
string verse = $"{(int)weekParashah.Factory.Book}.{weekParashah.Factory.VerseBegin}";
HebrewTools.OpenBibleProvider((string)menuitem.Tag, verse);
});
ContextMenuDayParashahRead.InitializeFromProviders(HebrewGlobals.WebProvidersBible, (sender, e) =>
{
var menuitem = (ToolStripMenuItem)sender;
Expand All @@ -80,33 +117,6 @@ public void InitializeSpecialMenus()
string verse = $"{(int)weekParashah.Book}.{weekParashah.VerseBegin}";
HebrewTools.OpenBibleProvider((string)menuitem.Tag, verse);
});
CommonMenusControl.Instance.ActionViewStats.Enabled = Settings.UsageStatisticsEnabled;
CommonMenusControl.Instance.ActionViewLog.Enabled = DebugManager.TraceEnabled;
ActionWebLinks.Visible = Settings.WebLinksMenuEnabled;
ActionLocalWeather.Visible = Settings.WeatherMenuItemsEnabled;
ActionOnlineWeather.Visible = Settings.WeatherMenuItemsEnabled;
SeparatorMenuWeather.Visible = Settings.WeatherMenuItemsEnabled;
ActionWebLinks.Enabled = Settings.WebLinksMenuEnabled;
ActionLocalWeather.Enabled = Settings.WeatherMenuItemsEnabled;
ActionOnlineWeather.Enabled = Settings.WeatherMenuItemsEnabled;
SeparatorMenuWeather.Enabled = Settings.WeatherMenuItemsEnabled;
var isVisible = Settings.WeatherMenuItemsEnabled ? (int?)null : int.MinValue;
ActionLocalWeather.Tag = isVisible;
ActionOnlineWeather.Tag = isVisible;
SeparatorMenuWeather.Tag = isVisible;
MenuWebLinks.Visible = Settings.WebLinksMenuEnabled;
MenuWebLinks.Enabled = Settings.WebLinksMenuEnabled;
if ( Settings.WebLinksMenuEnabled )
{
ActionWebLinks.InitializeFromWebLinks(InitializeSpecialMenus);
ActionWebLinks.DuplicateTo(MenuWebLinks);
}
ActionTools.DuplicateTo(MenuTools);
ActionInformation.DuplicateTo(MenuInformation);
if ( !Settings.AllowSuspendReminder && ActionEnableReminder.Enabled )
ActionEnableReminder.PerformClick();
ActionDisableReminder.Enabled = Settings.AllowSuspendReminder;
MenuDisableReminder.Enabled = Settings.AllowSuspendReminder;
}

}
Expand Down
2 changes: 1 addition & 1 deletion Project/Source/Program/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ void update(Form form)
});
}
MainForm.Instance.CalendarMonth._btnToday.ButtonText = AppTranslations.Today.GetLang();
task?.Wait();
MainForm.Instance.CreateSystemInformationMenu();
}
catch ( Exception ex )
Expand All @@ -327,7 +328,6 @@ void update(Form form)
}
finally
{
task?.Wait();
Globals.ChronoTranslate.Stop();
Settings.BenchmarkTranslate = Globals.ChronoTranslate.ElapsedMilliseconds;
}
Expand Down

0 comments on commit 190c249

Please sign in to comment.