public TreeView(BinaryTree tree) { this.tree = tree; // // The InitializeComponent() call is required for Windows Forms designer support. // InitializeComponent(); // // TODO: Add constructor code after the InitializeComponent() call. // //Walk(this.tree.Root,1,1); //Left = 5; //Top = 10; //Width = 200; }
public MainForm() { /* Node n1 = null, n2 = null, n3 = null, n4 = null, n5 = null, n6 = null, n7 = null; n1 = new Node(null, null, n5, "GGG"); n2 = new Node(null, null, n5, "FFF"); n3 = new Node(null, null, n6, "EEE"); n4 = new Node(null, null, n6, "DDD"); n5 = new Node(n1, n2, n7, "CCC"); n6 = new Node(n3, n4, n7, "BBB"); n7 = new Node(n5,n6,null,"AAA"); n1.Parent = n5; n2.Parent = n5; n3.Parent = n6; n4.Parent = n6; n5.Parent = n7; n6.Parent = n7; bt = new BinaryTree(n7); label1.DataBindings.Add(new Binding("Text", bt, "Status")); //label1.DataBindings. */ #if DEBUG bt = null; #endif bt = SaveLoad.Load(); InitializeComponent(); }
private void загрузитьToolStripMenuItem_Click(object sender, EventArgs e) { bt = SaveLoad.Load(); treeView1.Redraw(); }
public static BinaryTree Load() { BinaryTree bt = null; try { StreamReader sr = new StreamReader("data"); string all = sr.ReadToEnd(); Console.WriteLine(all); Node r = Parse( ref all); bt = new BinaryTree(r); Console.WriteLine("Tree Info:"); string s = ""; bt.Info(bt.Root,ref s); Console.WriteLine(s); } catch (Exception ex) { Console.WriteLine("Загрузка из файла не получилась, создаем дерево вручную из заготовки"); Console.WriteLine(ex.Message); Console.WriteLine(ex.Source); Console.WriteLine(ex.StackTrace); #region Стандартное дерево Node n1 = null, n2 = null, n3 = null, n4 = null, n5 = null, n6 = null, n7 = null; n1 = new Node(null, null, n5, "GGG"); n2 = new Node(null, null, n5, "FFF"); n3 = new Node(null, null, n6, "EEE"); n4 = new Node(null, null, n6, "DDD"); n5 = new Node(n1, n2, n7, "CCC"); n6 = new Node(n3, n4, n7, "BBB"); n7 = new Node(n6, n5, null, "AAA"); n1.Parent = n5; n2.Parent = n5; n3.Parent = n6; n4.Parent = n6; n5.Parent = n7; n6.Parent = n7; bt = new BinaryTree(n7); #endregion } return bt; }
public static void Save(BinaryTree tree) { string s = ""; Walk(tree.Root,ref s); //Console.WriteLine StreamWriter sw = new StreamWriter("data",false); try { sw.Write(s); sw.Close(); } catch (Exception e) { Console.WriteLine("Что-то пошло не так, а именно:"); Console.WriteLine(e.Message); } }