public CCSTestInterface() { InitializeComponent(); run_bt.Enabled = false; clear_bt.Enabled = false; baseline = new SearchList[5]; demoList = new DemoGuiList(); //--List Default-- SearchList sl = new SearchList("CiscoIOS-Default"); // Main Command List SearchListData sldf0 = sl.AddKeyList("interface"); SearchListData sldf1 = sl.AddKeyList("username cisco privilege 15"); SearchListData sldf2 = sl.AddKeyList("line"); //Value Check Command SearchListData value1 = sl.AddChildValueKey("*", sldf0); SearchListData value2 = sl.AddChildValueKey("FastEthernet*", sldf0); SearchListData value3 = sl.AddChildValueKey("GigabitEthernet*", sldf0); SearchListData value4 = sl.AddChildValueKey("*", sldf1); SearchListData value5 = sl.AddChildValueKey("*", sldf2); // Child Command // -- Child Interface any except Fastethernet and GigabitEthernet sl.AddChildData("no ip proxy-arp", null, "interface", "system", "Interface-Disable proxy arp", value1); // -- Child Interface Fastethernet sl.AddChildData("no ip proxy-arp", null, "interface", "system", "Interface-Disable proxy arp", value2); sl.AddChildData("no ip redirects", null, "interface", "system", "Interface-Redirection", value2); // -- Child Interface GigabitEthernet sl.AddChildData("no ip proxy-arp", null, "interface", "system", "Interface-Disable proxy arp", value3); sl.AddChildData("no ip redirects", null, "interface", "system", "Interface-Redirection", value3); sl.AddChildData("no ip unreachables", null, "interface", "system", "Interface-IP Unreachables Enabled", value3); // -- Child username cisco privilege 15 //NULL // -- Child Line sl.AddChildData("password", null, "line", "system", "Line - Password Login", value5); baseline[0] = sl; //init list in combobox for (int i = 0; i < baseline.Length; i++) { if (baseline[i] != null) { ComboBoxItem comItem = new ComboBoxItem(baseline[i].listName, i); baseline_cb.Items.Add(comItem); } } //always select index 0 baseline_cb.SelectedIndex = 0; //load default BaseLine to screen AddListToScreen(baseline[0],demoList); //resultBox.Text = "fastEthernet0/0/1\r\n"; //resultBox.AppendText("line 2 \r\n"); }
private void AddListToScreen(SearchList sl,DemoGuiList demoList) { //int cPosX = 49; int cPosY = 40; SearchListData tmpLoop = sl.head; while (tmpLoop != null) { SearchListData vaLoop = tmpLoop.child; //Add demoList (dynamic change) DemoGuiListData dMainList = demoList.AddList(tmpLoop, null, null); while (vaLoop != null) { //create pic status PictureBox px = new PictureBox(); px.Image = global::ConfigCompliance.Properties.Resources.cross; px.Location = new System.Drawing.Point(49, cPosY); px.Size = new System.Drawing.Size(16, 16); px.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; px.TabIndex = 3; px.TabStop = false; this.groupProfile.Controls.Add(px); //create Lable Label lb = new Label(); lb.AutoSize = true; lb.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); lb.Location = new System.Drawing.Point(70, cPosY); lb.Size = new System.Drawing.Size(140, 15); lb.TabIndex = 2; lb.Text = tmpLoop.key + " " + vaLoop.key; this.groupProfile.Controls.Add(lb); //update pos Y cPosY += 20; Console.WriteLine("-> " + tmpLoop.key + " " + vaLoop.key); //Add demoList (dynamic change) DemoGuiListData dValist = demoList.AddChildList(vaLoop, lb, px, dMainList); SearchListData subData = vaLoop.child; while (subData != null) { //create pic status PictureBox px1 = new PictureBox(); px1.Image = global::ConfigCompliance.Properties.Resources.cross; px1.Location = new System.Drawing.Point(49, cPosY); px1.Size = new System.Drawing.Size(16, 16); px1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; px1.TabIndex = 3; px1.TabStop = false; this.groupProfile.Controls.Add(px1); //create Lable Label lb1 = new Label(); lb1.AutoSize = true; lb1.Font = new System.Drawing.Font("Microsoft Sans Serif", 9F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); lb1.Location = new System.Drawing.Point(70 + 10, cPosY); lb1.Name = "llabel"; lb1.Size = new System.Drawing.Size(140, 15); lb1.TabIndex = 2; lb1.Text = subData.key; this.groupProfile.Controls.Add(lb1); //update pos Y cPosY += 20; Console.WriteLine("---> " + subData.key); DemoGuiListData dSubData = demoList.AddChildList(subData, lb1, px1, dValist); subData = subData.next; } vaLoop = vaLoop.next; } tmpLoop = tmpLoop.next; } }
private void clear_bt_Click(object sender, EventArgs e) { this.groupProfile.Controls.Clear(); demoList = new DemoGuiList(); AddListToScreen(baseline[0], demoList); this.run_bt.Enabled = true; this.clear_bt.Enabled = false; this.resultBox.Text = ""; }