Exemple #1
0
        protected override Size CalculateImageSize(Graphics g, object imageSelector)
        {
            if (imageSelector == null || imageSelector == DBNull.Value)
            {
                return(Size.Empty);
            }

            // Check for the image in the image list (most common case)
            ImageListAdv il = ImageList;

            if (il != null)
            {
                if (imageSelector is string selectorAsString)
                {
                    int selectorAsInt = il.Images.IndexOfKey(selectorAsString);
                    if (selectorAsInt >= 0)
                    {
                        return(il.ImageSize);
                    }
                }
            }

            // Is the selector actually an image?
            Image image = imageSelector as Image;

            if (image != null)
            {
                return(image.Size);
            }

            return(Size.Empty);
        }
Exemple #2
0
        /// <summary>
        /// creates resized ImageListAdv based on source ImageListAdv
        /// </summary>
        /// <param name="source"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <returns></returns>
        public static ImageListAdv MakeResizedImageList(ImageListAdv source, int width, int height)
        {
            if (width <= 0 || height <= 0)
            {
                throw new ArgumentException("Size must be positive.");
            }

            ImageListAdv il = new ImageListAdv();

            il.ImageSize = new Size(width, height);

            if (source == null)
            {
                return(il);
            }

#if !ANDROID
            for (int i = 0; i < source.Images.Count; i++)
            {
                il.Images.Add(new Bitmap(source.Images[i], new Size(width, height)));
            }
#endif //!ANDROID

            foreach (var key in source.Images.Keys)
            {
                il.Images.SetKeyName(source.Images.IndexOfKey(key), key);
            }

            return(il);
        }
 public void Add(Icon value)
 {
     if (value == null)
     {
         throw new ArgumentNullException("value");
     }
     base.InnerList.Add(new ImageInfo(ImageListAdv.IconToImageAlphaCorrect(value), null));
 }
Exemple #4
0
 internal ImageListAdv ResizeImagesForListView(Size size)
 {
     if (imageListIconsLarge.ImageSize == size)
     {
         return(imageListIconsLarge);
     }
     return(ImageListAdv.MakeResizedImageList(imageListIconsLarge, size.Width, size.Height));;
 }
Exemple #5
0
        internal void LoadDefaultImages()
        {
            defaultSmallImage = Properties.Resources.Default_16;
            defaultLargeImage = Properties.Resources.Default_32;

            AddImage("Default", Properties.Resources.Default_16, Properties.Resources.Default_32);
            AddImage("Namespace", Properties.Resources.Namespace_16, null);
            AddImage("Class", Properties.Resources.Class, Properties.Resources.Class_32);
            AddImage("Struct", Properties.Resources.Struct, null);
            AddImage("Assembly", Properties.Resources.Assembly, null);

            //!!!!tr
            //if( EditorAPI.DarkTheme )
            //	AddImage( "Resource", Properties.Resources.Resource_16_Dark, Properties.Resources.Resource_32_Dark );
            //else
            AddImage("Resource", Properties.Resources.Resource_16, Properties.Resources.Resource_32);

            AddImage("AssemblyList", Properties.Resources.AssemblyList, null);
            AddImage("Folder", Properties.Resources.Folder_16, Properties.Resources.Folder_32);
            AddImage("Delegate", Properties.Resources.Delegate, null);
            AddImage("Enum", Properties.Resources.Enum, null);
            AddImage("Property", Properties.Resources.Property, null);
            AddImage("GoUpper", Properties.Resources.GoUpper_16, null);
            AddImage("Method", Properties.Resources.Method, null);
            AddImage("Event", Properties.Resources.Event_16, null);
            AddImage("StaticClass", Properties.Resources.StaticClass, null);
            AddImage("StaticEvent", Properties.Resources.StaticEvent, null);
            AddImage("StaticMethod", Properties.Resources.StaticMethod, null);
            AddImage("StaticProperty", Properties.Resources.StaticProperty, null);
            AddImage("Constructor", Properties.Resources.Constructor, null);
            AddImage("Operator", Properties.Resources.Operator, null);

            AddImage("CSharp", Properties.Resources.CSharp_16, Properties.Resources.CSharp_32);
            AddImage("UI", Properties.Resources.Window_16, Properties.Resources.Window_32);
            AddImage("Image", Properties.Resources.Image_16, Properties.Resources.Image_32);
            AddImage("Sound", Properties.Resources.Sound_16, Properties.Resources.Sound_32);
            AddImage("Mesh", Properties.Resources.Mesh_16, Properties.Resources.Mesh_32);
            AddImage("Material", Properties.Resources.Material_16, Properties.Resources.Material_32);
            AddImage("Scene", Properties.Resources.Scene_16, Properties.Resources.Scene_32);

            AddImage("Cog", Properties.Resources.Cog_16, Properties.Resources.Cog_32);

            AddImage("CSharpProject", Properties.Resources.CSharpProject_16, Properties.Resources.CSharpProject_32);
            AddImage("Attach", Properties.Resources.Attach_16, Properties.Resources.Attach_32);
            AddImage("New", Properties.Resources.New_16, Properties.Resources.New_32);

            //AddImage( "Character", Properties.Resources.MeshSkeleton_16, Properties.Resources.MeshSkeleton_32 );

            //HACK: recreate images to fix render image size at different system scales.
            int listImageSize = imageListIconsLarge.ImageSize.Height;

            imageListIconsLarge = ImageListAdv.MakeResizedImageList(imageListIconsLarge, listImageSize, listImageSize);
        }
Exemple #6
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public object Clone()
        {
            ImageListAdv imageListAdv = new ImageListAdv();

            imageListAdv.ImageSize    = ImageSize;
            imageListAdv.UseImageSize = UseImageSize;
            for (int i = 0; i < Images.Count; i++)
            {
                if (Images[i] != null)
                {
                    imageListAdv.Images.Add((Image)Images[i].Clone());
                }
            }
            return(imageListAdv);
        }
Exemple #7
0
        Image GetImageFromList(object imageSelector)
        {
            if (imageSelector == null || imageSelector == DBNull.Value)
            {
                return(null);
            }

            // Draw from the image list (most common case)
            ImageListAdv il = ImageList;

            if (il != null)
            {
                // Try to translate our imageSelector into a valid ImageList index
                int selectorAsInt = -1;
                if (imageSelector is int)
                {
                    selectorAsInt = (int)imageSelector;
                    if (selectorAsInt >= il.Images.Count)
                    {
                        selectorAsInt = -1;
                    }
                }
                else
                {
                    string selectorAsString = imageSelector as string;
                    if (selectorAsString != null)
                    {
                        selectorAsInt = il.Images.IndexOfKey(selectorAsString);
                    }
                }

                if (selectorAsInt >= 0)
                {
                    imageSelector = il.Images[selectorAsInt];
                }
            }

            // Is the selector actually an image?
            return(imageSelector as Image);
        }
 public void Add(string key, Icon icon)
 {
     base.InnerList.Add(new ImageInfo(ImageListAdv.IconToImageAlphaCorrect(icon), key));
 }
            public override object EditValue(ITypeDescriptorContext context, IServiceProvider provider, object value)
            {
                ArrayList arrayList = new ArrayList();

                if (provider != null && (IWindowsFormsEditorService)provider.GetService(typeof(IWindowsFormsEditorService)) != null)
                {
                    if (fileDialog == null)
                    {
                        fileDialog             = new OpenFileDialog();
                        fileDialog.Multiselect = true;
                        string text = ImageEditor.CreateFilterEntry(this);
                        for (int i = 0; i < imageExtenders.Length; i++)
                        {
                            ImageEditor imageEditor = (ImageEditor)Activator.CreateInstance(imageExtenders[i], BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.CreateInstance, null, null, null);
                            Type        type        = GetType();
                            Type        type2       = imageEditor.GetType();
                            if (!type.Equals(type2) && imageEditor != null && type.IsInstanceOfType(imageEditor))
                            {
                                text = text + "|" + ImageEditor.CreateFilterEntry(imageEditor);
                            }
                        }
                        fileDialog.Filter = text;
                    }
                    IntPtr focus = NativeMethods.GetFocus();
                    try
                    {
                        if (fileDialog.ShowDialog() != DialogResult.OK)
                        {
                            return(arrayList);
                        }
                        string[] fileNames = fileDialog.FileNames;
                        foreach (string text2 in fileNames)
                        {
                            bool flag = false;
                            if (Path.GetExtension(text2) == ".ico")
                            {
                                try
                                {
                                    Icon icon = new Icon(text2);
                                    arrayList.Add(ImageListAdv.IconToImageAlphaCorrect(icon));
                                    flag = true;
                                }
                                catch (ArgumentException)
                                {
                                }
                            }
                            if (!flag)
                            {
                                FileStream stream = new FileStream(text2, FileMode.Open, FileAccess.Read, FileShare.Read);
                                arrayList.Add(LoadFromStream(stream));
                            }
                        }
                        return(arrayList);
                    }
                    finally
                    {
                        if (focus != IntPtr.Zero)
                        {
                            NativeMethods.SetFocus(focus);
                        }
                    }
                }
                return(arrayList);
            }
Exemple #10
0
 public ContentBrowserImageHelper(IContainer container)
 {
     imageListIconsSmall           = new ImageListAdv(container);
     imageListIconsLarge           = new ImageListAdv(container);
     imageListIconsLarge.ImageSize = new Size(32, 32);
 }