//------------------------------------------------------------------------- public void SetInvertBubbleChecked(BubbleItem value, bool controlPressed = false) { var item = FindCheckBox(value); if (item != null) { if (!controlPressed) item.Checked = !item.Checked; else { item.Checked = true; foreach (var itm in CheckBoxList) { BubbleItem bi = (BubbleItem)itm.Tag; if (bi.Bubble.areaNumber != value.Bubble.areaNumber || bi.Bubble.point.Y != value.Bubble.point.Y || bi.Equals(value)) continue; itm.Checked = false; EditorForm ef = (EditorForm)this.FindForm(); ef.DrawBubble(bi.CheckedBubble); } } } }
//------------------------------------------------------------------------- private CheckBox FindCheckBox(BubbleItem value) { foreach (var item in CheckBoxList) { if (((BubbleItem)item.Tag).Equals(value)) { return item; } } return null; }
private void VerifyButton_Click(object sender, EventArgs e) { log.LogMessage("Verify Button Click"); Status = StatusMessage.Verify; for (int i = 0; i < barCodeList.ControlList.Count; i++) { BarCodeListItemControl item = (BarCodeListItemControl)barCodeList.ControlList[i]; item.btnCheck.PerformClick(); var itm = barCodeList.DataSource[i]; if (!itm.Verify) { MessageBox.Show("Invalid value in " + item.Name, Text, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } } //if (BarCodeItems.Any(x => !x.Verify)) // return; if (VerifyDirectory(defaults.ManualSuccessFolder)) { try { if (rec.BubbleItems.Count == 0) { for (int i = 0; i < bac.CheckBoxArr.Length; i++) { BubbleItem bi = new BubbleItem(); Bubble b = (Bubble)bac.CheckBoxArr[i].Tag; bi.Bubble = b; bi.CheckedBubble = new CheckedBubble(); bi.CheckedBubble.isChecked = bac.CheckBoxArr[i].Checked; rec.BubbleItems.Add(bi); } } DrawBubbleItems(false); bool emty = true; for (int k = 0; k < rec.BubbleItems.Count; k++) { if (rec.BubbleItems[k].CheckedBubble.isChecked) { emty = false; break; } } if (emty) { if (MessageBox.Show("Are you sure you want verify this sheet? No answers selected." , Text, MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No) { Status = StatusMessage.NULL; return; } } rec.VerifySheetManual(BarCodeItems.ToList(), rec.BubbleItems.ToList()); allAreasNaturalSize = new Rectangle[0]; } catch (Exception) { allAreasNaturalSize = new Rectangle[0]; VerifyButton.Enabled = false; NextButton.Enabled = true; DeleteButton.Enabled = true; Status = StatusMessage.NULL; return; } lastSheetId = rec.SheetIdentifier; lastTestId = testId; lastAmoutOfQuestions = rec.AmoutOfQuestions.ToString(); lastIndexOfQuestion = rec.IndexOfFirstQuestion.ToString(); lastDistrictId = districtId; errList.Clear(); lblErr.Visible = false; DeleteTempFiles(rec.FileName, rec.AuditFileName); if (linsForm != null) linsForm_FormClosing(null, new FormClosingEventArgs(CloseReason.None, false)); } }
//------------------------------------------------------------------------- public void Select(BubbleItem item) { var temp = FindCheckBox(item); if (temp != null) { NotifyUpdated(BubbleMouseEnter, temp, null); } }
//------------------------------------------------------------------------- private CheckBox FindCheckBox(BubbleItem value) { EditorForm ef = (EditorForm)this.FindForm(); if (ef != null && EditorForm.rec != null && EditorForm.rec.BubbleItems != null) { int index = EditorForm.rec.BubbleItems.IndexOf(value); if (index > -1) return CheckBoxArr[index]; } return null; }
//------------------------------------------------------------------------- private void AnimatedBubble(BubbleItem bubbleItem) { if (bubbleItem == null) return; AnimatedBarCodeClear(); if (bac != null) { if (animatedTimer != null && animatedTimer.BorderColorOpacity != 255) { CheckBox cb = bac.CheckBoxArr[rec.BubbleItems.IndexOf(bubbleItem)]; if (cb != null) { using (Graphics g = cb.CreateGraphics()) { g.DrawRectangle(new Pen(Color.LightCyan, 1), new Rectangle ( cb.ClientRectangle.X , cb.ClientRectangle.Y , cb.ClientRectangle.Width - 3 , cb.ClientRectangle.Height - 2 )); } } } else { bac.Refresh(); } } AnimatedBubbleClear(); if (animatedTimer != null) animatedTimer.SetActiveValue(bubbleItem); if (animatedTimer.BorderColorOpacity == 255) { pictureBox1.Refresh(); return; } using (Graphics g = Graphics.FromImage(pictureBox1.Image)) { g.DrawRectangle(new Pen(Color.LightCyan, 3), animatedTimer.ActiveBubbleItem.CheckedBubble.rectangle); } pictureBox1.Refresh(); }
//------------------------------------------------------------------------- public void SetInvertBubbleChecked(BubbleItem value, bool controlPressed = false) { EditorForm ef = (EditorForm)this.FindForm(); var item = FindCheckBox(value); if (item != null) { if (!controlPressed) { lockReport = true; item.Checked = !item.Checked; ef.DrawBubble(value.CheckedBubble); } else { lockReport = true; item.Checked = true; value.CheckedBubble.isChecked = true; ef.DrawBubble(value.CheckedBubble); for (int i = 0; i < CheckBoxArr.Length; i++) { var itm = CheckBoxArr[i]; Bubble bi = (Bubble)itm.Tag; if (bi.areaNumber != value.Bubble.areaNumber || bi.point.Y != value.Bubble.point.Y || bi.Equals(value.Bubble)) continue; itm.Checked = false; EditorForm.rec.BubbleItems[i].CheckedBubble.isChecked = false; ef.DrawBubble(EditorForm.rec.BubbleItems[i].CheckedBubble); } lockReport = false; } } ef.pictureBox1.Refresh(); }
//------------------------------------------------------------------------- public void Select(BubbleItem item) { var temp = FindCheckBox(item); if (temp != null) checkBox1_MouseEnter(temp, null); }
public void SetActiveValue(BubbleItem item) { this.ActiveBubbleItem = item; }
//------------------------------------------------------------------------- private void GoodBubble(BubbleItem item, int k, int bubblesRegion , ref double factStepY, ref Bubble bubble, ref int prevGoodLineY, int factRectangle_k_Y) { //хороший пузырь if (bubble.Equals(new Bubble()) && item.Bubble.subLine == 0) { bubble = item.Bubble; prevGoodLineY = factRectangle_k_Y; } else { try { if (String.IsNullOrEmpty(areas[bubblesRegion].bubblesOrientation) || areas[bubblesRegion].bubblesOrientation == "horizontal") {//определение текущего значения lineFactStep if (item.Bubble.subLine == 0 && bubble.areaNumber == item.Bubble.areaNumber && bubble.point.Y != item.Bubble.point.Y) { factStepY = (double)(factRectangle_k_Y - prevGoodLineY) / (item.Bubble.point.Y - bubble.point.Y); bubble = item.Bubble; prevGoodLineY = factRectangle_k_Y; } } else { if (bubble.areaNumber == item.Bubble.areaNumber && bubble.subLine == item.Bubble.subLine && item.Bubble.point.X != bubble.point.X) { factStepY = (double)(factRectangle_k_Y - prevGoodLineY) / (item.Bubble.point.X - bubble.point.X); bubble = item.Bubble; prevGoodLineY = factRectangle_k_Y; //item.Key.point.X; } } } catch (Exception) { } } }
//------------------------------------------------------------------------- private void BadBubble(BubbleItem item, int k, int maxBubblesDist, int bubblesRegion , Rectangle bubble1, ref Rectangle prevRectangle, int bubbleStepX , double factStepY , int[] axisY = null ) { //плохой пузырь int dist, minDist = int.MaxValue, numCont = -1; int n; var itm = BubbleItems[k]; for (int kn = 1; kn < maxBubblesDist; kn++) { n = k + kn; if (n < BubbleItems.Count - 1) { itm = BubbleItems[n]; //if ((regionRectangle.ElementAt(n).Value == regionRectangle.ElementAt(k).Value) if (item.CheckedBubble.rectangle.Size != new Size() && (itm.Bubble.areaNumber == item.Bubble.areaNumber)) { dist = Math.Abs(item.Bubble.point.X - itm.Bubble.point.X) + Math.Abs(item.Bubble.point.Y - itm.Bubble.point.Y) + Math.Abs(item.Bubble.subLine - itm.Bubble.subLine); if (dist <= 1) { numCont = n; break; } else { if (dist < minDist) { minDist = dist; numCont = n; } } } } n = k - kn; if (n > -1) { itm = BubbleItems[n]; if (itm.CheckedBubble.rectangle.Size != new Size() && (itm.Bubble.areaNumber == item.Bubble.areaNumber)) { dist = Math.Abs(item.Bubble.point.X - itm.Bubble.point.X) + Math.Abs(item.Bubble.point.Y - itm.Bubble.point.Y) + Math.Abs(item.Bubble.subLine - itm.Bubble.subLine); if (dist <= 1) { numCont = n; break; } else { if (dist < minDist) { minDist = dist; numCont = n; } } } } } if (numCont > -1) {//itm = замещающий, item = замещаемый int distX; int distY; int distYsub; int moveX; int moveY; itm = BubbleItems[numCont]; if (String.IsNullOrEmpty(areas[bubblesRegion].bubblesOrientation) || areas[bubblesRegion].bubblesOrientation == "horizontal") { distX = item.Bubble.point.X - itm.Bubble.point.X; distY = item.Bubble.point.Y - itm.Bubble.point.Y; distYsub = item.Bubble.subLine - itm.Bubble.subLine; moveX = (bubble1.Width + bubbleStepX) * distX; moveY = (int)Math.Round((double)factStepY * distY + bubblesSubLinesStep[bubblesRegion] * distYsub); } else { distY = item.Bubble.point.X - itm.Bubble.point.X; distX = item.Bubble.point.Y - itm.Bubble.point.Y; distYsub = item.Bubble.subLine - itm.Bubble.subLine; moveY = (int)Math.Round((double)factStepY * distY); moveX = (int)Math.Round((double)bubbleStepX * distX + (bubblesSubLinesStep[bubblesRegion]) * distYsub); } prevRectangle = new Rectangle (BubbleItems[numCont].CheckedBubble.rectangle.X , BubbleItems[numCont].CheckedBubble.rectangle.Y , BubbleItems[numCont].CheckedBubble.rectangle.Width , BubbleItems[numCont].CheckedBubble.rectangle.Height ); prevRectangle.Y += moveY; if (moveY != 0 && axisY != null && axisY.Length > 0 && axisY[0] != 0) { if (item.Bubble.point.X == 0 && item.Bubble.subLine == 0) { int bestWal = int.MaxValue; int delta = int.MaxValue; foreach (int item2 in axisY) { int delta2 = Math.Abs(prevRectangle.Y - item2); if (delta2 < delta)// bestY) { delta = delta2; bestWal = item2; } } if (bestWal != int.MaxValue) prevRectangle.Y = bestWal; } else { if (BubbleItems[k - 1].Bubble.subLine == item.Bubble.subLine) { prevRectangle.Y = BubbleItems[k - 1].CheckedBubble.rectangle.Y; } } } if (item.Bubble.subLine > 0 && (String.IsNullOrEmpty(areas[bubblesRegion].bubblesOrientation) || areas[bubblesRegion].bubblesOrientation == "horizontal")) { prevRectangle.X = BubbleItems[k - areas[bubblesRegion].bubblesPerLine].CheckedBubble.rectangle.X; BubbleItems[k].CheckedBubble.rectangle = new Rectangle(prevRectangle.X, prevRectangle.Y, prevRectangle.Width, prevRectangle.Height); } else { prevRectangle.X += moveX; BubbleItems[k].CheckedBubble.rectangle = new Rectangle(prevRectangle.X, prevRectangle.Y, prevRectangle.Width, prevRectangle.Height); } } else {//err barCodesPrompt = recTools.PromptCalibrationError(item.Bubble); } }