Esempio n. 1
0
        //-------------------------------------------------------------------------------------
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="device">ref NodeController</param>
        /// <param name="deviceType">type of device</param>
        public DeviceView(DeviceController device, DeviceType deviceType)
        {
            InitializeComponent();
            this.deviceController = device;

            BitmapImage bi3 = new BitmapImage();

            if (deviceType == DeviceType.dPc)
            {
                bi3.BeginInit();
                bi3.UriSource = new Uri("/GEditor;component/Resources/screen_zoom_in_ch.png", UriKind.Relative);
                bi3.EndInit();
            }
            else
            {
                if (deviceType == DeviceType.dSwitch)
                {
                    bi3.BeginInit();
                    bi3.UriSource = new Uri("/GEditor;component/Resources/switch_ch.png", UriKind.Relative);
                    bi3.EndInit();
                }
                else
                {
                    bi3.BeginInit();
                    bi3.UriSource = new Uri("/GEditor;component/Resources/password_ch.png", UriKind.Relative);
                    bi3.EndInit();
                }
            }
            this.point.Source = bi3;
            Canvas.SetZIndex(this, 2);
            this.point.Width = this.point.Height = radiusView;
        }
Esempio n. 2
0
        //---------------------------------------------------------------------------------------
        /// <summary>
        /// Init expand menu & fill datagrid
        /// </summary>
        /// <param name="node"></param>
        private void openExpand(DeviceController device)
        {
            ClearSelections();
            CloseExpander(expander2);
            string type = "Тип : ";
            if (this.device != null & this.device == device)
            {
                if (expander1.IsExpanded)
                {
                    CloseExpander(expander1);
                }
                else
                {
                    expander1.IsExpanded = true;
                    expander1.Height = 370;
                }
            }
            else
            {
                if (!expander1.IsExpanded)
                {
                    expander1.IsExpanded = true;
                    expander1.Height = 370;
                }
                this.FillDeviceData(device);
            }

            this.device = device;

            if (expander1.IsExpanded)
            {
                this.image14.Source = device.View.point.Source;
                this.textBox1.Text = device.DeviceValue;
                if (device.deviceType == DeviceType.dRouter)
                    this.label16.Content = type + "Router";
                if (device.deviceType == DeviceType.dPc)
                    this.label16.Content = type + "PC";
                if (device.deviceType == DeviceType.dSwitch)
                    this.label16.Content = type + "Switch";
            }
            this.FillDeviceData(device);
        }
Esempio n. 3
0
        //---------------------------------------------------------------------------------------
        private void FillDeviceData(DeviceController device)
        {
            List<object> rows = new List<object>();
            string[] value;

                for (int i = 0; i < device.IpAdresses.Count; i++)
                {
                    value = new string[4];
                    value[0] = device.InterfaceName[i];
                    value[1] = device.IpAdresses[i] + "";
                    value[2] = device.MasksOctets[i] + "";

                        value[3] = device.InterfaceState[i] + "";

                    rows.Add(value);
                }

            dataGrid1.ItemsSource = rows;
        }
Esempio n. 4
0
 //-------------------------------------------------------------------------------
 /// <summary>
 /// Generate event for open expand in MainWindow
 /// </summary>
 /// <param name="device"></param>
 public void OpenExpand(DeviceController device)
 {
     if (this.OnCreateCallExpand != null)
     {
         OnCreateCallExpand(device);
     }
 }
Esempio n. 5
0
 //---------------------------------------------------------------------------
 /// <summary>
 /// Update device position on canvas
 /// </summary>
 /// <param name="device"></param>
 public void OnPointPositionChanged(DeviceController device)
 {
     device.UpdateDevicePosition();
     Canvas.SetLeft(device.View, device.RelativePosition.X);
     Canvas.SetTop(device.View, device.RelativePosition.Y);
 }
Esempio n. 6
0
 //-----------------------------------------------------------------------------
 /// <summary>
 /// finish to add new connection
 /// </summary>
 public void FinishAddLink()
 {
     if (canvas.Children.Contains(tempLine))
     {
         canvas.Children.Remove(tempLine);
     }
     if (canvas.Children.Contains(leftLine))
     {
         canvas.Children.Remove(leftLine);
         canvas.Children.Remove(rightLine);
         canvas.Children.Remove(startLeftLine);
         canvas.Children.Remove(startRightLine);
     }
     ifLinkAdd = false;
     firstDevice = null;
     canvas.Cursor = Cursors.Arrow;
     ifLinkAddProcess = false;
 }
Esempio n. 7
0
        //---------------------------------------------------------------------------
        /// <summary>
        /// Delete node
        /// </summary>
        /// <param name="device"></param>
        public void DeleteDevice(DeviceController device)
        {
            List<LinkController> copy = new List<LinkController>(linkList);
            if (deviceList.Contains(device))
            {

                foreach (LinkController connection in copy)
                {
                    if (connection.From == device || connection.To == device)
                    {
                        foreach (Shape line in connection.Edge)
                        {
                            canvas.Children.Remove(line);
                        }

                        int indexFrom = connection.From.Connected.IndexOf(connection);
                        int indexTo = connection.To.Connected.IndexOf(connection);

                        if (indexFrom != -1 && indexTo != -1)
                        {
                            connection.From.DeletePort(indexFrom);
                            connection.To.DeletePort(indexTo);
                        }
                        this.linkList.Remove(connection);
                    }
                }
                deviceList.Remove(device);
                canvas.Children.Remove(device.View);
            }
            UpdateIsClear();
            if (OnUpdateDatagrid != null)
            {
                OnUpdateDatagrid(device);
            }
            OnHistoryMessage("Удалено устройство : " + device.DeviceValue, true);
        }
Esempio n. 8
0
        //---------------------------------------------------------------------------
        /// <summary>
        /// add top
        /// </summary>
        /// <param name="is_center"></param>
        public void AddNewDevice(bool is_center, DeviceType name)
        {
            DeviceController device = new DeviceController(this, name);
            if (is_center)
            {
                device.StartDevicePosition();
            }
            else
            {
                OnPointPositionChanged(device);
            }

            UpdateIsClear();
            OnHistoryMessage("Добавлено новое устройство : " + device.DeviceValue,true);
        }
Esempio n. 9
0
        //-----------------------------------------------------------------------------
        /// <summary>
        /// Add Connection
        /// </summary>
        /// <param name="from">from device</param>
        /// <param name="to"> to device</param>
        public void AddLink(DeviceController from, DeviceController to)
        {
            //delete temo line
            canvas.Children.Remove(tempLine);
            canvas.Children.Remove(leftLine);
            canvas.Children.Remove(rightLine);
            canvas.Children.Remove(startLeftLine);
            canvas.Children.Remove(startRightLine);

            if (from == to)
            {
                firstDevice = null;
                FinishAddLink();
                to.UpdateCursor();
                UpdateIsClear();
                return;
            }
            //create
            LinkController link = new LinkController(this, from, to, this.cType);
            //add connections
            from.AddNewPort(this.cType,link);
            if (OnUpdateDatagrid != null)
            {
                OnUpdateDatagrid(from);
            }
            to.AddNewPort(this.cType, link);
            if (OnUpdateDatagrid != null)
            {
                OnUpdateDatagrid(to);
            }

            if (from != to)
            {
                linkList.Add(link);
                if (this.cType == ConnectionType.cEthernet)
                {
                    OnHistoryMessage("Добавлено новое соединение типа Ethernet между "+ from.DeviceValue + " и " + to.DeviceValue, true);
                }
                else
                {
                    OnHistoryMessage("Добавлено новое соединение типа Serial между " + from.DeviceValue + " и " + to.DeviceValue, true);
                }
            }
            firstDevice = null;
            FinishAddLink();
            to.UpdateCursor();
            UpdateIsClear();
        }