コード例 #1
0
        public void CellToControls(OcrZoneCell cell)
        {
            // Cell Type
            _cmbCellType.SelectedItem = cell.CellType;

            // Convert the cell bounds to pixels
            LeadRect bounds = cell.Bounds;

            _tbLeft.Text   = bounds.X.ToString();
            _tbTop.Text    = bounds.Y.ToString();
            _tbWidth.Text  = bounds.Width.ToString();
            _tbHeight.Text = bounds.Height.ToString();

            // Border Width
            _numLeftBorderWidth.Value   = (Decimal)cell.LeftBorderWidth;
            _numTopBorderWidth.Value    = (Decimal)cell.TopBorderWidth;
            _numRightBorderWidth.Value  = (Decimal)cell.RightBorderWidth;
            _numBottomBorderWidth.Value = (Decimal)cell.BottomBorderWidth;

            // Border Style
            _cmbLeftBorderStyle.SelectedItem   = cell.LeftBorderStyle;
            _cmbTopBorderStyle.SelectedItem    = cell.TopBorderStyle;
            _cmbRightBorderStyle.SelectedItem  = cell.RightBorderStyle;
            _cmbBottomBorderStyle.SelectedItem = cell.BottomBorderStyle;

            // Border Colors
            _btnLeftBorderColor.BackColor   = MainForm.ConvertColor(cell.LeftBorderColor);
            _btnTopBorderColor.BackColor    = MainForm.ConvertColor(cell.TopBorderColor);
            _btnRightBorderColor.BackColor  = MainForm.ConvertColor(cell.RightBorderColor);
            _btnBottomBorderColor.BackColor = MainForm.ConvertColor(cell.BottomBorderColor);
        }
コード例 #2
0
        private void _widthNumericBox_Leave(object sender, EventArgs e)
        {
            NumericUpDown numCtrl = sender as NumericUpDown;

            if (_tvZonesList.SelectedNode.Tag.GetType() == typeof(OcrZoneCell))
            {
                OcrZoneCell cell  = (OcrZoneCell)_tvZonesList.SelectedNode.Tag;
                int         index = _cells.IndexOf(cell);
                if (index >= 0)
                {
                    if (numCtrl == _numLeftBorderWidth)
                    {
                        _cells[index].LeftBorderWidth = (int)numCtrl.Value;
                    }
                    else if (numCtrl == _numTopBorderWidth)
                    {
                        _cells[index].TopBorderWidth = (int)numCtrl.Value;
                    }
                    else if (numCtrl == _numRightBorderWidth)
                    {
                        _cells[index].RightBorderWidth = (int)numCtrl.Value;
                    }
                    else if (numCtrl == _numBottomBorderWidth)
                    {
                        _cells[index].BottomBorderWidth = (int)numCtrl.Value;
                    }
                }
            }
        }
コード例 #3
0
 private void _cmbCellType_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (_tvZonesList.SelectedNode.Tag.GetType() == typeof(OcrZoneCell))
     {
         OcrZoneCell cell  = (OcrZoneCell)_tvZonesList.SelectedNode.Tag;
         int         index = _cells.IndexOf(cell);
         if (index >= 0)
         {
             _cells[index].CellType = (OcrZoneType)_cmbCellType.SelectedItem;
         }
     }
 }
コード例 #4
0
 private void _btnBottomBorderColor_Click(object sender, EventArgs e)
 {
     using (ColorDialog dlg = new ColorDialog())
     {
         dlg.Color = _btnBottomBorderColor.BackColor;
         if (dlg.ShowDialog(this) == DialogResult.OK)
         {
             _btnBottomBorderColor.BackColor = dlg.Color;
             if (_tvZonesList.SelectedNode.Tag.GetType() == typeof(OcrZoneCell))
             {
                 OcrZoneCell cell  = (OcrZoneCell)_tvZonesList.SelectedNode.Tag;
                 int         index = _cells.IndexOf(cell);
                 if (index >= 0)
                 {
                     _cells[index].BottomBorderColor = MainForm.ConvertColor(dlg.Color);
                 }
             }
         }
     }
 }
コード例 #5
0
        private void _tvZonesList_AfterSelect(object sender, TreeViewEventArgs e)
        {
            int index = 0;

            if (_tvZonesList.SelectedNode.Tag.GetType() == typeof(int))
            {
                if (_pnlContainer.Controls["UpdateZonesControl"].Visible == false)
                {
                    _pnlContainer.Controls["UpdateCellsControl"].Visible = false;
                    _pnlContainer.Controls["UpdateZonesControl"].Visible = true;

                    _updateZonesControl.Activate(_ocrEngine, _ocrPage, _tvZonesList, _ocrPage.Zones);
                }

                index = (_tvZonesList.SelectedNode != null) ? (int)_tvZonesList.SelectedNode.Tag : -1;
                if (index >= 0)
                {
                    _updateZonesControl.ZoneToControls(index);
                }
            }
            else
            {
                OcrZoneCell[] cells = null;

                cells = _ocrPage.Zones.GetZoneCells(_ocrPage.Zones[(int)_tvZonesList.SelectedNode.Parent.Tag]);

                if (_pnlContainer.Controls["UpdateCellsControl"].Visible == false)
                {
                    _pnlContainer.Controls["UpdateZonesControl"].Visible = false;
                    _pnlContainer.Controls["UpdateCellsControl"].Visible = true;

                    _updateCellsControl.Activate(_ocrEngine, _ocrPage, _tvZonesList, _ocrPage.Zones, cells);
                }

                OcrZoneCell cell = (OcrZoneCell)_tvZonesList.SelectedNode.Tag;
                _updateCellsControl.CellToControls(cell);
            }

            _updateZonesControl.UpdateUIState();
            UpdateUIState();
        }
コード例 #6
0
        private void _cmbBorderStyle_SelectedIndexChanged(object sender, EventArgs e)
        {
            ComboBox combo = sender as ComboBox;

            if (_tvZonesList.SelectedNode.Tag.GetType() == typeof(OcrZoneCell))
            {
                OcrZoneCell cell  = (OcrZoneCell)_tvZonesList.SelectedNode.Tag;
                int         index = _cells.IndexOf(cell);
                if (index >= 0)
                {
                    if (combo == _cmbLeftBorderStyle)
                    {
                        _cells[index].LeftBorderStyle = (OcrCellBorderLineStyle)combo.SelectedItem;
                        if (combo.Text == "None")
                        {
                            _numLeftBorderWidth.Value = 0;
                            cell.LeftBorderWidth      = 0;
                        }
                        else
                        {
                            if (_numLeftBorderWidth.Value == 0)
                            {
                                _numLeftBorderWidth.Value = 1;
                                cell.LeftBorderWidth      = 1;
                            }
                        }
                    }
                    else if (combo == _cmbTopBorderStyle)
                    {
                        _cells[index].TopBorderStyle = (OcrCellBorderLineStyle)combo.SelectedItem;
                        if (combo.Text == "None")
                        {
                            _numTopBorderWidth.Value = 0;
                            cell.TopBorderWidth      = 0;
                        }
                        else
                        {
                            if (_numTopBorderWidth.Value == 0)
                            {
                                _numTopBorderWidth.Value = 1;
                                cell.TopBorderWidth      = 1;
                            }
                        }
                    }
                    else if (combo == _cmbRightBorderStyle)
                    {
                        _cells[index].RightBorderStyle = (OcrCellBorderLineStyle)combo.SelectedItem;
                        if (combo.Text == "None")
                        {
                            _numRightBorderWidth.Value = 0;
                            cell.RightBorderWidth      = 0;
                        }
                        else
                        {
                            if (_numRightBorderWidth.Value == 0)
                            {
                                _numRightBorderWidth.Value = 1;
                                cell.RightBorderWidth      = 1;
                            }
                        }
                    }
                    else if (combo == _cmbBottomBorderStyle)
                    {
                        _cells[index].BottomBorderStyle = (OcrCellBorderLineStyle)combo.SelectedItem;
                        if (combo.Text == "None")
                        {
                            _numBottomBorderWidth.Value = 0;
                            cell.BottomBorderWidth      = 0;
                        }
                        else
                        {
                            if (_numBottomBorderWidth.Value == 0)
                            {
                                _numBottomBorderWidth.Value = 1;
                                cell.BottomBorderWidth      = 1;
                            }
                        }
                    }

                    _tvZonesList.SelectedNode.Tag = cell;
                }

                UpdateUIControls();
            }
        }