mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/PCK-Studio.git
synced 2026-06-01 19:04:50 +00:00
Create ImageCollectionExtension
-Added basic Insert method for ImageCollections
This commit is contained in:
36
PckStudio.Core/Extensions/ImageCollectionExtensions.cs
Normal file
36
PckStudio.Core/Extensions/ImageCollectionExtensions.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Linq;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows.Forms;
|
||||
|
||||
namespace PckStudio.Core.Extensions
|
||||
{
|
||||
public static class ImageCollectionExtensions
|
||||
{
|
||||
public static void Insert(this ImageList.ImageCollection _, int index, string key, Image image)
|
||||
{
|
||||
var images = new List<Image>();
|
||||
var keys = new List<string>();
|
||||
|
||||
for (int i = 0; i < _.Count; i++)
|
||||
{
|
||||
keys.Add(_.Keys[i]);
|
||||
images.Add(_[i]);
|
||||
}
|
||||
|
||||
images.Insert(index, image);
|
||||
keys.Insert(index, key);
|
||||
|
||||
_.Clear();
|
||||
|
||||
for (int i = 0; i < images.Count; i++)
|
||||
{
|
||||
_.Add(keys[i], images[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user