Пример #1
0
        private void _btnClearCells_Click(object sender, EventArgs e)
        {
            _tvZonesList.SelectedNode.Nodes.Clear();
            _viewerControl.ClearZoneCells((int)_tvZonesList.SelectedNode.Tag);

            _tvZonesList.Focus();
            UpdateUIState();
        }
Пример #2
0
        private void _areaTextBox_LostFocus(object sender, EventArgs e)
        {
            if (_tvZonesList.SelectedNode == null)
            {
                return;
            }

            // Make sure it is an integer and in valid range
            OcrZone  zone   = CurrentZone;
            LeadRect bounds = zone.Bounds;

            TextBox tb = sender as TextBox;
            int     val;

            if (!int.TryParse(tb.Text, out val) || val < 0)
            {
                ResetBoundsValue(tb, bounds);
                return;
            }

            LeadRect newBounds = bounds;

            // Calculate the new bounds
            if (tb == _leftTextBox)
            {
                newBounds.X = val;
            }
            else if (tb == _topTextBox)
            {
                newBounds.Y = val;
            }
            else if (tb == _widthTextBox)
            {
                if (val == 0)
                {
                    ResetBoundsValue(tb, bounds);
                    return;
                }
                newBounds.Width = val;
            }
            else if (tb == _heightTextBox)
            {
                if (val == 0)
                {
                    ResetBoundsValue(tb, bounds);
                    return;
                }
                newBounds.Height = val;
            }

            // Make sure the new bounds does not go outside the page
            LeadRect pageBounds = new LeadRect(0, 0, _ocrPage.Width, _ocrPage.Height);

            if (!pageBounds.Contains(newBounds))
            {
                ResetBoundsValue(tb, bounds);
                return;
            }

            // Valid value, update the bounds
            zone.Bounds = newBounds;
            CurrentZone = zone;
            OcrZoneCell[] cells = null;
            cells = _zones.GetZoneCells(_zones[(int)_tvZonesList.SelectedNode.Tag]);

            if (_zones[(int)_tvZonesList.SelectedNode.Tag].ZoneType == OcrZoneType.Table &&
                cells != null &&
                _oldValue != val)
            {
                _tvZonesList.SelectedNode.Nodes.Clear();
                _viewerControl.ClearZoneCells((int)_tvZonesList.SelectedNode.Tag);
            }
        }