private void RefreshTreeview() { treeView1.Nodes.Clear(); if (_scmFile == null) { return; } TreeNode parentTreeNode = treeView1.Nodes.Add(Path.GetFileName(_scmFile.FileName)); string[] allFiles = _scmFile.GetAllFiles(); foreach (string f in allFiles) { TreeNode treeNode = parentTreeNode.Nodes.Add(f); if (!SCMFile.IsSupportedFile(f)) { treeNode.ForeColor = Color.LightGray; } } treeView1.ExpandAll(); if (parentTreeNode.Nodes.Count > 0) { treeView1.SelectedNode = parentTreeNode.Nodes[0]; } else { CloseAll(); } }
private void CloseAll() { if (_scmFile != null) { _scmFile.Close(); _scmFile = null; } _currentFilename = ""; statusLabel.Text = ""; }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if ((treeView1.Nodes.Count <= 0) || (e.Node == treeView1.Nodes[0])) { return; } _currentFilename = e.Node.Text; try { Cursor.Current = Cursors.WaitCursor; // Reorder current map file if its loaded if (_mapFile != null) { ucSingleEdit1.SaveState(); } ucSingleEdit1.Clear(); _mapFile = null; _otherFile = null; if (SCMFile.IsSupportedFile(_currentFilename)) { if (SCMFile.IsChannelMapFile(_currentFilename)) { WriteStatus("Reading channels..."); if (OpenMapFile(_currentFilename)) { WriteChanels(); } } else { WriteStatus("Reading file..."); if (OpenOtherFile(_currentFilename)) { WriteOtherFile(); } } } else { WriteStatus("File not supported."); } } finally { Cursor.Current = Cursors.Default; } }
private void mnLoad_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog { Filter = SCM_FILTER + "|" + ALL_FILTER, FilterIndex = 0, Multiselect = false }; if (ofd.ShowDialog() != DialogResult.OK) { return; } CloseAll(); _currentFilename = ofd.FileName; ucSingleEdit1.Clear(); WriteStatus("Loading file..."); if (SCMFile.IsSCMFile(ofd.FileName)) { try { Cursor.Current = Cursors.WaitCursor; _scmFile = new SCMFile(ofd.FileName); RefreshTreeview(); WriteStatus(ofd.FileName); } catch (Exception ex) { Cursor.Current = Cursors.Default; ShowError(ex, "Open file"); CloseAll(); } finally { Cursor.Current = Cursors.Default; } } else { ShowInfo("Incorrect File extension : " + _currentFilename, "Open file"); } }
private void mnLoad_Click(object sender, EventArgs e) { var ofd = new OpenFileDialog { Filter = SCM_FILTER + "|" + ALL_FILTER, FilterIndex = 0, Multiselect = false }; if (ofd.ShowDialog() != DialogResult.OK) return; CloseAll(); _currentFilename = ofd.FileName; ucSingleEdit1.Clear(); WriteStatus("Loading file..."); if (SCMFile.IsSCMFile(ofd.FileName)) { try { Cursor.Current = Cursors.WaitCursor; _scmFile = new SCMFile(ofd.FileName); RefreshTreeview(); WriteStatus(ofd.FileName); } catch (Exception ex) { Cursor.Current = Cursors.Default; ShowError(ex, "Open file"); CloseAll(); } finally { Cursor.Current = Cursors.Default; } } else ShowInfo("Incorrect File extension : " + _currentFilename, "Open file"); }