/// <summary> /// Creates a new panel which contains a script. /// </summary> /// <param name="panelTitle">The title of the panel associated to this view model.</param> /// <param name="scriptingLanguage">The language of the new script.</param> private IScriptPanelViewModel CreateNewScript(string panelTitle, ScriptingLaguageKindSupported scriptingLanguage) { IScriptPanelViewModel scriptPanelViewModel; switch (scriptingLanguage) { case ScriptingLaguageKindSupported.Python: scriptPanelViewModel = new PythonScriptPanelViewModel(panelTitle, this.scriptingProxy, this.OpenSessions); break; case ScriptingLaguageKindSupported.Lua: scriptPanelViewModel = new LuaScriptPanelViewModel(panelTitle, this.scriptingProxy, this.OpenSessions); break; case ScriptingLaguageKindSupported.Text: scriptPanelViewModel = new TextScriptPanelViewModel(panelTitle, this.scriptingProxy, this.OpenSessions); break; default: throw new NotSupportedException(string.Format("The {0} is not supported", scriptingLanguage)); } this.PanelNavigationService.OpenInDock(scriptPanelViewModel as IPanelViewModel); this.CollectionScriptPanelViewModels.Add(scriptPanelViewModel); return(scriptPanelViewModel); }
/// <summary> /// Calls the <see cref="CreateNewScript"/> method and pass as title agrument, the language used and the number of <see cref="IScriptPanelViewModel"/> open. /// </summary> /// <param name="panelTitle">The title of the panel associated to this view model.</param> /// <param name="scriptingLanguage">The language of the new script.</param> private void ExecuteCreateNewScript(string panelTitle, ScriptingLaguageKindSupported scriptingLanguage) { var panelCounter = this.CollectionScriptPanelViewModels.Count - 1; bool captionExists = true; while (captionExists) { panelCounter++; captionExists = this.CollectionScriptPanelViewModels.Any(x => x.Caption == panelTitle + panelCounter); } this.CreateNewScript(panelTitle + panelCounter, scriptingLanguage); }