Some more layout editor improvements
Textures in the list keep aspect ratio now. Fix creating new user data. and remove any if empty.
This commit is contained in:
parent
1a548f9f80
commit
07b0259805
@ -514,7 +514,8 @@ namespace LayoutBXLYT.Cafe
|
||||
WriteSection(writer, pane.Signature, pane, () => pane.Write(writer, header));
|
||||
sectionCount++;
|
||||
|
||||
if (pane is IUserDataContainer && ((IUserDataContainer)pane).UserData != null)
|
||||
if (pane is IUserDataContainer && ((IUserDataContainer)pane).UserData != null &&
|
||||
((IUserDataContainer)pane).UserData.Entries.Count > 0)
|
||||
{
|
||||
var userData = ((IUserDataContainer)pane).UserData;
|
||||
WriteSection(writer, "usd1", userData, () => userData.Write(writer, this));
|
||||
|
@ -114,6 +114,7 @@ namespace LayoutBXLYT.Cafe
|
||||
originY = (OriginY)(mainorigin / 4);
|
||||
ParentOriginX = (OriginX)(parentorigin % 4);
|
||||
ParentOriginY = (OriginY)(parentorigin / 4);
|
||||
UserData = new USD1();
|
||||
}
|
||||
|
||||
public override void Write(FileWriter writer, LayoutHeader header)
|
||||
|
@ -14,6 +14,10 @@ namespace LayoutBXLYT.Cafe
|
||||
Entries = new List<UserDataEntry>();
|
||||
}
|
||||
|
||||
public override UserDataEntry CreateUserData() {
|
||||
return new USD1Entry();
|
||||
}
|
||||
|
||||
public USD1(FileReader reader, Header header) : base()
|
||||
{
|
||||
long startPos = reader.Position - 8;
|
||||
@ -68,6 +72,8 @@ namespace LayoutBXLYT.Cafe
|
||||
|
||||
public class USD1Entry : UserDataEntry
|
||||
{
|
||||
public USD1Entry() { }
|
||||
|
||||
public USD1Entry(FileReader reader, long startPos, Header header)
|
||||
{
|
||||
long pos = reader.Position;
|
||||
|
@ -541,7 +541,8 @@ namespace LayoutBXLYT
|
||||
WriteSection(writer, pane.Signature, pane, () => pane.Write(writer, header));
|
||||
sectionCount++;
|
||||
|
||||
if (pane is IUserDataContainer && ((IUserDataContainer)pane).UserData != null)
|
||||
if (pane is IUserDataContainer && ((IUserDataContainer)pane).UserData != null &&
|
||||
((IUserDataContainer)pane).UserData.Entries.Count > 0)
|
||||
{
|
||||
var userData = ((IUserDataContainer)pane).UserData;
|
||||
WriteSection(writer, "usd1", userData, () => userData.Write(writer, this));
|
||||
|
@ -93,6 +93,7 @@ namespace LayoutBXLYT.CTR
|
||||
|
||||
originX = OriginXMap[(OriginXRev)(origin % 3)];
|
||||
originY = OriginYMap[(OriginYRev)(origin / 3)];
|
||||
UserData = new USD1();
|
||||
}
|
||||
|
||||
public override void Write(FileWriter writer, LayoutHeader header)
|
||||
|
@ -14,6 +14,10 @@ namespace LayoutBXLYT.CTR
|
||||
Entries = new List<UserDataEntry>();
|
||||
}
|
||||
|
||||
public override UserDataEntry CreateUserData() {
|
||||
return new USD1Entry();
|
||||
}
|
||||
|
||||
public USD1(FileReader reader, BxlytHeader header) : base()
|
||||
{
|
||||
long startPos = reader.Position - 8;
|
||||
@ -64,6 +68,8 @@ namespace LayoutBXLYT.CTR
|
||||
|
||||
public class USD1Entry : UserDataEntry
|
||||
{
|
||||
public USD1Entry() { }
|
||||
|
||||
public USD1Entry(FileReader reader, long startPos, BxlytHeader header)
|
||||
{
|
||||
long pos = reader.Position;
|
||||
|
@ -873,6 +873,10 @@ namespace LayoutBXLYT
|
||||
Entries = new List<UserDataEntry>();
|
||||
}
|
||||
|
||||
public virtual UserDataEntry CreateUserData() {
|
||||
return new UserDataEntry();
|
||||
}
|
||||
|
||||
public override void Write(FileWriter writer, LayoutHeader header)
|
||||
{
|
||||
}
|
||||
|
@ -140,6 +140,7 @@ namespace LayoutBXLYT
|
||||
return;
|
||||
|
||||
temp = texture.GetComponentBitmap(temp, true);
|
||||
temp = BitmapExtension.CreateImageThumbnail(temp, 80, 80);
|
||||
|
||||
if (listViewCustom1.InvokeRequired)
|
||||
{
|
||||
|
@ -110,7 +110,7 @@ namespace LayoutBXLYT
|
||||
{
|
||||
if (activePane == null) return;
|
||||
|
||||
UserDataEntry userDataNew = new UserDataEntry();
|
||||
UserDataEntry userDataNew = ActiveUserData.CreateUserData();
|
||||
userDataNew.SetValue(new int[0]);
|
||||
SelectedEntry = userDataNew;
|
||||
bool IsEdited = EditData();
|
||||
|
@ -730,6 +730,43 @@ namespace Toolbox.Library
|
||||
}
|
||||
}
|
||||
|
||||
public static Bitmap CreateImageThumbnail(Bitmap image, int width, int height)
|
||||
{
|
||||
int tw, th, tx, ty;
|
||||
|
||||
int w = image.Width;
|
||||
int h = image.Height;
|
||||
|
||||
double whRatio = (double)w / h;
|
||||
if (image.Width >= image.Height)
|
||||
{
|
||||
tw = width;
|
||||
th = (int)(tw / whRatio);
|
||||
}
|
||||
else
|
||||
{
|
||||
th = height;
|
||||
tw = (int)(th * whRatio);
|
||||
}
|
||||
|
||||
tx = (width - tw) / 2;
|
||||
ty = (height - th) / 2;
|
||||
|
||||
Bitmap thumb = new Bitmap(width, height, image.PixelFormat);
|
||||
|
||||
Graphics g = Graphics.FromImage(thumb);
|
||||
|
||||
// g.Clear(Color.White);
|
||||
g.InterpolationMode = InterpolationMode.NearestNeighbor;
|
||||
g.DrawImage(image, new Rectangle(tx, ty, tw, th),
|
||||
new Rectangle(0, 0, w, h),
|
||||
|
||||
GraphicsUnit.Pixel);
|
||||
|
||||
return thumb;
|
||||
|
||||
}
|
||||
|
||||
public static Bitmap AdjustBrightness(Image image, float level)
|
||||
{
|
||||
ImageAttributes attributes = new ImageAttributes();
|
||||
|
Loading…
Reference in New Issue
Block a user