Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Switched to WinForms only.

  • Loading branch information...
commit 4c2f3ca0951caffcfe9ab1f34db2f18dcbdd52d9 1 parent 7daf92d
@polyethene authored
View
9 IronAHK.sln
@@ -7,9 +7,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IronAHK", "IronAHK\IronAHK.
EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Rusty", "Rusty\Rusty.csproj", "{818030A8-5FFE-4CA1-8248-0940C72EA47A}"
- ProjectSection(ProjectDependencies) = postProject
- {ED8B2B00-18F8-4187-A810-9C4028C80A56} = {ED8B2B00-18F8-4187-A810-9C4028C80A56}
- EndProjectSection
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Scripting", "Scripting\Scripting.csproj", "{D7C6B1FD-2247-40A4-8DAB-199F3B8084E0}"
ProjectSection(ProjectDependencies) = postProject
@@ -20,8 +17,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tests", "Tests\Tests.csproj
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deploy", "Deploy\Deploy.csproj", "{2ED27EA6-FC9E-49B4-B80F-2343FD070510}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Gtk", "Gtk\Gtk.csproj", "{ED8B2B00-18F8-4187-A810-9C4028C80A56}"
-EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -47,10 +42,6 @@ Global
{2ED27EA6-FC9E-49B4-B80F-2343FD070510}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2ED27EA6-FC9E-49B4-B80F-2343FD070510}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2ED27EA6-FC9E-49B4-B80F-2343FD070510}.Release|Any CPU.Build.0 = Release|Any CPU
- {ED8B2B00-18F8-4187-A810-9C4028C80A56}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {ED8B2B00-18F8-4187-A810-9C4028C80A56}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {ED8B2B00-18F8-4187-A810-9C4028C80A56}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {ED8B2B00-18F8-4187-A810-9C4028C80A56}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
View
43 Rusty/Core/Common/Properties.cs
@@ -66,7 +66,7 @@ static public int ErrorLevel
[ThreadStatic]
static int eventinfo;
- static Dictionary<string, BaseGui.Window> guis;
+ static Dictionary<string, Form> guis;
[ThreadStatic]
static string defaultGui;
@@ -81,7 +81,7 @@ static string DefaultGuiId
}
}
- static BaseGui.Window DefaultGui
+ static Form DefaultGui
{
get
{
@@ -94,9 +94,9 @@ static BaseGui.Window DefaultGui
}
[ThreadStatic]
- static BaseGui.TreeView defaultTreeView;
+ static TreeView defaultTreeView;
- static BaseGui.TreeView DefaultTreeView
+ static TreeView DefaultTreeView
{
get
{
@@ -108,11 +108,11 @@ static BaseGui.TreeView DefaultTreeView
if (gui == null)
return null;
- BaseGui.TreeView tv = null;
+ TreeView tv = null;
foreach (var control in gui.Controls)
- if (typeof(BaseGui.TreeView).IsAssignableFrom(control.GetType()))
- tv = (BaseGui.TreeView)control;
+ if (control.GetType() == typeof(TreeView))
+ tv = (TreeView)control;
return tv;
}
@@ -120,9 +120,9 @@ static BaseGui.TreeView DefaultTreeView
}
[ThreadStatic]
- static BaseGui.ListView defaultListView;
+ static ListView defaultListView;
- static BaseGui.ListView DefaultListView
+ static ListView DefaultListView
{
get
{
@@ -134,17 +134,36 @@ static BaseGui.ListView DefaultListView
if (gui == null)
return null;
- BaseGui.ListView lv = null;
+ ListView lv = null;
foreach (var control in gui.Controls)
- if (typeof(BaseGui.ListView).IsAssignableFrom(control.GetType()))
- lv = (BaseGui.ListView)control;
+ if (control.GetType() == typeof(ListView))
+ lv = (ListView)control;
return lv;
}
set { defaultListView = value; }
}
+ static StatusBar DefaultStatusBar
+ {
+ get
+ {
+ var gui = DefaultGui;
+
+ if (gui == null)
+ return null;
+
+ StatusBar sb = null;
+
+ foreach (var control in gui.Controls)
+ if (control.GetType() == typeof(StatusBar))
+ sb = (StatusBar)control;
+
+ return sb;
+ }
+ }
+
static NotifyIcon Tray;
#endregion
View
1,487 Rusty/Core/Gui/Gui.cs
@@ -1,6 +1,7 @@
-using System;
+using System;
using System.Collections.Generic;
using System.Drawing;
+using System.IO;
using System.Reflection;
using System.Windows.Forms;
@@ -36,7 +37,7 @@ partial class Core
public static void Gui(string Command, string Param2, string Param3, string Param4)
{
if (guis == null)
- guis = new Dictionary<string, BaseGui.Window>();
+ guis = new Dictionary<string, Form>();
string id = GuiId(ref Command);
@@ -49,641 +50,9 @@ public static void Gui(string Command, string Param2, string Param3, string Para
case Keyword_Add:
{
- switch (Param2.ToLowerInvariant())
- {
- case Keyword_Text:
- {
- var text = guis[id].CreateText();
- text.Contents = Param4;
- GuiApplyStyles(text, Param3);
- guis[id].Add(text);
- }
- break;
-
- case Keyword_Edit:
- {
- var edit = guis[id].CreateEdit();
- edit.Contents = Param4;
- string opts = GuiApplyStyles(edit, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case Keyword_Limit:
- if (!on)
- edit.Limit = int.MaxValue;
- break;
-
- case Keyword_Lowercase: edit.Lowercase = on; break;
- case Keyword_Multi: edit.Multi = on; break;
- case Keyword_Number: edit.Number = on; break;
- case Keyword_Password: edit.Password = on; break;
- case Keyword_Readonly: edit.ReadOnly = on; break;
- case Keyword_Uppercase: edit.Uppercase = on; break;
- case Keyword_WantCtrlA: edit.WantCtrlA = on; break;
- case Keyword_WantReturn: edit.WantReturn = on; break;
- case Keyword_WantTab: edit.WantTab = on; break;
- case Keyword_Wrap: edit.Wrap = on; break;
-
- default:
- int n;
- if (mode.StartsWith(Keyword_Limit) && int.TryParse(mode.Substring(Keyword_Limit.Length), out n))
- edit.Limit = n;
- else if (mode[0] == 't' && int.TryParse(mode.Substring(1), out n))
- edit.TabStops = n;
- break;
- }
- }
-
- guis[id].Add(edit);
- }
- break;
-
- case Keyword_UpDown:
- {
- var updown = guis[id].CreateUpDown();
- updown.Contents = Param4;
- string opts = GuiApplyStyles(updown, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case Keyword_Horz: updown.Horizontal = on; break;
- case Keyword_Left: updown.Left = on; break;
- case Keyword_Wrap: updown.Wrap = on; break;
- case "16": updown.Isolated = on; break;
- case "0x80": updown.ThousandsSeperator = on; break;
-
- default:
- if (mode.StartsWith(Keyword_Range))
- {
- string[] range = mode.Substring(Keyword_Range.Length).Split(new[] { '-' }, 2);
- int n;
-
- if (int.TryParse(range[0], out n))
- updown.RangeMinimum = n;
-
- if (range.Length > 1 && int.TryParse(range[1], out n))
- updown.RangeMaximum = n;
- }
- break;
- }
- }
-
- guis[id].Add(updown);
- }
- break;
-
- case Keyword_Picture:
- case Keyword_Pic:
- {
- var pic = guis[id].CreatePicture();
- pic.Contents = Param4;
- GuiApplyStyles(pic, Param3);
- guis[id].Add(pic);
- }
- break;
-
- case Keyword_Button:
- {
- var button = guis[id].CreateButton();
- button.Contents = Param4;
- GuiApplyStyles(button, Param3);
- guis[id].Add(button);
- }
- break;
-
- case Keyword_CheckBox:
- {
- var check = guis[id].CreateCheckbox();
- check.Contents = Param4;
- check.State = CheckState.Unchecked;
- string opts = GuiApplyStyles(check, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- switch (opt.ToLowerInvariant())
- {
- case Keyword_Check3:
- case Keyword_CheckedGray:
- check.State = CheckState.Indeterminate;
- break;
-
- case Keyword_Checked:
- check.State = CheckState.Checked;
- break;
-
- default:
- if (opt.StartsWith(Keyword_Checked, StringComparison.OrdinalIgnoreCase))
- {
- string arg = opt.Substring(Keyword_Checked.Length).Trim();
- int n;
-
- if (int.TryParse(arg, out n))
- check.State = n == -1 ? CheckState.Indeterminate : n == 1 ? CheckState.Checked : CheckState.Unchecked;
- }
- break;
- }
- }
-
- guis[id].Add(check);
- }
- break;
-
- case Keyword_Radio:
- {
- var radio = guis[id].CreateRadio();
- radio.Contents = Param4;
- radio.Checked = false;
- string opts = GuiApplyStyles(radio, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- switch (opt.ToLowerInvariant())
- {
- case Keyword_Checked:
- radio.Checked = true;
- break;
-
- default:
- if (opt.StartsWith(Keyword_Checked, StringComparison.OrdinalIgnoreCase))
- {
- string arg = opt.Substring(Keyword_Checked.Length).Trim();
- int n;
-
- if (int.TryParse(arg, out n))
- radio.Checked = n == 1;
- }
- break;
- }
- }
-
- guis[id].Add(radio);
- }
- break;
-
- case Keyword_DropDownList:
- case Keyword_DDL:
- {
- var ddl = guis[id].CreateDropDownList();
- ddl.Contents = Param4;
- string opts = GuiApplyStyles(ddl, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case Keyword_Sort: ddl.Sort = on; break;
- case Keyword_Uppercase: ddl.Uppercase = on; break;
- case Keyword_Lowercase: ddl.Lowercase = on; break;
-
- default:
- if (mode.StartsWith(Keyword_Choose, StringComparison.OrdinalIgnoreCase))
- {
- mode = mode.Substring(Keyword_Choose.Length);
- int n;
-
- if (int.TryParse(mode, out n))
- ddl.Choose = n;
- }
- break;
- }
- }
-
- guis[id].Add(ddl);
- }
- break;
-
- case Keyword_ComboBox:
- {
- var combo = guis[id].CreateComboBox();
- combo.Contents = Param4;
- string opts = GuiApplyStyles(combo, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case Keyword_Limit: combo.Limit = on; break;
- case Keyword_Simple: combo.Simple = on; break;
- }
- }
-
- guis[id].Add(combo);
- }
- break;
-
- case Keyword_ListBox:
- {
- var listbox = guis[id].CreateListBox();
- listbox.Contents = Param4;
- string opts = GuiApplyStyles(listbox, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case Keyword_Multi:
- case "8":
- listbox.MultiSelect = on;
- break;
-
- case Keyword_Readonly: listbox.ReadOnly = on; break;
- case Keyword_Sort: listbox.Sort = on; break;
-
- default:
- if (mode.StartsWith(Keyword_Choose, StringComparison.OrdinalIgnoreCase))
- {
- mode = mode.Substring(Keyword_Choose.Length);
- int n;
-
- if (int.TryParse(mode, out n))
- listbox.Choose = n;
- }
- break;
- }
- }
-
- guis[id].Add(listbox);
- }
- break;
-
- case Keyword_ListView:
- {
- var lv = guis[id].CreateListView();
- lv.Contents = Param4;
- string opts = GuiApplyStyles(lv, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case Keyword_Checked: lv.Checklist = on; break;
- case Keyword_Grid: lv.Grid = on; break;
- case Keyword_Hdr: lv.Header = on; break;
- case "lv0x10": lv.MovableColumns = on; break;
- case "lv0x20": lv.ClickToSelect = on; break;
- case Keyword_Multi: lv.MultiSelect = on; break;
- case Keyword_NoSortHdr: lv.SortableHeader = !on; break;
- case Keyword_Readonly: lv.ReadOnly = on; break;
- case Keyword_Sort: lv.Sort = on; break;
- case Keyword_SortDesc: lv.SortDesc = on; break;
- case Keyword_WantF2: lv.WantF2 = on; break;
- }
- }
-
- guis[id].Add(lv);
- }
- break;
-
- case Keyword_TreeView:
- {
- var tree = guis[id].CreateTreeView();
- tree.Contents = Param4;
- string opts = GuiApplyStyles(tree, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case Keyword_Buttons: tree.Buttons = on; break;
- case Keyword_HScroll: tree.HorizontalScroll = on; break;
- case Keyword_Lines: tree.Lines = on; break;
- case Keyword_Readonly: tree.ReadOnly = on; break;
- case Keyword_WantF2: tree.WantF2 = on; break;
-
- default:
- if (mode.StartsWith(Keyword_ImageList))
- {
- mode = mode.Substring(Keyword_ImageList.Length);
-
- // UNDONE: TreeView control ImageList
- }
- break;
- }
- }
-
- guis[id].Add(tree);
- }
- break;
-
- case Keyword_Hotkey:
- {
- var hotkey = guis[id].CreateHotkey();
- hotkey.Contents = Param4;
- string opts = GuiApplyStyles(hotkey, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- if (!opt.StartsWith(Keyword_Limit, StringComparison.OrdinalIgnoreCase))
- continue;
-
- int n;
- hotkey.Limit = int.TryParse(opt.Substring(Keyword_Limit.Length), out n) ? n : 0;
- }
-
- guis[id].Add(hotkey);
- }
- break;
-
- case Keyword_DateTime:
- {
- var date = guis[id].CreateDateTime();
- date.Contents = ToDateTime(Param4).Ticks.ToString();
- string opts = GuiApplyStyles(date, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case "1": date.UpDown = on; break;
- case "2": date.Checklist = on; break;
- case Keyword_Right: date.Right = on; break;
- case Keyword_LongDate: date.LongDate = on; break;
- case Keyword_Time: date.Time = on; break;
-
- default:
- if (mode.StartsWith(Keyword_Range))
- {
- string[] range = mode.Substring(Keyword_Range.Length).Split(new[] { '-' }, 2);
-
- date.RangeMinimum = ToDateTime(range[0]);
-
- if (range.Length > 1)
- date.RangeMaximum = ToDateTime(range[1]);
- }
- else if (mode.StartsWith(Keyword_Choose))
- {
- mode = mode.Substring(Keyword_Choose.Length);
- int n;
-
- if (int.TryParse(mode, out n))
- date.Choose = n;
- }
- break;
- }
- }
-
- guis[id].Add(date);
- }
- break;
-
- case Keyword_MonthCal:
- {
- var cal = guis[id].CreateMonthCal();
- cal.Contents = ToDateTime(Param4).Ticks.ToString();
- string opts = GuiApplyStyles(cal, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case "4": cal.DisplayWeek = on; break;
- case "8": cal.HightlightToday = !on; break;
- case "16": cal.DisplayToday = !on; break;
- case Keyword_Multi: cal.MultiSelect = on; break;
-
- default:
- if (mode.StartsWith(Keyword_Range, StringComparison.OrdinalIgnoreCase))
- {
- string[] range = mode.Substring(Keyword_Range.Length).Split(new[] { '-' }, 2);
-
- cal.RangeMinimum = ToDateTime(range[0]);
-
- if (range.Length > 1)
- cal.RangeMaximum = ToDateTime(range[1]);
- }
- break;
- }
- }
-
- guis[id].Add(cal);
- }
- break;
-
- case Keyword_Slider:
- {
- var slider = guis[id].CreateSider();
- slider.Contents = Param4;
- string opts = GuiApplyStyles(slider, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case Keyword_Center: slider.Rounded = on; break;
- case Keyword_Invert: slider.Invert = on; break;
- case Keyword_Left: slider.Left = on; break;
- case Keyword_NoTicks: slider.Tick = !on; break;
- case Keyword_Thick: slider.Thick = on; break;
- case Keyword_Vertical: slider.Vertical = on; break;
-
- default:
- int n;
- if (mode.StartsWith(Keyword_Line))
- {
- mode = mode.Substring(Keyword_Line.Length);
-
- if (int.TryParse(mode, out n))
- slider.Line = n;
- }
- else if (mode.StartsWith(Keyword_Page))
- {
- mode = mode.Substring(Keyword_Page.Length);
-
- if (int.TryParse(mode, out n))
- slider.Page = n;
- }
- else if (mode.StartsWith(Keyword_Range))
- {
- mode = mode.Substring(Keyword_Range.Length);
- string[] parts = mode.Split(new[] { '-' }, 2);
-
- if (int.TryParse(parts[0], out n))
- slider.RangeMinimum = n;
-
- if (parts.Length > 1 && int.TryParse(parts[1], out n))
- slider.RangeMaximum = n;
- }
- else if (mode.StartsWith(Keyword_TickInterval))
- {
- mode = mode.Substring(Keyword_TickInterval.Length);
-
- if (int.TryParse(mode, out n))
- slider.TickInterval = n;
- }
- else if (mode.StartsWith(Keyword_ToolTip))
- {
- mode = mode.Substring(Keyword_ToolTip.Length);
-
- switch (mode)
- {
- case Keyword_Left: slider.ToolTip = 0; break;
- case Keyword_Right: slider.ToolTip = 1; break;
- case Keyword_Top: slider.ToolTip = 2; break;
- case Keyword_Bottom: slider.ToolTip = 3; break;
- }
- }
- break;
- }
- }
-
- guis[id].Add(slider);
- }
- break;
-
- case Keyword_Progress:
- {
- var progress = guis[id].CreateProgress();
- progress.Contents = Param4;
- string opts = GuiApplyStyles(progress, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case Keyword_Smooth: progress.Smooth = on; break;
- case Keyword_Vertical: progress.Vertical = on; break;
-
- default:
- if (mode.StartsWith(Keyword_Range))
- {
- mode = mode.Substring(Keyword_Range.Length);
- int z = mode.IndexOf('-');
- string a = mode, b;
-
- if (z == -1)
- b = string.Empty;
- else
- {
- a = mode.Substring(0, z);
- z++;
- b = z == mode.Length ? string.Empty : mode.Substring(z);
- }
-
- int x, y;
-
- if (int.TryParse(a, out x) && int.TryParse(b, out y))
- {
- progress.RangeMinimum = x;
- progress.RangeMaximum = y;
- }
- }
- else if (mode.StartsWith(Keyword_Background))
- {
- mode = mode.Substring(Keyword_Background.Length);
- progress.BackgroundColor = ParseColor(mode);
- }
- break;
- }
- }
-
- guis[id].Add(progress);
- }
- break;
-
- case Keyword_GroupBox:
- {
- var group = guis[id].CreateGroupBox();
- group.Contents = Param4;
- GuiApplyStyles(group, Param3);
- guis[id].Add(group);
- }
- break;
-
- case Keyword_Tab:
- case Keyword_Tab2:
- {
- var tab = guis[id].CreateTab();
- tab.Contents = Param4;
- string opts = GuiApplyStyles(tab, Param3);
-
- foreach (string opt in ParseOptions(opts))
- {
- bool on = opt[0] != '-';
- string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
-
- switch (mode)
- {
- case Keyword_Background: tab.Background = on; break;
- case Keyword_Buttons: tab.Buttons = on; break;
- case Keyword_Top: tab.Align = 0; break;
- case Keyword_Left: tab.Align = 1; break;
- case Keyword_Right: tab.Align = 2; break;
- case Keyword_Bottom: tab.Align = 3; break;
- case Keyword_Wrap: tab.Wrap = on; break;
-
- default:
- if (mode.StartsWith(Keyword_Choose, StringComparison.OrdinalIgnoreCase))
- {
- mode = mode.Substring(Keyword_Choose.Length);
- int n;
-
- if (int.TryParse(mode, out n))
- tab.Choose = n;
- }
- break;
- }
- }
-
- guis[id].Add(tab);
- }
- break;
-
- case Keyword_StatusBar:
- {
- var status = guis[id].CreateStatusBar();
- status.Contents = Param4;
- GuiApplyStyles(status, Param3);
- guis[id].Add(status);
- guis[id].StatusBar = status;
- }
- break;
-
- case Keyword_WebBrowser:
- {
- var web = guis[id].CreateWebBrowser();
- web.Contents = Param4;
- GuiApplyStyles(web, Param3);
- guis[id].Add(web);
- }
- break;
- }
+ Control control = null;
+ GuiControlEdit(ref control, Param2, Param3, Param4);
+ guis[id].Controls.Add(control);
}
break;
@@ -741,7 +110,7 @@ public static void Gui(string Command, string Param2, string Param3, string Para
}
if (auto)
- guis[id].AutoSize();
+ guis[id].AutoSize = true;
else
{
var size = guis[id].Size;
@@ -773,16 +142,16 @@ public static void Gui(string Command, string Param2, string Param3, string Para
guis[id].Location = location;
- guis[id].Draw(Param3);
+ guis[id].ResumeLayout(true);
if (min)
- guis[id].Minimise();
+ guis[id].WindowState = FormWindowState.Minimized;
else if (max)
- guis[id].Maximise();
+ guis[id].WindowState = FormWindowState.Maximized;
else if (restore)
- guis[id].Restore();
+ guis[id].WindowState = FormWindowState.Normal;
else if (hide)
- guis[id].Cancel();
+ guis[id].Hide();
else
guis[id].Show();
}
@@ -794,20 +163,22 @@ public static void Gui(string Command, string Param2, string Param3, string Para
case Keyword_Submit:
{
- var table = guis[id].Submit(!Keyword_NoHide.Equals(Param2, StringComparison.OrdinalIgnoreCase));
+ if (!Keyword_NoHide.Equals(Param2, StringComparison.OrdinalIgnoreCase))
+ guis[id].Hide();
- foreach (string key in table.Keys)
- SetEnv("." + key, table[key]); // TODO: variable scoping with gui,submit
+ foreach (Control ctrl in guis[id].Controls)
+ SetEnv("." + ctrl.Name, ctrl.Text);
}
break;
case Keyword_Cancel:
case Keyword_Hide:
- guis[id].Cancel();
+ guis[id].Hide();
break;
case Keyword_Destroy:
- guis[id].Destroy();
+ guis[id].Hide();
+ guis[id].Dispose();
guis.Remove(id);
break;
@@ -816,13 +187,13 @@ public static void Gui(string Command, string Param2, string Param3, string Para
break;
case Keyword_Color:
- guis[id].WindowColour = Keyword_Default.Equals(Param2, StringComparison.OrdinalIgnoreCase) ? Color.Transparent : ParseColor(Param2);
- guis[id].ControlColour = Keyword_Default.Equals(Param3, StringComparison.OrdinalIgnoreCase) ? Color.Transparent : ParseColor(Param3);
+ guis[id].BackColor = Keyword_Default.Equals(Param2, StringComparison.OrdinalIgnoreCase) ? Color.Transparent : ParseColor(Param2);
+ guis[id].ForeColor = Keyword_Default.Equals(Param3, StringComparison.OrdinalIgnoreCase) ? Color.Transparent : ParseColor(Param3);
break;
case Keyword_Margin:
{
- int d, x = guis[id].Margin.X, y = guis[id].Margin.Y;
+ int d, x = guis[id].Margin.Left, y = guis[id].Margin.Top;
if (int.TryParse(Param2, out d))
x = d;
@@ -830,7 +201,7 @@ public static void Gui(string Command, string Param2, string Param3, string Para
if (int.TryParse(Param3, out d))
y = d;
- guis[id].Margin = new System.Drawing.Point(x, y);
+ guis[id].Margin = new Padding(x, y, guis[id].Margin.Right, guis[id].Margin.Bottom);
}
break;
@@ -838,19 +209,20 @@ public static void Gui(string Command, string Param2, string Param3, string Para
break;
case Keyword_Minimize:
- guis[id].Minimise();
+ guis[id].WindowState = FormWindowState.Minimized;
break;
case Keyword_Maximize:
- guis[id].Maximise();
+ guis[id].WindowState = FormWindowState.Maximized;
break;
case Keyword_Restore:
- guis[id].Restore();
+ guis[id].WindowState = FormWindowState.Normal;
break;
case Keyword_Flash:
- guis[id].Flash(OnOff(Param2) ?? true);
+ if (Environment.OSVersion.Platform == PlatformID.Win32NT)
+ Windows.FlashWindow(guis[id].Handle, OnOff(Param2) ?? true);
break;
case Keyword_Default:
@@ -861,10 +233,10 @@ public static void Gui(string Command, string Param2, string Param3, string Para
{
var tree = GuiFindControl(Param2, guis[id]);
- if (tree == null || !typeof(BaseGui.TreeView).IsAssignableFrom(tree.GetType()))
+ if (tree == null || !typeof(TreeView).IsAssignableFrom(tree.GetType()))
DefaultTreeView = null;
else
- DefaultTreeView = (BaseGui.TreeView)tree;
+ DefaultTreeView = (TreeView)tree;
}
break;
@@ -872,10 +244,10 @@ public static void Gui(string Command, string Param2, string Param3, string Para
{
var list = GuiFindControl(Param2, guis[id]);
- if (list == null || !typeof(BaseGui.ListView).IsAssignableFrom(list.GetType()))
+ if (list == null || !typeof(ListView).IsAssignableFrom(list.GetType()))
DefaultListView = null;
else
- DefaultListView = (BaseGui.ListView)list;
+ DefaultListView = (ListView)list;
}
break;
@@ -900,20 +272,20 @@ public static void Gui(string Command, string Param2, string Param3, string Para
switch (mode)
{
- case Keyword_AlwaysOnTop: guis[id].AlwaysOnTop = on; break;
- case Keyword_Border: guis[id].Border = on; break;
- case Keyword_Caption: guis[id].Caption = on; break;
+ case Keyword_AlwaysOnTop: guis[id].TopMost = on; break;
+ case Keyword_Border: break;
+ case Keyword_Caption: break;
case Keyword_Disabled: guis[id].Enabled = !on; break;
- case Keyword_LastFound: guis[id].LastFound = on; break;
- case Keyword_LastFoundExist: guis[id].LastFoundExist = on; break;
- case Keyword_MaximizeBox: guis[id].MaximiseBox = on; break;
- case Keyword_MinimizeBox: guis[id].MinimiseBox = on; break;
- case Keyword_OwnDialogs: guis[id].OwnDialogs = on; break;
- case Keyword_Owner: guis[id].Owner = on; break;
- case Keyword_Resize: guis[id].Resize = on; break;
- case Keyword_SysMenu: guis[id].SysMenu = on; break;
- case Keyword_Theme: guis[id].Theme = on; break;
- case Keyword_ToolWindow: guis[id].ToolWindow = on; break;
+ case Keyword_LastFound: break;
+ case Keyword_LastFoundExist: break;
+ case Keyword_MaximizeBox: guis[id].MaximizeBox = on; break;
+ case Keyword_MinimizeBox: guis[id].MinimizeBox = on; break;
+ case Keyword_OwnDialogs: ((GuiInfo)guis[id].Tag).OwnDialogs = on; break;
+ case Keyword_Owner: break;
+ case Keyword_Resize: break;
+ case Keyword_SysMenu: break;
+ case Keyword_Theme: Application.EnableVisualStyles(); break;
+ case Keyword_ToolWindow: break;
default:
string arg;
@@ -924,13 +296,13 @@ public static void Gui(string Command, string Param2, string Param3, string Para
{
arg = mode.Substring(Keyword_Delimiter.Length);
if (arg.Length > 0)
- guis[id].Delimieter = arg[0];
+ ((GuiInfo)guis[id].Tag).Delimiter = arg[0];
}
else if (mode.StartsWith(Keyword_Label))
{
arg = mode.Substring(Keyword_Label.Length);
if (arg.Length > 0)
- guis[id].Label = arg;
+ guis[id].Name = arg;
}
else if (mode.StartsWith(Keyword_MinSize))
{
@@ -970,90 +342,705 @@ public static void Gui(string Command, string Param2, string Param3, string Para
#region Helpers
- static BaseGui.Window GuiCreateWindow(string name)
+ static void GuiControlEdit(ref Control control, string type, string options, string content)
{
- BaseGui.Window win;
+ string opts = null;
- if (Type.GetType("Gtk.Window") != null)
+ switch (type.ToLowerInvariant())
{
- string prefix = typeof(Core).Namespace;
- var src = Assembly.GetExecutingAssembly().GetManifestResourceStream(string.Format("{0}.Resources.{0}.Gtk.dll", prefix));
+ #region Text
+ case Keyword_Text:
+ {
+ var text = (Label)(control ?? new Label());
+ control = text;
+ text.Text = content;
+ }
+ break;
+ #endregion
- var bin = new byte[src.Length];
- src.Read(bin, 0, bin.Length);
- var gtk = Assembly.Load(bin);
+ #region Edit
+ case Keyword_Edit:
+ {
+ var edit = (TextBox)(control ?? new TextBox());
+ control = edit;
+ edit.Text = content;
+ opts = GuiApplyStyles(edit, options);
- var type = gtk.GetType(prefix + ".GtkForms.Window");
- win = (BaseGui.Window)Activator.CreateInstance(type);
- }
- else
- win = new WinForms.Window();
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
- if (name != "1")
- win.Label = name + win.Label;
+ switch (mode)
+ {
+ case Keyword_Limit:
+ if (!on)
+ edit.MaxLength = int.MaxValue;
+ break;
- win.Closed += new EventHandler<BaseGui.Window.ClosedArgs>(delegate(object sender, BaseGui.Window.ClosedArgs e)
- {
- SafeInvoke(win.Label + Keyword_GuiClose);
- });
+ case Keyword_Lowercase: edit.CharacterCasing = on ? CharacterCasing.Lower : CharacterCasing.Normal; break;
+ case Keyword_Multi: edit.Multiline = on; break;
+ case Keyword_Number: break;
+ case Keyword_Password: edit.PasswordChar = ''; break;
+ case Keyword_Readonly: edit.ReadOnly = on; break;
+ case Keyword_Uppercase: edit.CharacterCasing = on ? CharacterCasing.Upper : CharacterCasing.Normal; break;
+ case Keyword_WantCtrlA: break;
+ case Keyword_WantReturn: edit.AcceptsReturn = on; break;
+ case Keyword_WantTab: edit.AcceptsTab = on; break;
+ case Keyword_Wrap: edit.WordWrap = on; break;
- win.Escaped += new EventHandler<BaseGui.Window.EscapedArgs>(delegate(object sender, BaseGui.Window.EscapedArgs e)
- {
- SafeInvoke(win.Label + Keyword_GuiEscape);
- });
+ default:
+ int n;
+ if (mode.StartsWith(Keyword_Limit) && int.TryParse(mode.Substring(Keyword_Limit.Length), out n))
+ edit.MaxLength = n;
+ break;
+ }
+ }
+ }
+ break;
+ #endregion
- win.Resized += new EventHandler<BaseGui.Window.ResizedArgs>(delegate(object sender, BaseGui.Window.ResizedArgs e)
- {
- eventinfo = error = e.Mode;
- SafeInvoke(win.Label + Keyword_GuiSize);
- });
+ #region UpDown
+ case Keyword_UpDown:
+ {
+ var updown = (NumericUpDown)(control ?? new NumericUpDown());
+ control = updown;
+ updown.Value = decimal.Parse(content);
+ opts = GuiApplyStyles(updown, options);
- return win;
- }
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
- static string GuiApplyStyles(BaseGui.Control control, string styles)
- {
- string[] opts = ParseOptions(styles), excess = new string[opts.Length];
+ switch (mode)
+ {
+ case Keyword_Horz: break;
+ case Keyword_Left: break;
+ case Keyword_Wrap: break;
+ case "16": break;
+ case "0x80": break;
- for (int i = 0; i < opts.Length; i++)
- {
- string mode = opts[i].ToLowerInvariant();
- bool append = false;
+ default:
+ if (mode.StartsWith(Keyword_Range))
+ {
+ string[] range = mode.Substring(Keyword_Range.Length).Split(new[] { '-' }, 2);
+ decimal n;
- bool on = mode[0] != '-';
- if (!on || mode[0] == '+')
- mode = mode.Substring(1);
+ if (decimal.TryParse(range[0], out n))
+ updown.Minimum = n;
- if (mode.Length == 0)
- continue;
+ if (range.Length > 1 && decimal.TryParse(range[1], out n))
+ updown.Maximum = n;
+ }
+ break;
+ }
+ }
+ }
+ break;
+ #endregion
- string arg = mode.Substring(1);
- int n;
+ #region Picture
+ case Keyword_Picture:
+ case Keyword_Pic:
+ {
+ var pic = (PictureBox)(control ?? new PictureBox());
+ control = pic;
+ bool exists = File.Exists(content);
- switch (mode)
- {
- case Keyword_Left:
- control.Alignment = ContentAlignment.MiddleLeft;
+ if (exists)
+ pic.ImageLocation = content;
+
+ GuiApplyStyles(pic, options);
+
+ if (exists && pic.Size.IsEmpty)
+ {
+ var image = Image.FromFile(pic.ImageLocation);
+ pic.Size = image.Size;
+ }
+ }
+ break;
+ #endregion
+
+ #region Button
+ case Keyword_Button:
+ {
+ var button = (Button)(control ?? new Button());
+ control = button;
+ button.Text = content;
+ }
+ break;
+ #endregion
+
+ #region CheckBox
+ case Keyword_CheckBox:
+ {
+ var check = (CheckBox)(control ?? new CheckBox());
+ control = check;
+ check.Text = content;
+ opts = GuiApplyStyles(check, options);
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ switch (opt.ToLowerInvariant())
+ {
+ case Keyword_Check3:
+ case Keyword_CheckedGray:
+ check.CheckState = CheckState.Indeterminate;
+ break;
+
+ case Keyword_Checked:
+ check.CheckState = CheckState.Checked;
+ break;
+
+ default:
+ if (opt.StartsWith(Keyword_Checked, StringComparison.OrdinalIgnoreCase))
+ {
+ string arg = opt.Substring(Keyword_Checked.Length).Trim();
+ int n;
+
+ if (int.TryParse(arg, out n))
+ check.CheckState = n == -1 ? CheckState.Indeterminate : n == 1 ? CheckState.Checked : CheckState.Unchecked;
+ }
+ break;
+ }
+ }
+ }
+ break;
+ #endregion
+
+ #region Radio
+ case Keyword_Radio:
+ {
+ var radio = (RadioButton)(control ?? new RadioButton());
+ control = radio;
+ radio.Text = content;
+ radio.Checked = false;
+ opts = GuiApplyStyles(radio, options);
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ switch (opt.ToLowerInvariant())
+ {
+ case Keyword_Checked:
+ radio.Checked = true;
+ break;
+
+ default:
+ if (opt.StartsWith(Keyword_Checked, StringComparison.OrdinalIgnoreCase))
+ {
+ string arg = opt.Substring(Keyword_Checked.Length).Trim();
+ int n;
+
+ if (int.TryParse(arg, out n))
+ radio.Checked = n == 1;
+ }
+ break;
+ }
+ }
+ }
+ break;
+ #endregion
+
+ #region DropDownList
+ case Keyword_DropDownList:
+ case Keyword_DDL:
+ {
+ var ddl = (ComboBox)(control ?? new ComboBox());
+ control = ddl;
+ ddl.Text = content;
+ opts = GuiApplyStyles(ddl, options);
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
+
+ switch (mode)
+ {
+ case Keyword_Sort: ddl.Sorted = on; break;
+ case Keyword_Uppercase: ddl.Text = ddl.Text.ToUpperInvariant(); break;
+ case Keyword_Lowercase: ddl.Text = ddl.Text.ToLowerInvariant(); break;
+
+ default:
+ if (mode.StartsWith(Keyword_Choose, StringComparison.OrdinalIgnoreCase))
+ {
+ mode = mode.Substring(Keyword_Choose.Length);
+ int n;
+
+ if (int.TryParse(mode, out n) && n > -1 && n < ddl.Items.Count)
+ ddl.SelectedIndex = n;
+ }
+ break;
+ }
+ }
+ }
+ break;
+ #endregion
+
+ #region ComboBox
+ case Keyword_ComboBox:
+ {
+ var combo = (ComboBox)(control ?? new ComboBox());
+ control = combo;
+ combo.Text = content;
+ opts = GuiApplyStyles(combo, options);
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
+
+ switch (mode)
+ {
+ case Keyword_Limit: break;
+ case Keyword_Simple: break;
+ }
+ }
+ }
+ break;
+ #endregion
+
+ #region ListBox
+ case Keyword_ListBox:
+ {
+ var listbox = new ListBox();
+ listbox.Text = content;
+ opts = GuiApplyStyles(listbox, options);
+
+ bool multi = false, read = false;
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
+
+ switch (mode)
+ {
+ case Keyword_Multi:
+ case "8":
+ multi = on;
+ break;
+
+ case Keyword_Readonly: read = on; break;
+ case Keyword_Sort: listbox.Sorted = on; break;
+
+ default:
+ if (mode.StartsWith(Keyword_Choose, StringComparison.OrdinalIgnoreCase))
+ {
+ mode = mode.Substring(Keyword_Choose.Length);
+ int n;
+
+ if (int.TryParse(mode, out n) && n > -1 && n < listbox.Items.Count)
+ listbox.SelectedIndex = n;
+ }
+ break;
+ }
+ }
+
+ listbox.SelectionMode = multi ? SelectionMode.MultiExtended : read ? SelectionMode.None : SelectionMode.One;
+ }
+ break;
+ #endregion
+
+ #region ListView
+ case Keyword_ListView:
+ {
+ var lv = (ListView)(control ?? new ListView());
+ control = lv;
+ opts = GuiApplyStyles(lv, options);
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
+
+ switch (mode)
+ {
+ case Keyword_Checked: lv.CheckBoxes = on; break;
+ case Keyword_Grid: lv.GridLines = on; break;
+ case Keyword_Hdr: break;
+ case "lv0x10": break;
+ case "lv0x20": break;
+ case Keyword_Multi: lv.MultiSelect = on; break;
+ case Keyword_NoSortHdr: break;
+ case Keyword_Readonly: break;
+ case Keyword_Sort: lv.Sorting = on ? SortOrder.Ascending : SortOrder.None; break;
+ case Keyword_SortDesc: lv.Sorting = on ? SortOrder.Descending : SortOrder.None; break;
+ case Keyword_WantF2: break;
+ }
+ }
+ }
+ break;
+ #endregion
+
+ #region TreeView
+ case Keyword_TreeView:
+ {
+ var tree = (TreeView)(control ?? new TreeView());
+ control = tree;
+ opts = GuiApplyStyles(tree, options);
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
+
+ switch (mode)
+ {
+ case Keyword_Buttons: break;
+ case Keyword_HScroll: break;
+ case Keyword_Lines: break;
+ case Keyword_Readonly: break;
+ case Keyword_WantF2: break;
+
+ default:
+ if (mode.StartsWith(Keyword_ImageList))
+ {
+ mode = mode.Substring(Keyword_ImageList.Length);
+
+ // UNDONE: TreeView control ImageList
+ }
+ break;
+ }
+ }
+ }
+ break;
+ #endregion
+
+ #region Hotkey
+ case Keyword_Hotkey:
+ {
+ // TODO: subclass edit for hotkey control
+ }
+ break;
+ #endregion
+
+ #region DateTime
+ case Keyword_DateTime:
+ {
+ var date = (DateTimePicker)(control ?? new DateTimePicker());
+ control = date;
+ opts = GuiApplyStyles(date, options);
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
+
+ switch (mode)
+ {
+ case "1": break;
+ case "2": break;
+ case Keyword_Right: break;
+ case Keyword_LongDate: break;
+ case Keyword_Time: break;
+
+ default:
+ if (mode.StartsWith(Keyword_Range))
+ {
+ string[] range = mode.Substring(Keyword_Range.Length).Split(new[] { '-' }, 2);
+
+ }
+ else if (mode.StartsWith(Keyword_Choose))
+ {
+ mode = mode.Substring(Keyword_Choose.Length);
+
+ }
+ break;
+ }
+ }
+ }
+ break;
+ #endregion
+
+ #region MonthCal
+ case Keyword_MonthCal:
+ {
+ var cal = (MonthCalendar)(control ?? new MonthCalendar());
+ control = cal;
+ opts = GuiApplyStyles(cal, options);
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
+
+ switch (mode)
+ {
+ case "4": break;
+ case "8": break;
+ case "16": break;
+ case Keyword_Multi: break;
+
+ default:
+ if (mode.StartsWith(Keyword_Range, StringComparison.OrdinalIgnoreCase))
+ {
+ string[] range = mode.Substring(Keyword_Range.Length).Split(new[] { '-' }, 2);
+
+ }
+ break;
+ }
+ }
+ }
+ break;
+ #endregion
+
+ #region Slider
+ case Keyword_Slider:
+ {
+ var slider = (TrackBar)(control ?? new TrackBar());
+ control = slider;
+ opts = GuiApplyStyles(slider, options);
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
+
+ switch (mode)
+ {
+ case Keyword_Center: break;
+ case Keyword_Invert: break;
+ case Keyword_Left: break;
+ case Keyword_NoTicks: break;
+ case Keyword_Thick: break;
+ case Keyword_Vertical: break;
+
+ default:
+ if (mode.StartsWith(Keyword_Line))
+ {
+ mode = mode.Substring(Keyword_Line.Length);
+
+ }
+ else if (mode.StartsWith(Keyword_Page))
+ {
+ mode = mode.Substring(Keyword_Page.Length);
+
+ }
+ else if (mode.StartsWith(Keyword_Range))
+ {
+ mode = mode.Substring(Keyword_Range.Length);
+ string[] parts = mode.Split(new[] { '-' }, 2);
+
+ }
+ else if (mode.StartsWith(Keyword_TickInterval))
+ {
+ mode = mode.Substring(Keyword_TickInterval.Length);
+
+ }
+ else if (mode.StartsWith(Keyword_ToolTip))
+ {
+ mode = mode.Substring(Keyword_ToolTip.Length);
+
+ switch (mode)
+ {
+ case Keyword_Left: break;
+ case Keyword_Right: break;
+ case Keyword_Top: break;
+ case Keyword_Bottom: break;
+ }
+ }
+ break;
+ }
+ }
+ }
+ break;
+ #endregion
+
+ #region Progress
+ case Keyword_Progress:
+ {
+ var progress = (ProgressBar)(control ?? new ProgressBar());
+ control = progress;
+ opts = GuiApplyStyles(progress, options);
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
+
+ switch (mode)
+ {
+ case Keyword_Smooth: break;
+ case Keyword_Vertical: break;
+
+ default:
+ if (mode.StartsWith(Keyword_Range))
+ {
+ mode = mode.Substring(Keyword_Range.Length);
+ int z = mode.IndexOf('-');
+ string a = mode, b;
+
+ if (z == -1)
+ b = string.Empty;
+ else
+ {
+ a = mode.Substring(0, z);
+ z++;
+ b = z == mode.Length ? string.Empty : mode.Substring(z);
+ }
+
+ int x, y;
+
+ if (int.TryParse(a, out x) && int.TryParse(b, out y))
+ {
+
+ }
+ }
+ else if (mode.StartsWith(Keyword_Background))
+ {
+ mode = mode.Substring(Keyword_Background.Length);
+ }
+ break;
+ }
+ }
+ }
+ break;
+ #endregion
+
+ #region GroupBox
+ case Keyword_GroupBox:
+ {
+ var group = (GroupBox)(control ?? new GroupBox());
+ control = group;
+ group.Text = content;
+ }
+ break;
+ #endregion
+
+ #region Tab
+ case Keyword_Tab:
+ case Keyword_Tab2:
+ {
+ var tab = (TabPage)(control ?? new TabPage());
+ control = tab;
+ opts = GuiApplyStyles(tab, options);
+
+ foreach (string opt in ParseOptions(opts))
+ {
+ bool on = opt[0] != '-';
+ string mode = opt.Substring(!on || opt[0] == '+' ? 1 : 0).ToLowerInvariant();
+
+ switch (mode)
+ {
+ case Keyword_Background: break;
+ case Keyword_Buttons: break;
+ case Keyword_Top: break;
+ case Keyword_Left: break;
+ case Keyword_Right: break;
+ case Keyword_Bottom: break;
+ case Keyword_Wrap: break;
+
+ default:
+ if (mode.StartsWith(Keyword_Choose, StringComparison.OrdinalIgnoreCase))
+ {
+ mode = mode.Substring(Keyword_Choose.Length);
+ }
+ break;
+ }
+ }
+ }
+ break;
+ #endregion
+
+ #region StatusBar
+ case Keyword_StatusBar:
+ {
+ var status = (StatusBar)(control ?? new StatusBar());
+ control = status;
+ status.Text = content;
+ }
+ break;
+ #endregion
+
+ #region WebBrowser
+ case Keyword_WebBrowser:
+ {
+ var web = (WebBrowser)(control ?? new WebBrowser());
+ control = web;
+ web.Navigate(content);
+ }
+ break;
+ #endregion
+ }
+
+ if (opts != null)
+ GuiApplyStyles(control, options);
+ }
+
+ static Form GuiCreateWindow(string name)
+ {
+ if (name== "1")
+ name = string.Empty;
+
+ var win = new Form { Name = name, Tag = new GuiInfo { } };
+
+ win.FormClosed += new FormClosedEventHandler(delegate(object sender, FormClosedEventArgs e)
+ {
+ SafeInvoke(win.Name + Keyword_GuiClose);
+ });
+
+ win.KeyDown += new KeyEventHandler(delegate(object sender, KeyEventArgs e)
+ {
+ if (e.KeyCode == Keys.Escape)
+ {
+ e.Handled = true;
+ SafeInvoke(win.Name + Keyword_GuiEscape);
+ }
+ });
+
+ win.Resize += new EventHandler(delegate(object sender, EventArgs e)
+ {
+ SafeInvoke(win.Name + Keyword_GuiSize);
+ });
+
+ return win;
+ }
+
+ static string GuiApplyStyles(Control control, string styles)
+ {
+ string[] opts = ParseOptions(styles), excess = new string[opts.Length];
+
+ for (int i = 0; i < opts.Length; i++)
+ {
+ string mode = opts[i].ToLowerInvariant();
+ bool append = false;
+
+ bool on = mode[0] != '-';
+ if (!on || mode[0] == '+')
+ mode = mode.Substring(1);
+
+ if (mode.Length == 0)
+ continue;
+
+ string arg = mode.Substring(1);
+ int n;
+
+ switch (mode)
+ {
+ case Keyword_Left:
+ //control.Alignment = ContentAlignment.MiddleLeft;
break;
case Keyword_Center:
- control.Alignment = ContentAlignment.MiddleCenter;
+ //control.Alignment = ContentAlignment.MiddleCenter;
break;
case Keyword_Right:
- control.Alignment = ContentAlignment.MiddleRight;
+ //control.Alignment = ContentAlignment.MiddleRight;
break;
case Keyword_AltSubmit:
- control.AltSubmit = on;
+ //control.AltSubmit = on;
break;
case Keyword_Background:
- control.Background = on;
+ //control.Background = on;
break;
case Keyword_Border:
- control.Border = on;
+ //control.Border = on;
break;
case Keyword_Enabled:
@@ -1065,11 +1052,11 @@ static string GuiApplyStyles(BaseGui.Control control, string styles)
break;
case Keyword_HScroll:
- control.HorizontalScroll = on;
+ //control.HorizontalScroll = on;
break;
case Keyword_VScroll:
- control.VerticalScroll = on;
+ //control.VerticalScroll = on;
break;
case Keyword_TabStop:
@@ -1077,11 +1064,11 @@ static string GuiApplyStyles(BaseGui.Control control, string styles)
break;
case Keyword_Theme:
- control.Theme = on;
+ //control.Theme = on;
break;
case Keyword_Transparent:
- control.Transparent = on;
+ //control.Transparent = on;
break;
case Keyword_Visible:
@@ -1090,7 +1077,7 @@ static string GuiApplyStyles(BaseGui.Control control, string styles)
break;
case Keyword_Wrap:
- control.Wrap = on;
+ //control.Wrap = on;
break;
default:
@@ -1117,13 +1104,13 @@ static string GuiApplyStyles(BaseGui.Control control, string styles)
if (arg.Length != 0 &&
!mode.StartsWith(Keyword_Check, StringComparison.OrdinalIgnoreCase) &&
!mode.StartsWith(Keyword_Choose, StringComparison.OrdinalIgnoreCase))
- control.Colour = ParseColor(arg);
+ control.ForeColor = ParseColor(arg);
else
append = true;
break;
case 'v':
- control.Id = arg;
+ control.Name = arg;
break;
default:
@@ -1140,12 +1127,7 @@ static string GuiApplyStyles(BaseGui.Control control, string styles)
return string.Join(Keyword_Spaces[1].ToString(), excess).Trim();
}
- static void GuiApplyExtendedStyles(BaseGui.Control control, string type, string styles)
- {
- // UNDONE: apply extended gui control styles
- }
-
- static void GuiControlMove(string mode, BaseGui.Control control)
+ static void GuiControlMove(string mode, Control control)
{
if (mode.Length < 2)
return;
@@ -1171,7 +1153,7 @@ static void GuiControlMove(string mode, BaseGui.Control control)
case 'm':
case 'M':
- x = alt ? control.Parent.Margin.Y : control.Parent.Margin.X;
+ x = alt ? control.Parent.Margin.Top : control.Parent.Margin.Left;
break;
case '+':
@@ -1244,18 +1226,18 @@ static void GuiControlMove(string mode, BaseGui.Control control)
}
}
- static BaseGui.Control GuiFindControl(string name)
+ static Control GuiFindControl(string name)
{
return GuiFindControl(name, DefaultGui);
}
- static BaseGui.Control GuiFindControl(string name, BaseGui.Window gui)
+ static Control GuiFindControl(string name, Form gui)
{
if (gui == null)
return null;
- foreach (var control in gui.Controls)
- if (control.Id.Equals(name, StringComparison.OrdinalIgnoreCase))
+ foreach (Control control in gui.Controls)
+ if (control.Name.Equals(name, StringComparison.OrdinalIgnoreCase))
return control;
return null;
@@ -1282,7 +1264,7 @@ public static void GuiControl(string Command, string ControlID, string Param3)
{
case Keyword_Text:
case "":
- ctrl.Contents = Param3;
+ ctrl.Text = Param3;
break;
case Keyword_Move:
@@ -1291,7 +1273,7 @@ public static void GuiControl(string Command, string ControlID, string Param3)
break;
case Keyword_Focus:
- ctrl.Parent.Focus(ctrl);
+ ctrl.Focus();
break;
case Keyword_Enable:
@@ -1311,7 +1293,8 @@ public static void GuiControl(string Command, string ControlID, string Param3)
break;
case Keyword_Delete:
- ctrl.Parent.Remove(ctrl);
+ ctrl.Parent.Controls.Remove(ctrl);
+ ctrl.Dispose();
break;
case Keyword_Choose:
@@ -1319,7 +1302,7 @@ public static void GuiControl(string Command, string ControlID, string Param3)
break;
case Keyword_Font:
- ctrl.Parent.ChangeFont(ctrl);
+ // TODO: change control font
break;
default:
@@ -1328,7 +1311,7 @@ public static void GuiControl(string Command, string ControlID, string Param3)
ctrl.Enabled = n == 1;
if (Command.StartsWith(Keyword_Disable) && int.TryParse(Command.Substring(Keyword_Disable.Length), out n) && (n == 1 || n == 0))
ctrl.Enabled = n == 0;
- GuiApplyExtendedStyles(ctrl, ctrl.GetType().Name, Param3);
+ //GuiApplyExtendedStyles(ctrl, ctrl.GetType().Name, Param3);
break;
}
}
@@ -1355,7 +1338,7 @@ public static void GuiControlGet(out object OutputVar, string Command, string Co
{
case Keyword_Text:
case "":
- OutputVar = ctrl.Contents;
+ OutputVar = ctrl.Text;
break;
case Keyword_Pos:
View
24 Rusty/Core/Gui/Info.cs
@@ -0,0 +1,24 @@
+
+namespace IronAHK.Rusty
+{
+ partial class Core
+ {
+ class GuiInfo
+ {
+ char delimiter;
+ bool owndialogs = false;
+
+ public char Delimiter
+ {
+ get { return delimiter; }
+ set { delimiter = value; }
+ }
+
+ public bool OwnDialogs
+ {
+ get { return owndialogs; }
+ set { owndialogs = value; }
+ }
+ }
+ }
+}
View
33 Rusty/Core/Gui/ListView.cs
@@ -19,7 +19,7 @@ public static int LV_Add(string Options, string[] FieldN)
if (list == null)
return 0;
- return list.Add(Options, FieldN);
+ throw new NotImplementedException(); // TODO: LV_Add
}
/// <summary>
@@ -34,8 +34,7 @@ public static bool LV_Delete(int RowNumber)
if (list == null)
return false;
- list.Delete(RowNumber);
- return true;
+ throw new NotImplementedException(); // TODO: LV_Delete
}
/// <summary>
@@ -50,8 +49,7 @@ public static bool LV_DeleteCol(int ColumnNumber)
if (list == null)
return false;
- list.DeleteColumn(ColumnNumber);
- return true;
+ throw new NotImplementedException(); // TODO: LV_DeleteCol
}
/// <summary>
@@ -66,7 +64,7 @@ public static int LV_GetCount(string Type)
if (list == null)
return 0;
- return list.CountColumn(Type);
+ throw new NotImplementedException(); // TODO: LV_GetCount
}
/// <summary>
@@ -82,7 +80,7 @@ public static int LV_GetNext(int StartingRowNumber, string Mode)
if (list == null)
return 0;
- return list.Next(StartingRowNumber, Mode);
+ throw new NotImplementedException(); // TODO: LV_GetNext
}
/// <summary>
@@ -100,8 +98,7 @@ public static bool LV_GetText(out string OutputVar, int RowNumber, int ColumnNum
if (list == null)
return false;
- OutputVar = list.Text(RowNumber, ColumnNumber);
- return true;
+ throw new NotImplementedException(); // TODO: LV_GetText
}
/// <summary>
@@ -114,8 +111,10 @@ public static void LV_Insert(int RowNumber, string Options, string[] ColN)
{
var list = DefaultListView;
- if (list != null)
- list.Insert(RowNumber, Options, ColN);
+ if (list == null)
+ return;
+
+ throw new NotImplementedException(); // TODO: LV_Insert
}
/// <summary>
@@ -132,7 +131,7 @@ public static int LV_InsertCol(int ColumnNumber, string Options, string ColumnTi
if (list == null)
return 0;
- return list.InsertColumn(ColumnNumber, Options, ColumnTitle);
+ throw new NotImplementedException(); // TODO: LV_InsertCol
}
/// <summary>
@@ -145,8 +144,10 @@ public static void LV_Modify(int RowNumber, string Options, string[] NewCol)
{
var list = DefaultListView;
- if (list != null)
- list.Modify(RowNumber, Options, NewCol);
+ if (list == null)
+ return;
+
+ throw new NotImplementedException(); // TODO: LV_Modify
}
/// <summary>
@@ -163,7 +164,7 @@ public static int LV_ModifyCol(int ColumnNumber, string Options, string ColumnTi
if (list == null)
return 0;
- return list.ModifyColumn(ColumnNumber, Options, ColumnTitle);
+ throw new NotImplementedException(); // TODO: LV_ModifyCol
}
/// <summary>
@@ -176,7 +177,7 @@ public static int LV_ModifyCol(int ColumnNumber, string Options, string ColumnTi
/// <param name="Mode"></param>
public static void LV_SetImageList(int ImageListID, string Mode)
{
- throw new NotImplementedException();
+ throw new NotImplementedException(); // TODO: LV_SetImageList
}
}
}
View
29 Rusty/Core/Gui/StatusBar.cs
@@ -15,18 +15,12 @@ partial class Core
/// <param name="PartNumber"></param>
public static void SB_SetIcon(string Filename, int IconNumber, int PartNumber)
{
- PartNumber--;
+ var status = DefaultStatusBar;
- if (PartNumber < 0 || PartNumber > 256)
+ if (status == null)
return;
- var gui = DefaultGui;
-
- if (gui == null || gui.StatusBar == null)
- return;
-
- var icon = Image.FromFile(Filename);
- gui.StatusBar.SetIcon(PartNumber, icon);
+ throw new NotImplementedException(); // TODO: SB_SetIcon
}
/// <summary>
@@ -35,12 +29,12 @@ public static void SB_SetIcon(string Filename, int IconNumber, int PartNumber)
/// <param name="WidthN"></param>
public static void SB_SetParts(int[] WidthN)
{
- var gui = DefaultGui;
+ var status = DefaultStatusBar;
- if (gui == null || gui.StatusBar == null)
+ if (status == null)
return;
- gui.StatusBar.SetParts(WidthN);
+ throw new NotImplementedException(); // TODO: SB_SetParts
}
/// <summary>
@@ -51,17 +45,12 @@ public static void SB_SetParts(int[] WidthN)
/// <param name="Style"></param>
public static void SB_SetText(string NewText, int PartNumber, int Style)
{
- PartNumber--;
-
- if (PartNumber < 0 || PartNumber > 256)
- return;
-
- var gui = DefaultGui;
+ var status = DefaultStatusBar;
- if (gui == null || gui.StatusBar == null)
+ if (status == null)
return;
- gui.StatusBar.SetText(PartNumber, NewText);
+ throw new NotImplementedException(); // TODO: SB_SetText
}
}
}
View
24 Rusty/Core/Gui/TreeView.cs
@@ -20,9 +20,7 @@ public static int TV_Add(string Name, int ParentItemID, string Options)
if (tree == null)
return 0;
- int id = tree.Add(Name, ParentItemID);
- tree.Modify(id, Options, null);
- return id;
+ throw new NotImplementedException(); // TODO: TV_Add
}
/// <summary>
@@ -37,8 +35,7 @@ public static bool TV_Delete(int ItemID)
if (tree == null)
return false;
- tree.Delete(ItemID);
- return true;
+ throw new NotImplementedException(); // TODO: TV_Delete
}
/// <summary>
@@ -53,7 +50,7 @@ public static int TV_GetChild(int ParentItemID)
if (tree == null)
return 0;
- return tree.Child(ParentItemID);
+ throw new NotImplementedException(); // TODO: TV_GetChild
}
/// <summary>
@@ -67,7 +64,7 @@ public static int TV_GetCount()
if (tree == null)
return 0;
- return tree.Count();
+ throw new NotImplementedException(); // TODO: TV_GetCount
}
/// <summary>
@@ -83,7 +80,7 @@ public static int TV_GetNext(int ItemID, string Mode)
if (tree == null)
return 0;
- return tree.Next(ItemID, Mode);
+ throw new NotImplementedException(); // TODO: TV_GetNext
}
/// <summary>
@@ -98,7 +95,7 @@ public static int TV_GetParent(int ItemID)
if (tree == null)
return 0;
- return tree.ParentOf(ItemID);
+ throw new NotImplementedException(); // TODO: TV_GetParent
}
/// <summary>
@@ -113,7 +110,7 @@ public static int TV_GetPrev(int ItemID)
if (tree == null)
return 0;
- return tree.Previous(ItemID);
+ throw new NotImplementedException(); // TODO: TV_GetPrev
}
/// <summary>
@@ -127,7 +124,7 @@ public static int TV_GetSelection()
if (tree == null)
return 0;
- return tree.Selection();
+ throw new NotImplementedException(); // TODO: TV_GetSelection
}
/// <summary>
@@ -144,8 +141,7 @@ public static int TV_GetText(out string OutputVar, int ItemID)
if (tree == null)
return 0;
- OutputVar = tree.Text(ItemID);
- return 1;
+ throw new NotImplementedException(); // TODO: TV_GetText
}
/// <summary>
@@ -162,7 +158,7 @@ public static int TV_Modify(int ItemID, string Options, string NewName)
if (tree == null)
return 0;
- return tree.Modify(ItemID, Options, NewName);
+ throw new NotImplementedException(); // TODO: TV_Modify
}
}
}
View
1,300 Rusty/Extras/Gui/BaseGui.cs
@@ -1,1300 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Drawing;
-using System.Windows.Forms;
-
-#pragma warning disable 1591
-
-namespace IronAHK.Rusty
-{
- public abstract class BaseGui
- {
- #region Information
-
- public abstract bool Available { get; }
-
- public abstract string Name { get; }
-
- public abstract Window CreateWindow();
-
- #endregion
-
- #region Window
-
- public abstract class Window
- {
- #region Methods
-
- public abstract void Add(Control control);
- public abstract void Remove(Control control);
- public abstract void Draw(string title);
- public abstract void Show();
- public abstract void AutoSize();
- public abstract Dictionary<string, string> Submit(bool hide);
- public abstract void Cancel();
- public abstract void Destroy();
- public abstract void Minimise();
- public abstract void Maximise();
- public abstract void Restore();
- public abstract void Flash(bool off);
- public abstract void Focus(Control control);
- public abstract void ChangeFont(Control control);
-
- #region Controls
-
- public abstract Text CreateText();
- public abstract Edit CreateEdit();
- public abstract UpDown CreateUpDown();
- public abstract Picture CreatePicture();
- public abstract Button CreateButton();
- public abstract Checkbox CreateCheckbox();
- public abstract Radio CreateRadio();
- public abstract DropDownList CreateDropDownList();
- public abstract ComboBox CreateComboBox();
- public abstract ListBox CreateListBox();
- public abstract ListView CreateListView();
- public abstract TreeView CreateTreeView();
- public abstract Hotkey CreateHotkey();
- public abstract DateTime CreateDateTime();
- public abstract MonthCal CreateMonthCal();
- public abstract Slider CreateSider();
- public abstract Progress CreateProgress();
- public abstract GroupBox CreateGroupBox();
- public abstract StatusBar CreateStatusBar();
- public abstract Tab CreateTab();
- public abstract WebBrowser CreateWebBrowser();
-
- #endregion
-
- #endregion
-
- #region Events
-
- #region Args
-
- public class ClosedArgs : EventArgs { }
-
- public class EscapedArgs : EventArgs { }
-
- public class ResizedArgs : EventArgs
- {
- int mode;
-
- public ResizedArgs(int mode)
- {
- this.mode = mode;
- }
-
- public int Mode
- {
- get { return mode; }
- }
- }
-
- public class ContextMenuArgs : EventArgs
- {
- Control control;
- object target;
- Point location;
- bool rightclick;
-
- public ContextMenuArgs(Control control, object target, Point point, bool rightclick)
- {
- this.control = control;
- this.target = target;
- this.location = point;
- this.rightclick = rightclick;
- }
-
- public Control Control
- {
- get { return control; }
- }
-
- public object Target
- {
- get { return target; }
- }
-
- public Point Location
- {
- get { return location; }
- }
-
- public bool RightClick
- {
- get { return rightclick; }
- }
- }
-
- public class DroppedFilesArgs : EventArgs
- {
- Control control;
- int number;
- Point location;
- string[] filenames;
-
- public DroppedFilesArgs(Control control, int number, Point location, string[] filenames)
- {
- this.control = control;
- this.number = number;
- this.location = location;
- this.filenames = filenames;
- }