async
This commit is contained in:
parent
6f207c2a3c
commit
ae8bf46a44
|
|
@ -42,7 +42,7 @@ class CharacterCustomizationShared
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Form Event Functions
|
#region Form Event Functions
|
||||||
public void InitForm()
|
public async void InitForm()
|
||||||
{
|
{
|
||||||
if (GlobalFuncs.HasColorsChanged())
|
if (GlobalFuncs.HasColorsChanged())
|
||||||
{
|
{
|
||||||
|
|
@ -112,7 +112,10 @@ class CharacterCustomizationShared
|
||||||
}
|
}
|
||||||
|
|
||||||
int imgsize = (FormStyle == Settings.Style.Extended) ? 28 : 18;
|
int imgsize = (FormStyle == Settings.Style.Extended) ? 28 : 18;
|
||||||
PartColorLoader.AddPartColorsToListView(GlobalVars.PartColorList, ColorView, imgsize);
|
string oldTitle = Parent.Text;
|
||||||
|
Parent.Text = "Please Wait...";
|
||||||
|
await PartColorLoader.AddPartColorsToListView(GlobalVars.PartColorList, ColorView, imgsize);
|
||||||
|
Parent.Text = oldTitle;
|
||||||
|
|
||||||
//body
|
//body
|
||||||
SelectedPartLabel.Text = SelectedPart;
|
SelectedPartLabel.Text = SelectedPart;
|
||||||
|
|
|
||||||
|
|
@ -75,7 +75,12 @@ public class PartColorLoader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//make faster
|
||||||
|
#if !BASICLAUNCHER
|
||||||
|
public static async Task AddPartColorsToListView(PartColor[] PartColorList, ListView ColorView, int imgsize, bool showIDs = false)
|
||||||
|
#else
|
||||||
public static void AddPartColorsToListView(PartColor[] PartColorList, ListView ColorView, int imgsize, bool showIDs = false)
|
public static void AddPartColorsToListView(PartColor[] PartColorList, ListView ColorView, int imgsize, bool showIDs = false)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
@ -105,15 +110,14 @@ public class PartColorLoader
|
||||||
|
|
||||||
lvi.Group = group;
|
lvi.Group = group;
|
||||||
|
|
||||||
Bitmap Bmp = new Bitmap(imgsize, imgsize, PixelFormat.Format32bppArgb);
|
#if !BASICLAUNCHER
|
||||||
using (Graphics gfx = Graphics.FromImage(Bmp))
|
Bitmap Bmp = await GeneratePartColorIconAsync(item, imgsize);
|
||||||
using (SolidBrush brush = new SolidBrush(item.ColorObject))
|
if (Bmp != null)
|
||||||
{
|
{
|
||||||
gfx.FillRectangle(brush, 0, 0, imgsize, imgsize);
|
ColorImageList.Images.Add(item.ColorName, Bmp);
|
||||||
|
lvi.ImageIndex = ColorImageList.Images.IndexOfKey(item.ColorName);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
ColorImageList.Images.Add(item.ColorName, Bmp);
|
|
||||||
lvi.ImageIndex = ColorImageList.Images.IndexOfKey(item.ColorName);
|
|
||||||
ColorView.Items.Add(lvi);
|
ColorView.Items.Add(lvi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,6 +137,40 @@ public class PartColorLoader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !BASICLAUNCHER
|
||||||
|
public static async Task<Bitmap> GeneratePartColorIconAsync(PartColor color, int imgsize)
|
||||||
|
{
|
||||||
|
Task<Bitmap> task = Task<Bitmap>.Factory.StartNew(() => GeneratePartColorIcon(color, imgsize));
|
||||||
|
await task;
|
||||||
|
return task.Result;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
public static Bitmap GeneratePartColorIcon(PartColor color, int imgsize)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Bitmap Bmp = new Bitmap(imgsize, imgsize, PixelFormat.Format32bppArgb);
|
||||||
|
using (Graphics gfx = Graphics.FromImage(Bmp))
|
||||||
|
using (SolidBrush brush = new SolidBrush(color.ColorObject))
|
||||||
|
{
|
||||||
|
gfx.FillRectangle(brush, 0, 0, imgsize, imgsize);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Bmp;
|
||||||
|
}
|
||||||
|
#if URI || LAUNCHER || CMD
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
GlobalFuncs.LogExceptions(ex);
|
||||||
|
#else
|
||||||
|
catch (Exception)
|
||||||
|
{
|
||||||
|
#endif
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static PartColor FindPartColorByName(PartColor[] colors, string query)
|
public static PartColor FindPartColorByName(PartColor[] colors, string query)
|
||||||
{
|
{
|
||||||
if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.PartColorXMLName))
|
if (File.Exists(GlobalPaths.ConfigDir + "\\" + GlobalPaths.PartColorXMLName))
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ public partial class ItemCreationSDKColorMenu : Form
|
||||||
Close();
|
Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ItemCreationSDKColorMenu_Load(object sender, EventArgs e)
|
private async void ItemCreationSDKColorMenu_Load(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (GlobalFuncs.HasColorsChanged())
|
if (GlobalFuncs.HasColorsChanged())
|
||||||
{
|
{
|
||||||
|
|
@ -60,7 +60,10 @@ public partial class ItemCreationSDKColorMenu : Form
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
PartColorLoader.AddPartColorsToListView(GlobalVars.PartColorList, colorMenu, 32, true);
|
string oldTitle = Text;
|
||||||
|
Text = "Please Wait...";
|
||||||
|
await PartColorLoader.AddPartColorsToListView(GlobalVars.PartColorList, colorMenu, 32, true);
|
||||||
|
Text = oldTitle;
|
||||||
CenterToScreen();
|
CenterToScreen();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue