/// <summary> /// Render NumberBox control. /// Return true if failed. /// </summary> /// <param name="r.Canvas">Parent r.Canvas</param> /// <param name="r.MasterScale">Master Scale Factor</param> /// <param name="uiCtrl">UIControl</param> /// <returns>Success = false, Failure = true</returns> public static void RenderNumberBox(RenderInfo r, UIControl uiCtrl) { Debug.Assert(uiCtrl.Info.GetType() == typeof(UIInfo_NumberBox)); UIInfo_NumberBox info = uiCtrl.Info as UIInfo_NumberBox; FreeNumberBox box = new FreeNumberBox() { Value = info.Value, FontSize = CalcFontPointScale(), Minimum = info.Min, Maximum = info.Max, DecimalPlaces = 0, IncrementUnit = info.Interval, VerticalContentAlignment = VerticalAlignment.Center, }; box.ValueChanged += (object sender, RoutedPropertyChangedEventArgs <decimal> e) => { info.Value = (int)e.NewValue; uiCtrl.Update(); }; SetToolTip(box, info.ToolTip); DrawToCanvas(r, box, uiCtrl.Rect); }
/// <summary> /// Render RadioGroup control. /// Return true if failed. /// </summary> /// <param name="r.Canvas">Parent r.Canvas</param> /// <param name="uiCtrl">UIControl</param> /// <returns>Success = false, Failure = true</returns> public static void RenderRadioButton(RenderInfo r, UIControl uiCtrl, UIControl[] radioButtons) { Debug.Assert(uiCtrl.Info.GetType() == typeof(UIInfo_RadioButton)); UIInfo_RadioButton info = uiCtrl.Info as UIInfo_RadioButton; double fontSize = CalcFontPointScale(); RadioButton radio = new RadioButton() { GroupName = r.Script.FullPath, Content = uiCtrl.Text, FontSize = fontSize, IsChecked = info.Selected, VerticalContentAlignment = VerticalAlignment.Center, }; if (info.SectionName != null) { radio.Click += (object sender, RoutedEventArgs e) => { if (r.Script.Sections.ContainsKey(info.SectionName)) // Only if section exists { SectionAddress addr = new SectionAddress(r.Script, r.Script.Sections[info.SectionName]); UIRenderer.RunOneSection(addr, $"{r.Script.Title} - RadioButton [{uiCtrl.Key}]", info.HideProgress); } else { Application.Current.Dispatcher.Invoke((Action)(() => { MainWindow w = Application.Current.MainWindow as MainWindow; w.Logger.System_Write(new LogInfo(LogState.Error, $"Section [{info.SectionName}] does not exists")); })); } }; } radio.Checked += (object sender, RoutedEventArgs e) => { RadioButton btn = sender as RadioButton; info.Selected = true; // Uncheck the other RadioButtons List <UIControl> updateList = radioButtons.Where(x => !x.Key.Equals(uiCtrl.Key, StringComparison.Ordinal)).ToList(); foreach (UIControl uncheck in updateList) { Debug.Assert(uncheck.Info.GetType() == typeof(UIInfo_RadioButton)); UIInfo_RadioButton unInfo = uncheck.Info as UIInfo_RadioButton; unInfo.Selected = false; } updateList.Add(uiCtrl); UIControl.Update(updateList); }; SetToolTip(radio, info.ToolTip); DrawToCanvas(r, radio, uiCtrl.Rect); }
public static List <LogInfo> Visible(EngineState s, CodeCommand cmd) { List <LogInfo> logs = new List <LogInfo>(1); Debug.Assert(cmd.Info.GetType() == typeof(CodeInfo_Visible)); CodeInfo_Visible info = cmd.Info as CodeInfo_Visible; string visibilityStr = StringEscaper.Preprocess(s, info.Visibility); bool visibility = false; if (visibilityStr.Equals("True", StringComparison.OrdinalIgnoreCase)) { visibility = true; } else if (visibilityStr.Equals("False", StringComparison.OrdinalIgnoreCase) == false) { logs.Add(new LogInfo(LogState.Error, $"Invalid boolean value [{visibilityStr}]")); return(logs); } Script p = cmd.Addr.Script; ScriptSection iface = p.GetInterface(out string ifaceSecName); if (iface == null) { logs.Add(new LogInfo(LogState.Error, $"Script [{cmd.Addr.Script.ShortPath}] does not have section [{ifaceSecName}]")); return(logs); } List <UIControl> uiCtrls = iface.GetUICtrls(true); UIControl uiCtrl = uiCtrls.Find(x => x.Key.Equals(info.InterfaceKey, StringComparison.OrdinalIgnoreCase)); if (uiCtrl == null) { logs.Add(new LogInfo(LogState.Error, $"Cannot find interface control [{info.InterfaceKey}] in section [{ifaceSecName}]")); return(logs); } if (uiCtrl.Visibility != visibility) { uiCtrl.Visibility = visibility; uiCtrl.Update(); // Re-render Script Application.Current.Dispatcher.Invoke(() => { MainWindow w = (Application.Current.MainWindow as MainWindow); if (w.CurMainTree.Script == cmd.Addr.Script) { w.DrawScript(cmd.Addr.Script); } }); } logs.Add(new LogInfo(LogState.Success, $"Interface control [{info.InterfaceKey}]'s visibility set to [{visibility}]")); return(logs); }
/// <summary> /// Render CheckBox control. /// Return true if failed. /// </summary> /// <param name="r.Canvas">Parent r.Canvas</param> /// <param name="uiCtrl">UIControl</param> /// <returns>Success = false, Failure = true</returns> public static void RenderCheckBox(RenderInfo r, UIControl uiCtrl) { Debug.Assert(uiCtrl.Info.GetType() == typeof(UIInfo_CheckBox)); UIInfo_CheckBox info = uiCtrl.Info as UIInfo_CheckBox; CheckBox checkBox = new CheckBox() { Content = uiCtrl.Text, IsChecked = info.Value, FontSize = CalcFontPointScale(), VerticalContentAlignment = VerticalAlignment.Center, }; if (info.SectionName != null) { checkBox.Click += (object sender, RoutedEventArgs e) => { if (r.Script.Sections.ContainsKey(info.SectionName)) // Only if section exists { SectionAddress addr = new SectionAddress(r.Script, r.Script.Sections[info.SectionName]); UIRenderer.RunOneSection(addr, $"{r.Script.Title} - CheckBox [{uiCtrl.Key}]", info.HideProgress); } else { r.Logger.System_Write(new LogInfo(LogState.Error, $"Section [{info.SectionName}] does not exists")); } }; } checkBox.Checked += (object sender, RoutedEventArgs e) => { CheckBox box = sender as CheckBox; info.Value = true; uiCtrl.Update(); }; checkBox.Unchecked += (object sender, RoutedEventArgs e) => { CheckBox box = sender as CheckBox; info.Value = false; uiCtrl.Update(); }; SetToolTip(checkBox, info.ToolTip); DrawToCanvas(r, checkBox, uiCtrl.Rect); }
public void LateUpdate() { // 处理绘制 m_UIMesh.RemoveAll(); for (int i = 0; i < m_Controls.Count; ++i) { UIControl control = (UIControl)m_Controls[i]; control.Update(); if (control.Visible) { control.Draw(); } } m_UIMesh.DoLateUpdate(); }
/// <summary> /// Render ComboBox control. /// Return true if failed. /// </summary> /// <param name="r.Canvas">Parent r.Canvas</param> /// <param name="uiCtrl">UIControl</param> /// <returns>Success = false, Failure = true</returns> public static void RenderComboBox(RenderInfo r, UIControl uiCtrl) { Debug.Assert(uiCtrl.Info.GetType() == typeof(UIInfo_ComboBox)); UIInfo_ComboBox info = uiCtrl.Info as UIInfo_ComboBox; ComboBox comboBox = new ComboBox() { FontSize = CalcFontPointScale(), ItemsSource = info.Items, SelectedIndex = info.Index, VerticalContentAlignment = VerticalAlignment.Center, }; comboBox.LostFocus += (object sender, RoutedEventArgs e) => { ComboBox box = sender as ComboBox; if (info.Index != box.SelectedIndex) { info.Index = box.SelectedIndex; uiCtrl.Text = info.Items[box.SelectedIndex]; uiCtrl.Update(); } }; if (info.SectionName != null) { comboBox.SelectionChanged += (object sender, SelectionChangedEventArgs e) => { if (r.Script.Sections.ContainsKey(info.SectionName)) // Only if section exists { SectionAddress addr = new SectionAddress(r.Script, r.Script.Sections[info.SectionName]); UIRenderer.RunOneSection(addr, $"{r.Script.Title} - CheckBox [{uiCtrl.Key}]", info.HideProgress); } else { r.Logger.System_Write(new LogInfo(LogState.Error, $"Section [{info.SectionName}] does not exists")); } }; } SetToolTip(comboBox, info.ToolTip); DrawToCanvas(r, comboBox, uiCtrl.Rect); }
/// <summary> /// Render TextBox control. /// Return true if failed. /// </summary> /// <param name="canvas">Parent canvas</param> /// <param name="uiCtrl">UIControl</param> /// <returns>Success = false, Failure = true</returns> public static void RenderTextBox(RenderInfo r, UIControl uiCtrl) { // WB082 textbox control's y coord is of textbox's, not textlabel's. Debug.Assert(uiCtrl.Info.GetType() == typeof(UIInfo_TextBox)); UIInfo_TextBox info = uiCtrl.Info as UIInfo_TextBox; TextBox box = new TextBox() { Text = info.Value, FontSize = CalcFontPointScale(), VerticalContentAlignment = VerticalAlignment.Center, }; box.LostFocus += (object sender, RoutedEventArgs e) => { TextBox tBox = sender as TextBox; info.Value = tBox.Text; uiCtrl.Update(); }; SetToolTip(box, info.ToolTip); DrawToCanvas(r, box, uiCtrl.Rect); if (uiCtrl.Text.Equals(string.Empty, StringComparison.Ordinal) == false) { TextBlock block = new TextBlock() { Text = uiCtrl.Text, LineStackingStrategy = LineStackingStrategy.BlockLineHeight, LineHeight = CalcFontPointScale(), FontSize = CalcFontPointScale(), }; SetToolTip(block, info.ToolTip); double margin = PointToDeviceIndependentPixel * DefaultFontPoint * 1.2; Rect blockRect = new Rect(uiCtrl.Rect.Left, uiCtrl.Rect.Top - margin, uiCtrl.Rect.Width, uiCtrl.Rect.Height); DrawToCanvas(r, block, blockRect); } }
public static List <LogInfo> Set(EngineState s, CodeCommand cmd) { CodeInfo_Set info = cmd.Info.Cast <CodeInfo_Set>(); Variables.VarKeyType varType = Variables.DetectType(info.VarKey); if (varType == Variables.VarKeyType.None) { // Check Macro if (Regex.Match(info.VarKey, Macro.MacroNameRegex, RegexOptions.Compiled | RegexOptions.CultureInvariant).Success) // Macro Name Validation { string macroCommand = StringEscaper.Preprocess(s, info.VarValue); if (macroCommand.Equals("NIL", StringComparison.OrdinalIgnoreCase)) { macroCommand = null; } LogInfo log = s.Macro.SetMacro(info.VarKey, macroCommand, cmd.Section, info.Permanent, false); return(new List <LogInfo>(1) { log }); } } // [WB082 Behavior] -> Enabled if s.CompatAllowSetModifyInterface == true // If PERMANENT was used but the key exists in interface command, the value will not be written to script.project but in interface. // Need to investigate where the logs are saved in this case. switch (info.Permanent) { case true: { // Check if interface contains VarKey List <LogInfo> logs = new List <LogInfo>(); if (Variables.DetectType(info.VarKey) != Variables.VarKeyType.Variable) { goto case false; } #region Set interface control's value (Compat) if (s.CompatAllowSetModifyInterface) { string varKey = Variables.TrimPercentMark(info.VarKey); string finalValue = StringEscaper.Preprocess(s, info.VarValue); Script sc = cmd.Section.Script; ScriptSection iface = sc.GetInterfaceSection(out _); if (iface == null) { goto case false; } (List <UIControl> uiCtrls, _) = UIParser.ParseStatements(iface.Lines, iface); UIControl uiCtrl = uiCtrls.Find(x => x.Key.Equals(varKey, StringComparison.OrdinalIgnoreCase)); if (uiCtrl == null) { goto case false; } bool valid = uiCtrl.SetValue(finalValue, false, out List <LogInfo> varLogs); logs.AddRange(varLogs); if (valid) { uiCtrl.Update(); // Also update variables logs.AddRange(Variables.SetVariable(s, info.VarKey, info.VarValue, false, false)); return(logs); } } goto case false; #endregion } case false: default: return(Variables.SetVariable(s, info.VarKey, info.VarValue, info.Global, info.Permanent)); } }
public static List <LogInfo> Set(EngineState s, CodeCommand cmd) { Debug.Assert(cmd.Info.GetType() == typeof(CodeInfo_Set)); CodeInfo_Set info = cmd.Info as CodeInfo_Set; Variables.VarKeyType varType = Variables.DetermineType(info.VarKey); if (varType == Variables.VarKeyType.None) { // Check Macro if (Regex.Match(info.VarKey, Macro.MacroNameRegex, RegexOptions.Compiled | RegexOptions.CultureInvariant).Success) // Macro Name Validation { string macroCommand = StringEscaper.Preprocess(s, info.VarValue); if (macroCommand.Equals("NIL", StringComparison.OrdinalIgnoreCase)) { macroCommand = null; } LogInfo log = s.Macro.SetMacro(info.VarKey, macroCommand, cmd.Addr, info.Permanent, false); return(new List <LogInfo>(1) { log }); } } // [WB082 Behavior] // If PERMANENT was used but the key exists in interface command, the value will not be written to script.project but in interface. // Need to investigate where the logs are saved in this case. switch (info.Permanent) { case true: { // Check if interface contains VarKey List <LogInfo> logs = new List <LogInfo>(); if (Variables.DetermineType(info.VarKey) != Variables.VarKeyType.Variable) { goto case false; } string varKey = Variables.TrimPercentMark(info.VarKey); string finalValue = StringEscaper.Preprocess(s, info.VarValue); #region Set UI Script p = cmd.Addr.Script; ScriptSection iface = p.GetInterface(out string sectionName); if (iface == null) { goto case false; } List <UIControl> uiCmds = iface.GetUICtrls(true); UIControl uiCmd = uiCmds.Find(x => x.Key.Equals(varKey, StringComparison.OrdinalIgnoreCase)); if (uiCmd == null) { goto case false; } bool match = uiCmd.SetValue(finalValue, false, out List <LogInfo> varLogs); logs.AddRange(varLogs); if (match) { uiCmd.Update(); logs.AddRange(Variables.SetVariable(s, info.VarKey, info.VarValue, false, false)); return(logs); } else { goto case false; } #endregion } case false: default: return(Variables.SetVariable(s, info.VarKey, info.VarValue, info.Global, info.Permanent)); } }
/// <summary> /// Render RadioGroup control. /// Return true if failed. /// </summary> /// <param name="r.Canvas">Parent r.Canvas</param> /// <param name="uiCtrl">UIControl</param> /// <returns>Success = false, Failure = true</returns> public static void RenderRadioGroup(RenderInfo r, UIControl uiCtrl) { Debug.Assert(uiCtrl.Info.GetType() == typeof(UIInfo_RadioGroup)); UIInfo_RadioGroup info = uiCtrl.Info as UIInfo_RadioGroup; double fontSize = CalcFontPointScale(); GroupBox box = new GroupBox() { Header = uiCtrl.Text, FontSize = fontSize, BorderBrush = Brushes.LightGray, }; SetToolTip(box, info.ToolTip); Grid grid = new Grid(); box.Content = grid; for (int i = 0; i < info.Items.Count; i++) { RadioButton radio = new RadioButton() { GroupName = r.Script.FullPath + uiCtrl.Key, Content = info.Items[i], Tag = i, FontSize = fontSize, VerticalContentAlignment = VerticalAlignment.Center, }; radio.IsChecked = (i == info.Selected); radio.Checked += (object sender, RoutedEventArgs e) => { RadioButton btn = sender as RadioButton; info.Selected = (int)btn.Tag; uiCtrl.Update(); }; if (info.SectionName != null) { radio.Click += (object sender, RoutedEventArgs e) => { if (r.Script.Sections.ContainsKey(info.SectionName)) // Only if section exists { SectionAddress addr = new SectionAddress(r.Script, r.Script.Sections[info.SectionName]); UIRenderer.RunOneSection(addr, $"{r.Script.Title} - RadioGroup [{uiCtrl.Key}]", info.HideProgress); } else { Application.Current.Dispatcher.Invoke(() => { MainWindow w = Application.Current.MainWindow as MainWindow; w.Logger.System_Write(new LogInfo(LogState.Error, $"Section [{info.SectionName}] does not exists")); }); } }; } SetToolTip(radio, info.ToolTip); Grid.SetRow(radio, i); grid.RowDefinitions.Add(new RowDefinition()); grid.Children.Add(radio); } Rect rect = new Rect(uiCtrl.Rect.Left, uiCtrl.Rect.Top, uiCtrl.Rect.Width, uiCtrl.Rect.Height); DrawToCanvas(r, box, rect); }
/// <summary> /// Render FileBox control. /// Return true if failed. /// </summary> /// <param name="canvas">Parent canvas</param> /// <param name="uiCtrl">UIControl</param> public static void RenderFileBox(RenderInfo r, UIControl uiCtrl, Variables variables) { // It took time to find WB082 textbox control's y coord is of textbox's, not textlabel's. Debug.Assert(uiCtrl.Info.GetType() == typeof(UIInfo_FileBox)); UIInfo_FileBox info = uiCtrl.Info as UIInfo_FileBox; TextBox box = new TextBox() { Text = uiCtrl.Text, FontSize = CalcFontPointScale(), VerticalContentAlignment = VerticalAlignment.Center, }; box.TextChanged += (object sender, TextChangedEventArgs e) => { TextBox tBox = sender as TextBox; uiCtrl.Text = tBox.Text; uiCtrl.Update(); }; SetToolTip(box, info.ToolTip); Button button = new Button() { FontSize = CalcFontPointScale(), Content = ImageHelper.GetMaterialIcon(PackIconMaterialKind.FolderUpload, 0), }; SetToolTip(button, info.ToolTip); button.Click += (object sender, RoutedEventArgs e) => { Button bt = sender as Button; if (info.IsFile) { // File string currentPath = StringEscaper.Preprocess(variables, uiCtrl.Text); if (File.Exists(currentPath)) { currentPath = Path.GetDirectoryName(currentPath); } else { currentPath = string.Empty; } Microsoft.Win32.OpenFileDialog dialog = new Microsoft.Win32.OpenFileDialog() { Filter = "All Files|*.*", InitialDirectory = currentPath, }; if (dialog.ShowDialog() == true) { box.Text = dialog.FileName; } } else { // Directory VistaFolderBrowserDialog dialog = new VistaFolderBrowserDialog(); string currentPath = StringEscaper.Preprocess(variables, uiCtrl.Text); if (Directory.Exists(currentPath)) { dialog.SelectedPath = currentPath; } Application.Current.Dispatcher.Invoke(() => { if (dialog.ShowDialog(r.Window) == true) { box.Text = dialog.SelectedPath; if (!dialog.SelectedPath.EndsWith("\\", StringComparison.Ordinal)) { box.Text += "\\"; } } }); } }; double margin = 5; Rect boxRect = new Rect(uiCtrl.Rect.Left, uiCtrl.Rect.Top, uiCtrl.Rect.Width - (uiCtrl.Rect.Height + margin), uiCtrl.Rect.Height); Rect btnRect = new Rect(boxRect.Right + margin, uiCtrl.Rect.Top, uiCtrl.Rect.Height, uiCtrl.Rect.Height); DrawToCanvas(r, box, boxRect); DrawToCanvas(r, button, btnRect); }
public static List <LogInfo> WriteInterface(EngineState s, CodeCommand cmd) { // WriteInterface,<Element>,<ScriptFile>,<Section>,<Key>,<Value> List <LogInfo> logs = new List <LogInfo>(2); Debug.Assert(cmd.Info.GetType() == typeof(CodeInfo_WriteInterface)); CodeInfo_WriteInterface info = cmd.Info as CodeInfo_WriteInterface; string scriptFile = StringEscaper.Preprocess(s, info.ScriptFile); string section = StringEscaper.Preprocess(s, info.Section); string key = StringEscaper.Preprocess(s, info.Key); string finalValue = StringEscaper.Preprocess(s, info.Value); Script p = Engine.GetScriptInstance(s, cmd, s.CurrentScript.FullPath, scriptFile, out bool inCurrentScript); if (!p.Sections.ContainsKey(section)) { logs.Add(new LogInfo(LogState.Error, $"Script [{scriptFile}] does not have section [{section}]")); return(logs); } ScriptSection iface = p.Sections[section]; List <UIControl> uiCmds = iface.GetUICtrls(true); UIControl uiCmd = uiCmds.Find(x => x.Key.Equals(key, StringComparison.OrdinalIgnoreCase)); if (uiCmd == null) { logs.Add(new LogInfo(LogState.Error, $"Interface control [{key}] does not exist")); return(logs); } switch (info.Element) { case InterfaceElement.Text: uiCmd.Text = finalValue; break; case InterfaceElement.Visible: { bool visibility = false; if (finalValue.Equals("True", StringComparison.OrdinalIgnoreCase)) { visibility = true; } else if (!finalValue.Equals("False", StringComparison.OrdinalIgnoreCase)) { logs.Add(new LogInfo(LogState.Error, $"[{finalValue}] is not a valid boolean value")); return(logs); } uiCmd.Visibility = visibility; } break; case InterfaceElement.PosX: { if (!NumberHelper.ParseInt32(finalValue, out int x)) { logs.Add(new LogInfo(LogState.Error, $"[{finalValue}] is not a valid integer")); return(logs); } uiCmd.Rect.X = x; } break; case InterfaceElement.PosY: { if (!NumberHelper.ParseInt32(finalValue, out int y)) { logs.Add(new LogInfo(LogState.Error, $"[{finalValue}] is not a valid integer")); return(logs); } uiCmd.Rect.Y = y; } break; case InterfaceElement.Width: { if (!NumberHelper.ParseInt32(finalValue, out int width)) { logs.Add(new LogInfo(LogState.Error, $"[{finalValue}] is not a valid integer")); return(logs); } uiCmd.Rect.Width = width; } break; case InterfaceElement.Height: { if (!NumberHelper.ParseInt32(finalValue, out int height)) { logs.Add(new LogInfo(LogState.Error, $"[{finalValue}] is not a valid integer")); return(logs); } uiCmd.Rect.Height = height; } break; case InterfaceElement.Value: { bool success = uiCmd.SetValue(finalValue, false, out List <LogInfo> varLogs); logs.AddRange(varLogs); if (success == false && varLogs.Count == 0) { logs.Add(new LogInfo(LogState.Error, $"Writing [Value] to [{uiCmd.Type}] is not supported")); return(logs); } } break; default: throw new InternalException($"Internal Logic Error at WriteInterface"); } // Update uiCmd into file uiCmd.Update(); // Rerender Script Application.Current?.Dispatcher.Invoke(() => { // Application.Current is null in unit test MainWindow w = (Application.Current.MainWindow as MainWindow); if (w.CurMainTree.Script == cmd.Addr.Script) { w.DrawScript(cmd.Addr.Script); } }); return(logs); }
public static List <LogInfo> VisibleOp(EngineState s, CodeCommand cmd) { List <LogInfo> logs = new List <LogInfo>(8); Debug.Assert(cmd.Info.GetType() == typeof(CodeInfo_VisibleOp)); CodeInfo_VisibleOp infoOp = cmd.Info as CodeInfo_VisibleOp; Script p = cmd.Addr.Script; ScriptSection iface = p.GetInterface(out string ifaceSecName); if (iface == null) { logs.Add(new LogInfo(LogState.Error, $"Script [{cmd.Addr.Script.ShortPath}] does not have section [{ifaceSecName}]")); return(logs); } List <UIControl> uiCtrls = iface.GetUICtrls(true); List <Tuple <string, bool> > prepArgs = new List <Tuple <string, bool> >(); foreach (CodeInfo_Visible info in infoOp.InfoList) { string visibilityStr = StringEscaper.Preprocess(s, info.Visibility); bool visibility = false; if (visibilityStr.Equals("True", StringComparison.OrdinalIgnoreCase)) { visibility = true; } else if (visibilityStr.Equals("False", StringComparison.OrdinalIgnoreCase) == false) { throw new ExecuteException($"Invalid boolean value [{visibilityStr}]"); } prepArgs.Add(new Tuple <string, bool>(info.InterfaceKey, visibility)); } List <UIControl> uiCmdList = new List <UIControl>(); foreach (Tuple <string, bool> args in prepArgs) { UIControl uiCmd = uiCtrls.Find(x => x.Key.Equals(args.Item1, StringComparison.OrdinalIgnoreCase)); if (uiCmd == null) { logs.Add(new LogInfo(LogState.Error, $"Cannot find interface control [{args.Item1}] in section [{ifaceSecName}]")); continue; } uiCmd.Visibility = args.Item2; uiCmdList.Add(uiCmd); } UIControl.Update(uiCmdList); foreach (Tuple <string, bool> args in prepArgs) { logs.Add(new LogInfo(LogState.Success, $"Interface control [{args.Item1}]'s visibility set to [{args.Item2}]")); } // Re-render Script Application.Current.Dispatcher.Invoke(() => { MainWindow w = (Application.Current.MainWindow as MainWindow); if (w.CurMainTree.Script == cmd.Addr.Script) { w.DrawScript(cmd.Addr.Script); } }); return(logs); }