private void Editor_ChangeImportLibrary(object sender, EventArgs e) { foreach (var l in libs) { var used = false; Script script = Editor.Script as Script; foreach (var s in script.Imports) { if (l.Library.Name.Equals(s)) { used = true; } } l.IsImported = used; } LibraryWindow libWnd = new LibraryWindow(libs); libWnd.Owner = this; var ret = libWnd.ShowDialog(); if (ret.HasValue && ret.Value) { Script script = Editor.Script as Script; script.Imports.Clear(); List <ScriptStepGroup> toolbar = Editor.GetToolBar(); foreach (var l in libs) { bool imprted = false; ScriptStepGroup lbar = null; foreach (var g in toolbar) { if (g.Name.Equals(l.Library.Title)) { imprted = true; lbar = g; } } if (l.IsImported) { script.Imports.Add(l.Library.Name); if (!imprted) { toolbar.Add(GetCommandsFromLib(l.Library)); } } else { if (imprted) { toolbar.Remove(lbar); } } } Editor.SetToolBar(toolbar); } }
ScriptStepGroup GetCommandsFromLib(Library l) { ScriptStepGroup g = new ScriptStepGroup(); g.Types = new List <object>(); g.Name = l.Title; foreach (var gp in l) { g.Types.Add(new Label() { Content = gp.Name, ToolTip = gp.Description }); foreach (var s in gp) { g.Types.Add(new ScriptStep(s.Step, s.IsColorEditable, s.Description)); } } return(g); }