public GeneratorCracker(MyBigInteger first) { var curve = MyCurve.GetP256NistCurve(); _randomValues = new Queue <MyBigInteger>(); _generatedPointBatches = new PointGenerator(curve, first).GeneratePoints(); }
public ClassicCurve(List <PointF> points, GesturesCollection gestures) { string name = "curve_name"; int postfix = 1; while (gestures.GetCurve(name + postfix.ToString()) != null) { postfix++; } m_id = name + postfix.ToString(); m_points = MyCurve.CreateExactPath(points, 20, 20); m_bezierCurve = MyCurve.CreateBezierCurve(points); m_type = Types.ClassicCurve; }
public override void Display_MouseMove(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && m_mouseDown && m_pathPoints != null && m_pen != null) { if (m_tempGesture.Activator != null && m_tempGesture.Activator.AbortAnimating()) { m_gp.FillRectangle(Brushes.White, 0, 0, m_pbDisplay.Width, m_pbDisplay.Height); } Point point = new Point(e.X, e.Y); m_pathPoints.Add(point); m_curveLength += MyCurve.Distance(m_pathPoints[m_pathPoints.Count - 2], m_pathPoints[m_pathPoints.Count - 1]); Color penColor = m_pen.Color; if (m_curveLength < CURVE_MIN_LENGTH || m_curveLength >= 1500) { m_pen.Color = Color.Red; } else if (m_curveLength >= 100 && m_curveLength < 300 || m_curveLength >= 1300 && m_curveLength < 1500) { m_pen.Color = Color.Orange; } else { m_pen.Color = Color.Green; } if (penColor != m_pen.Color) { for (int i = 0; i < m_pathPoints.Count - 1; i++) { m_gp.DrawLine(m_pen, m_pathPoints[i], m_pathPoints[i + 1]); } } m_gp.DrawLine(m_pen, m_pathPoints[m_pathPoints.Count - 1], m_pathPoints[m_pathPoints.Count - 2]); m_pbDisplay.Invalidate(); } }
public MyPoint(MyBigInteger x, MyBigInteger y, MyCurve curve) { X = x; Y = y; Curve = curve; }
public override void AnimateToPictureBox(System.Windows.Forms.PictureBox pictureBox) { MyCurve.DrawCurve(pictureBox, m_bezierCurve, DELAY); }
public override void DrawToPictureBox(System.Windows.Forms.PictureBox pictureBox) { MyCurve.DrawCurve(pictureBox, m_bezierCurve, 0); }
public override Bitmap ExtractIcon(Size size) { return(MyCurve.DrawCurveToBmp(m_bezierCurve, size)); }
public PointGenerator(MyCurve curve, MyBigInteger randomValue) { _curve = curve; _randomValue = randomValue; }
//private double GetOutPointsRatio(string learntCurveName) //{ // ClassicCurve learntCurve = m_gesturesCollection.GetCurve(learntCurveName); // if (learntCurve != null) // { // Rectangle rect = new Rectangle(0, 0, 20, 20); // int parts = 5; // List<PointF> centerLearnPoints = MyCurve.ScaleToCenter(MyCurve.CreateExactPath(learntCurve.Points, 1, 2), rect); // int centerCount = centerLearnPoints.Count / parts; // List<PointF> centerPoints = MyCurve.ScaleToCenter(MyCurve.CreateExactPath(m_pathPoints, 1, 2), rect); // int testCount = centerPoints.Count / parts; // int outPoints = 0; // for (int i = 0; i < parts; i++) // { // int centerMax = centerCount; // int testMax =testCount; // if (i + 1 == parts) // { // centerMax = centerLearnPoints.Count - i * centerCount; // testMax = centerPoints.Count - i * testCount; // } // System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); // List<PointF> center10 = centerLearnPoints.GetRange(i * centerCount, centerMax); // path.AddLines(center10.ToArray()); // path.Widen(new Pen(Color.Green, 3)); // List<PointF> test10 = centerPoints.GetRange(i * testCount, testMax); // foreach (PointF point in test10) // { // if (!path.IsVisible(point)) // outPoints++; // } // m_gp.DrawPath(new Pen(Brushes.Yellow, 1), path); // m_gp.DrawLines(new Pen(Brushes.Red, 1), test10.ToArray()); // } // m_pbDisplay.Invalidate(); // double ratio = outPoints / (double)centerPoints.Count; // Debug.WriteLine("Ratio of points out of region is: " + ratio); // return ratio; // } // return 1; //} #endregion Not in use public override void Display_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && m_pathPoints.Count > 1) { m_mouseDown = false; MyCurve curve = new MyCurve(m_pathPoints, true); if (m_curveLength > CURVE_MIN_LENGTH) { //if (curve != null && curve.Points.Count > 1) //{ // List<PointF> rotated = MyCurve.RotateCurve(curve.Points, 10); // m_gp.DrawLines(new Pen(Brushes.Yellow, 2), rotated.ToArray()); // rotated = MyCurve.RotateCurve(curve.Points, -10); // m_gp.DrawLines(new Pen(Brushes.Pink, 2), rotated.ToArray()); // m_pbDisplay.Invalidate(); //} //return; //if (curve != null && curve.Points.Count > 1) //{ // List<PointF> resized = MyCurve.ResizeCurve(curve.Points, 0.25, 0); // m_gp.DrawLines(new Pen(Brushes.Yellow, 2), resized.ToArray()); // resized = MyCurve.ResizeCurve(curve.Points, -0.25, 0); // m_gp.DrawLines(new Pen(Brushes.Pink, 2), resized.ToArray()); // m_pbDisplay.Invalidate(); //} //return; //m_network.StopLearning(); m_newCurveUsed = true; m_networkTrained.StopLearning(); m_network = new MyNeuralNetwork(m_networkBackup); m_shortCurve = false; double divergence; string name = m_network.RecognizeCurve(curve.GetScaledInput(), out divergence); m_tooMuchSimilar = (divergence >= 0 && divergence < MAX_DIVERGENCE); if (name != string.Empty) { if (m_tooMuchSimilar) m_newCurve = m_gesturesCollection.GetCurve(name); else m_newCurve = new ClassicCurve(m_pathPoints, m_gesturesCollection); rB_newCurve.Enabled = !m_tooMuchSimilar; lv_curvesList.Focus(); lv_curvesList.EnsureVisible(lv_curvesList.Items[name].Index); if (!lv_curvesList.Items[name].Selected) lv_curvesList.Items[name].Selected = true; else { if (!rB_suggestedCurve.Checked) rB_suggestedCurve.Checked = true; else { lv_curvesList.Items[name].Selected = false; lv_curvesList.Items[name].Selected = true; //panel_curveDraw.Refresh(); } } } else { m_newCurve = new ClassicCurve(m_pathPoints, m_gesturesCollection); rB_newCurve.Enabled = true; if (!rB_newCurve.Checked) rB_newCurve.Checked = true; else { Debug.WriteLine("Drawing - MouseUp (new gesture)"); m_newCurve.DrawToPictureBox(m_pbDisplay); SetNewGesture(); } } OnCanContinue(true); SetInfoValues(); } else { m_newCurve = null; m_shortCurve = true; //Debug.WriteLine("Drawing - MouseUp (short gesture)"); m_gp = Graphics.FromImage(m_pbDisplay.Image); m_gp.FillRectangle(Brushes.White, 0, 0, m_pbDisplay.Width, m_pbDisplay.Height); m_pbDisplay.Invalidate(); m_pbDisplay.Focus(); rB_newCurve.Enabled = false; OnCanContinue(false); SetInfoValues(); } m_gp.Dispose(); } }
//private double GetOutPointsRatio(string learntCurveName) //{ // ClassicCurve learntCurve = m_gesturesCollection.GetCurve(learntCurveName); // if (learntCurve != null) // { // Rectangle rect = new Rectangle(0, 0, 20, 20); // int parts = 5; // List<PointF> centerLearnPoints = MyCurve.ScaleToCenter(MyCurve.CreateExactPath(learntCurve.Points, 1, 2), rect); // int centerCount = centerLearnPoints.Count / parts; // List<PointF> centerPoints = MyCurve.ScaleToCenter(MyCurve.CreateExactPath(m_pathPoints, 1, 2), rect); // int testCount = centerPoints.Count / parts; // int outPoints = 0; // for (int i = 0; i < parts; i++) // { // int centerMax = centerCount; // int testMax =testCount; // if (i + 1 == parts) // { // centerMax = centerLearnPoints.Count - i * centerCount; // testMax = centerPoints.Count - i * testCount; // } // System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); // List<PointF> center10 = centerLearnPoints.GetRange(i * centerCount, centerMax); // path.AddLines(center10.ToArray()); // path.Widen(new Pen(Color.Green, 3)); // List<PointF> test10 = centerPoints.GetRange(i * testCount, testMax); // foreach (PointF point in test10) // { // if (!path.IsVisible(point)) // outPoints++; // } // m_gp.DrawPath(new Pen(Brushes.Yellow, 1), path); // m_gp.DrawLines(new Pen(Brushes.Red, 1), test10.ToArray()); // } // m_pbDisplay.Invalidate(); // double ratio = outPoints / (double)centerPoints.Count; // Debug.WriteLine("Ratio of points out of region is: " + ratio); // return ratio; // } // return 1; //} #endregion Not in use public override void Display_MouseUp(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left && m_pathPoints.Count > 1) { m_mouseDown = false; MyCurve curve = new MyCurve(m_pathPoints, true); if (m_curveLength > CURVE_MIN_LENGTH) { //if (curve != null && curve.Points.Count > 1) //{ // List<PointF> rotated = MyCurve.RotateCurve(curve.Points, 10); // m_gp.DrawLines(new Pen(Brushes.Yellow, 2), rotated.ToArray()); // rotated = MyCurve.RotateCurve(curve.Points, -10); // m_gp.DrawLines(new Pen(Brushes.Pink, 2), rotated.ToArray()); // m_pbDisplay.Invalidate(); //} //return; //if (curve != null && curve.Points.Count > 1) //{ // List<PointF> resized = MyCurve.ResizeCurve(curve.Points, 0.25, 0); // m_gp.DrawLines(new Pen(Brushes.Yellow, 2), resized.ToArray()); // resized = MyCurve.ResizeCurve(curve.Points, -0.25, 0); // m_gp.DrawLines(new Pen(Brushes.Pink, 2), resized.ToArray()); // m_pbDisplay.Invalidate(); //} //return; //m_network.StopLearning(); m_newCurveUsed = true; m_networkTrained.StopLearning(); m_network = new MyNeuralNetwork(m_networkBackup); m_shortCurve = false; double divergence; string name = m_network.RecognizeCurve(curve.GetScaledInput(), out divergence); m_tooMuchSimilar = (divergence >= 0 && divergence < MAX_DIVERGENCE); if (name != string.Empty) { if (m_tooMuchSimilar) { m_newCurve = m_gesturesCollection.GetCurve(name); } else { m_newCurve = new ClassicCurve(m_pathPoints, m_gesturesCollection); } rB_newCurve.Enabled = !m_tooMuchSimilar; lv_curvesList.Focus(); lv_curvesList.EnsureVisible(lv_curvesList.Items[name].Index); if (!lv_curvesList.Items[name].Selected) { lv_curvesList.Items[name].Selected = true; } else { if (!rB_suggestedCurve.Checked) { rB_suggestedCurve.Checked = true; } else { lv_curvesList.Items[name].Selected = false; lv_curvesList.Items[name].Selected = true; //panel_curveDraw.Refresh(); } } } else { m_newCurve = new ClassicCurve(m_pathPoints, m_gesturesCollection); rB_newCurve.Enabled = true; if (!rB_newCurve.Checked) { rB_newCurve.Checked = true; } else { Debug.WriteLine("Drawing - MouseUp (new gesture)"); m_newCurve.DrawToPictureBox(m_pbDisplay); SetNewGesture(); } } OnCanContinue(true); SetInfoValues(); } else { m_newCurve = null; m_shortCurve = true; //Debug.WriteLine("Drawing - MouseUp (short gesture)"); m_gp = Graphics.FromImage(m_pbDisplay.Image); m_gp.FillRectangle(Brushes.White, 0, 0, m_pbDisplay.Width, m_pbDisplay.Height); m_pbDisplay.Invalidate(); m_pbDisplay.Focus(); rB_newCurve.Enabled = false; OnCanContinue(false); SetInfoValues(); } m_gp.Dispose(); } }