Moved "loadimage" to globalfuncs
This commit is contained in:
parent
c711c4f1bf
commit
1f3fa96353
|
|
@ -232,7 +232,7 @@ class CharacterCustomizationShared
|
|||
FaceList.Items.Clear();
|
||||
ExtraItemList.Items.Clear();
|
||||
|
||||
Image icon1 = CustomizationFuncs.LoadImage(GlobalPaths.extradirIcons + "\\" + GlobalVars.UserConfiguration.PlayerName + ".png", GlobalPaths.extradir + "\\NoExtra.png");
|
||||
Image icon1 = GlobalFuncs.LoadImage(GlobalPaths.extradirIcons + "\\" + GlobalVars.UserConfiguration.PlayerName + ".png", GlobalPaths.extradir + "\\NoExtra.png");
|
||||
IconImage.Image = icon1;
|
||||
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -10,41 +10,6 @@ using System.Windows.Forms;
|
|||
#region Customization Functions
|
||||
class CustomizationFuncs
|
||||
{
|
||||
//modified from the following:
|
||||
//https://stackoverflow.com/questions/28887314/performance-of-image-loading
|
||||
//https://stackoverflow.com/questions/2479771/c-why-am-i-getting-the-process-cannot-access-the-file-because-it-is-being-u
|
||||
public static Image LoadImage(string fileFullName, string fallbackFileFullName = "")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(fileFullName))
|
||||
return null;
|
||||
|
||||
Image image = null;
|
||||
|
||||
try
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(fileFullName)))
|
||||
{
|
||||
image = Image.FromStream(ms);
|
||||
}
|
||||
|
||||
// PropertyItems seem to get lost when fileStream is closed to quickly (?); perhaps
|
||||
// this is the reason Microsoft didn't want to close it in the first place.
|
||||
PropertyItem[] items = image.PropertyItems;
|
||||
|
||||
foreach (PropertyItem item in items)
|
||||
{
|
||||
image.SetPropertyItem(item);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(fallbackFileFullName))
|
||||
image = LoadImage(fallbackFileFullName);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
public static void ChangeItem(string item, string itemdir, string defaultitem, PictureBox outputImage, TextBox outputString, ListBox box, bool initial, bool hatsinextra = false)
|
||||
{
|
||||
ChangeItem(item, itemdir, defaultitem, outputImage, outputString, box, initial, null, hatsinextra);
|
||||
|
|
@ -108,7 +73,7 @@ using System.Windows.Forms;
|
|||
}
|
||||
else
|
||||
{
|
||||
outputImage.Image = LoadImage(itemdir + @"\\" + item.Replace(".rbxm", "") + ".png", itemdir + @"\\" + defaultitem + ".png");
|
||||
outputImage.Image = GlobalFuncs.LoadImage(itemdir + @"\\" + item.Replace(".rbxm", "") + ".png", itemdir + @"\\" + defaultitem + ".png");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -123,9 +88,9 @@ using System.Windows.Forms;
|
|||
public static Image GetItemURLImageFromProvider(Provider provider)
|
||||
{
|
||||
if (provider != null)
|
||||
return LoadImage(GlobalPaths.CustomPlayerDir + @"\\" + provider.Icon, GlobalPaths.extradir + @"\\NoExtra.png");
|
||||
return GlobalFuncs.LoadImage(GlobalPaths.CustomPlayerDir + @"\\" + provider.Icon, GlobalPaths.extradir + @"\\NoExtra.png");
|
||||
|
||||
return LoadImage(GlobalPaths.extradir + @"\\NoExtra.png");
|
||||
return GlobalFuncs.LoadImage(GlobalPaths.extradir + @"\\NoExtra.png");
|
||||
}
|
||||
|
||||
//we launch the 3dview seperately from normal clients.
|
||||
|
|
|
|||
|
|
@ -997,7 +997,7 @@ public partial class CharacterCustomizationCompact : Form
|
|||
MessageBox.Show(icon.getInstallOutcome());
|
||||
}
|
||||
|
||||
Image icon1 = CustomizationFuncs.LoadImage(GlobalPaths.extradirIcons + "\\" + GlobalVars.UserConfiguration.PlayerName + ".png", GlobalPaths.extradir + "\\NoExtra.png");
|
||||
Image icon1 = GlobalFuncs.LoadImage(GlobalPaths.extradirIcons + "\\" + GlobalVars.UserConfiguration.PlayerName + ".png", GlobalPaths.extradir + "\\NoExtra.png");
|
||||
pictureBox10.Image = icon1;
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -1000,7 +1000,7 @@ public partial class CharacterCustomizationExtended : Form
|
|||
MessageBox.Show(icon.getInstallOutcome());
|
||||
}
|
||||
|
||||
Image icon1 = CustomizationFuncs.LoadImage(GlobalPaths.extradirIcons + "\\" + GlobalVars.UserConfiguration.PlayerName + ".png", GlobalPaths.extradir + "\\NoExtra.png");
|
||||
Image icon1 = GlobalFuncs.LoadImage(GlobalPaths.extradirIcons + "\\" + GlobalVars.UserConfiguration.PlayerName + ".png", GlobalPaths.extradir + "\\NoExtra.png");
|
||||
pictureBox10.Image = icon1;
|
||||
}
|
||||
#endregion
|
||||
|
|
|
|||
|
|
@ -570,6 +570,41 @@ public class GlobalFuncs
|
|||
File.SetAttributes(dest, FileAttributes.Normal);
|
||||
}
|
||||
|
||||
//modified from the following:
|
||||
//https://stackoverflow.com/questions/28887314/performance-of-image-loading
|
||||
//https://stackoverflow.com/questions/2479771/c-why-am-i-getting-the-process-cannot-access-the-file-because-it-is-being-u
|
||||
public static Image LoadImage(string fileFullName, string fallbackFileFullName = "")
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(fileFullName))
|
||||
return null;
|
||||
|
||||
Image image = null;
|
||||
|
||||
try
|
||||
{
|
||||
using (MemoryStream ms = new MemoryStream(File.ReadAllBytes(fileFullName)))
|
||||
{
|
||||
image = Image.FromStream(ms);
|
||||
}
|
||||
|
||||
// PropertyItems seem to get lost when fileStream is closed to quickly (?); perhaps
|
||||
// this is the reason Microsoft didn't want to close it in the first place.
|
||||
PropertyItem[] items = image.PropertyItems;
|
||||
|
||||
foreach (PropertyItem item in items)
|
||||
{
|
||||
image.SetPropertyItem(item);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(fallbackFileFullName))
|
||||
image = LoadImage(fallbackFileFullName);
|
||||
}
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
public static string CopyMapToRBXAsset()
|
||||
{
|
||||
string clientcontentpath = GlobalPaths.ClientDir + @"\\" + GlobalVars.UserConfiguration.SelectedClient + @"\\content\\temp.rbxl";
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ public partial class ItemCreationSDK : Form
|
|||
MessageBox.Show(icon.getInstallOutcome());
|
||||
}
|
||||
|
||||
Image icon1 = CustomizationFuncs.LoadImage(icon.ItemDir + "\\" + icon.ItemName.Replace(" ", "") + ".png", "");
|
||||
Image icon1 = GlobalFuncs.LoadImage(icon.ItemDir + "\\" + icon.ItemName.Replace(" ", "") + ".png", "");
|
||||
ItemIcon.Image = icon1;
|
||||
|
||||
if (type == RobloxFileType.TShirt || type == RobloxFileType.Face)
|
||||
|
|
@ -260,14 +260,14 @@ public partial class ItemCreationSDK : Form
|
|||
textbox.ReadOnly = !enable;
|
||||
textbox.Text = "";
|
||||
button.Enabled = browseButton;
|
||||
ItemIcon.Image = CustomizationFuncs.LoadImage("", "");
|
||||
ItemIcon.Image = GlobalFuncs.LoadImage("", "");
|
||||
}
|
||||
|
||||
private void ToggleGroup(GroupBox groupbox, string labelText, bool enable = true)
|
||||
{
|
||||
groupbox.Text = enable ? labelText : (string.IsNullOrWhiteSpace(labelText) ? "This option is disabled." : labelText);
|
||||
groupbox.Enabled = enable;
|
||||
ItemIcon.Image = CustomizationFuncs.LoadImage("", "");
|
||||
ItemIcon.Image = GlobalFuncs.LoadImage("", "");
|
||||
}
|
||||
|
||||
private void ToggleHatMeshBox(string labelText, bool enable = true)
|
||||
|
|
|
|||
Loading…
Reference in New Issue