Esempio n. 1
0
        public VariableBitForm(string varName, WatchVariable watchVar, List <uint> fixedAddressList)
        {
            _varName          = varName;
            _watchVar         = watchVar;
            _fixedAddressList = fixedAddressList;
            _timer            = new Timer {
                Interval = 30
            };

            InitializeComponent();

            _textBoxVarName.Text = _varName;
            _bytes = new BindingList <ByteModel>();
            for (int i = 0; i < watchVar.ByteCount.Value; i++)
            {
                _bytes.Add(new ByteModel(watchVar.ByteCount.Value - 1 - i, 0, _dataGridViewBits, this));
            }
            _dataGridViewBits.DataSource        = _bytes;
            _dataGridViewBits.CellContentClick += (sender, e) =>
                                                  _dataGridViewBits.CommitEdit(new DataGridViewDataErrorContexts());
            ControlUtilities.SetTableDoubleBuffered(_dataGridViewBits, true);

            _reversedBytes = _bytes.ToList();
            _reversedBytes.Reverse();

            int effectiveTableHeight = ControlUtilities.GetTableEffectiveHeight(_dataGridViewBits);
            int totalTableHeight     = _dataGridViewBits.Height;
            int emptyHeight          = totalTableHeight - effectiveTableHeight + 3;

            Height -= emptyHeight;

            ControlUtilities.AddCheckableContextMenuStripItems(
                this,
                new List <string>()
            {
                "Show Value", "Show Float Components"
            },
                new List <bool>()
            {
                false, true
            },
                boolValue => _showFloatComponents = boolValue,
                false);

            _timer.Tick += (s, e) => UpdateForm();
            _timer.Start();
        }