Пример #1
0
        protected virtual IntPtr GetIconHandle()
        {
            var hIcon = IconHandler.LoadIconFromFile(_options.RelativePathToIconFile);

            try
            {
                if (hIcon == null)
                {
                    var assembly       = Assembly.GetEntryAssembly();
                    var iconAsResource = assembly?.GetManifestResourceNames()
                                         .FirstOrDefault(res => res.EndsWith(_options.RelativePathToIconFile));
                    if (iconAsResource != null)
                    {
                        using (var resStream = assembly.GetManifestResourceStream(iconAsResource))
                        {
                            using (var fileStream = new FileStream(_options.RelativePathToIconFile, FileMode.Create))
                            {
                                resStream?.CopyTo(fileStream);
                            }
                        }
                    }
                    hIcon = IconHandler.LoadIconFromFile(_options.RelativePathToIconFile);
                }
            }
            catch
            {
                // ignore
            }
            return(hIcon ?? LoadIconW(IntPtr.Zero, (IntPtr)IDI_APPLICATION));
        }
Пример #2
0
 protected virtual void SetAppIcon(IntPtr window, string filename)
 {
     try
     {
         filename = IconHandler.IconFullPath(filename);
         if (!string.IsNullOrWhiteSpace(filename))
         {
             IntPtr error = IntPtr.Zero;
             gtk_window_set_icon_from_file(window, filename, out error);
             if (error != IntPtr.Zero)
             {
                 Logger.Instance.Log.LogError("Icon handle not successfully freed.");
             }
         }
     }
     catch (Exception exception)
     {
         Logger.Instance.Log.LogError(exception, exception.Message);
     }
 }