private static void ManageError(Form1 form, Exception exception) { WindowManager.ShowErrorBox(form, LanguageUtil.GetCurrentLanguageString("ErrorCreating", className), exception); form.TabIdentity = FileManager.OpenFile(form, form.TabIdentity, new[] { ConstantUtil.noFile }); FileListManager.SaveFileList(ConstantUtil.noFile, ConstantUtil.defaultNoteFileContent); }
private static String GetContent(int number) { try { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.clFile)); XmlNodeList clipList = xmldoc.GetElementsByTagName("clip"); foreach (XmlNode clip in clipList) { if (clip.ChildNodes[0].InnerText == number.ToString()) { return(clip.ChildNodes[2].InnerText); } } } catch (XmlException exception) { WindowManager.ShowErrorBox(null, LanguageUtil.GetCurrentLanguageString("ErrorReading", className), exception); FileListManager.SaveFileList(ConstantUtil.clFile, ConstantUtil.defaultClipboardFileContent); } return(String.Empty); }
internal static void GetClipboardList(Form1 form, bool forceLoad) { ListBox clipboardListBox = form.clipboardPanel.clipboardListBox; XtraTabControl verticalTabControl = form.verticalTabControl; XtraTabPage clipboardTabPage = form.clipboardTabPage; if ((verticalTabControl.SelectedTabPage != clipboardTabPage) || (!forceLoad && clipboardListBox.Items.Count > 0)) { return; } ClearClipboardList(form); try { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.clFile)); XmlNodeList clipList = xmldoc.GetElementsByTagName("clip"); foreach (XmlNode clip in clipList) { clipboardListBox.Items.Add(clip.ChildNodes[1].InnerText); //short } } catch (XmlException exception) { WindowManager.ShowErrorBox(form, LanguageUtil.GetCurrentLanguageString("ErrorReading", className), exception); FileListManager.SaveFileList(ConstantUtil.clFile, ConstantUtil.defaultClipboardFileContent); } }
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)); } }
private static bool IsContentAlreadyClipboarded(Form form, String newContent) { try { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.clFile)); XmlNodeList contentList = xmldoc.GetElementsByTagName("content"); //foreach (XmlNode content in contentList) //{ // if (content.InnerText == newContent) // { // return true; // } //} if (contentList.Cast <XmlNode>().Any(content => content.InnerText == newContent)) { return(true); } } catch (XmlException exception) { WindowManager.ShowErrorBox(form, LanguageUtil.GetCurrentLanguageString("ErrorReading", className), exception); FileListManager.SaveFileList(ConstantUtil.clFile, ConstantUtil.defaultClipboardFileContent); } return(false); }
internal static TemplateObjectList LoadTemplatesList(Templates form) { TreeView templateTreeView = form.templateTreeView; TextBox descriptionTextBox = form.descriptionTextBox; TextBox textTextBox = form.textTextBox; Button removeButton = form.removeButton; TemplateObjectList templateObjectList = new TemplateObjectList(); String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.tmFile)); String[] separator = { Environment.NewLine }; String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (splittedFileContent.Length > 0) { templateTreeView.BeginUpdate(); } foreach (String templateString in splittedFileContent) //HTML@|-<html></html> { separator[0] = "@|-"; String[] splittedExtensionContent = templateString.Split(separator, StringSplitOptions.None); if (splittedExtensionContent.Length != 2) { WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("ErrorReading", className)); FileListManager.SaveFileList(ConstantUtil.tmFile, String.Empty); return(LoadTemplatesList(form)); } templateTreeView.Nodes.Add(splittedExtensionContent[0]); //HTML TemplateObject templateObject = new TemplateObject(splittedExtensionContent[0], splittedExtensionContent[1]); templateObjectList.Add(templateObject); } if (splittedFileContent.Length > 0) { templateTreeView.EndUpdate(); } templateTreeView.Focus(); if (templateTreeView.Nodes.Count > 0) { templateTreeView.SelectedNode = templateTreeView.Nodes[0]; } else { descriptionTextBox.Enabled = false; textTextBox.Enabled = false; removeButton.Enabled = false; } return(templateObjectList); }
private static ExtensionObjectList LoadExtensionsListPrivate(Extensions form, bool suppressMessageBox) { TreeView extensionTreeView = form.extensionTreeView; ExtensionObjectList extensionObjectList = new ExtensionObjectList(); String fileContent = FileUtil.ReadToEndWithStandardEncoding(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.exFile)); String[] separator = { Environment.NewLine }; String[] splittedFileContent = fileContent.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (splittedFileContent.Length > 0) { extensionTreeView.BeginUpdate(); } foreach (String extensionString in splittedFileContent) { separator[0] = "|"; String[] splittedExtensionContent = extensionString.Split(separator, StringSplitOptions.RemoveEmptyEntries); if (splittedExtensionContent.Length != 3) { if (!suppressMessageBox) { WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("Reading", className)); } FileListManager.SaveFileList(ConstantUtil.exFile, ConstantUtil.defaultExtensionFileContent); return(LoadExtensionsList(form)); } extensionTreeView.Nodes.Add(splittedExtensionContent[0]); //Text document ExtensionObject extensionObject = new ExtensionObject(splittedExtensionContent[0], splittedExtensionContent[1], Convert.ToBoolean(splittedExtensionContent[2])); extensionObjectList.Add(extensionObject); } if (splittedFileContent.Length > 0) { extensionTreeView.EndUpdate(); } extensionTreeView.Focus(); extensionTreeView.SelectedNode = extensionTreeView.Nodes[0]; return(extensionObjectList); }
internal static bool SaveToolsIntoFile(Form form, ToolObjectList toolObjectList) { String fileContent = String.Empty; foreach (ToolObject toolObject in toolObjectList) { if (String.IsNullOrEmpty(toolObject.CommandLine)) { WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("Unvalorized", className)); return(false); } fileContent += String.Format("{0}|{1}|{2}|{3}{4}", toolObject.Description, toolObject.CommandLine, toolObject.WorkingFolder, toolObject.Run, Environment.NewLine); } FileListManager.SaveFileList(ConstantUtil.toFile, fileContent); return(true); }
internal static bool SaveTemplatesIntoFile(Form form, TemplateObjectList templateObjectList) { String fileContent = String.Empty; foreach (TemplateObject templateObject in templateObjectList) { if (String.IsNullOrEmpty(templateObject.Text)) { WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("Unvalorized", className)); return(false); } fileContent += String.Format("{0}@|-{1}{2}", templateObject.Description, templateObject.Text, Environment.NewLine); } FileListManager.SaveFileList(ConstantUtil.tmFile, fileContent); return(true); }
private static bool SaveExtensionsIntoFilePrivate(Form form, ExtensionObjectList extensionObjectList, bool suppressMessageBox) { String fileContent = String.Empty; foreach (ExtensionObject extensionObject in extensionObjectList) { if (String.IsNullOrEmpty(extensionObject.Extension) || String.IsNullOrEmpty(extensionObject.Description)) { if (!suppressMessageBox) { WindowManager.ShowAlertBox(form, LanguageUtil.GetCurrentLanguageString("Unvalorized", className)); } return(false); } fileContent += String.Format("{0}|{1}|{2}{3}", extensionObject.Description, extensionObject.Extension, extensionObject.DefaultExtension, Environment.NewLine); } FileListManager.SaveFileList(ConstantUtil.exFile, fileContent); return(true); }
internal static void AddContent(Form1 form) { ListBox clipboardListBox = form.clipboardPanel.clipboardListBox; String content; try { if (!Clipboard.ContainsText()) { return; } content = Clipboard.GetText(); } catch (ExternalException exception) { WindowManager.ShowErrorBox(form, exception.Message, exception); return; } String shortContent = content.Replace(ConstantUtil.newLine, " "); shortContent = shortContent.Replace(Environment.NewLine, " "); shortContent = StringUtil.CheckStringLengthEnd(shortContent, maxCharCount); //shortContent.Replace("<", "<"); //shortContent.Replace(">", ">"); if (IsContentAlreadyClipboarded(form, content)) { return; } try { XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.clFile)); XmlElement newClip = xmldoc.CreateElement("clip"); XmlElement numberNode = xmldoc.CreateElement("number"); numberNode.InnerText = clipboardListBox.Items.Count.ToString(); newClip.AppendChild(numberNode); XmlElement shortNode = xmldoc.CreateElement("short"); XmlCDataSection shortNodeCData = xmldoc.CreateCDataSection(shortContent); shortNode.InnerText = String.Empty; shortNode.AppendChild(shortNodeCData); XmlElement contentNode = xmldoc.CreateElement("content"); XmlText contentNodeCData = xmldoc.CreateTextNode(content); //XmlCDataSection contentNodeCData = xmldoc.CreateCDataSection(content); contentNode.InnerText = String.Empty; contentNode.AppendChild(contentNodeCData); newClip.AppendChild(shortNode); newClip.AppendChild(contentNode); if (xmldoc.DocumentElement != null) { xmldoc.DocumentElement.InsertAfter(newClip, xmldoc.DocumentElement.LastChild); xmldoc.Save(Path.Combine(ConstantUtil.ApplicationExecutionPath(), ConstantUtil.clFile)); clipboardListBox.Items.Add(shortContent); } else { throw new XmlException(); } } catch (XmlException exception) { WindowManager.ShowErrorBox(form, LanguageUtil.GetCurrentLanguageString("ErrorCreation", className), exception); FileListManager.SaveFileList(ConstantUtil.clFile, ConstantUtil.defaultClipboardFileContent); } }
internal static void ClearClipboardFile(Form1 form) { ClearClipboardList(form); FileListManager.SaveFileList(ConstantUtil.clFile, ConstantUtil.defaultClipboardFileContent); }
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); }
private static String WriteSessionXML(Form1 form, String fileName) { XtraTabControl pagesTabControl = form.pagesTabControl; ToolStripDropDownButton sessionImageToolStripButton = form.sessionImageToolStripButton; ToolStripMenuItem useDefaultToolStripMenuItem = form.useDefaultToolStripMenuItem; ToolStripMenuItem closeButtonToolStripMenuItem = form.closeButtonToolStripMenuItem; ToolStripMenuItem tabPositionToolStripMenuItem = form.tabPositionToolStripMenuItem; ToolStripMenuItem tabOrientationToolStripMenuItem = form.tabOrientationToolStripMenuItem; sessionImageToolStripButton.DropDownItems.Clear(); String newSessionName = Path.GetFileNameWithoutExtension(fileName); FileListManager.SaveFileList(fileName, ConstantUtil.defaultSessionFileContent); XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(fileName); if (xmldoc.DocumentElement == null) { throw new XmlException(String.Format(LanguageUtil.GetCurrentLanguageString("XmlDocError", className), Path.GetFileName(fileName))); } xmldoc.DocumentElement.SetAttribute("name", newSessionName); xmldoc.DocumentElement.SetAttribute("aspect", useDefaultToolStripMenuItem.Checked ? "default" : "custom"); xmldoc.DocumentElement.SetAttribute("button", GetDropDownIndexChecked(closeButtonToolStripMenuItem).ToString()); xmldoc.DocumentElement.SetAttribute("position", GetDropDownIndexChecked(tabPositionToolStripMenuItem).ToString()); xmldoc.DocumentElement.SetAttribute("orientation", GetDropDownIndexChecked(tabOrientationToolStripMenuItem).ToString()); sessionImageToolStripButton.DropDownItems.Add(fileName); sessionImageToolStripButton.DropDownItems[0].Image = ToolbarResource.diagram; sessionImageToolStripButton.DropDownItems[0].Click += form.sessionPropertiesToolStripMenuItem_Click; sessionImageToolStripButton.DropDownItems.Add(new ToolStripSeparator()); foreach (XtraTabPage tabControl in pagesTabControl.TabPages) { String fileNameTab = ProgramUtil.GetFilenameTabPage(tabControl); if (String.IsNullOrEmpty(ProgramUtil.GetPageTextBox(tabControl).Text) && String.IsNullOrEmpty(fileNameTab)) { continue; } XmlElement newFile = xmldoc.CreateElement("file"); String relativePath = FileUtil.EvaluateRelativePath(Path.GetDirectoryName(fileName), Path.GetDirectoryName(fileNameTab)); newFile.SetAttribute("path", relativePath); newFile.SetAttribute("name", Path.GetFileName(fileNameTab)); newFile.SetAttribute("tabcolor", TabManager.GetTabColor(tabControl).ToKnownColor().ToString()); //newFile.SetAttribute("tabcolor", tabControl.Appearance.Header.ForeColor.ToKnownColor().ToString()); if (pagesTabControl.SelectedTabPage == tabControl) { newFile.SetAttribute("open", true.ToString()); } if (xmldoc.DocumentElement == null) { throw new XmlException(String.Format(LanguageUtil.GetCurrentLanguageString("XmlDocError", className), Path.GetFileName(fileName))); } xmldoc.DocumentElement.AppendChild(newFile); sessionImageToolStripButton.DropDownItems.Add(fileNameTab); sessionImageToolStripButton.DropDownItems[sessionImageToolStripButton.DropDownItems.Count - 1].Click += form.sessionImageToolStripButton_Click; } xmldoc.Save(fileName); //WindowManager.ShowInfoBox(form, String.Format(LanguageUtil.GetCurrentLanguageString("SaveSuccesfull", className), newSessionName)); return(newSessionName); }