public override Bitmap GetDisplayIcon(double dpi)
        {
            if (!string.IsNullOrEmpty(_presentationName))
            {
                return(PluginUtils.GetCachedExeIcon(_exePath, IconPresentation, dpi > 100));
            }

            return(PluginUtils.GetCachedExeIcon(_exePath, IconApplication, dpi > 100));
        }
Exemple #2
0
        public override Bitmap GetDisplayIcon(double dpi)
        {
            var exePath = PluginUtils.GetExePath("MSPVIEW.EXE");

            if (exePath != null && File.Exists(exePath))
            {
                return(PluginUtils.GetCachedExeIcon(exePath, 0, dpi > 100));
            }
            return(null);
        }
 public override Bitmap GetDisplayIcon(double dpi)
 {
     if (_outlookInspectorCaption == null)
     {
         return(PluginUtils.GetCachedExeIcon(_exePath, IconApplication, dpi > 100));
     }
     if (OlObjectClass.olAppointment.Equals(_outlookInspectorType))
     {
         // Make sure we loaded the icon, maybe the configuration has been changed!
         return(PluginUtils.GetCachedExeIcon(_exePath, IconMeeting, dpi > 100));
     }
     return(MailIcon);
 }
Exemple #4
0
 /// <summary>
 /// Fix icon reference
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnIconSizeChanged(object sender, PropertyChangedEventArgs e)
 {
     if (e.PropertyName == "IconSize")
     {
         try {
             string exePath = PluginUtils.GetExePath("cmd.exe");
             if (exePath != null && File.Exists(exePath))
             {
                 itemPlugInRoot.Image = PluginUtils.GetCachedExeIcon(exePath, 0);
             }
         } catch (Exception ex) {
             LOG.Warn("Couldn't get the cmd.exe image", ex);
         }
     }
 }
Exemple #5
0
        public static Image IconForCommand(string commandName)
        {
            Image icon = null;

            if (commandName != null)
            {
                if (config.Commandline.ContainsKey(commandName) && File.Exists(config.Commandline[commandName]))
                {
                    try {
                        icon = PluginUtils.GetCachedExeIcon(config.Commandline[commandName], 0);
                    } catch (Exception ex) {
                        LOG.Warn("Problem loading icon for " + config.Commandline[commandName], ex);
                    }
                }
            }
            return(icon);
        }
Exemple #6
0
        /// <summary>
        /// Retrieve the icon for a command
        /// </summary>
        /// <param name="externalCommandDefinition">string</param>
        /// <param name="useLargeIcons">true to use the large icon</param>
        /// <returns>Bitmap</returns>
        public static Bitmap IconForCommand(ExternalCommandDefinition externalCommandDefinition, bool useLargeIcons)
        {
            Bitmap icon = null;

            if (externalCommandDefinition == null)
            {
                return(null);
            }
            if (!File.Exists(externalCommandDefinition.Command))
            {
                return(null);
            }
            try
            {
                icon = PluginUtils.GetCachedExeIcon(externalCommandDefinition.Command, 0, useLargeIcons);
            }
            catch (Exception ex)
            {
                Log.Warn().WriteLine(ex, "Problem loading icon for " + externalCommandDefinition.Command);
            }
            return(icon);
        }
 /// <summary>
 ///     Fix icon reference
 /// </summary>
 /// <param name="dpi">double with DPI</param>
 private void OnIconSizeChanged(double dpi)
 {
     try
     {
         var exePath = PluginUtils.GetExePath("cmd.exe");
         if (exePath == null || !File.Exists(exePath))
         {
             return;
         }
         if (true.Equals(_itemPlugInRoot.Tag))
         {
             _itemPlugInRoot.Image?.Dispose();
         }
         var exeIcon = PluginUtils.GetCachedExeIcon(exePath, 0, dpi > 100);
         _itemPlugInRoot.Image = exeIcon.ScaleIconForDisplaying(dpi);
         _itemPlugInRoot.Tag   = !Equals(exeIcon, _itemPlugInRoot.Image);
     }
     catch (Exception ex)
     {
         Log.Warn().WriteLine(ex, "Couldn't get the cmd.exe image");
     }
 }
Exemple #8
0
        /// <summary>
        /// Retrieve the icon for a command
        /// </summary>
        /// <param name="commandName">string</param>
        /// <param name="useLargeIcons">true to use the large icon</param>
        /// <returns>Bitmap</returns>
        public static Bitmap IconForCommand(string commandName, bool useLargeIcons)
        {
            Bitmap icon = null;

            if (commandName == null)
            {
                return(null);
            }
            if (!Config.Commandline.ContainsKey(commandName) || !File.Exists(Config.Commandline[commandName]))
            {
                return(null);
            }
            try
            {
                icon = PluginUtils.GetCachedExeIcon(Config.Commandline[commandName], 0, useLargeIcons);
            }
            catch (Exception ex)
            {
                Log.Warn().WriteLine(ex, "Problem loading icon for " + Config.Commandline[commandName]);
            }
            return(icon);
        }
 public override Bitmap GetDisplayIcon(double dpi)
 {
     return(PluginUtils.GetCachedExeIcon(_exePath, !string.IsNullOrEmpty(_documentCaption) ? IconDocument : IconApplication, dpi > 100));
 }
Exemple #10
0
 public override Bitmap GetDisplayIcon(double dpi)
 {
     return(PluginUtils.GetCachedExeIcon(_exePath, IconApplication, dpi > 100));
 }
Exemple #11
0
        /// <summary>
        /// Setup the Bitmap scaling (for icons)
        /// </summary>
        private void SetupBitmapScaleHandler()
        {
            ContextMenuDpiHandler = contextMenu.AttachDpiHandler();

            var dpiChangeSubscription = FormDpiHandler.OnDpiChanged.Subscribe(info =>
            {
                // Change the ImageScalingSize before setting the bitmaps
                var width  = DpiHandler.ScaleWithDpi(_coreConfiguration.IconSize.Width, info.NewDpi);
                var height = DpiHandler.ScaleWithDpi(_coreConfiguration.IconSize.Height, info.NewDpi);
                var size   = new Size(width, height);
                contextMenu.SuspendLayout();
                contextMenu.ImageScalingSize   = size;
                contextmenu_quicksettings.Size = new Size(170, width + 8);
                contextMenu.ResumeLayout(true);
                contextMenu.Refresh();
                notifyIcon.Icon = GreenshotResources.GetGreenshotIcon();
            });

            var contextMenuResourceScaleHandler = BitmapScaleHandler.WithComponentResourceManager(ContextMenuDpiHandler, GetType(), (bitmap, dpi) => bitmap.ScaleIconForDisplaying(dpi));

            contextMenuResourceScaleHandler.AddTarget(contextmenu_capturewindow, "contextmenu_capturewindow.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_capturearea, "contextmenu_capturearea.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_capturelastregion, "contextmenu_capturelastregion.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_capturefullscreen, "contextmenu_capturefullscreen.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_captureclipboard, "contextmenu_captureclipboard.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_openfile, "contextmenu_openfile.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_settings, "contextmenu_settings.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_help, "contextmenu_help.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_donate, "contextmenu_donate.Image");
            contextMenuResourceScaleHandler.AddTarget(contextmenu_exit, "contextmenu_exit.Image");

            // this is special handling, for the icons which come from the executables
            var exeBitmapScaleHandler = BitmapScaleHandler.Create <string>(ContextMenuDpiHandler,
                                                                           (path, dpi) => PluginUtils.GetCachedExeIcon(path, 0, dpi >= 120),
                                                                           (bitmap, dpi) => bitmap.ScaleIconForDisplaying(dpi));

            exeBitmapScaleHandler.AddTarget(contextmenu_captureie, PluginUtils.GetExePath("iexplore.exe"));

            // Add cleanup
            Application.ApplicationExit += (sender, args) =>
            {
                dpiChangeSubscription.Dispose();
                ContextMenuDpiHandler.Dispose();
                contextMenuResourceScaleHandler.Dispose();
                exeBitmapScaleHandler.Dispose();
            };
        }
 public override Bitmap GetDisplayIcon(double dpi)
 {
     return(PluginUtils.GetCachedExeIcon(_exePath, !string.IsNullOrEmpty(_workbookName) ? IconWorkbook : IconApplication, dpi > 100));
 }