private void button1_Click(object sender, EventArgs e) { int age; double BMR, DCR; string activ; if (!int.TryParse(textBox1.Text, out age)) { errorProvider1.SetError(this.textBox1, "Enter Number"); } else if (comboBox1.Text == "" || comboBox1.Text != "1.Sedentary" && comboBox1.Text != "2.Light Exercise(1-3 days / week)" && comboBox1.Text != "3.Moderate Exercise(3-5 days / week)" && comboBox1.Text != "4.Intense Exercise(6-7 days / week)" && comboBox1.Text != "5.Very Intense Exercise (2 extreme workouts per day)") { errorProvider1.SetError(this.comboBox1, "Chose menu"); } else { age = Convert.ToInt32(textBox1.Text); BMR = BasalMetabolicRate(weight, height, age, gender); activ = comboBox1.SelectedItem.ToString(); DCR = ActivityLevel(BMR, activ); ListViewItem item = new ListViewItem(BMR.ToString()); item.SubItems.Add(DCR.ToString()); listView1.Items.Add(item); } }
internal void Read(CRContext crc, DCR.BlkDataTable blkdt) { DataTable dt = crc.dtCR; int cx = dt.Columns.Count; DataRow dr = crc.drCR; if (dr == null) return; for (int x = 0; x < cx; x++) { String nam = dt.Columns[x].ColumnName; String dat = Convert.ToString(dr[x]); if (String.IsNullOrEmpty(nam)) continue; foreach (DCR.BlkRow blk in blkdt.Select("FieldName = '" + (nam.Replace("'", "''")) + "'")) { if (!blk.IfImport) break; DSRes.TResRow row = dsRes.TRes.AddTResRow(nam, dat, 0, 0, 0, 0); row.x = blk.x; row.y = blk.y; row.cx = blk.cx; row.cy = blk.cy; break; } } }
public bool ReadSet(String baseDir) { dictSet.Clear(); foreach (String fpSet in Directory.GetFiles(baseDir, "*.OCR-Settei")) { using (FileStream fs = File.OpenRead(fpSet)) { XmlSerializer xs = new XmlSerializer(typeof(OCRSettei)); OCRSettei ocrs = dictSet[fpSet] = (OCRSettei)xs.Deserialize(fs); DCR dcr = new DCR(); dcr.Merge(ocrs.DCR, true, MissingSchemaAction.Add); ocrs.DCR = dcr; } } return dictSet.Count != 0; }
public static object Recognize3(Bitmap picSrc, DCR.BlkRow row, out Bitmap picUsed) { SizeF PPM = UtPelsPerMeter.Compute(picSrc); Rectangle rc = new Rectangle( (int)(row.x * PPM.Width * 1000), (int)(row.y * PPM.Height * 1000), (int)(row.cx * PPM.Width * 1000), (int)(row.cy * PPM.Height * 1000) ); Object textrec = null; Bitmap picS = (row.ResampleDPI == 0) ? CUt.Cut(picSrc, rc) : CUt.CutDPI(picSrc, rc, row.ResampleDPI); { Bitmap pic = picS; if (!String.IsNullOrEmpty(row.NoiseReduction) && Magick.IsInstalled) { pic = Magick.Run(pic, row.NoiseReduction); } picUsed = pic; String ty = row.CRType; if (ty == "zxing") { if (pic.Width >= 8 && pic.Height >= 8) { IBarcodeReader reader = new BarcodeReader(); try { Result result = reader.Decode(pic); if (result != null) textrec = result.Text; } catch (IndexOutOfRangeException) { // 画像が小さいなど } } } else if (ty == "gocr") { textrec = GOcr.Rec(pic); } else if (ty == "ocrad") { textrec = Ocrad.Rec(pic); } else if (ty == "nhocr") { textrec = NHocr.Rec(pic); } else if (ty.StartsWith("ocr.") && TOcr.IsInstalled) { textrec = TOcr.Rec(pic, ty.Substring(4), row.Whitelist, row.Blacklist, row.PSM); if (textrec is String) { textrec = ((String)textrec).Replace("—", "-"); } } } if (textrec is String && row.PostProcess != null) { String[] alpp = row.PostProcess.Replace("\r\n", "\n").Split('\n'); String ntr = ""; foreach (char c in "" + textrec) { foreach (String pp in alpp) { if (false) { } else if (pp.Length == 2 && pp[0] == '×') { if (pp[1] == c) { goto _SkipIt; } } else if (pp.Length == 3) { if (false) { } else if (pp[1] == '⇔') { if (false) { } else if (pp[0] == c) { ntr += pp[2]; goto _SkipIt; } else if (pp[2] == c) { ntr += pp[0]; goto _SkipIt; } } else if (pp[1] == '→') { if (false) { } else if (pp[0] == c) { ntr += pp[2]; goto _SkipIt; } } else if (pp[1] == '←') { if (false) { } else if (pp[2] == c) { ntr += pp[0]; goto _SkipIt; } } } } ntr += c; _SkipIt: ; } textrec = ntr; } return textrec; }
public static object Recognize2(Bitmap picSrc, DCR.BlkRow row) { Bitmap picUsed; Object res = Recognize3(picSrc, row, out picUsed); if (picUsed != null) picUsed.Dispose(); return res; }