Ejemplo n.º 1
0
        public static Pixbuf GetIcon(string fileName)
        {
            #if GTK3
            GLib.FileInfo info = new GLib.FileInfo(Gtk3Wrapper.g_file_query_info(Gtk3Wrapper.g_file_new_for_path(fileName), "standard::*", 0, new IntPtr(), new IntPtr()));

            try
            {
                string[] sicon = info.Icon.ToString().Split(' ');

                for (int i = sicon.Length - 1; i >= 1; i--)
                {
                    try
                    {
                        var icon = theme.LoadIcon(sicon[i], 16, (IconLookupFlags)0);

                        if (icon != null)
                        {
                            return(icon);
                        }
                    }
                    catch { }
                }
            }
            catch { }
            return(theme.LoadIcon("text-x-generic", 16, (IconLookupFlags)0));
            #endif

            return(new Pixbuf(null, "MonoGame.Tools.Pipeline.Icons.blueprint.png"));
        }
Ejemplo n.º 2
0
        private static Gdk.Pixbuf PlatformGetFileIcon(string path)
        {
            Gdk.Pixbuf icon = null;

            var info  = new GLib.FileInfo(Gtk3Wrapper.g_file_query_info(Gtk3Wrapper.g_file_new_for_path(path), "standard::*", 0, new IntPtr(), new IntPtr()));
            var sicon = info.Icon.ToString().Split(' ');

            for (int i = sicon.Length - 1; i >= 1; i--)
            {
                try
                {
                    icon = _theme.LoadIcon(sicon[i], 16, 0);
                    if (icon != null)
                    {
                        break;
                    }
                }
                catch { }
            }

            if (icon == null)
            {
                throw new Exception();
            }

            return(icon);
        }
Ejemplo n.º 3
0
        private static Eto.Drawing.Image PlatformGetFileIcon(string path, bool exists)
        {
            Gdk.Pixbuf icon = null;

            try
            {
                var info  = new GLib.FileInfo(Gtk3Wrapper.g_file_query_info(Gtk3Wrapper.g_file_new_for_path(path), "standard::*", 0, new IntPtr(), new IntPtr()));
                var sicon = info.Icon.ToString().Split(' ');

                for (int i = sicon.Length - 1; i >= 1; i--)
                {
                    try
                    {
                        icon = _theme.LoadIcon(sicon[i], 16, 0);
                        if (icon != null)
                        {
                            break;
                        }
                    }
                    catch { }
                }
            }
            catch { }

            if (icon == null)
            {
                icon = _theme.LoadIcon("text-x-generic", 16, 0);
            }


            if (!exists)
            {
                icon = icon.Copy();
                _iconMissing.Composite(icon, 8, 8, 8, 8, 8, 8, 0.5, 0.5, Gdk.InterpType.Tiles, 255);
            }

            return(new Bitmap(new BitmapHandler(icon)));
        }