コード例 #1
0
        void setCurrentAnchorRow(int?anchorId, bool clearSelection)
        {
            if (settingCurrentAnchorRow)
            {
                return;
            }
            try
            {
                settingCurrentAnchorRow = true;

                if (anchorId == null)
                {
                    anchors.ClearSelection();
                    anchors.CurrentCell  = null;
                    currentAnchorControl = null;

                    return;
                }

                Template.Anchor a = getAnchor(anchorId, out DataGridViewRow row);
                if (row == null || a == null)
                {
                    throw new Exception("Anchor[Id=" + anchorId + "] does not exist.");
                }
                anchors.CurrentCell = anchors[0, row.Index];

                if (clearSelection)
                {
                    anchors.ClearSelection();
                }
                else
                {
                    setCurrentConditionRow(null);
                    setCurrentFieldRow(null);
                }

                Template.Anchor.Types t = ((Template.Anchor)row.Tag).Type;
                switch (t)
                {
                case Template.Anchor.Types.PdfText:
                {
                    currentAnchorControl = new AnchorPdfTextControl(new TextAutoInsertSpace {
                            Threshold = (float)textAutoInsertSpaceThreshold.Value, Representative = Regex.Unescape(textAutoInsertSpaceRepresentative.Text)
                        });
                }
                break;

                case Template.Anchor.Types.OcrText:
                {
                    currentAnchorControl = new AnchorOcrTextControl(new TextAutoInsertSpace {
                            Threshold = (float)textAutoInsertSpaceThreshold.Value, Representative = Regex.Unescape(textAutoInsertSpaceRepresentative.Text)
                        });
                }
                break;

                case Template.Anchor.Types.ImageData:
                {
                    currentAnchorControl = new AnchorImageDataControl((float)pictureScale.Value);
                }
                break;

                case Template.Anchor.Types.CvImage:
                {
                    currentAnchorControl = new AnchorCvImageControl((float)pictureScale.Value);
                }
                break;

                //case Template.Anchor.Types.Script:
                //    {
                //        if (currentAnchorControl == null || !(currentAnchorControl is AnchorScriptControl))
                //            currentAnchorControl = new AnchorScriptControl();
                //    }
                //    break;
                default:
                    throw new Exception("Unknown option: " + t);
                }
                currentAnchorControl.Initialize(row, (DataGridViewRow r) => { setAnchorRow(r, a); });
            }
            finally
            {
                settingCurrentAnchorRow = false;
            }
        }
コード例 #2
0
        void setCurrentAnchorRow(int?anchorId, bool clearSelection)
        {
            if (settingCurrentAnchorRow)
            {
                return;
            }
            try
            {
                settingCurrentAnchorRow = true;

                if (anchorId == null)
                {
                    anchors.ClearSelection();
                    anchors.CurrentCell  = null;
                    currentAnchorControl = null;
                    return;
                }

                Template.Anchor a = getAnchor(anchorId, out DataGridViewRow row);
                if (row == null || a == null)
                {
                    throw new Exception("Anchor[Id=" + anchorId + "] does not exist.");
                }
                if (anchors.CurrentCell?.RowIndex != row.Index)
                {
                    anchors.CurrentCell = anchors[0, row.Index];
                }

                if (clearSelection)
                {
                    anchors.ClearSelection();
                }
                else
                {
                    setCurrentConditionRow(null);
                    setCurrentFieldRow(null);
                }

                Template.Anchor.Types t = ((Template.Anchor)row.Tag).Type;
                switch (t)
                {
                case Template.Anchor.Types.PdfText:
                {
                    currentAnchorControl = new AnchorPdfTextControl(new TextAutoInsertSpace {
                            Threshold = (float)textAutoInsertSpace_Threshold.Value, IgnoreSourceSpaces = textAutoInsertSpace_IgnoreSourceSpaces.Checked                                                                          /*, Representative//default*/
                        });
                }
                break;

                case Template.Anchor.Types.OcrText:
                {
                    currentAnchorControl = new AnchorOcrTextControl(new TextAutoInsertSpace {
                            Threshold = (float)textAutoInsertSpace_Threshold.Value, IgnoreSourceSpaces = textAutoInsertSpace_IgnoreSourceSpaces.Checked                                                                          /*, Representative//default*/
                        });
                }
                break;

                case Template.Anchor.Types.ImageData:
                {
                    currentAnchorControl = new AnchorImageDataControl((float)pictureScale.Value);
                }
                break;

                case Template.Anchor.Types.CvImage:
                {
                    currentAnchorControl = new AnchorCvImageControl((float)pictureScale.Value);
                }
                break;

                default:
                    throw new Exception("Unknown option: " + t);
                }
                currentAnchorControl.Initialize(row, (DataGridViewRow r) => { setAnchorRow(r, a); });
                settingsControlHeader.Text = "Anchor [" + a?.Id + "]:";
            }
            finally
            {
                settingCurrentAnchorRow = false;
            }
        }