From c1691623f172cc530b6c69098c227d738a904021 Mon Sep 17 00:00:00 2001
From: lastbattle <4586194+lastbattle@users.noreply.github.com>
Date: Tue, 1 Mar 2022 11:24:34 +0800
Subject: [PATCH] [MapleLib] InfoTool - added GetLtRbRectangle() and
SetLtRbRectangle() method
---
MapleLib/WzLib/WzStructure/InfoTool.cs | 41 ++++++++++++++++++++++++++
1 file changed, 41 insertions(+)
diff --git a/MapleLib/WzLib/WzStructure/InfoTool.cs b/MapleLib/WzLib/WzStructure/InfoTool.cs
index ed084ec0..9d93d810 100644
--- a/MapleLib/WzLib/WzStructure/InfoTool.cs
+++ b/MapleLib/WzLib/WzStructure/InfoTool.cs
@@ -15,6 +15,7 @@ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
along with this program. If not, see .*/
using System;
+using System.Drawing;
using MapleLib.WzLib.WzProperties;
namespace MapleLib.WzLib.WzStructure
@@ -100,7 +101,47 @@ public static WzStringProperty SetOptionalTranslatedInt(int? value)
}
#endregion
+ #region Rectangle
+ ///
+ /// Gets System.Drawing.Rectangle from "lt" and "rb"
+ ///
+ ///
+ ///
+ public static Rectangle GetLtRbRectangle(this WzImageProperty parentSource)
+ {
+ WzVectorProperty lt = InfoTool.GetOptionalVector(parentSource["lt"]);
+ WzVectorProperty rb = InfoTool.GetOptionalVector(parentSource["rb"]);
+
+ int width = rb.X.Value - lt.X.Value;
+ int height = rb.Y.Value - lt.Y.Value;
+
+ Rectangle rectangle = new Rectangle(
+ lt.X.Value,
+ lt.Y.Value,
+ width,
+ height);
+ return rectangle;
+ }
+
+ ///
+ /// Sets the "lt" and "rb" value in a WzImageProperty parentSource
+ /// derived from Rectangle
+ ///
+ ///
+ ///
+ public static void SetLtRbRectangle(this WzImageProperty parentSource, Rectangle rect)
+ {
+ parentSource["lt"] = InfoTool.SetVector(rect.X, rect.Y);
+ parentSource["rb"] = InfoTool.SetVector(rect.X + rect.Width, rect.Y + rect.Height);
+ }
+ #endregion
+
#region Vector
+ ///
+ /// Gets the vector value of the WzImageProperty
+ ///
+ ///
+ ///
public static WzVectorProperty GetVector(this WzImageProperty source)
{
return (WzVectorProperty)source;