private MenuItem SettingsMenu()
 {
     Log.LogCaller();
     return(new MenuItem(Resources.SettingsMenu, new MenuItem[10]
     {
         new MenuItem(Resources.StartWithWindowsMenu, StartWithWindowsClick)
         {
             Checked = Settings.StartWithWindows
         },
         new MenuItem(Resources.AutoUpdateMenu, AutoUpdateClick)
         {
             Checked = Settings.SettingIsValue(Resources.AutoUpdate, "True")
         },
         LanguageMenu(),
         ApplicationLogMenu(),
         NotificationsMenu(),
         new MenuItem(TaskbarUtil.UsingSmallTaskbarButtons() ?
                      Resources.SwitchToLargeTaskbarButtonsMenu : Resources.SwitchToSmallTaskbarButtonsMenu,
                      ToogleTaskbarIconSizeMenuClick),
         new MenuItem(Resources.ExportSettingsMenu, ExportSettingsClick),
         new MenuItem(Resources.ImportSettingsMenu, ImportSettingsClick),
         CalendarSettingsMenu(),
         IconMenu()
     }));
 }
 private void ToogleTaskbarIconSizeMenuClick(object o, EventArgs e)
 {
     try
     {
         Log.LogCaller();
         MenuItem mi = (MenuItem)o;
         TaskbarUtil.ToogleTaskbarIconSize();
         mi.Text = TaskbarUtil.UsingSmallTaskbarButtons() ? Resources.SwitchToLargeTaskbarButtonsMenu : Resources.SwitchToSmallTaskbarButtonsMenu;
         SettingsChangedHandler?.Invoke(null, null);
     }
     catch (Exception ex)
     {
         Message.Show(Resources.UnhandledException, ex);
     }
 }
Esempio n. 3
0
        internal static int GetIconResolution(bool forceUpdate = false)
        {
            int    iconResolution = Settings.GetIntSetting(Resources.IconResolution, -1);
            double myDbl          = 1.0d;

            if (forceUpdate || iconResolution == -1)
            {
                // guess what icon resolution to use based on system
                double winZoomLvl             = GetWindowsZoom();
                bool   usingSmallTaskbarIcons = TaskbarUtil.UsingSmallTaskbarButtons();
                myDbl = (double)System.Windows.SystemParameters.SmallIconHeight * winZoomLvl;
                if (!usingSmallTaskbarIcons)
                {
                    myDbl *= 1.5d;
                }
                if (System.Windows.SystemParameters.PrimaryScreenWidth > 1600)
                {
                    myDbl *= 2.0d;
                }
                Log.Info = $"SmallIconHeight={System.Windows.SystemParameters.SmallIconHeight}";
                Log.Info = $"WindowsZoomLevel={winZoomLvl * 100}";
                Log.Info = $"UsingSmallTaskbarButtons={usingSmallTaskbarIcons}";
                Log.Info = $"Guessed icon resolution={myDbl}x{myDbl}";

                // find closes match to existing configs (do not allow 16,20,24)
                List <int> list = new List <int> {
                    32, 40, 48, 64, 128, 256, 512
                };
                int closest = list.Aggregate((x, y) => Math.Abs(x - myDbl) < Math.Abs(y - myDbl) ? x : y);

                Log.Info = $"Closest icon resolution={closest}x{closest}";

                Settings.UpdateSetting(Resources.IconResolution, closest.ToString());
                iconResolution = closest;
            }

            return(iconResolution);
        }