public int GetValue(Buffer buffer)
        {
            string  name = buffer != null ? buffer.Name : null;
            IntInfo info = null;

            if (name != null)
            {
                for (int i = value.Count; i-- > 0;)
                {
                    IntInfo infoI = value[i];
                    if (infoI.filter != null && infoI.filter.Match(name))
                    {
                        info = infoI;
                        break;
                    }
                }
            }
            if (info == null)
            {
                for (int i = value.Count; i-- > 0;)
                {
                    IntInfo infoI = value[i];
                    if (infoI.filter == null)
                    {
                        info = infoI;
                        break;
                    }
                }
            }
            return(Math.Max(min, Math.Min(max, info.value)));
        }
Beispiel #2
0
 public void ForceKill()
 {
     if (this.hp.IsZero)
     {
         return;
     }
     this.hp = this.hp.SetMin(0);
     this.hp = this.hp.ToMin();
     OnDamage();
     OnBeforeDead();
     OnAfterDead();
 }
Beispiel #3
0
        public void UpdateNetworkInterface()
        {
            IntInfo.Items.Clear();
            /// Grab NetworkInterface object that describes the current interface
            NetworkInterface nic = nicArr[cmbInterface.SelectedIndex];

            // Grab the stats for that interface
            IPv4InterfaceStatistics interfaceStats = nic.GetIPv4Statistics();

            // Calculate the speed of bytes going in and out
            // NOTE: we could use something faster and more reliable than Windows Forms Timer

            int bytesReceivedSpeed = (int)(interfaceStats.BytesReceived - double.Parse(lblBytesReceived.Text)) / 1024;
            int bytesSentSpeed     = (int)(interfaceStats.BytesSent - double.Parse(lblBytesSent.Text)) / 1024;


            // Update the labels
            lblSpeed.Text         = "Speed Line :" + (nicArr[cmbInterface.SelectedIndex].Speed / 1000000).ToString() + " MB/sec";
            lblInterfaceType.Text = "InterfaceType :" + nicArr[cmbInterface.SelectedIndex].NetworkInterfaceType.ToString();
            lblBytesReceived.Text = interfaceStats.BytesReceived.ToString();
            lblBytesSent.Text     = interfaceStats.BytesSent.ToString();
            lblUpload.Text        = bytesSentSpeed.ToString();
            lblDownload.Text      = bytesReceivedSpeed.ToString();
            //+" KB/s"
            double upload   = Convert.ToDouble(lblUpload.Text) / 100;
            double download = Convert.ToDouble(lblDownload.Text) / 100;

            InternetChart.ChartAreas[0].AxisY.Minimum  = 0;
            InternetChart.ChartAreas[0].AxisY.Interval = 12.5;
            if (upload >= 0 && upload <= 100 && download >= 0 && download <= 100)
            {
                InternetChart.Series["UploadSpeed"].Points.AddY(upload);
                InternetChart.Series["LoadSpeed"].Points.AddY(download);
            }
            while (InternetChart.Series[0].Points.Count > 60)
            {
                InternetChart.Series[0].Points.RemoveAt(0);
                InternetChart.Series[1].Points.RemoveAt(0);
            }
            //Edit ListBox INtInfo with informationn Internet connection

            IntInfo.BeginUpdate();
            IntInfo.Items.Add("Speed Line :" + (nicArr[cmbInterface.SelectedIndex].Speed / 1000000).ToString() + " MB/sec");
            IntInfo.Items.Add(lblInterfaceType.Text = "InterfaceType :" + nicArr[cmbInterface.SelectedIndex].NetworkInterfaceType.ToString());
            IntInfo.Items.Add("Bytes Received :" + lblBytesReceived.Text);
            IntInfo.Items.Add("Bytes Sent :" + lblBytesSent.Text);
            IntInfo.Items.Add(string.Format("Usage Network: {0:0.00}%", download));
            IntInfo.Items.Add("Upload   Speed :" + bytesSentSpeed.ToString() + " KB/s");
            IntInfo.Items.Add("Download Speed :" + bytesReceivedSpeed.ToString() + " KB/s");
            IntInfo.Items.Add("Host name: " + Host);
            IntInfo.Items.Add("IP: " + ip.ToString());
            IntInfo.EndUpdate();
        }
Beispiel #4
0
 public void SetHeal(int hp)
 {
     if (this.hp.IsMax)
     {
         return;
     }
     hp = Mathf.Max(0, hp);
     if (hp == 0)
     {
         return;
     }
     this.hp.Value += hp;
     OnHeal();
     if (this.hp.IsMax)
     {
         OnFull();
     }
 }
Beispiel #5
0
 public void SetDamage(int hp)
 {
     if (this.hp.IsZero)
     {
         return;
     }
     hp = Mathf.Max(0, hp);
     if (hp == 0)
     {
         return;
     }
     this.hp.Value -= hp;
     OnDamage();
     if (this.hp.IsZero)
     {
         OnBeforeDead();
         OnAfterDead();
     }
     ;
 }
Beispiel #6
0
    void SetNewHpValue(IntInfo hp)
    {
        int diff = hp.value - this.hp.value;

        if (diff == 0)
        {
            return;
        }
        this.hp = hp;
        if (diff > 0)
        {
            OnHeal(diff, hp);
        }
        if (diff < 0)
        {
            OnDamage(-diff, hp);
        }
        if (hp.IsZero)
        {
            OnDead();
        }
    }
Beispiel #7
0
 public void SetMax(int hp)
 {
     hp      = Mathf.Max(1, hp);
     this.hp = this.hp.SetMax(hp);
 }
Beispiel #8
0
 public void SetMin(int hp)
 {
     hp      = Mathf.Max(0, hp);
     this.hp = this.hp.SetMin(hp);
 }
 void RefreshHp(IntInfo hp)
 {
     this.bar.SetHpValue(hp.Normalize);
 }