public static OutputViewController Create(string name, ScriptStore store, ScriptRunner runner) { UIStoryboard mainStoryboard = UIStoryboard.FromName("Main", null); OutputViewController outputViewController = (OutputViewController)mainStoryboard.InstantiateViewController("OutputViewController"); outputViewController.scriptName = name; outputViewController.store = store; outputViewController.runner = runner; return(outputViewController); }
void OnAddNewFile(EditScriptViewController editScriptViewController, string name) { name = ScriptStore.FixName(name); if (!dataSource.Exists(name)) { WriteNewFileAndReloadList(name); editScriptViewController.Dismiss(); PerformSegue("showDetail", this); return; } ConfirmFileReplace(editScriptViewController, name, Replace_AddNew_Dismissed); }
void OnRenameScript(EditScriptViewController editViewController, string oldName, string newName) { newName = ScriptStore.FixName(newName); // No-op if (oldName == newName) { editViewController.Dismiss(); return; } string existingFile = scripts.FirstOrDefault(s => s.Equals(newName, StringComparison.OrdinalIgnoreCase)); existingFile = existingFile ?? newName; if (oldName.Equals(newName, StringComparison.OrdinalIgnoreCase) || !Exists(newName)) { Store.RenameFile(oldName, newName, existingFile); editViewController.Dismiss(); Reload(); controller.TableView.ReloadData(); if (controller.ScriptViewController?.ScriptName == oldName) { controller.ScriptViewController.SetScript(newName); } return; } controller.ConfirmFileReplace(editViewController, newName, (edit, n) => { Store.RenameFile(oldName, newName, existingFile); edit.Dismiss(); Reload(); controller.TableView.ReloadData(); if (controller.ScriptViewController?.ScriptName == oldName) { controller.ScriptViewController.SetScript(newName); } }); }
public ScriptsDataSource(ScriptListViewController controller) { this.controller = controller; Store = new ScriptStore(LocalPathPrepare.ScriptsPath); }