// ----------------------------------- // Refresh the UI // ----------------------------------- public override void OnRefresh() { TabControl.TabPages.Clear(); // Fill the property grid. XmlNode UINode = XmlHelper.Find(Data, "ui"); if ((UINode != null) && UINode.HasChildNodes) { TabControl.TabPages.Add(PropertiesTabPage); GenericUI.OnLoad(Controller, NodePath, UINode.OuterXml); GenericUI.OnRefresh(); } // Create tabs for each script tag. foreach (XmlNode Script in XmlHelper.ChildNodes(Data, "script")) { string TabName = ""; foreach (XmlNode EventData in XmlHelper.ChildNodes(Script, "event")) { if (!string.IsNullOrEmpty(TabName)) { TabName = TabName + ","; } TabName = TabName + EventData.InnerText; } string Value = XmlHelper.Value(Script, "text"); AddScriptTab(TabName, Value); } }
private void OnPropertiesMenuItemClick(System.Object sender, System.EventArgs e) { if (TabControl.TabPages.Count == 1) { TabControl.TabPages.Insert(0, Properties); // Fill the property grid. string UIXml = "<ui/>"; XmlNode UINode = XmlHelper.Find(Data, "ui"); if ((UINode != null)) { UIXml = UINode.OuterXml; } GenericUI.OnLoad(Controller, NodePath, UIXml); GenericUI.OnRefresh(); PropertiesMenuItem.Checked = TabControl.TabPages.Count == 2; TabControl.SelectedIndex = 0; } else { // Save the current contents of the grid GenericUI.OnSave(); string Contents = GenericUI.GetData(); if (!string.IsNullOrEmpty(Contents) && PropertiesMenuItem.Checked) { XmlDocument Doc = new XmlDocument(); Doc.LoadXml(Contents); XmlNode UINode = XmlHelper.Find(Data, "ui"); UINode.InnerXml = Doc.FirstChild.InnerXml; } TabControl.TabPages.Remove(Properties); } PropertiesMenuItem.Checked = TabControl.TabPages.Count == 2; }
private void LoadCustom() { XmlNode UINode = XmlHelper.Find(Data, "CustomUI"); if (UINode != null) { GenericUI.OnLoad(Controller, NodePath, UINode.OuterXml); GenericUI.OnRefresh(); } }
// ----------------------------------- // Refresh the UI // ----------------------------------- public override void OnRefresh() { // Fill the property grid. XmlNode UINode = XmlHelper.Find(Data, "ui"); string UIXml = "<ui/>"; if ((UINode == null) || UINode.InnerXml == "") { TabControl.TabPages.Remove(Properties); } else { if (TabControl.TabPages.Count == 1) { TabControl.TabPages.Insert(0, Properties); } UIXml = UINode.OuterXml; } GenericUI.OnLoad(Controller, NodePath, UIXml); GenericUI.OnRefresh(); PropertiesMenuItem.Checked = TabControl.TabPages.Count == 2; string scriptText = XmlHelper.Value(Data, "text"); if (scriptText.Contains("Imports ")) { TextBox.Lexer = VbParser; } else { TextBox.Lexer = CsParser; } TextBox.Text = scriptText; Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), "CSDotNetComponentInterface.dll")); Assembly.LoadFile(Types.GetProbeInfoDLLFileName()); foreach (string @ref in XmlHelper.ValuesRecursive(Data, "reference")) { if (File.Exists(@ref)) { Assembly.LoadFile(@ref); } else if (File.Exists(RuntimeEnvironment.GetRuntimeDirectory() + @ref)) { Assembly.LoadFile(RuntimeEnvironment.GetRuntimeDirectory() + @ref); } else if (File.Exists(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @ref))) { Assembly.LoadFile(Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @ref)); } else { MessageBox.Show("Error loading reference '" + @ref + "' - file does not exist" + Environment.NewLine + "Tried:" + Environment.NewLine + @ref + Environment.NewLine + RuntimeEnvironment.GetRuntimeDirectory() + @ref + Environment.NewLine + Path.Combine(Path.GetDirectoryName(Application.ExecutablePath), @ref)); } } CsParser.RegisterAllAssemblies(); VbParser.RegisterAllAssemblies(); int[] TabStops = { 3 }; TextBox.Lines.TabStops = TabStops; TextBox.Lines.UseSpaces = true; // restore the scrolling and cursor position for the textbox CursorPos pos; if (positions.TryGetValue(this.NodePath, out pos)) { TextBox.MoveToLine(pos.TopLine, 0); // ensure that the cursor is only set if it was in view if (pos.TopLine < TextBox.Source.GetPositionFromCharIndex(pos.CharIndex).Y) { TextBox.Selection.SelectionStart = pos.CharIndex; } TextBox.Selection.SelectionLength = 0; } TextBox.Focus(); // this doesn't really work because the system tinkers with a few other controls // after this procedure and then the textbox loses focus anyway. It would // be good to find a solution for this. }