public TimerData(XmlReader xml, ServerData parent)
            {
                this.parent = parent;
                int? strikes = null, interval = null, startup = null, shutdown = null;
                while (xml.Read())
                {
                    if (xml.NodeType != XmlNodeType.Element)
                        continue;
                    switch (xml.Name)
                    {
                        case "strikes":
                            strikes = xml.ReadElementContentAsInt();
                            break;
                        case "interval":
                            interval = xml.ReadElementContentAsInt();
                            break;
                        case "startup":
                            startup = xml.ReadElementContentAsInt();
                            break;
                        case "shutdown":
                            shutdown = xml.ReadElementContentAsInt();
                            break;
                    }
                }

                not_null(strikes, "strikes");
                not_null(startup, "startup");
                not_null(interval, "interval");
                not_null(shutdown, "shutdown");

                validate_value(ref strikes);
                validate_value(ref startup);
                validate_value(ref interval);
                if (shutdown < 0)
                    shutdown = 0;

                this.strikes = (ushort) strikes;
                this.startup = (ushort) startup;
                this.interval = (ushort) interval;
                this.shutdown = (ushort) shutdown;
            }
Example #2
0
        public void CreateNew(ushort id)
        {
            if (server != null)
                throw new InvalidOperationException("Cannot call CreateNew while an Edit Server operation is in progress!");

            ServerData.TimerData timer = new ServerData.TimerData();
            timer.Interval = (ushort) this.QueryInterval.Value;
            timer.Strikes  = (ushort) this.QueryStrikes.Value;
            timer.Startup  = (ushort) this.StartupTime.Value;
            timer.Shutdown = (ushort) this.ShutdownTime.Value;

            server = new ServerData (id,
                                    this.NameBox.Text,
                                    this.IPBox.Text,
                                    (ushort) this.PortBox.Value,
                                    this.ExeBox.Text,
                                    this.ParamBox.Text,
                                    CalculateAffinity(),
                                    CalculateQueryType(),
                                    timer);
        }
Example #3
0
 public void PrepareNew()
 {
     this.Text = "New Server";
     SaveButton.Enabled = true;
     server = null;
     ResetMarkers(NormalColour);
     NameBox.Text = "";
     IPBox.Text = PublicIP;
     PortBox.Value = 27015;
     ExeBox.Text = "";
     ExePicker.InitialDirectory = "C:/";
     ParamBox.Text = "";
     StartupTime.Value = 30;
     ShutdownTime.Value = 5;
     QueryInterval.Value = 15;
     QueryStrikes.Value = 3;
     ProcessorAffinity.ClearSelected();
     QueryType.SelectedIndex = 1;
 }
Example #4
0
 public void PrepareEdit(ServerData server)
 {
     if (server == null)
         throw new ArgumentNullException("server");
     this.Text = "Edit Server";
     SaveButton.Enabled = true;
     this.server = server;
     ResetMarkers(FadeColour);
     NameBox.Text = server.Name;
     IPBox.Text = server.IPAddress;
     PortBox.Value = server.Port;
     ExeBox.Text = server.Executable;
     if (System.IO.File.Exists(ExeBox.Text))
         ExePicker.InitialDirectory = System.IO.Path.GetDirectoryName(ExeBox.Text);
     else
         ExePicker.InitialDirectory = "C:/";
     ParamBox.Text = server.Parameters;
     StartupTime.Value = server.TimingData.Startup;
     ShutdownTime.Value = server.TimingData.Shutdown;
     QueryInterval.Value = server.TimingData.Interval;
     QueryStrikes.Value = server.TimingData.Strikes;
     switch (server.Query)
     {
         case ServerChecker2012.QueryType.NONE:
             this.QueryType.SelectedIndex = 0;
             break;
         case ServerChecker2012.QueryType.SOURCE:
             this.QueryType.SelectedIndex = 1;
             break;
         default:
             this.QueryType.SelectedIndex = 0;
             break;
     }
     Int64 affinity = server.ProcessAffinity;
     for (var i = 0; i < ProcessorCount; ++i)
         if ((affinity & 1 << i) > 0)
             ProcessorAffinity.SetSelected(i, true);
 }
 public SourceQuery(ServerData data)
     : this(data.IPAddress, data.Port)
 {
 }
 public ServerListViewItem(ServerData data)
 {
     this.data = data;
     Text = data.ID.ToString();
     var row  = SubItems;
     var name = row.Add(data.Name);
     var ip   = row.Add(data.IPAddress);
     var port = row.Add(data.Port.ToString());
     var pid  = row.Add("");
     var stat = row.Add("Offline");
     var ping = row.Add("N/a");
     mPingCBack = (string Ping) =>
     {
         ping.Text = Ping;
     };
     mProcCBack = (string PID, string Status) =>
     {
         pid.Text = PID;
         stat.Text = Status;
     };
     mInfoCBack = () =>
     {
         name.Text = data.Name;
         ip.Text = data.IPAddress;
         port.Text = data.Port.ToString();
     };
     data.PingChanged += new ServerPingUpdateEventHandler(OnServerPing);
     data.ProcessChanged += new ServerProcessUpdateEventHandler(OnServerProc);
     data.InfoChanged += new EventHandler(OnServerInfo);
 }