コード例 #1
0
        //---------------------------------------------
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="network">ref for MainController</param>
        /// <param name="deviceType">type of device</param>
        public DeviceController(MainController network, DeviceType deviceType)
        {
            this.network = network;
            network.Devices.Add(this);
            this.deviceType = deviceType;
            //init device's interface;)
            this.interfaceDescription = new List<string>();
            this.interfaceName = new List<string>();
            this.ipAdresses = new List<string>();
            this.masksOctets = new List<string>();
            this.connected = new List<LinkController>();
            countEthernet = 0;
            countSerial = 0;

            deviceView = new DeviceView(this, deviceType);

            int count = 0;
            for (int i = 0; i < network.Devices.Count; i++)
            {
                if (network.Devices[i].deviceType == deviceType)
                    count++;
            }

            this.deviceIndex = count++;
            if (deviceType == DeviceType.dPc)
            {
                deviceView.label1.Content = "PC-" + this.deviceIndex;
                this.deviceValue = "PC-" + this.deviceIndex;
            }
            else if (deviceType == DeviceType.dRouter)
            {
                deviceView.label1.Content = "Router-" + this.deviceIndex;
                this.deviceValue = "Router-" + this.deviceIndex;
            }
            else
            {
                deviceView.label1.Content = "Switch-" + this.deviceIndex;
                this.deviceValue = "Switch-" + this.deviceIndex;
            }

            network.GraphCanvas.Children.Add(deviceView);
            DevicePositionChange += network.OnPointPositionChanged;
        }
コード例 #2
0
 //-------------------------------------------------------------------------------------
 /// <summary>
 /// create node after graph's loading(or deserialize)
 /// </summary>
 public void OnDeserializedInit()
 {
     deviceView = new DeviceView(this, this.deviceType);
 }