public void Select(BarCodeItem item) { var temp = FindControlByName(item.Name); if (temp != null) { NotifyUpdated(BarCodeMouseClick, temp, null); } }
public BarCodeListItemControl(BarCodeItem item) : this() { this.Item = item; if (Item != null) { comboBox1.DropDownStyle = ComboBoxStyle.Simple; comboBox1.DataBindings.Add("Text", Item, "Value", true, DataSourceUpdateMode.OnPropertyChanged, ""); BorderPanel.DataBindings.Add("BackColor", Item, "BorderColor"); DataBindings.Add("Text", Item, "Name"); Name = item.Name; } }
//for custom barcodes //------------------------------------------------------------------------- private void VerifyBarCode(BarCodeItem item) { if (String.IsNullOrEmpty(item.Value)) { item.Verify = false; MouseEnterBarCode(item); return; } int i = 0; bool isNumeric = true; if (item.TextType == "numbersText") isNumeric = utils.IsNumeric(item.Value, out i); //else // isNumeric = utils.IsNumeric(item.Value); if (item.TextType == "numbersText" && !isNumeric) { item.Verify = false; UpdateUI("Exception", "Invalid value in " + item.Name + "!"); return; } else item.Verify = true; if (errList.Contains("Error in " + item.Name)) { errList.Remove("Error in " + item.Name); VerifyErrList(); } if (Status == StatusMessage.Verify || Status == StatusMessage.Delete) return; item.Value = item.Value.Trim(); if (item.Name.StartsWith("question_number")) { string number = item.Name; number = number.Remove(0, number.LastIndexOf("_") + 1); int index = Convert.ToInt32(number); index--; rec.questionNumbers[index] = Convert.ToInt32(item.Value); //BarCodeListItemControl b = barCodeList.ControlList[index] as BarCodeListItemControl; //rec.lineNumbers[index]= if (bac != null) bac.indexOfFirstQuestion = 1; //BarCodeListItemControl b = barCodeList.ControlList[item.Name] as BarCodeListItemControl; } switch (item.Name) { case "district_id": lastDistrictId = item.Value; break; case "amout_of_questions": bool largerValue = false; //if (regions == null || rec.maxAmoutOfQuestions == 0) // regions = rec.regions; if (i > rec.MaxAmoutOfQuestions) { UpdateUI("Exception", "Value is larger than allowed!");//MessageBoxIcon.Error largerValue = true; item.Value = rec.MaxAmoutOfQuestions.ToString(); amoutOfQuestions = rec.MaxAmoutOfQuestions.ToString(); rec.AmoutOfQuestions = rec.MaxAmoutOfQuestions; } else { rec.AmoutOfQuestions = i; rec.allBarCodeValues[amout_of_questionsIndex] = i.ToString(); amoutOfQuestions = i.ToString(); } if (linsForm == null) CreateLinsForm(); else InitLinsForm(false); if (rec.AmoutOfQuestions <= factLinesPerArea[0]) {//пока только для 2 - х полей if (factLinesPerArea.Length > 1) factLinesPerArea[1] = 0; } else if (factLinesPerArea.Length > 1) { factLinesPerArea[1] = rec.AmoutOfQuestions - factLinesPerArea[0]; } if (bac.CheckBoxArr.Length == 0) { GetAreasSettings(); //if (rec.areas.Length == 0) //{ rec.areas = bubblesRegions.areas; //} maxCountRectangles = rec.AddMaxCountRectangles(); rec.FillBubbleItems(maxCountRectangles);// if (rec.factRectangle.Length > 0) { rec.FillBubbleItemsRectangle(rec.allContourMultiLine, rec.factRectangle); rec.FindBubble(rec.factRectangle, rec.allContourMultiLine, true); } //rec.BubbleItems = rec.rec.BubbleItems; bac = CreateNewBubblesAreaControl(rec.areas, rec.AmoutOfQuestions); bac.lockReport = true; DrawBubbleItems(); bac.lockReport = false; VerifyButton.Enabled = true; } else { if (rec.AmoutOfQuestions.ToString() != item.Value) { GetAreasSettings(); InitLinsForm(false); } } if (rec.Status == RecognizeAction.SearchBublesFinished || rec.Status == RecognizeAction.Cancelled)// { if (rec.Status == RecognizeAction.Cancelled && bac == new BubblesAreaControl()) bac = CreateNewBubblesAreaControl(rec.areas, rec.AmoutOfQuestions); if (rec.AmoutOfQuestions > i) { if (Status != StatusMessage.Verify && Status != StatusMessage.Delete) { ShowImage(false); rec.AmoutOfQuestions = i; bac.AmoutOfQuestions = i; DrawBubbleItems(); pictureBox1.Refresh(); } } else { if (rec.AmoutOfQuestions == i || rec.allBarCodeValues[amout_of_questionsIndex] == i.ToString()) { if (bac != null && bac != new BubblesAreaControl() && bac.labelArr.Length == i) return; } rec.AmoutOfQuestions = i; if (linsForm != null) if (linsForm.Visible) return; rec.Status = RecognizeAction.SearchBubles; RecognizeBubblesButton.Enabled = true; RecognizeBubblesButton.PerformClick(); } if (largerValue) return; } else { Status = StatusMessage.ChangeAmoutOfQuestions; return; } break; case "question_number_1": case "index_of_first_question": rec.IndexOfFirstQuestion = i; bac.indexOfFirstQuestion = i; break; //if (rec.Status == RecognizeAction.SearchBublesFinished) //{ //rec.IndexOfFirstQuestion = i; //bac.indexOfFirstQuestion = i; //} //else //{ // Status = StatusMessage.ChangeIndexOfFirstQuestion; // return; //} //break; default: break; } rec.SetValueManual(item); //f.btnExport.Focus(); }
//------------------------------------------------------------------------- private void MouseEnterBarCode(BarCodeItem item) { barCodeList.SelectedItem = item; if (linsForm != null) return; MoveScrollBubble(item.Rectangle); //UpdateZoomedImage(item.Rectangle.X, item.Rectangle.Y); AnimatedBarCode(item); }
//------------------------------------------------------------------------- private void InitLinsForm(bool BarCodeControlsBuilding) { Application.DoEvents(); int qn = 0; try { RecognizeAllButton.Enabled = true; CreateEtalonAreas(); if (BarCodeControlsBuilding)// && (rec.areas == null || rec.areas.Length == 0)) { rec.areas = (RegionsArea[])etalonAreas.Clone(); } if (linsForm != null && appSettings.Fields.LinsTrackBar1Value != 0) linsForm.trackBar1.Value = appSettings.Fields.LinsTrackBar1Value; UpdateZoomedImage(0, 0); //regions = recTools.GetRegions(rec.SheetIdentifier, rec.regionsList); int amout_of_questions = -1; if (rec.regions == null) { if (appSettings.Fields.ChbSheetId && !string.IsNullOrEmpty(lastSheetId)) { rec.regions = recTools.GetRegions(lastSheetId, rec.regionsList); } } for (int i = 0; i < rec.regions.regions.Length; i++) { var item = rec.regions.regions[i]; if (item.value == rec.SheetIdentifier) continue; if (item.type.StartsWith("bar")) { if (item.name == "sheetIdentifier") continue; int j = Array.IndexOf(rec.allBarCodeNames, item.name); if (j >= 0) { BarCodeListItemControl b = barCodeList.ControlList[j] as BarCodeListItemControl; switch (item.name) { case "district_id": if (string.IsNullOrEmpty(b.comboBox1.Text))//item.value == null { if (appSettings.Fields.DistrictId && lastDistrictId != "") { rec.allBarCodeValues[j] = lastDistrictId; b.comboBox1.Text = lastDistrictId; item.value = lastDistrictId; b.comboBox1.ForeColor = Color.Red; } } break; case "amout_of_questions": if (rec != null && rec.SheetIdentifier == "FLEX") { BarCodeListItemControl b2 = barCodeList.ControlList["bubbles_per_line"] as BarCodeListItemControl; if (string.IsNullOrEmpty(b2.comboBox1.Text) || !utils.IsNumeric(b2.comboBox1.Text)) { b.comboBox1.Text = ""; MessageBox.Show("You must specify bubbles_per_line." , Text, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } rep: for (int k = 0; k < BarCodeItems.Count; k++) { var itm = BarCodeItems[k]; //} //foreach (var item in BarCodeItems)//barCodeList.ControlList //{ if (itm.Name.StartsWith("question_number")) { qn++; if (qn > rec.AmoutOfQuestions) { BarCodeItems.Remove(itm); barCodeList.ControlList.Remove(barCodeList.ControlList[k]); rec.BarCodeItems.RemoveAt(k); goto rep; } } } Array.Resize(ref rec.allBarCodeNames, BarCodeItems.Count); Array.Resize(ref rec.allBarCodeValues, BarCodeItems.Count); Array.Resize(ref rec.questionNumbers, rec.AmoutOfQuestions); BarCodeControlsBuilding = true; } amout_of_questionsIndex = j; string s = rec.allBarCodeValues[j]; if (!string.IsNullOrEmpty(s)) { s = b.comboBox1.Text; rec.allBarCodeValues[j] = s; } try { j = Convert.ToInt32(s); amout_of_questions = j; amoutOfQuestions = j.ToString(); SetRowsValue(amout_of_questions); if (rec.allBarCodeValues[amout_of_questionsIndex] != s) { rec.allBarCodeValues[amout_of_questionsIndex] = s; SetAmoutOfQuestions(amout_of_questions); } } catch (Exception) { if (appSettings.Fields.AmoutOfQuestions && lastAmoutOfQuestions != "") { b.comboBox1.Text = lastAmoutOfQuestions; b.comboBox1.ForeColor = Color.Red; } else amout_of_questions = -1; } break; } continue; } if (rec.QrCodeHeaders != null && rec.QrCodeHeaders.Length > 0 && rec.defaults.useStudentId) continue; if (item.areas != null && item.areas[0].width == 0) continue; string value = ""; bool verify = false; if (item.name.StartsWith("question_number")) { string number = item.name; number = number.Remove(0, number.LastIndexOf("_") + 1); int index = Convert.ToInt32(number); if (amout_of_questions > -1 && index > amout_of_questions) continue; if (rec.questionNumbers.Length < index) { Array.Resize(ref rec.questionNumbers, index); } index--; } switch (item.name) { case "district_id": if (rec.QrCodeHeaders != null && rec.QrCodeHeaders.Length > 0) { int index = Array.IndexOf(rec.QrCodeHeaders, "{" + item.name + "}"); if (index > -1) { value = rec.QrCodeValues[index]; districtId = value; verify = true; } } else if (appSettings.Fields.DistrictId && !string.IsNullOrEmpty(lastDistrictId)) value = lastDistrictId; break; case "test_id": if (rec.QrCodeHeaders != null && rec.QrCodeHeaders.Length > 0) { int index = Array.IndexOf(rec.QrCodeHeaders, "{" + item.name + "}"); if (index > -1) { value = rec.QrCodeValues[index]; testId = value; verify = true; } } else if (appSettings.Fields.TestId && !string.IsNullOrEmpty(lastTestId)) { value = lastTestId; testId = lastTestId; } break; case "amout_of_questions": if (rec.QrCodeHeaders != null && rec.QrCodeHeaders.Length > 0) { int index = Array.IndexOf(rec.QrCodeHeaders, "{" + item.name + "}"); if (index > -1) { value = rec.QrCodeValues[index]; amoutOfQuestions = value; rec.AmoutOfQuestions = Convert.ToInt32(value); verify = true; } } else if (appSettings.Fields.AmoutOfQuestions && !string.IsNullOrEmpty(lastAmoutOfQuestions)) value = lastAmoutOfQuestions; break; case "question_number_1": case "index_of_first_question": if (rec.QrCodeHeaders != null && rec.QrCodeHeaders.Length > 0) { int index = Array.IndexOf(rec.QrCodeHeaders, "{" + item.name + "}"); if (index > -1) { value = rec.QrCodeValues[index]; //indexOfQuestion = value;//??? verify = true; } } else if (appSettings.Fields.IndexOfFirstQuestion && !string.IsNullOrEmpty(lastIndexOfQuestion)) value = lastIndexOfQuestion; break; default: value = ""; break; } if ((rec.QrCodeHeaders == null || rec.QrCodeHeaders.Length == 0) && lastSheetId != "" && lastSheetId == rec.SheetIdentifier && lastTestId != "" && testId == lastTestId) { if (item.name == "amout_of_questions") { value = lastAmoutOfQuestions; if (utils.IsNumeric(lastAmoutOfQuestions)) rec.AmoutOfQuestions = Convert.ToInt32(lastAmoutOfQuestions); } else if (item.name == "index_of_first_question" || item.name == "question_number_1") { value = lastIndexOfQuestion; if (utils.IsNumeric(lastIndexOfQuestion)) rec.IndexOfFirstQuestion = Convert.ToInt32(lastIndexOfQuestion); } } //var bItem = new BarCodeItem(item.name, "numbersText", value, value//item.type//rec.areas[1].type //, new Rectangle(item.areas[0].left, item.areas[0].top, item.areas[0].width, item.areas[0].height)); var bItem = new BarCodeItem(item.name, item.areas[1].type, value, value//item.type//rec.areas[1].type , new Rectangle(item.areas[0].left, item.areas[0].top, item.areas[0].width, item.areas[0].height)); recTools.SetOutputValues(ref rec.headers, ref rec.headersValues, ref rec.totalOutput, ref rec.allBarCodeNames , ref rec.allBarCodeValues, bItem.Name, bItem.Value, item.outputPosition); if (BarCodeControlsBuilding) rec.FindOrAddAndSetValueBarcode(bItem.Name, value, verify); if (item.name == "amout_of_questions") amout_of_questionsIndex = rec.allBarCodeValues.Length - 1; if (!verify || (item.name == "bubbles_per_line" && (bItem.Value != "5" || bItem.Value != "6"))) { lblErr.Text = "Error in " + bItem.Name; if (!errList.Contains(lblErr.Text)) errList.Add(lblErr.Text); try { int index = Array.IndexOf(rec.allBarCodeNames, item.name); BarCodeListItemControl b = barCodeList.ControlList[index] as BarCodeListItemControl; b.comboBox1.ForeColor = Color.Red; } catch (Exception) { } lblErr.Visible = true; } else if (item.name == "bubbles_per_line") { switch (bItem.Value) { case "5": case "6": rec.bubbles_per_lineErr = false; break; default: if (!errList.Contains(lblErr.Text)) errList.Add(lblErr.Text); rec.bubbles_per_lineErr = true; try { int index = Array.IndexOf(rec.allBarCodeNames, item.name); BarCodeListItemControl b = barCodeList.ControlList[index] as BarCodeListItemControl; b.comboBox1.ForeColor = Color.Red; } catch (Exception) { } lblErr.Visible = true; break; } } } else if (item.type == "bubblesRegions") { rec.numberOfBubblesRegion = i; bubblesRegions = item; if (linsForm != null) { linsForm.nudArea.Maximum = item.areas.Length; linsForm.nudArea.Value = 1; } if (factAreas.Length == 0) { for (int j = 0; j < rec.areas.Length; j++) rec.areas[j].bubblesPerLine = item.areas[j].bubblesPerLine; } recTools.SetSettings ( ref rec.bubblesRegions , ref rec.bubblesOfRegion , ref rec.bubblesSubLinesCount , ref rec.bubblesSubLinesStep , ref rec.bubblesPerLine , ref rec.lineHeight , ref rec.linesPerArea , out rec.answersPosition , out rec.indexAnswersPosition , ref rec.totalOutput , ref rec.bubbleLines , item , rec.kx, rec.ky , rec.curRect, rec.etRect ); } } if (BarCodeControlsBuilding) { rec.maxAmoutOfQuestions = rec.linesPerArea.Sum(); allAreasNaturalSize = new Rectangle[bubblesRegions.areas.Length]; factAreasManualSet = new bool[bubblesRegions.areas.Length]; if (rec.SheetIdentifier == "FANDP")//rec.AmoutOfQuestions == 0 { maxAmoutOfQuestions = rec.linesPerArea.Sum(); rec.AmoutOfQuestions = maxAmoutOfQuestions; rec.FindOrAddAndSetValueBarcode("amout_of_questions", maxAmoutOfQuestions.ToString()); rec.FindOrAddAndSetValueBarcode("index_of_first_question", rec.IndexOfFirstQuestion.ToString()); BarCodeListItemControl b = barCodeList.ControlList["amout_of_questions"] as BarCodeListItemControl; rbtnGrid.Enabled = false;//!!! b.btnCheck.PerformClick(); linsForm.Close(); linsForm = null; return; } } //amout_of_questions = GetFactAreas(amout_of_questions); if (!SetFactAreasSetting()) { if (rec.AmoutOfQuestions > 0) { amout_of_questions = rec.AmoutOfQuestions; } amout_of_questions = GetFactAreas(amout_of_questions); if (BarCodeControlsBuilding && lastSheetId != rec.SheetIdentifier || factAreas.Length == 0 || (amout_of_questions > 0 && amout_of_questions != factLinesPerArea.Sum())) { //if (factAreas.Length == 0) // amout_of_questions = GetFactAreas(amout_of_questions); nudArea_ValueChanged(null, null); for (int i = 0; i < factAreas.Length; i++) { factAreas[i].height = 0; } } else { if (factLinesPerArea.Length == 0 && linsForm != null) linsForm.nudRows.Value = rec.linesPerArea[0]; else { if (linsForm != null && BarCodeControlsBuilding) linsForm.nudRows.Value = factLinesPerArea[0]; } if (linsForm != null && BarCodeControlsBuilding) { linsForm.nudCols.Value = 4;// factAreas[0].bubblesPerLine; linsForm.nudSubRows.Value = factAreas[0].subLinesAmount; } } } RecognizeBubblesButton.Enabled = true; } catch (Exception ex) { log.LogMessage(ex.Message); } }
//------------------------------------------------------------------------- private void AnimatedBarCode(BarCodeItem item) { try { if (animatedTimer != null && item == null || item.Rectangle == Rectangle.Empty) return; AnimatedBarCodeClear(); AnimatedBubbleClear(); animatedTimer.SetActiveValue((Bitmap)pictureBox1.Image, item);//animatedTimer==null? if (animatedTimer.BorderColorOpacity == 255) { pictureBox1.Refresh(); return; } using (Graphics g = Graphics.FromImage(pictureBox1.Image)) { Rectangle r = Rectangle.Empty; r.Location = new Point(animatedTimer.ActiveBarCode.Rectangle.X, animatedTimer.ActiveBarCode.Rectangle.Y); if (animatedTimer.ActiveBarCode.Rectangle.Width > animatedTimer.ActiveBarCode.Rectangle.Height) { r.Width = animatedTimer.ActiveBarCode.Rectangle.Height; r.Height = animatedTimer.ActiveBarCode.Rectangle.Height - 1; } else { r.Width = animatedTimer.ActiveBarCode.Rectangle.Width; r.Height = animatedTimer.ActiveBarCode.Rectangle.Width - 1; } Color c = Color.FromArgb(128, 0, 255, 0); g.DrawEllipse(new Pen(c, 1), r);//Color.LightGreen g.FillEllipse(new SolidBrush(c), r); } pictureBox1.Refresh(); } catch (Exception) { } }
//------------------------------------------------------------------------- public void SetActiveValue(Bitmap bitmap, BarCodeItem item) { this.ActiveBarCode = item; this.ActiveBarCodeBitmap = CopyBitmap(bitmap, item.Rectangle); }
public BarcodeEventArgs(BarCodeItem barCode) { BarCode = barCode; }
//------------------------------------------------------------------------- public void ProcessingRegions(string qrCodeText = "") { string[] chars = new string[0];//, vals = new string[0] //string district_id = "D", test_id = "T", student_uid = "S", amout_of_questions = "Q", index_of_first_question = "F"; string[] qrCodeFormatItemsId = new string[0]; //string[] qrCodeFormatItems = new string[0]; MatchCollection qrCodeFormatItemsVal = null; string barCodesPromptMem = barCodesPrompt; questionNumbers = new int[0]; //QrCode = qrCodeText; if (qrCodeText != "") { var outputFileNameFormat = GetOutputFileNameFormat(); chars = Regex.Split(qrCodeText, "\\d+"); QrCodeValues = Regex.Split(qrCodeText.Remove(0, 1), "\\D+"); for (int num = 0; num < regions.regions.Length; num++) { Region regs = (Region)regions.regions[num]; bool? active = regs.active; if (active == false) continue; if (regs.name != "qr_code") continue; qrCodeFormatItemsId = Regex.Split(regs.QRCodeFormat, "{\\w+}"); qrCodeFormatItemsVal = Regex.Matches(regs.QRCodeFormat, "{\\w+}"); QrCodeHeaders = new string[qrCodeFormatItemsVal.Count]; for (int i = 0; i < QrCodeHeaders.Length; i++) { QrCodeHeaders[i] = qrCodeFormatItemsVal[i].Value; } } } if (QrCodeHeaders != null) { int index = Array.IndexOf(QrCodeHeaders, "{student_id}"); if (index > -1) student_id = QrCodeValues[index]; } notConfident = false; Rectangle lastSymbolRectangle = Rectangle.Empty; //bool notRet = false; for (int num = 0; num < regions.regions.Length; num++) { if (cancellationToken.IsCancellationRequested) return; string barcodeMem = ""; string type = regions.regions[num].type; bool? active = regions.regions[num].active; string name = regions.regions[num].name; if (active != false && type != "marker" && name != "sheetIdentifier") { areas = regions.regions[num].areas; RegionsArea arr = areas[0]; Rectangle rArr = new Rectangle(arr.left, arr.top, arr.width, arr.height); percent_confident_text_region = regions.regions[num].percent_confident_text_region; regionOutputPosition = regions.regions[num].outputPosition; int rotateParameter = regions.regions[num].rotate; // if (!barCodesPrompt.StartsWith("Markers")) //{ int deltaX = 0;// (int)((etRect.X - curRect.X) / kx); x1 = curRect.X + deltaX + (int)Math.Round((decimal)(rArr.Left - etRect.X) * kx); y1 = curRect.Y + (int)Math.Round((decimal)(rArr.Top - etRect.Y) * ky); x2 = curRect.X + deltaX + (int)Math.Round((decimal)(rArr.Right - etRect.X) * kx); y2 = curRect.Y + (int)Math.Round((decimal)(rArr.Bottom - etRect.Y) * ky); if (name == "lastBanner")// && SheetIdentifier != "100POINT" { if (barCodesPromptMem.StartsWith("M") || barCodesPromptMem.StartsWith("A")) { barCodesPrompt = "Aligment error 2"; deltaY = 0; continue; } deltaY = recTools.LastBannerFind(Bitmap, x1, y1, x2, y2, out lastBannerBottom);//, filterType if (Math.Abs(deltaY) > ((y2 - y1) / 2) + 1) { // notConfident = true; barCodesPrompt = "Aligment error 3"; deltaY = 0; } } //} // else { }//Когда заполняются дефолтные значения при Markers Not Found if (type.StartsWith("barCode")) { if (name == "sheetIdentifier") continue; if (name == "question_number_1") lastSymbolRectangle = Rectangle.Empty; if (name.StartsWith("question_number")) if (AmoutOfQuestions > 0 && questionNumbers.Length >= AmoutOfQuestions) continue; Rectangle rn = new Rectangle(x1, y1, x2 - x1, y2 - y1); // if (!barCodesPrompt.StartsWith("Markers")) //{ //barCodesPrompt = ""; int id = 0; //oldRec: if (qrCodeText == "" || id == -1 || QrCodeHeaders == null) { if (rArr == Rectangle.Empty) continue; GetBarCode(ref lastSymbolRectangle, num, ref barcodeMem, name, ref rn); if (!Auto && SheetIdentifier == "FLEX") { if (recTools.result1 != null && recTools.result1.ResultPoints[0].X > recTools.result1.ResultPoints[1].X) {//перевёрнут на 180 BarCodesPrompt = "Rotate180"; return; } } if (name == "question_number_1")// && barCodesPrompt != "" { try { IndexOfFirstQuestion = Convert.ToInt32(barcodeMem); } catch (Exception) { } } if (Auto && barCodesPrompt != "")//вставить IndexOfFirstQuestion и index_of_first_question для FLEX return;//if (name == "question_number_1") } else { if (defaults.useStudentId) { id = Array.IndexOf(QrCodeHeaders, "{" + name + "}"); if (id < 0) continue; barcode = QrCodeValues[id]; if (barcode == "0")//(name == "student_uid" || name == "student_id") && { barcode = ""; barcodeMem = barcode; barCodesPrompt = "Error in " + name; if (Auto) return; } barcodeMem = barcode; } else { if (name == "student_id") continue; id = Array.IndexOf(QrCodeHeaders, "{" + name + "}"); if (id < 0) { if (rArr == Rectangle.Empty) continue; GetBarCode(ref lastSymbolRectangle, num, ref barcodeMem, name, ref rn); if (Auto && barCodesPrompt != "") return; } else { barcode = QrCodeValues[id]; barcodeMem = barcode; } } } //var bItem = new BarCodeItem(name, arr.type, barcode, barcodeMem, rn); var bItem = new BarCodeItem(name, areas[1].type, barcode, barcodeMem, rn); recTools.SetOutputValues(ref headers, ref headersValues, ref totalOutput, ref allBarCodeNames , ref allBarCodeValues, bItem.Name, bItem.Value, regionOutputPosition); try { if (name.StartsWith("question_number")) { Array.Resize(ref questionNumbers, questionNumbers.Length + 1); questionNumbers[questionNumbers.Length - 1] = Convert.ToInt32(bItem.Value); } switch (name) { case "amout_of_questions": AmoutOfQuestions = Convert.ToInt32(bItem.Value); break; case "index_of_first_question": case "question_number_1": IndexOfFirstQuestion = Convert.ToInt32(bItem.Value); //notRet = true; break; case "bubbles_per_line": //singleArea = true; //areas[0].bubblesPerLine = Convert.ToInt32(bItem.Value); //if (bubblesPerLine.Length == 0) // bubblesPerLine = new int[areas.Length]; //bubblesPerLine[0] = areas[0].bubblesPerLine; try { bubbles_per_lineFLEX = Convert.ToInt32(bItem.Value); switch (bubbles_per_lineFLEX) { case 5: case 6: foreach (var item in regionsListFLEX) { if (item.regions[item.regions.Length - 1].areas[0].bubblesPerLine == bubbles_per_lineFLEX) { regions = item; break; } } break; default: bItem.Value = ""; break; } } catch (Exception) { bItem.Value = ""; } //areas[0].bubblesPerLine; break; } } catch (Exception) { if (name == "index_of_first_question" || name == "question_number_1") { bItem.Value = IndexOfFirstQuestion.ToString(); } } //FindOrAddAndSetValueBarcode(bItem.Name, bItem.Value); BarCodeItems.Add(bItem); NotifyUpdated(FindedBarcodeControllEvent, null, new BarcodeEventArgs(bItem)); } else if (type == "bubblesRegions") { //indexOfFirstBubble = regions.regions[num].indexOfFirstBubble; numberOfBubblesRegion = num; //if (SheetIdentifier == "FLEX") //{ // areas[0].bubblesPerLine = bubbles_per_lineFLEX; //} recTools.SetSettings(ref bubblesRegions, ref bubblesOfRegion, ref bubblesSubLinesCount , ref bubblesSubLinesStep, ref bubblesPerLine, ref lineHeight, ref linesPerArea , out answersPosition, out indexAnswersPosition, ref totalOutput , ref bubbleLines, regions.regions[num], kx, ky, curRect, etRect); } } } }
//------------------------------------------------------------------------- public void FindOrAddAndSetValueBarcode(string name, string value, bool verify = true) { // public BarCodeItem BarCodeItem bItem; if (BarCodeItems.Any(x => x.Name == name)) { bItem = BarCodeItems.First(x => x.Name == name); bItem.Value = value; bItem.Verify = false; } else {//для FANDP!!!!!!!!!! if (name == "student_uid") bItem = new BarCodeItem(name, "Text", verify);//Rectangle??????????????? else bItem = new BarCodeItem(name, "numbersText", verify); bItem.Value = value; BarCodeItems.Add(bItem); NotifyUpdated(FindedBarcodeControllEvent, null, new BarcodeEventArgs(bItem)); if (Array.IndexOf(allBarCodeNames, name) < 0) { Array.Resize(ref allBarCodeValues, allBarCodeValues.Length + 1); allBarCodeValues[allBarCodeValues.Length - 1] = value; Array.Resize(ref allBarCodeNames, allBarCodeNames.Length + 1); allBarCodeNames[allBarCodeNames.Length - 1] = name; } } //return bItem; }
public void SetValueManual(BarCodeItem item) { int index = Array.IndexOf(allBarCodeNames, item.Name); if (index > -1) { allBarCodeValues[index] = item.Value; item.Verify = true; } }