internal static ToolObjectList GetToolObjectListFromToFile(Form form) { try { ToolObjectList toolObjectList = new ToolObjectList(); String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.toFile)); String[] separator = { Environment.NewLine }; String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries); foreach (String extensionString in splittedFileContent) { separator[0] = "|"; String[] splittedExtensionContent = extensionString.Split(separator, StringSplitOptions.None); ToolObject toolObject = new ToolObject(splittedExtensionContent[0], splittedExtensionContent[1], splittedExtensionContent[2], Convert.ToInt32(splittedExtensionContent[3])); toolObjectList.Add(toolObject); } return(toolObjectList); } catch (Exception) { WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("ErrorReading", className)); FileListManager.SaveFileList(ConstantUtil.toFile, String.Empty); return(GetToolObjectListFromToFile(form)); } }
internal static int AddTool(Tools form, ToolObjectList toolObjectList, int newToolIdentity) { TreeView toolTreeView = form.toolTreeView; TextBox descriptionTextBox = form.descriptionTextBox; TextBox commandLineTextBox = form.commandLineTextBox; TextBox workingFolderTextBox = form.workingFolderTextBox; ComboBox runComboBox = form.runComboBox; Button removeButton = form.removeButton; String newTool = LanguageUtil.GetCurrentLanguageString("New", className); newToolIdentity++; String description = String.Format("{0} ({1})", newTool, newToolIdentity); while (CheckIdentityExists(form, toolObjectList, description)) { newToolIdentity++; description = String.Format("{0} ({1})", newTool, newToolIdentity); } ToolObject toolObject = new ToolObject(description, String.Empty, String.Empty, 0); toolObjectList.Add(toolObject); toolTreeView.Focus(); toolTreeView.Nodes.Add(description); toolTreeView.SelectedNode = toolTreeView.Nodes[toolTreeView.Nodes.Count - 1]; descriptionTextBox.Enabled = true; commandLineTextBox.Enabled = true; workingFolderTextBox.Enabled = true; runComboBox.Enabled = true; removeButton.Enabled = true; return(newToolIdentity); }
internal static ToolObjectList LoadToolsList(Tools form) { TreeView toolTreeView = form.toolTreeView; TextBox descriptionTextBox = form.descriptionTextBox; TextBox commandLineTextBox = form.commandLineTextBox; TextBox workingFolderTextBox = form.workingFolderTextBox; ComboBox runComboBox = form.runComboBox; Button removeButton = form.removeButton; ToolObjectList toolObjectList = new ToolObjectList(); String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.toFile)); String[] separator = { Environment.NewLine }; String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (splittedFileContent.Length > 0) { toolTreeView.BeginUpdate(); } foreach (String toolString in splittedFileContent) { separator[0] = "|"; String[] splittedExtensionContent = toolString.Split(separator, StringSplitOptions.None); if (splittedExtensionContent.Length != 4) { WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("ErrorReading", className)); FileListManager.SaveFileList(ConstantUtil.toFile, String.Empty); return(LoadToolsList(form)); } toolTreeView.Nodes.Add(splittedExtensionContent[0]); //DtPad ToolObject toolObject = new ToolObject(splittedExtensionContent[0], splittedExtensionContent[1], splittedExtensionContent[2], Convert.ToInt32(splittedExtensionContent[3])); toolObjectList.Add(toolObject); } if (splittedFileContent.Length > 0) { toolTreeView.EndUpdate(); } toolTreeView.Focus(); if (toolTreeView.Nodes.Count > 0) { toolTreeView.SelectedNode = toolTreeView.Nodes[0]; } else { descriptionTextBox.Enabled = false; commandLineTextBox.Enabled = false; workingFolderTextBox.Enabled = false; runComboBox.Enabled = false; runComboBox.SelectedIndex = 0; removeButton.Enabled = false; } return(toolObjectList); }