/// <summary> /// get the names of networks. /// laod the all the txt files in the topologyies. /// </summary> /// <returns></returns> public static List <NetwokImport> ImportNetworkNames(UiImportTopology ui) { List <NetwokImport> networks = new List <NetwokImport>(); DirectoryInfo d = new DirectoryInfo(dbSettings.PathString); //Assuming Test is your Folder FileInfo[] Files = d.GetFiles("*.txt"); //Getting Text files int i = 0; foreach (FileInfo file in Files) { NetwokImport net = new NetwokImport(); net.UiImportTopology = ui; net.lbl_id.Content = i++; net.lbl_network_name.Content = file.Name; networks.Add(net); } return(networks); }
private void ComponentMenuItem_Click(object sender, RoutedEventArgs e) { Point po = Mouse.GetPosition(canvas_vanet); MenuItem item = sender as MenuItem; string itemString = item.Header.ToString(); switch (itemString) { case "_Network Generator": { OpenTopGen(); } break; case "_Two Lanes": { RoadSegment rs = new RoadSegment(this, 2, RoadOrientation.Horizontal); rs.Height = rs.LanesCount * PublicParamerters.LaneWidth + 1.5; rs.Margin = new Thickness(po.X + 50, po.Y + 50, 0, 0); canvas_vanet.Children.Add(rs); } break; case "_Four Lanes": { RoadSegment rs = new RoadSegment(this, 4, RoadOrientation.Horizontal); rs.Height = rs.LanesCount * PublicParamerters.LaneWidth + 1.5; rs.Margin = new Thickness(po.X + 50, po.Y + 50, 0, 0); canvas_vanet.Children.Add(rs); } break; case "_Six Lanes": { RoadSegment rs = new RoadSegment(this, 6, RoadOrientation.Horizontal); rs.Height = rs.LanesCount * PublicParamerters.LaneWidth + 1.5; rs.Margin = new Thickness(po.X + 50, po.Y + 50, 0, 0); canvas_vanet.Children.Add(rs); } break; case "_Add Junction": Junction jun = new Junction(this); jun.Margin = new Thickness(po.X + 50, po.Y + 50, 0, 0); canvas_vanet.Children.Add(jun); break; case "_Import Vanet": UiImportTopology uim = new db.UiImportTopology(this); uim.Show(); break; case "_Export Vanet": UiExportTopology win = new UiExportTopology(this); win.Show(); break; case "_Clear": { Clear(); } break; } }