public CalibrateSize(System.Drawing.Bitmap bitmap, Action <int> next)
 {
     size      = 16;
     origin    = bitmap;
     this.next = next;
     omr       = new OMR.OMRv1();
     InitializeComponent();
     TextBoxSize.Text   = size.ToString();
     ImageOrigin.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
         bitmap.GetHbitmap(),
         IntPtr.Zero,
         System.Windows.Int32Rect.Empty,
         BitmapSizeOptions.FromWidthAndHeight(bitmap.Width, bitmap.Height));
 }
 public PageCreateTemplate(TextBlock textBlockTitle, System.Drawing.Bitmap bitmap, int circleSize, Action back, Action <Template> next)
 {
     dirty = true;
     textBlockTitle.Text = "สร้างรูปแบบกระดาษคำตอบ";
     this.back           = back;
     this.next           = next;
     omr = new OMR.OMRv1();
     InitializeComponent();
     ButtonEdit.Visibility   = Visibility.Hidden;
     ButtonAddInfo.IsEnabled = true;
     ButtonAddAns.IsEnabled  = true;
     (var list, var size)    = omr.GetPositionPoint(bitmap, circleSize);
     template            = new Template(bitmap, circleSize, list, size);
     preview             = OMR.ImageDrawing.Draw(OMR.ImageDrawing.Mode.Circle, bitmap, list, System.Drawing.Color.Black, 2);
     ImagePreview.Source = System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
         preview.GetHbitmap(),
         IntPtr.Zero,
         System.Windows.Int32Rect.Empty,
         BitmapSizeOptions.FromWidthAndHeight(preview.Width, preview.Height));
     CheckNext();
 }