/// <summary> /// 添加一个脚本 /// </summary> /// <param name="script"></param> public StackingMainLayout AddScript() { IScriptLayout script = new IScriptLayout(); script.ScriptName = GetScriptName(); StackingMainLayout stackingMainLayout = StackingMainLayout.InstanceStackingMainLayout(script); Scripts.Add(stackingMainLayout); ItemAddEvent?.Invoke(stackingMainLayout); return(stackingMainLayout); }
/// <summary> /// 加载脚本 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Load_Click(object sender, RoutedEventArgs e) { System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog(); openFileDialog.Filter = "脚本项目文件 (*.sProject)|*.sProject"; if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ScriptConfig = JsonConvert.DeserializeObject <ScriptConfig>(openFileDialog.FileName.GetStringFromFile()); string path = System.IO.Path.GetDirectoryName(openFileDialog.FileName); foreach (var item in ScriptConfig.ScriptFiles) { IScriptLayout scriptLayout = new IScriptLayout(); scriptLayout.LoadFromJson(System.IO.Path.Combine(path, item + ".script")); scriptContent.ScriptControl.AddScript(StackingMainLayout.InstanceStackingMainLayout(scriptLayout)); } } }