Example #1
0
        private string[] getConnections(string Filename)
        {
            NetHost Selected = null;

            for (int i = 0; i < netHosts.listOfHosts.Count; i++)
            {
                if (netHosts.listOfHosts[i].GetFileName().Contains(Filename))
                {
                    Selected = netHosts.listOfHosts[i];
                    break;
                }
            }

            List <string> result = new List <string>();

            for (int i = 0; i < Selected.ListOfRecords.Count; i++)
            {
                result.Add(Selected.ListOfRecords[i].GetCons());
            }

            return(result.ToArray());
        }
Example #2
0
 public HostRectangle(NetHost netHost, Rectangle rectangle)
 {
     this.netHost   = netHost;
     this.rectangle = rectangle;
 }
Example #3
0
 public void addSetHostRectangle(NetHost host, Rectangle rectangle)
 {
     listOfHostRectangles.Add(new HostRectangle(host, rectangle));
 }
Example #4
0
 public void addNetHost(NetHost host)
 {
     listOfHosts.Add(host);
 }
Example #5
0
        private void LoadFileButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Pliki .ethan (*.ethan)|*.ethan|Wszystkie pliki (*.*)|*.*";
            DialogResult dr = ofd.ShowDialog();

            bool exists = false;

            if (dr == DialogResult.OK)
            {
                FileStream   fs = new FileStream(ofd.FileName, FileMode.Open);
                StreamReader sr = new StreamReader(fs);

                NetHost newhost = null;

                for (int i = 0; i < netHosts.listOfHosts.Count; i++)
                {
                    if (netHosts.listOfHosts[i].GetFileName() == ofd.SafeFileName)
                    {
                        exists = true;
                    }
                }
                try
                {
                    if (!exists)
                    {
                        if (ofd.SafeFileName[0] == 'R')
                        {
                            newhost = new NetHost(ofd.SafeFileName, true);
                        }
                        else
                        {
                            newhost = new NetHost(ofd.SafeFileName, false);
                        }

                        while (!sr.EndOfStream)
                        {
                            string tmp   = sr.ReadLine();
                            int    count = 0;

                            string eth = "";
                            for (; count < tmp.Length; count++)
                            {
                                if (tmp[count] != '\t')
                                {
                                    eth += tmp[count];
                                }
                                else
                                {
                                    count++;
                                    break;
                                }
                            }

                            string ethmac = "";
                            for (; count < tmp.Length; count++)
                            {
                                if (tmp[count] != '\t')
                                {
                                    ethmac += tmp[count];
                                }
                                else
                                {
                                    count++;
                                    break;
                                }
                            }

                            string consmac = "";
                            for (; count < tmp.Length; count++)
                            {
                                if (tmp[count] != '\t')
                                {
                                    consmac += tmp[count];
                                }
                                else
                                {
                                    count++;
                                    break;
                                }
                            }

                            for (; count < tmp.Length; count++)
                            {
                                if (tmp[count] != '\t')
                                {
                                    eth += tmp[count];
                                }
                                else
                                {
                                    break;
                                }
                            }

                            if (eth.Contains("true"))
                            {
                                eth = eth.Substring(0, 4);
                            }

                            newhost.addRecord(new HostRecord(eth, ethmac, consmac, true));
                            Label hostLabel = new Label();
                            hostLabel.Text    = consmac;
                            hostLabel.Visible = false;
                            newhost.labelList.Add(hostLabel);
                        }
                        newhost.hostLabel.Text = ofd.SafeFileName.Split('.')[0];
                        netHosts.addNetHost(newhost);
                        listOfFilesListBox.Items.Add(ofd.SafeFileName);
                    }
                } catch (Exception)
                {
                    MessageBox.Show("Format pliku wejściowego jest nieprawidłowy!!!");
                }
                sr.Close();
                fs.Close();
            }
        }