public void AddWindow(string name, string filter) { if (!tabEditor.Visible) { tabEditor.Visible = true; } TabPage tab = FindPage(filter, name); if (tab != null) { tabEditor.SelectTab(tab); return; } RichQCEditor textBox = new RichQCEditor(); string pathToFile = ProjectUtils.GetFilePathForTreeNodeItem(filter, name); if (!string.IsNullOrEmpty(pathToFile)) { textBox.Text = File.ReadAllText(pathToFile); } tab = new TabPage(name); tab.Name = filter; textBox.Parent = tab; textBox.Dock = DockStyle.Fill; tabEditor.TabPages.Add(tab); tabEditor.SelectTab(tab); }
private void RemoveFile(TreeNode node, bool bDelete = false) { if (node == null) { return; } TreeNode parent = node.Parent; if (parent == null || (node.Nodes.Count > 0)) { return; } string path = ProjectUtils.GetFilePathForTreeNodeItem(node.Parent.Text, node.Text); if (ProjectUtils.RemoveFile(node.Text, node.Parent.Text)) { WindowHandler.DeregisterWindow(node.Text, node.Parent.Text); parent.Nodes.Remove(node); if (bDelete && File.Exists(path)) { try { File.Delete(path); } catch { LoggingUtils.LogEvent(string.Format("Unable to delete file {0}!", path)); } } } }
private void OnMenuStripClickOnOpenHLMV(object sender, EventArgs e) { TabPage tab = GetCurrentTabPage(); if (tab != null) { string pathToFile = ProjectUtils.GetFilePathForTreeNodeItem(tab.Name, tab.Text); Globals.OpenModelInHLMV(pathToFile); } }
private void OnMenuStripClickBuild(object sender, EventArgs e) { TabPage tab = GetCurrentTabPage(); if (tab != null) { string pathToFile = ProjectUtils.GetFilePathForTreeNodeItem(tab.Name, tab.Text); if (!string.IsNullOrEmpty(pathToFile)) { CompilerUtils.AddToQueue(pathToFile); } } }
private void SaveFile(TabPage tab) { RichQCEditor richText = GetTextBoxFromTab(tab); if (richText == null) { return; } string pathToFile = ProjectUtils.GetFilePathForTreeNodeItem(tab.Name, tab.Text); if (!string.IsNullOrEmpty(pathToFile)) { File.WriteAllText(pathToFile, richText.Text); } }
private void MenuStripFileOnOpenHLMV(object sender, EventArgs e) { TreeNode node = projectTreeView.GetNodeAt(projectTreeView.PointToClient(fileMenuStrip.Bounds.Location)); if (node == null) { return; } if (node.Parent == null || (node.Nodes.Count > 0)) { return; } string path = ProjectUtils.GetFilePathForTreeNodeItem(node.Parent.Text, node.Text); Globals.OpenModelInHLMV(path); }
private void projectTreeView_DoubleClick(object sender, EventArgs e) { TreeNode selectedNode = projectTreeView.SelectedNode; if ((selectedNode == null)) { return; } if (selectedNode.Parent == null || (selectedNode.Nodes.Count > 0)) { return; } string path = ProjectUtils.GetFilePathForTreeNodeItem(projectTreeView.SelectedNode.Parent.Text, projectTreeView.SelectedNode.Text); if (!string.IsNullOrEmpty(path) && File.Exists(path)) { WindowHandler.RegisterWindow(projectTreeView.SelectedNode.Text, projectTreeView.SelectedNode.Parent.Text); } }
private void MenuStripFileOnOpen(object sender, EventArgs e) { TreeNode node = projectTreeView.GetNodeAt(projectTreeView.PointToClient(fileMenuStrip.Bounds.Location)); if (node == null) { return; } if (node.Parent == null || (node.Nodes.Count > 0)) { return; } string path = ProjectUtils.GetFilePathForTreeNodeItem(node.Parent.Text, node.Text); if (!string.IsNullOrEmpty(path) && File.Exists(path)) { WindowHandler.RegisterWindow(node.Text, node.Parent.Text); } }
public void BuildActiveFile() { if (!tabEditor.Visible) { return; } TabPage tab = tabEditor.SelectedTab; if (tab == null) { return; } string pathToFile = ProjectUtils.GetFilePathForTreeNodeItem(tab.Name, tab.Text); if (!string.IsNullOrEmpty(pathToFile)) { CompilerUtils.AddToQueue(pathToFile); } }
private void btnAddFile_Click(object sender, EventArgs e) { string fileName = textBoxName.Text; string path = fileName; if (File.Exists(fileName)) { path = string.Format("{0}\\{1}", _filter.GetFilterDirectory(), Path.GetFileName(fileName)); QCParser importedQC = new QCParser(fileName); if (!importedQC.ImportDependenciesToPath(string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), Path.GetDirectoryName(path)))) { try { File.Copy(fileName, string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), path), true); } catch { LoggingUtils.LogEvent("Failed to import a file!"); } } } else { if (!Globals.IsStringValid(fileName)) { return; } path = string.Format("{0}\\{1}", _filter.GetFilterDirectory(), fileName); } if (!fileName.EndsWith(".qc", StringComparison.InvariantCultureIgnoreCase) && !fileName.EndsWith(".qci", StringComparison.InvariantCultureIgnoreCase)) { InfoDialog.ShowDialog(this, "Invalid file extension!", "Error!"); return; } string hasFile = ProjectUtils.GetFilePathForTreeNodeItem(_filter.GetName(), Path.GetFileName(path)); if (!string.IsNullOrEmpty(hasFile)) { InfoDialog.ShowDialog(this, "This file already exists in the choosen filter!", "Error!"); return; } string fullPath = string.Format("{0}\\{1}", ProjectUtils.GetProjectDirectory(), path); if (!File.Exists(fullPath)) { Directory.CreateDirectory(Path.GetDirectoryName(fullPath)); File.WriteAllText(fullPath, ""); } _filter.AddFile("local", path); TreeNode newNode = new TreeNode(Path.GetFileName(path)); newNode.ContextMenuStrip = _fileStrip; newNode.ImageIndex = newNode.SelectedImageIndex = newNode.StateImageIndex = 0; _node.Nodes.Add(newNode); _node.ExpandAll(); Close(); }