Skip to content

Commit 80cc804

Browse files
v2.1.2 : Updated Control Settings and added control:align
1 parent f22e3b2 commit 80cc804

4 files changed

Lines changed: 70 additions & 8 deletions

File tree

EZCode/EZCode.cs

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
using Group = EZCode.Groups.Group;
1313
using Player = Sound.Player;
1414
using Types = EZCode.Variables.Ivar.Types;
15-
using System.Security.Cryptography;
1615

1716
namespace EZCode
1817
{
@@ -2738,7 +2737,7 @@ async Task<Group> DoGroup(string[] parts, int _index, string keyword, bool globa
27382737
{
27392738
varray.Add(getControl(values_.Trim()));
27402739
}
2741-
else if (values_.StartsWith(":"))
2740+
else if (values_.StartsWith(":"))
27422741
{
27432742
string[] allv = values_.Remove(0, 1).Split(",").Select(x => x.Trim()).ToArray();
27442743
for (int i = 0; i < allv.Length; i++)
@@ -3604,6 +3603,20 @@ string ColonResponse(string value, string[] parts = null)
36043603
Control control = getControl(ind[0]);
36053604
switch (ind[1].ToLower())
36063605
{
3606+
case "align":
3607+
if (control is GLabel _glb1)
3608+
{
3609+
value = _glb1.TextAlign.ToString();
3610+
}
3611+
else if (control is GButton _gbt1)
3612+
{
3613+
value = _gbt1.TextAlign.ToString();
3614+
}
3615+
else
3616+
{
3617+
ErrorText(parts, ErrorTypes.custom, custom: $"Only Labels or Buttons have '{ind[1]}' property");
3618+
}
3619+
break;
36073620
case "id":
36083621
value = control.AccessibleName;
36093622
break;
@@ -4023,6 +4036,21 @@ string ColonResponse(string value, string[] parts = null)
40234036
name = n;
40244037
}
40254038
}
4039+
if (name.Contains("'"))
4040+
{
4041+
string[] varray = name.Split("'");
4042+
for (int j = 0; j < varray.Length; j++)
4043+
{
4044+
if (j % 2 == 1)
4045+
{
4046+
for (int k = 0; k < vars.Count; k++)
4047+
{
4048+
if (varray[j] == vars[k].Name) varray[j] = vars[k].Value;
4049+
}
4050+
}
4051+
}
4052+
name = string.Join("", varray);
4053+
}
40264054

40274055
switch (controltype)
40284056
{
@@ -4257,6 +4285,10 @@ async Task<Control> Change(Control _control, string[] _parts, int index, bool te
42574285
ScrollBars scrollbars = control is GTextBox tb4 ? tb4.ScrollBars : ScrollBars.None;
42584286
Font font = control.Font;
42594287
PointF[] _points = control is GShape gsa3 ? gsa3.Points : Array.Empty<PointF>();
4288+
ContentAlignment align =
4289+
align = control is GLabel lb1 ? lb1.TextAlign :
4290+
align = control is GButton bt1 ? bt1.TextAlign :
4291+
ContentAlignment.TopLeft;
42604292

42614293
foreach (string p in parts)
42624294
{
@@ -4265,6 +4297,28 @@ async Task<Control> Change(Control _control, string[] _parts, int index, bool te
42654297
string[] after = getString_value(values, int.Parse(before[1]), true);
42664298
switch (before[0].Trim().ToLower())
42674299
{
4300+
case "align":
4301+
if (control is GButton or GLabel)
4302+
{
4303+
switch (after[0])
4304+
{
4305+
case "topleft": align = ContentAlignment.TopLeft; break;
4306+
case "topright": align = ContentAlignment.TopCenter; break;
4307+
case "topcenter": align = ContentAlignment.TopRight; break;
4308+
case "middleleft": align = ContentAlignment.MiddleLeft; break;
4309+
case "middlecenter": align = ContentAlignment.MiddleCenter; break;
4310+
case "middleright": align = ContentAlignment.MiddleRight; break;
4311+
case "bottomleft": align = ContentAlignment.BottomLeft; break;
4312+
case "bottomcenter": align = ContentAlignment.BottomCenter; break;
4313+
case "bottomright": align = ContentAlignment.BottomRight; break;
4314+
default: ErrorText(parts, ErrorTypes.custom, custom: $"Expected 'topleft', 'topright', 'topcenter', 'middleleft', 'middlecenter', 'middleright', 'bottomleft', 'bottomcenter', or 'bottomright' for '{control.Name}'"); break;
4315+
}
4316+
}
4317+
else
4318+
{
4319+
ErrorText(parts, ErrorTypes.custom, custom: $"Expected 'label' or 'button' for '{control.Name}'");
4320+
}
4321+
break;
42684322
case "id":
42694323
{
42704324
if (!AllControls.Any(x => x.AccessibleName == after[0]))
@@ -4605,6 +4659,14 @@ async Task<Control> Change(Control _control, string[] _parts, int index, bool te
46054659
a2.AcceptsTab = !wordwrap;
46064660
a2.AllowDrop = !wordwrap;
46074661
}
4662+
if (control is GLabel a3)
4663+
{
4664+
a3.TextAlign = align;
4665+
}
4666+
if (control is GButton a4)
4667+
{
4668+
a4.TextAlign = align;
4669+
}
46084670
if (instance & control.Name == "")
46094671
{
46104672
ErrorText(parts, ErrorTypes.custom, custom: $"Control instance created has no name. Please add the name property, `name:`, to the control");

EZ_IDE/EZCode_Syntax.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<rule style="Pink">\b(if|loop|else|DEVPORTAL|method|endmethod)\b</rule>
1010

1111
<style name="Keyword" color="CadetBlue" fontStyle="Regular"></style>
12-
<rule style="Keyword">\b(list|group|sound|var|print|await|bringto|clear|destroy|event|file|input|intersects|messagebox|stop|shape|textbox|label|button|window|global)\b</rule>
12+
<rule style="Keyword">\b(list|group|sound|var|print|await|bringto|clear|instance|destroy|event|file|input|intersects|messagebox|stop|shape|textbox|label|button|window|global)\b</rule>
1313

1414
<style name="Loop" color="LightBlue" fontStyle="Regular"/>
1515
<rule style="Loop">(?&lt;=\blist\b\s*).*\b(new|add|equals|remove|destroy|clear)\b</rule>

EZ_IDE/IDE.Designer.cs

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

EZ_IDE/IDE.resx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
AAEAAAD/////AQAAAAAAAAAMAgAAAEZTeXN0ZW0uV2luZG93cy5Gb3JtcywgQ3VsdHVyZT1uZXV0cmFs
184184
LCBQdWJsaWNLZXlUb2tlbj1iNzdhNWM1NjE5MzRlMDg5BQEAAAAmU3lzdGVtLldpbmRvd3MuRm9ybXMu
185185
SW1hZ2VMaXN0U3RyZWFtZXIBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAACAgAAAJNU0Z0AUkBTAIBAQMB
186-
AAGIAQUBiAEFARABAAEQAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABQAMAARADAAEBAQABGAYAAQwh
186+
AAGQAQUBkAEFARABAAEQAQAE/wEZAQAI/wFCAU0BNgcAATYDAAEoAwABQAMAARADAAEBAQABGAYAAQwh
187187
AAP/A/QD/jkAA/8DAAP/FQAD/gP7A/cD9gP5A/1RAAO9AbMBsgGxA+0zAAP5AbwBuwG8A88DvwP9DwAD
188188
/gP1A+AD0gHMAcsBzALTAdQD6gP8A/9LAAP+Ac8CzgHLAcoByAO7A/QqAAP9A8EC7wHwA+kD6APdA/8J
189189
AAP+A/UB2gLYAckCxQHBArwBtAGzAbQBrwGsAa4BwAG/AcAD5wP8SwAD7gHxAvAC7gHtAecB5QHkAcIB

0 commit comments

Comments
 (0)