public DisplayAttribute(string _DisplayName, string _GroupName, UIControlType _ControType, object _data) { DisplayName = _DisplayName; GroupName = _GroupName; ControlType = _ControType; data = _data; }
public UIControl(string rawLine, SectionAddress addr, string key) { this.RawLine = rawLine; this.Addr = addr; this.Key = key; this.Text = string.Empty; this.Visibility = false; this.Type = UIControlType.None; this.Rect = new Rect(0, 0, 0, 0); }
public UIControl(string rawLine, SectionAddress addr, string key, string text, bool visibility, UIControlType type, Rect rect, UIInfo info) { this.RawLine = rawLine; this.Addr = addr; this.Key = key; this.Text = text; this.Visibility = visibility; this.Type = type; this.Rect = rect; this.Info = info; }
// Methods public ArgumentStruct() { _moChildArguments = new ArrayList(); _moParameterXml = null; Name = string.Empty; Description = string.Empty; DataType = string.Empty; Value = string.Empty; ValueAttriName = string.Empty; IsTagName = false; UIType = UIControlType.SingleLineTextBox; ParentArgument = null; }
public UIRowFromXML(string rowLabel, string key, string buttonText, UIControlType control, int Height, string DataType, bool ReadOnly, string ToolTip, bool Required) { _rowLabel = rowLabel; _key = key; _buttonText = buttonText; _controlType = control; _height = Height; _dataType = DataType; _readOnly = ReadOnly; _ToolTip = ToolTip; _Required = Required; }
public UIControl(string rawLine, ScriptSection section, string key, string text, bool visibility, UIControlType type, int x, int y, int width, int height, UIInfo info, int lineIdx) { RawLine = rawLine; Section = section; Key = key; Text = text; Visibility = visibility; Type = type; X = x; Y = y; Width = width; Height = height; Info = info; LineIdx = lineIdx; }
public UIControl(string rawLine, ScriptSection section, string key) { RawLine = rawLine; Section = section; Key = key; Text = string.Empty; Visibility = false; Type = UIControlType.None; X = 0; Y = 0; Width = 0; Height = 0; Info = null; LineIdx = 0; }
public UIControlParams(string key, UIControlMode model = UIControlMode.Standard, string unit = null, UIControlType type = UIControlType.TextBox, UIControlFormat format = UIControlFormat.String, string cssClass = "form-control", string style = null) { this.Key = key; this.Model = model; this.Unit = unit; this.Type = type; this.Format = format; this.CssClass = cssClass; this.Style = style; }
public static string GetUIControlTemplate(UIControlType type, string key) { switch (type) { case UIControlType.TextBox: return(UIInfo_TextBox.Template(key)); case UIControlType.TextLabel: return(UIInfo_TextLabel.Template(key)); case UIControlType.NumberBox: return(UIInfo_NumberBox.Template(key)); case UIControlType.CheckBox: return(UIInfo_CheckBox.Template(key)); case UIControlType.ComboBox: return(UIInfo_ComboBox.Template(key)); case UIControlType.Image: return(UIInfo_Image.Template(key)); case UIControlType.TextFile: return(UIInfo_TextFile.Template(key)); case UIControlType.Button: return(UIInfo_Button.Template(key)); case UIControlType.WebLabel: return(UIInfo_WebLabel.Template(key)); case UIControlType.RadioButton: return(UIInfo_RadioButton.Template(key)); case UIControlType.Bevel: return(UIInfo_Bevel.Template(key)); case UIControlType.FileBox: return(UIInfo_FileBox.Template(key)); case UIControlType.RadioGroup: return(UIInfo_RadioGroup.Template(key)); default: throw new InvalidOperationException("Internal Logic Error at UIControl.GetUIControlTemplate"); } }
private UIControlType ParseUIControlTypeFromString(string UIString) { UIControlType oTemp = UIControlType.None; for (int i = 0; i < 100; i++) { try { oTemp = (UIControlType)i; if (oTemp.ToString() == UIString) { break; } } catch (InvalidCastException) { oTemp = UIControlType.None; } } return(oTemp); }
private static UIInfo ParseUIControlInfo(UIControlType type, List <string> fullArgs) { // Only use fields starting from 8th operand List <string> args = fullArgs.Skip(6).ToList(); // Remove Text, Visibility, X, Y, width, height switch (type) { #region TextBox case UIControlType.TextBox: { const int minOpCount = 1; const int maxOpCount = 1; if (CodeParser.CheckInfoArgumentCount(args, minOpCount, maxOpCount + 1)) // +1 for tooltip { throw new InvalidCommandException($"[{type}] can have [{minOpCount}] ~ [{maxOpCount + 1}] arguments"); } return(new UIInfo_TextBox(GetInfoTooltip(args, maxOpCount), args[0])); } #endregion #region TextLabel case UIControlType.TextLabel: { const int minOpCount = 2; const int maxOpCount = 3; if (CodeParser.CheckInfoArgumentCount(args, minOpCount, maxOpCount + 1)) // +1 for tooltip { throw new InvalidCommandException($"[{type}] can have [{minOpCount}] ~ [{maxOpCount + 1}] arguments"); } int cnt = args.Count; string tooltip = null; if (0 < args.Count && args.Last().StartsWith("__", StringComparison.Ordinal)) // Has <ToolTip> { tooltip = GetInfoTooltip(args, cnt - 1); cnt -= 1; } if (!NumberHelper.ParseInt32(args[0], out int fontSize)) { throw new InvalidCommandException($"FontSize [{args[0]}] is not a valid integer"); } UIFontWeight?weight = ParseUIFontWeight(args[1]); if (weight == null) { throw new InvalidCommandException($"FontWeight [{args[1]}] is invalid"); } UIFontStyle?style = null; if (3 <= cnt) { style = ParseUIFontStyle(args[2]); if (style == null) { throw new InvalidCommandException($"FontStyle [{args[2]}] is invalid"); } } return(new UIInfo_TextLabel(tooltip, fontSize, (UIFontWeight)weight, style)); } #endregion #region NumberBox case UIControlType.NumberBox: { const int minOpCount = 4; const int maxOpCount = 4; if (CodeParser.CheckInfoArgumentCount(args, minOpCount, maxOpCount + 1)) // +1 for tooltip { throw new InvalidCommandException($"[{type}] can have [{minOpCount}] ~ [{maxOpCount + 1}] arguments"); } NumberHelper.ParseInt32(args[0], out int value); NumberHelper.ParseInt32(args[1], out int min); NumberHelper.ParseInt32(args[2], out int max); NumberHelper.ParseInt32(args[3], out int interval); return(new UIInfo_NumberBox(GetInfoTooltip(args, maxOpCount), value, min, max, interval)); } #endregion #region CheckBox case UIControlType.CheckBox: { const int minOpCount = 1; const int maxOpCount = 3; // +2 for [RunOptional] if (CodeParser.CheckInfoArgumentCount(args, minOpCount, maxOpCount + 1)) // +1 for tooltip { throw new InvalidCommandException($"[{type}] can have [{minOpCount}] ~ [{maxOpCount + 1}] arguments"); } bool _checked = false; if (args[0].Equals("True", StringComparison.OrdinalIgnoreCase)) { _checked = true; } else if (args[0].Equals("False", StringComparison.OrdinalIgnoreCase) == false) { throw new InvalidCommandException($"Invalid argument [{args[0]}], must be [True] or [False]"); } string tooltip = null; if (0 < args.Count && args.Last().StartsWith("__", StringComparison.Ordinal)) // Has <ToolTip> { tooltip = GetInfoTooltip(args, args.Count - 1); } string sectionName = null; bool hideProgress = false; if (3 <= args.Count && (args[2].Equals("True", StringComparison.OrdinalIgnoreCase) || args[2].Equals("False", StringComparison.OrdinalIgnoreCase)) && args[1].StartsWith("_", StringComparison.Ordinal) && args[1].EndsWith("_", StringComparison.Ordinal)) { // Has [RunOptional] -> <SectionName>,<HideProgress> if (args[2].Equals("True", StringComparison.OrdinalIgnoreCase)) { hideProgress = true; } else if (args[2].Equals("False", StringComparison.OrdinalIgnoreCase) == false) { throw new InvalidCommandException($"Invalid argument [{args[2]}], must be [True] or [False]"); } // Trim one '_' from start and end string rawSectionName = args[1]; sectionName = rawSectionName.Substring(1, rawSectionName.Length - 2); } return(new UIInfo_CheckBox(tooltip, _checked, sectionName, hideProgress)); } #endregion #region ComboBox case UIControlType.ComboBox: { // Variable Length List <string> items = new List <string>(); int cnt = args.Count; string toolTip = null; if (0 < args.Count && args.Last().StartsWith("__", StringComparison.Ordinal)) // Has <ToolTip> { toolTip = GetInfoTooltip(args, args.Count - 1); cnt -= 1; } string sectionName = null; bool hideProgress = false; if (2 <= cnt && (args[cnt - 1].Equals("True", StringComparison.OrdinalIgnoreCase) || args[cnt - 1].Equals("False", StringComparison.OrdinalIgnoreCase)) && args[cnt - 2].StartsWith("_", StringComparison.Ordinal) && args[cnt - 2].EndsWith("_", StringComparison.Ordinal)) { // Has [RunOptional] -> <SectionName>,<HideProgress> if (args[cnt - 1].Equals("True", StringComparison.OrdinalIgnoreCase)) { hideProgress = true; } else if (args[cnt - 1].Equals("False", StringComparison.OrdinalIgnoreCase) == false) { throw new InvalidCommandException($"Invalid argument [{args[cnt - 1]}], must be [True] or [False]"); } // Trim one '_' from start and end string rawSectionName = args[cnt - 2]; sectionName = rawSectionName.Substring(1, rawSectionName.Length - 2); cnt -= 2; } for (int i = 0; i < cnt; i++) { items.Add(args[i]); } // Allow even if an index is -1. (At least SyntaxChecker will raise an error later) int idx = items.IndexOf(fullArgs[0]); return(new UIInfo_ComboBox(toolTip, items, idx, sectionName, hideProgress)); } #endregion #region Image case UIControlType.Image: { const int minOpCount = 0; const int maxOpCount = 1; // [URL] if (CodeParser.CheckInfoArgumentCount(args, minOpCount, maxOpCount + 1)) // +1 for tooltip { throw new InvalidCommandException($"[{type}] can have [{minOpCount}] ~ [{maxOpCount + 1}] arguments"); } int cnt = args.Count; string tooltip = null; if (0 < args.Count && args.Last().StartsWith("__", StringComparison.Ordinal)) // Has <ToolTip> { tooltip = GetInfoTooltip(args, cnt - 1); cnt -= 1; } string url = null; if (1 <= cnt) { url = args[0]; } return(new UIInfo_Image(tooltip, url)); } #endregion #region TextFile case UIControlType.TextFile: { const int minOpCount = 0; const int maxOpCount = 0; if (CodeParser.CheckInfoArgumentCount(args, minOpCount, maxOpCount + 1)) { throw new InvalidCommandException($"[{type}] can have [{minOpCount}] ~ [{maxOpCount + 1}] arguments"); } return(new UIInfo_TextFile(GetInfoTooltip(args, maxOpCount))); } #endregion #region Button case UIControlType.Button: { // <SectionToRun>,<Picture>,[HideProgress] +[UnknownBoolean] +[RunOptional] // Ex) // pButton1 =,1,8,382,47,24,24,Process-OpenDriver_x86,opendir.bmp,False,_Process-OpenDriver_x86,False,_Process-OpenDriver_x86_,False // Button_Download=,1,8,403,21,24,24,DownloadXXX,DoubleJDesignRavenna3dArrowDown0016016.bmp,False,False,_DownloadXXX_,False,"__DOWNLOAD Script" // OpendirSMFilesButton=,1,8,475,204,24,24,Opendir_SMFiles,opendir.bmp,"__Open Custom .ini Folder" // Button_HiveUnload_Target="HiveUnload: Target + ProjectTemp + MountFolders",1,8,15,17,293,46,HiveUnload_Launch_B,HiveUnload3232.bmp,0,"__UnLoad hives" // Button_Tools_Folder="Open Tools Folder",1,8,98,256,134,25,Open_Tools_Folder const int minOpCount = 1; if (CodeParser.CheckInfoArgumentCount(args, minOpCount, -1)) { throw new InvalidCommandException($"[{type}] must have at least [{minOpCount}] arguments"); } int cnt = args.Count; string tooltip = null; if (0 < args.Count && args.Last().StartsWith("__", StringComparison.Ordinal)) // Has <ToolTip> { tooltip = GetInfoTooltip(args, cnt - 1); cnt -= 1; } string picture = null; if (2 <= cnt) { if (!args[1].Equals("0", StringComparison.OrdinalIgnoreCase)) { picture = args[1]; } } bool hideProgress = false; if (3 <= cnt) { if (args[2].Equals("True", StringComparison.OrdinalIgnoreCase)) { hideProgress = true; } else if (!args[2].Equals("False", StringComparison.OrdinalIgnoreCase)) { // WB082 Compability Shim if (args[2].Equals("1", StringComparison.Ordinal)) { hideProgress = true; } else if (!args[2].Equals("0", StringComparison.Ordinal)) { throw new InvalidCommandException($"Invalid argument [{args[2]}], must be [True] or [False]"); } } } // Ignore [UnknownBoolean] and [RunOptional] return(new UIInfo_Button(tooltip, args[0], picture, hideProgress)); } #endregion #region WebLabel case UIControlType.WebLabel: { const int minOpCount = 1; const int maxOpCount = 1; if (CodeParser.CheckInfoArgumentCount(args, minOpCount, maxOpCount + 1)) // +1 for tooltip { throw new InvalidCommandException($"[{type}] can have [{minOpCount}] ~ [{maxOpCount + 1}] arguments"); } return(new UIInfo_WebLabel(GetInfoTooltip(args, maxOpCount), args[0])); } #endregion #region RadioButton case UIControlType.RadioButton: { const int minOpCount = 1; const int maxOpCount = 3; // +2 for [RunOptional] if (CodeParser.CheckInfoArgumentCount(args, minOpCount, maxOpCount + 1)) { throw new InvalidCommandException($"[{type}] can have [{minOpCount}] ~ [{maxOpCount + 1}] arguments"); } bool selected = false; if (args[0].Equals("True", StringComparison.OrdinalIgnoreCase)) { selected = true; } else if (!args[0].Equals("False", StringComparison.OrdinalIgnoreCase)) { throw new InvalidCommandException($"Invalid argument [{args[0]}], must be [True] or [False]"); } string tooltip = null; if (0 < args.Count && args.Last().StartsWith("__", StringComparison.Ordinal)) // Has <ToolTip> { tooltip = GetInfoTooltip(args, args.Count - 1); } string sectionName = null; bool hideProgress = false; if (3 <= args.Count && (args[2].Equals("True", StringComparison.OrdinalIgnoreCase) || args[2].Equals("False", StringComparison.OrdinalIgnoreCase)) && args[1].StartsWith("_", StringComparison.Ordinal) && args[1].EndsWith("_", StringComparison.Ordinal)) { // Has [RunOptional] -> <SectionName>,<HideProgress> if (args[2].Equals("True", StringComparison.OrdinalIgnoreCase)) { hideProgress = true; } else if (args[2].Equals("False", StringComparison.OrdinalIgnoreCase) == false) { throw new InvalidCommandException($"Invalid argument [{args[2]}], must be [True] or [False]"); } // Trim one '_' from start and end string rawSectionName = args[1]; sectionName = rawSectionName.Substring(1, rawSectionName.Length - 2); } return(new UIInfo_RadioButton(tooltip, selected, sectionName, hideProgress)); } #endregion #region Bevel case UIControlType.Bevel: { const int minOpCount = 0; const int maxOpCount = 3; if (CodeParser.CheckInfoArgumentCount(args, minOpCount, maxOpCount + 1)) // +1 for tooltip { throw new InvalidCommandException($"[{type}] can have [{minOpCount}] ~ [{maxOpCount + 1}] arguments"); } int cnt = args.Count; string tooltip = null; if (0 < args.Count && args.Last().StartsWith("__", StringComparison.Ordinal)) // Has <ToolTip> { tooltip = GetInfoTooltip(args, cnt - 1); cnt -= 1; } int? fontSize = null; UIFontWeight?weight = null; UIFontStyle? style = null; if (1 <= cnt) { if (!NumberHelper.ParseInt32(args[0], out int fontSizeVal)) { throw new InvalidCommandException($"FontSize {args[0]} is not a valid integer"); } fontSize = fontSizeVal; } if (2 <= cnt) { weight = ParseUIFontWeight(args[1]); if (weight == null) { throw new InvalidCommandException($"FontWeight [{args[1]}] is invalid"); } } if (3 <= cnt) { style = ParseUIFontStyle(args[2]); if (style == null) { throw new InvalidCommandException($"FontStyle [{args[2]}] is invalid"); } } return(new UIInfo_Bevel(tooltip, fontSize, weight, style)); } #endregion #region FileBox case UIControlType.FileBox: { const int minOpCount = 0; const int maxOpCount = 3; if (CodeParser.CheckInfoArgumentCount(args, minOpCount, maxOpCount + 1)) { throw new InvalidCommandException($"[{type}] can have [{minOpCount}] ~ [{maxOpCount + 1}] arguments"); } bool isFile = false; if (0 < args.Count) { if (args[0].Equals("file", StringComparison.OrdinalIgnoreCase)) { isFile = true; } else if (!args[0].Equals("dir", StringComparison.OrdinalIgnoreCase)) { throw new InvalidCommandException($"Argument [{type}] should be either [file] or [dir]"); } } string title = null; string filter = null; string tooltip = null; const string titleKey = "Title="; const string filterKey = "Filter="; for (int i = 1; i < args.Count; i++) { string arg = args[i]; if (arg.StartsWith(titleKey, StringComparison.OrdinalIgnoreCase)) { if (title != null) { throw new InvalidCommandException("Argument <Title> cannot be duplicated"); } title = arg.Substring(titleKey.Length); } else if (arg.StartsWith(filterKey, StringComparison.OrdinalIgnoreCase)) { if (!isFile) { throw new InvalidCommandException("Argument <Filter> can only be used for file selection"); } if (filter != null) { throw new InvalidCommandException("Argument <Filter> cannot be duplicated"); } filter = arg.Substring(filterKey.Length); } else if (arg.StartsWith("__", StringComparison.OrdinalIgnoreCase)) // ToolTip { tooltip = GetInfoTooltip(args, i); } else { throw new InvalidCommandException($"Invalid optional argument [{arg}]"); } } return(new UIInfo_FileBox(tooltip, isFile, title, filter)); } #endregion #region RadioGroup case UIControlType.RadioGroup: { // Variable Length List <string> items = new List <string>(); string sectionName = null; bool showProgress = false; int cnt = args.Count - 1; if (0 < args.Count && args.Last().StartsWith("__", StringComparison.Ordinal)) // Has <ToolTip> { cnt -= 1; } if ((args[cnt].Equals("True", StringComparison.OrdinalIgnoreCase) || args[cnt].Equals("False", StringComparison.OrdinalIgnoreCase)) && args[cnt - 1].StartsWith("_", StringComparison.Ordinal) && args[cnt - 1].EndsWith("_", StringComparison.Ordinal)) { // Has [RunOptional] -> <SectionName>,<HideProgress> if (args[cnt].Equals("True", StringComparison.OrdinalIgnoreCase)) { showProgress = true; } else if (!args[cnt].Equals("False", StringComparison.OrdinalIgnoreCase)) { throw new InvalidCommandException($"Invalid argument [{args[cnt]}], must be [True] or [False]"); } sectionName = args[cnt - 1].Substring(1, args[cnt - 1].Length - 2); cnt -= 2; } for (int i = 0; i < cnt; i++) { items.Add(args[i]); } if (!NumberHelper.ParseInt32(args[cnt], out int idx)) { throw new InvalidCommandException($"Invalid argument [{args[cnt]}], must be an integer"); } return(new UIInfo_RadioGroup(GetInfoTooltip(args, args.Count), items, idx, sectionName, showProgress)); } #endregion #region default default: Debug.Assert(false); break; #endregion } throw new InvalidCommandException($"Invalid interface control type [{type}]"); }
public DisplayAttribute(string _DisplayName, UIControlType _ControType) { DisplayName = _DisplayName; ControlType = _ControType; GroupName = "数据"; }
//public UIControlAttribute(UIControlType type, // string sourceEnumerable = "", // string displayProperty = "", // string storageProperty = "", // UIControlOptions options = UIControlOptions.None) //{ // SourceEnumerable = sourceEnumerable; // DisplayProperty = displayProperty; // StorageProperty = storageProperty; // Type = type; // Options = options; //} public UIControlAttribute(UIControlType type, UIControlOptions options = UIControlOptions.None) { Type = type; Options = options; }
public static UIControl ParseUIControl(List <string> rawLines, SectionAddress addr, ref int idx) { UIControlType type = UIControlType.None; string rawLine = rawLines[idx].Trim(); // Check if rawCode is Empty if (rawLine.Equals(string.Empty)) { return(null); } // Comment Format : starts with '//' or '#', ';' if (rawLine.StartsWith("//") || rawLine.StartsWith("#") || rawLine.StartsWith(";")) { return(null); } // Find key of interface control string key = string.Empty; string rawValue = string.Empty; int equalIdx = rawLine.IndexOf('='); if (equalIdx != -1 && equalIdx != 0) { key = rawLine.Substring(0, equalIdx); rawValue = rawLine.Substring(equalIdx + 1); } else { throw new InvalidCommandException($"Interface control [{rawValue}] does not have a name defined", rawLine); } // Parse Arguments List <string> args = new List <string>(); try { string remainder = rawValue; while (remainder != null) { Tuple <string, string> tuple = CodeParser.GetNextArgument(remainder); args.Add(tuple.Item1); remainder = tuple.Item2; } } catch (InvalidCommandException e) { throw new InvalidCommandException(e.Message, rawLine); } // Check doublequote's occurence - must be 2n if (StringHelper.CountOccurrences(rawValue, "\"") % 2 == 1) { throw new InvalidCommandException($"Interface control [{rawValue}]'s doublequotes mismatch", rawLine); } // Check if last operand is \ - MultiLine check - only if one or more operands exists if (0 < args.Count) { while (args.Last().Equals(@"\", StringComparison.OrdinalIgnoreCase)) { // Split next line and append to List<string> operands if (rawLines.Count <= idx) // Section ended with \, invalid grammar! { throw new InvalidCommandException($@"Last interface control [{rawValue}] cannot end with '\' ", rawLine); } idx++; args.AddRange(rawLines[idx].Trim().Split(',')); } } // UIControl should have at least 7 operands // Text, Visibility, Type, X, Y, width, height, [Optional] if (args.Count < 7) { throw new InvalidCommandException($"Interface control [{rawValue}] must have at least 7 arguments", rawLine); } // Parse opcode try { type = UIParser.ParseControlType(args[2]); } catch (InvalidCommandException e) { throw new InvalidCommandException(e.Message, rawLine); } // Remove UIControlType from operands // Leftover : Text, Visibility, X, Y, width, height, [Optional] args.RemoveAt(2); // Forge UIControl string text = StringEscaper.Unescape(args[0]); bool visibility = args[1].Equals("1", StringComparison.Ordinal); bool intParse = true; intParse &= NumberHelper.ParseInt32(args[2], out int x); intParse &= NumberHelper.ParseInt32(args[3], out int y); intParse &= NumberHelper.ParseInt32(args[4], out int width); intParse &= NumberHelper.ParseInt32(args[5], out int height); if (intParse == false) { throw new InvalidCommandException($"Invalid integers in [{rawValue}]", rawLine); } Rect rect = new Rect(x, y, width, height); UIInfo info; try { info = ParseUIControlInfo(type, args); } catch (InvalidCommandException e) { throw new InvalidCommandException(e.Message, rawLine); } return(new UIControl(rawLine, addr, key, text, visibility, type, rect, info)); }