private void tbSave_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show(this, "Sort all nodes before saving?", "Alert!", MessageBoxButtons.YesNoCancel); if (dr == DialogResult.Yes) { treeView1.TreeViewNodeSorter = new NodeSorter(); this.treeView1.Sort(); } string saveFile = this.staFileName.Text; if (saveFile == "") { this.saveFileDialog1.FileName = ""; this.saveFileDialog1.Title = "Save tree structure to ..."; this.saveFileDialog1.Filter = "Packge Info(*.pkg)|*.pkg"; if (this.saveFileDialog1.ShowDialog() == DialogResult.OK) { saveFile = this.saveFileDialog1.FileName; } else { return; } } TreeCls.SaveTree(this.treeView1, saveFile); this.staStatus.Text = "Saved!"; this.staFileName.Text = saveFile; }
bool loadTreefromPkgFile(string fle, bool warning) { if (File.Exists(fle)) { if (fle.ToLower().EndsWith(".pkg")) { DialogResult dr; if (warning == true) { dr = MessageBox.Show(this, "Load tree structure from " + fle, "Loading", MessageBoxButtons.YesNoCancel); } else { dr = DialogResult.Yes; } if (dr == DialogResult.Yes) { this.treeView1.Nodes.Clear(); TreeCls.LoadTree(this.treeView1, fle); browseAllNodes(this.treeView1.Nodes[0]); this.treeView1.Nodes[0].Expand(); this.staFileName.Text = fle; this.staStatus.Text = "Loaded"; return(true); } return(false); } return(false); } return(false); }