Beispiel #1
0
        private void initScalePort()
        {
            decimal?weight;
            bool?   isStable;

            USBScale s = new USBScale();

            s.Connect();

            if (s.IsConnected)
            {
                s.GetWeight(out weight, out isStable);
                s.Disconnect();
                decimal roundedWeight = weight.HasValue ? Math.Round(weight.Value) : 0;
                scaleWt.Text = Convert.ToString(roundedWeight);
                if (string.IsNullOrEmpty(tbLbs.Text) && (tbLbs.Text == "0"))
                {
                    tbLbs.Text = scaleWt.Text;
                }
            }
            else
            {
                scaleWt.Text = "0";
            }
        }
        private void initScalePort()
        {
            decimal? weight;
            bool? isStable;

            USBScale s = new USBScale();
            s.Connect();

            if (s.IsConnected)
            {
                s.GetWeight(out weight, out isStable);
                s.Disconnect();
                decimal roundedWeight = weight.HasValue ? Math.Round(weight.Value) : 0;
                scaleWt.Text = Convert.ToString(roundedWeight);
                if (string.IsNullOrEmpty(tbLbs.Text) && (tbLbs.Text == "0"))
                {
                    tbLbs.Text = scaleWt.Text;
                }
            }
            else
            {
                scaleWt.Text = "0";
            }
        }