예제 #1
0
        private void UpdateIcon(AppIcon icon)
        {
            string tempPath = null;

            string path;

            if (icon == null || icon.Icons.Length == 0)
            {
                path = DefaultIconName;
            }
            else if (icon.Source == AppIcon.IconSource.File)
            {
                path = icon.DefaultIcon.Path;
            }
            else
            {
                tempPath = Path.GetTempFileName();
                using (var tmpStream = File.Open(tempPath, FileMode.Create))
                    using (var iconStream = icon.GetIconDataStream(icon.DefaultIcon))
                    {
                        iconStream.CopyTo(tmpStream);
                    }

                path = tempPath;
            }

            using (GLibString gpath = path)
            {
                AppIndicator.SetIcon(Handle, gpath);
            }

            ClearTempFile();
            tempIconFile = tempPath;
        }
예제 #2
0
        public void SetIcon(AppIcon icon)
        {
            this.icon = icon;

            if (icon == null || icon.Icons.Length == 0)
            {
                Icon = null;
            }
            else
            {
                using var stream = icon.GetIconDataStream(icon.DefaultIcon);
                Icon             = new Icon(stream);
            }
        }
 private void UpdateIcon(AppIcon icon)
 {
     if (icon == null || icon.Icons.Length == 0)
     {
         notifyIcon.Icon = null;
     }
     else
     {
         using (var stream = icon.GetIconDataStream(icon.DefaultIcon))
         {
             notifyIcon.Icon = new System.Drawing.Icon(stream);
         }
     }
 }