示例#1
0
        /// <summary>
        /// Writes the appropriate values for each of the current devices in the analysis
        /// </summary>
        /// <param name="writer"></param>
        protected void WriteDevices(BinaryWriter writer)
        {
            try {
                if (_deviceList != null)
                {
                    foreach (Device device in _deviceList)
                    {
                        if (device != null)
                        {
                            Device.Attributes attributes = device.CurrentAttributes;

                            // Address
                            int address =
                                EntryWindow.ReverseIntBytes(EntryWindow.IPIntRepresentation(attributes.StringAddress));

                            writer.Write(address);

                            // Ping Interval
                            if (attributes.PingInterval > 0)
                            {
                                writer.Write(attributes.PingInterval);
                            }

                            else
                            {
                                writer.Write(Device.Attributes.DefaultPingInterval);
                            }

                            // Ping Timeout
                            if (attributes.PingTimeout > 0)
                            {
                                writer.Write(attributes.PingTimeout);
                            }

                            else
                            {
                                writer.Write(Device.Attributes.DefaultTimeout);
                            }

                            // Ping TTL
                            if (attributes.PingTimeToLive > 0)
                            {
                                writer.Write(attributes.PingTimeToLive);
                            }

                            else
                            {
                                writer.Write(Device.Attributes.DefaultTimeToLive);
                            }
                        }
                    }
                }
            } catch (IOException exception) { Console.WriteLine(Tag + ": " + exception.Message); }
        }
        /// <summary>
        /// Raised when the 'Add Addresses' MenuItem is pressed.
        /// Opens an EntryWindow to specify the IP Addresses to add
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="routedEventArgs"></param>
        protected void AddAddresses_Click(object sender, RoutedEventArgs routedEventArgs)
        {
            // Create the Window
            EntryWindow entryWindow = new EntryWindow(_analysis);

            entryWindow.Owner = this;

            // Subscribe to the Window Close Event
            entryWindow.Closed += new EventHandler(DevicesAdded);

            // Display it
            entryWindow.Show();
        }