コード例 #1
0
ファイル: PropertyControl.cs プロジェクト: JPsychotic/SWP16
        /// <summary>
        /// Creates a RouteConfigControl and adds it to the list of routes to be displayed.
        /// </summary>
        /// <param name="RouteName"></param>
        /// <param name="Destination">IP address of the route destination</param>
        /// <param name="Route">IP address of the route</param>
        /// <param name="Subnetmask">Assigned subnetmasks</param>
        /// <param name="Parameters">Parameters for the route</param>
        public void AddRouteConfigControl(string RouteName, IPAddress Destination, IPAddress Route, IPAddress Subnetmask, string Parameters)
        {
            var newControl = new RouteConfigControl(RouteName, Destination, Route, Subnetmask, Parameters);

            newControl.Closing      += ConfigControl_Closing;
            newControl.RouteChanged += RouteConfigControl_RouteChanged;
            routeConfigControls.Add(newControl);
        }
コード例 #2
0
ファイル: PropertyControl.cs プロジェクト: JPsychotic/SWP16
 /// <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();
 }
コード例 #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());
            }
        }