Example #1
0
        /// <summary>
        /// Creates a GateWayConfigControl and adds it to the list of controls to be displayed.
        /// </summary>
        /// <param name="DefaultGatewayAddress">The IP adress of the default gateway</param>
        /// <param name="AssignedInterfaceName">The name of the ethernet interface to be used for the default gateway</param>
        /// <param name="IsRouter">Flag indicating whether the selected hardwarenode is a router</param>
        /// <param name="HasInternetAccess">Flag indicating whether the selected hardwarenode has internet access</param>
        public void AddGatewayConfigControl(IPAddress DefaultGatewayAddress, string AssignedInterfaceName, bool IsRouter, bool HasInternetAccess = true)
        {
            var gwConfigControl = new GwConfigControl(DefaultGatewayAddress, AssignedInterfaceName, IsRouter, HasInternetAccess);

            gwConfigControl.GatewayChanged += GWConfigControl_GatewayChanged;
            tempControls.Add(gwConfigControl);
        }
Example #2
0
 /// <summary>
 /// Clears the controls in the property control.
 /// </summary>
 public void ClearControls()
 {
     if (RetainScrollPosition)
     {
         scrollPosition = flpContents.VerticalScroll.Value;
     }
     foreach (Control c in flpContents.Controls)
     {
         if (c is InterfaceConfigControl)
         {
             InterfaceConfigControl icc = c as InterfaceConfigControl;
             icc.InterfaceChanged -= InterfaceConfigControl_InterfaceChanged;
             icc.Closing          -= ConfigControl_Closing;
         }
         else if (c is RouteConfigControl)
         {
             RouteConfigControl rcc = c as RouteConfigControl;
             rcc.RouteChanged -= RouteConfigControl_RouteChanged;
             rcc.Closing      -= ConfigControl_Closing;
         }
         else if (c is GwConfigControl)
         {
             GwConfigControl gcc = c as GwConfigControl;
             gcc.GatewayChanged -= GWConfigControl_GatewayChanged;
             gcc.Closing        -= ConfigControl_Closing;
         }
         else if (c is LayerstackConfigControl)
         {
             LayerstackConfigControl lscc = c as LayerstackConfigControl;
             lscc.LayerAdded        -= LayerStackConfigControl_LayerAdded;
             lscc.LayerRemoved      -= LayerStackConfigControl_LayerRemoved;
             lscc.LayerNameChanged  -= LayerStackConfigControl_LayerNameChanged;
             lscc.LayerIndexChanged -= LayerStackConfigControl_LayerIndexChanged;
             lscc.Closing           -= ConfigControl_Closing;
         }
         else if (c is AddInterfaceButton)
         {
             AddInterfaceButton aib = c as AddInterfaceButton;
             aib.Click -= AddInterfaceButton_Click;
         }
         else if (c is AddRouteButton)
         {
             AddRouteButton arb = c as AddRouteButton;
             arb.Click -= AddRouteButton_Click;
         }
     }
     flpContents.Controls.Clear();
     interfaceConfigControls.Clear();
     routeConfigControls.Clear();
     tempControls.Clear();
 }
Example #3
0
        /// <summary>
        /// Load properties of a hardwarenode for editing in the PropertyConfigControl
        /// </summary>
        /// <param name="ElementName"></param>
        public void LoadElementProperties(string ElementName)
        {
            selectedNode = NetworkManager.Instance.GetHardwarenodeByName(ElementName);
            propertyControl.ClearControls();
            if (selectedNode is Workstation)
            {
                var station = selectedNode as Workstation;

                // load workstation ethernet interface config controls
                foreach (var eth in station.Interfaces)
                {
                    propertyControl.AddInterfaceConfigControl(eth.Name, eth.IpAddress, eth.Subnetmask);
                }

                // Set InterfaceList in RouteConfigControl
                RouteConfigControl.SetInterfaces(station.Interfaces.Select(i => i.Name).ToList());
                // load route controls
                foreach (var route in station.GetRoutes())
                {
                    propertyControl.AddRouteConfigControl(route.Name, route.Destination, route.Gateway, route.Subnetmask,
                                                          route.Iface.Name);
                }

                // load workstation Layerstack controls
                propertyControl.AddLayerStackConfigControl();
                foreach (ILayer layer in station.Layerstack.GetAllLayers())
                {
                    propertyControl.AddLayerToLayerConfigControl(layer.GetLayerName(), layer is CustomLayer);
                }

                GwConfigControl.SetInterfaces(station.Interfaces.Select(i => i.Name).ToList());
                if (selectedNode is Router)
                {
                    // load gateway config control
                    propertyControl.AddGatewayConfigControl(station.StandardGateway ?? IPAddress.None,
                                                            station.StandardGatewayPort?.Name, true, (selectedNode as Router).IsGateway);
                }
                else
                {
                    propertyControl.AddGatewayConfigControl(station.StandardGateway ?? IPAddress.None,
                                                            station.StandardGatewayPort?.Name, false);
                }
                propertyControl.DisplayElements();
            }
            else if (selectedNode is Switch)
            {
                Switch selectedSwitch = selectedNode as Switch;
                propertyControl.AddSwitchConfigControl(selectedSwitch.GetInterfaceCount());
            }
        }