Exemplo n.º 1
0
        private void LoadProfileIntoUI(HostSettings hs)
        {
            suppressHostSettingsSaveUntil = DateTime.Now.AddMilliseconds(100);

            txtHost.Text                       = hs.host;
            txtDisplayName.Text                = hs.displayName;
            nudPingsPerSecond.Value            = hs.rate;
            selectPingsPerSecond.SelectedIndex = hs.pingsPerSecond ? 0 : 1;
            cbTraceroute.Checked               = hs.doTraceRoute;
            cbReverseDNS.Checked               = hs.reverseDnsLookup;
            cbAlwaysShowServerNames.Checked    = hs.drawServerNames;
            cbLastPing.Checked                 = hs.drawLastPing;
            cbAverage.Checked                  = hs.drawAverage;
            cbJitter.Checked                   = hs.drawJitter;
            cbMinMax.Checked                   = hs.drawMinMax;
            cbPacketLoss.Checked               = hs.drawPacketLoss;
            nudBadThreshold.Value              = hs.badThreshold;
            nudWorseThreshold.Value            = hs.worseThreshold;
            cbPreferIpv4.Checked               = hs.preferIpv4;


            lock (settings.hostHistory)
            {
                for (int i = 1; i < settings.hostHistory.Count; i++)
                {
                    if (settings.hostHistory[i].host == hs.host)
                    {
                        HostSettings justLoaded = settings.hostHistory[i];
                        settings.hostHistory.RemoveAt(i);
                        settings.hostHistory.Insert(0, justLoaded);
                        break;
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void LoadHostSettings(HostSettings hs)
        {
            suppressHostSettingsSaveUntil = DateTime.Now.AddMilliseconds(100);

            txtHost.Text                    = hs.host;
            txtDisplayName.Text             = hs.displayName;
            nudPingsPerSecond.Value         = hs.rate;
            cbTraceroute.Checked            = hs.doTraceRoute;
            cbReverseDNS.Checked            = hs.reverseDnsLookup;
            cbAlwaysShowServerNames.Checked = hs.drawServerNames;
            cbMinMax.Checked                = hs.drawMinMax;
            cbPacketLoss.Checked            = hs.drawPacketLoss;
            nudBadThreshold.Value           = hs.badThreshold;
            nudWorseThreshold.Value         = hs.worseThreshold;


            lock (settings.hostHistory)
            {
                for (int i = 1; i < settings.hostHistory.Count; i++)
                {
                    if (settings.hostHistory[i].host == hs.host)
                    {
                        HostSettings justLoaded = settings.hostHistory[i];
                        settings.hostHistory.RemoveAt(i);
                        settings.hostHistory.Insert(0, justLoaded);
                        break;
                    }
                }
            }
        }
Exemplo n.º 3
0
        private void rsitem_Click(object sender, EventArgs e)
        {
            if (isRunning)
            {
                MessageBox.Show("Cannot load a stored host while pings are running." + Environment.NewLine + "Please stop the pings first.");
                return;
            }

            ToolStripItem tsi = (ToolStripItem)sender;
            HostSettings  hs  = (HostSettings)tsi.Tag;

            LoadHostSettings(hs);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Adds the current profile to the profile list and saves it to disk. Only if the host field is defined.
        /// </summary>
        private void SaveProfileFromUI()
        {
            if (DateTime.Now < suppressHostSettingsSaveUntil)
            {
                return;
            }
            HostSettings p = new HostSettings();

            p.host             = txtHost.Text;
            p.displayName      = txtDisplayName.Text;
            p.rate             = (int)nudPingsPerSecond.Value;
            p.pingsPerSecond   = selectPingsPerSecond.SelectedIndex == 0;
            p.doTraceRoute     = cbTraceroute.Checked;
            p.reverseDnsLookup = cbReverseDNS.Checked;
            p.drawServerNames  = cbAlwaysShowServerNames.Checked;
            p.drawLastPing     = cbLastPing.Checked;
            p.drawAverage      = cbAverage.Checked;
            p.drawJitter       = cbJitter.Checked;
            p.drawMinMax       = cbMinMax.Checked;
            p.drawPacketLoss   = cbPacketLoss.Checked;
            p.badThreshold     = (int)nudBadThreshold.Value;
            p.worseThreshold   = (int)nudWorseThreshold.Value;
            p.preferIpv4       = cbPreferIpv4.Checked;

            if (!string.IsNullOrWhiteSpace(p.host))
            {
                lock (settings.hostHistory)
                {
                    if (settings.hostHistory.Count == 0)
                    {
                        settings.hostHistory.Add(p);
                    }
                    else
                    {
                        for (int i = 0; i < settings.hostHistory.Count; i++)
                        {
                            if (settings.hostHistory[i].host == p.host && settings.hostHistory[i].preferIpv4 == p.preferIpv4)
                            {
                                settings.hostHistory.RemoveAt(i);
                                break;
                            }
                        }
                        settings.hostHistory.Insert(0, p);
                    }
                    settings.Save();
                }
            }
        }
Exemplo n.º 5
0
 public override bool Equals(object other)
 {
     if (other is HostSettings)
     {
         HostSettings o = (HostSettings)other;
         return(host == o.host &&
                rate == o.rate &&
                doTraceRoute == o.doTraceRoute &&
                reverseDnsLookup == o.reverseDnsLookup &&
                drawServerNames == o.drawServerNames &&
                drawMinMax == o.drawMinMax &&
                drawPacketLoss == o.drawPacketLoss &&
                badThreshold == o.badThreshold &&
                worseThreshold == o.worseThreshold);
     }
     return(false);
 }
Exemplo n.º 6
0
        /// <summary>
        /// Adds the current host and settings to the recent hosts history and saves the history if necessary.
        /// </summary>
        private void SaveHost()
        {
            if (DateTime.Now < suppressHostSettingsSaveUntil)
            {
                return;
            }
            HostSettings hs = new HostSettings();

            hs.host             = txtHost.Text;
            hs.displayName      = txtDisplayName.Text;
            hs.rate             = (int)nudPingsPerSecond.Value;
            hs.pingsPerSecond   = selectPingsPerSecond.SelectedIndex == 0;
            hs.doTraceRoute     = cbTraceroute.Checked;
            hs.reverseDnsLookup = cbReverseDNS.Checked;
            hs.drawServerNames  = cbAlwaysShowServerNames.Checked;
            hs.drawMinMax       = cbMinMax.Checked;
            hs.drawPacketLoss   = cbPacketLoss.Checked;
            hs.badThreshold     = (int)nudBadThreshold.Value;
            hs.worseThreshold   = (int)nudWorseThreshold.Value;

            if (!string.IsNullOrWhiteSpace(hs.host))
            {
                lock (settings.hostHistory)
                {
                    if (settings.hostHistory.Count == 0)
                    {
                        settings.hostHistory.Add(hs);
                    }
                    else
                    {
                        for (int i = 0; i < settings.hostHistory.Count; i++)
                        {
                            if (settings.hostHistory[i].host == hs.host)
                            {
                                settings.hostHistory.RemoveAt(i);
                                break;
                            }
                        }
                        settings.hostHistory.Insert(0, hs);
                    }
                    settings.Save();
                }
            }
        }