Esempio n. 1
0
        public void Deploy()
        {
            NetworkTopolgy.ImportNetwok(this);
            Settings.Default.NetworkName = lbl_network_name.Content.ToString();
            Settings.Default.Save();
            PublicParamerters.SensingRangeRadius = ImportedSensorSensors[0].R;
            // now add them to feild.


            // set the size of the network:
            // area_300_m2
            string[] arr = Settings.Default.NetworkName.Split('_');
            if (arr.Length == 3)
            {
                PublicParamerters.NetworkSquareSideLength = System.Convert.ToDouble(arr[1]);
                MainWindow.Canvas_SensingFeild.Height     = PublicParamerters.NetworkSquareSideLength;
                MainWindow.Canvas_SensingFeild.Width      = PublicParamerters.NetworkSquareSideLength;
            }
            else
            {
                PublicParamerters.NetworkSquareSideLength = 550;
                MainWindow.Canvas_SensingFeild.Height     = PublicParamerters.NetworkSquareSideLength;
                MainWindow.Canvas_SensingFeild.Width      = PublicParamerters.NetworkSquareSideLength;
            }


            //

            foreach (ImportedSensor imsensor in ImportedSensorSensors)
            {
                Sensor node = new Sensor(imsensor.NodeID);
                node.MainWindow = MainWindow;
                Point p = new Point(imsensor.Pox, imsensor.Poy);
                node.Position         = p;
                node.VisualizedRadius = imsensor.R;
                MainWindow.myNetWork.Add(node);
                MainWindow.Canvas_SensingFeild.Children.Add(node);


                node.ShowID(Settings.Default.ShowID);
                node.ShowSensingRange(Settings.Default.ShowSensingRange);
                node.ShowComunicationRange(Settings.Default.ShowComunicationRange);
                node.ShowBattery(Settings.Default.ShowBattry);
            }


            try
            {
                if (UiImportTopology != null)
                {
                    UiImportTopology.Close();
                }
            }
            catch
            {
            }
        }
Esempio n. 2
0
        public UiImportTopology(MainWindow MainWindow)
        {
            InitializeComponent();

            foreach (NetwokImport net in NetworkTopolgy.ImportNetworkNames(this))
            {
                net.MainWindow = MainWindow;
                stk_netwoks.Children.Add(net);
            }
        }
Esempio n. 3
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {
            NetworkTopolgy topolog   = new NetworkTopolgy();
            bool           isExisted = topolog.createNewTopology(txt_networkName.Text);

            if (!isExisted)
            {
                this.WindowState = WindowState.Minimized;
                foreach (Sensor sensor in myNetWork)
                {
                    topolog.SaveSensor(sensor, txt_networkName.Text);
                }
                this.Close();
            }
            else
            {
                MessageBox.Show("please change network name!");
            }
        }