Esempio n. 1
0
        private void DrawNumberButton(PrimesBigInteger value, double x, double y)
        {
            Ellipse nb = ControlHandler.CreateObject(typeof(Ellipse)) as Ellipse;

            //NumberButton nb = ControlHandler.CreateObject(typeof(NumberButton)) as NumberButton;
            //ControlHandler.SetPropertyValue(nb, "NumberButtonStyle", NumberButtonStyle.Ellipse.ToString());
            //ControlHandler.SetPropertyValue(nb, "BINumber", value);
            ControlHandler.SetPropertyValue(nb, "Width", 6);
            ControlHandler.SetPropertyValue(nb, "Height", 6);
            ToolTip tt = ControlHandler.CreateObject(typeof(ToolTip)) as ToolTip;

            ControlHandler.SetPropertyValue(tt, "Content", value.ToString());
            ControlHandler.SetPropertyValue(nb, "ToolTip", tt);

            //if (value.IsPrime(10))
            //  ControlHandler.SetPropertyValue(nb, "Background", Brushes.Blue);
            //else
            //  ControlHandler.SetPropertyValue(nb, "Background", Brushes.Gray);
            if (value.IsPrime(10))
            {
                ControlHandler.SetPropertyValue(nb, "Fill", Brushes.Blue);
            }
            else
            {
                ControlHandler.SetPropertyValue(nb, "Fill", Brushes.Gray);
            }

            ControlHandler.ExecuteMethod(PaintArea, "SetTop", new object[] { nb, y - 3 });
            ControlHandler.ExecuteMethod(PaintArea, "SetLeft", new object[] { nb, x - 3 });
            ControlHandler.AddChild(nb, PaintArea);
        }
Esempio n. 2
0
        //private ArrowLine GetLine(ArrowLine l)
        //{
        //    foreach (ArrowLine line in m_Arrows)
        //    {
        //        double srcx1 = (double)ControlHandler.GetPropertyValue(line, "X1");
        //        double srcx2 = (double)ControlHandler.GetPropertyValue(line, "X2");
        //        double srcy1 = (double)ControlHandler.GetPropertyValue(line, "Y1");
        //        double srcy2 = (double)ControlHandler.GetPropertyValue(line, "Y2");
        //        double destx1 = (double)ControlHandler.GetPropertyValue(l, "X1");
        //        double destx2 = (double)ControlHandler.GetPropertyValue(l, "X2");
        //        double desty1 = (double)ControlHandler.GetPropertyValue(l, "Y1");
        //        double desty2 = (double)ControlHandler.GetPropertyValue(l, "Y2");

        //        if (srcx1 == destx1 && srcx2 == destx2 && srcy1 == desty1 && srcy2 == desty2) return line;
        //    }
        //    return null;
        //}

        //private bool ContainsLine(ArrowLine l)
        //{
        //    return GetLine(l) != null;
        //}

        //public void AddCircle(PrimesBigInteger counter, double x, double y)
        //{
        //    Polyline p = ControlHandler.CreateObject(typeof(Polyline)) as Polyline;
        //    ControlHandler.SetPropertyValue(p, "Stroke", Brushes.Black);
        //    ControlHandler.SetPropertyValue(p, "StrokeThickness", 1.5);
        //    PointCollection pc = ControlHandler.GetPropertyValue(p, "Points") as PointCollection;
        //    int c = 16;
        //    double radius = 25;
        //    for (int value = 0; value <= c; value++)
        //    {
        //        double angle = (360.0 / (double)c) * value;
        //        double top = radius / 2 + (Math.Sin((angle * 2 * Math.PI) / 360.0) * radius / 2);
        //        double left = radius / 2 + (Math.Cos((angle * 2 * Math.PI) / 360.0) * radius / 2);
        //        ControlHandler.ExecuteMethod(pc, "Add", new object[] { new Point(top, left) });
        //    }
        //    if (!ContainsCircle(x, y))
        //    {
        //        m_Circles.Add(p);
        //        m_CirclesMark.Add(counter, p);
        //        ControlHandler.ExecuteMethod(ArrowArea, "SetLeft", new object[] { p, x });
        //        ControlHandler.ExecuteMethod(ArrowArea, "SetTop", new object[] { p, y });
        //        ControlHandler.AddChild(p, ArrowArea);
        //    }
        //    else
        //    {
        //        ResetCircle(counter, x, y);
        //    }
        //}

        public void AddCircle(PrimesBigInteger counter, Ellipse source)
        {
            Polyline p = ControlHandler.CreateObject(typeof(Polyline)) as Polyline;

            ControlHandler.SetPropertyValue(p, "Stroke", Brushes.Black);
            ControlHandler.SetPropertyValue(p, "StrokeThickness", 1.5);
            PointCollection pc     = ControlHandler.GetPropertyValue(p, "Points") as PointCollection;
            int             c      = 16;
            double          radius = 25;
            double          x      = (double)ControlHandler.ExecuteMethod(PaintArea, "GetLeft", source);
            double          y      = (double)ControlHandler.ExecuteMethod(PaintArea, "GetTop", source);

            for (int value = 0; value <= c; value++)
            {
                double angle = (360.0 / (double)c) * value;
                double top   = radius / 2 + (Math.Sin((angle * 2 * Math.PI) / 360.0) * radius / 2);
                double left  = radius / 2 + (Math.Cos((angle * 2 * Math.PI) / 360.0) * radius / 2);
                ControlHandler.ExecuteMethod(pc, "Add", new object[] { new Point(top, left) });
            }
            if (!m_CirclesSource.ContainsKey(source))
            {
                m_CirclesSource.Add(source, p);
                m_CirclesMark.Add(counter, p);
                ControlHandler.ExecuteMethod(ArrowArea, "SetLeft", new object[] { p, x });
                ControlHandler.ExecuteMethod(ArrowArea, "SetTop", new object[] { p, y });
                ControlHandler.AddChild(p, ArrowArea);
            }
            else
            {
                p = m_CirclesSource[source];
                ResetCircle(counter, p);
            }
        }
        private void Paint()
        {
            Ellipse el = ControlHandler.CreateObject(typeof(Ellipse)) as Ellipse;

            ControlHandler.SetPropertyValue(el, "Width", Aperture);
            ControlHandler.SetPropertyValue(el, "Height", Aperture);
            ControlHandler.ExecuteMethod(CircleArea, "SetTop", new object[] { el, 25 });
            ControlHandler.ExecuteMethod(CircleArea, "SetLeft", new object[] { el, 25 });
            ControlHandler.SetPropertyValue(el, "StrokeThickness", 1.0);
            ControlHandler.SetPropertyValue(el, "Stroke", Brushes.Black);
            ControlHandler.SetPropertyValue(el, "Name", "dontremove");

            ControlHandler.AddChild(el, CircleArea);

            //Ellipse middle = ControlHandler.CreateObject(typeof(Ellipse)) as Ellipse;
            //ControlHandler.SetPropertyValue(middle, "Width", 2);
            //ControlHandler.SetPropertyValue(middle, "Height", 2);
            //ControlHandler.ExecuteMethod(PaintArea, "SetTop", new object[] { middle, 25 + (Aperture / 2.0) - 1.0 });
            //ControlHandler.ExecuteMethod(PaintArea, "SetLeft", new object[] { middle, 25 + (Aperture / 2.0) - 1.0 });
            //ControlHandler.SetPropertyValue(middle, "StrokeThickness", 1.0);
            //ControlHandler.SetPropertyValue(middle, "Stroke", Brushes.Black);
            //ControlHandler.AddChild(middle, PaintArea);
            //Line l = ControlHandler.CreateObject(typeof(Line)) as Line;
            //l.Y1 = l.Y2 = 25 + Radius;
            //l.X1 = 25 + Radius;
            //l.X2 = 25 + 2*Radius;

            //l.Stroke = Brushes.Black;
            //l.StrokeThickness = 1.0;

            //ControlHandler.AddChild(l, PaintArea);
        }
Esempio n. 4
0
        private void Paint()
        {
            Ellipse el = ControlHandler.CreateObject(typeof(Ellipse)) as Ellipse;

            ControlHandler.SetPropertyValue(el, "Width", Aperture);
            ControlHandler.SetPropertyValue(el, "Height", Aperture);
            ControlHandler.ExecuteMethod(CircleArea, "SetTop", new object[] { el, Margin });
            ControlHandler.ExecuteMethod(CircleArea, "SetLeft", new object[] { el, Margin });
            ControlHandler.SetPropertyValue(el, "StrokeThickness", 1.0);
            ControlHandler.SetPropertyValue(el, "Stroke", Brushes.Black);
            ControlHandler.SetPropertyValue(el, "Name", "dontremove");
            ControlHandler.AddChild(el, CircleArea);
        }
Esempio n. 5
0
        private void DrawLine(double x1, double x2, double y1, double y2)
        {
            Line result = ControlHandler.CreateObject(typeof(Line)) as Line;

            ControlHandler.SetPropertyValue(result, "X1", x1);
            ControlHandler.SetPropertyValue(result, "X2", x2);
            ControlHandler.SetPropertyValue(result, "Y1", y1);
            ControlHandler.SetPropertyValue(result, "Y2", y2);
            ControlHandler.SetPropertyValue(result, "Stroke", Brushes.Black);
            ControlHandler.SetPropertyValue(result, "StrokeThickness", 0.5);

            ControlHandler.AddChild(result, PaintArea);
        }
Esempio n. 6
0
        private void CreatePoint(int value)
        {
            double x, y;

            GetCoords(value, out x, out y);
            y -= PointRadius;
            x -= PointRadius;

            Ellipse point = m_Points.ContainsKey(value) ? GetEllipseAt(m_Points[value]) : null;

            if (point == null)
            {
                point         = ControlHandler.CreateObject(typeof(Ellipse)) as Ellipse;
                point.ToolTip = new ToolTip();
                (point.ToolTip as ToolTip).Content = value.ToString();
                ControlHandler.SetPropertyValue(point, "Width", PointRadius * 2);
                ControlHandler.SetPropertyValue(point, "Height", PointRadius * 2);
                ControlHandler.SetPropertyValue(point, "Fill", Brushes.Black);
                ControlHandler.SetPropertyValue(point, "Stroke", Brushes.Black);
                ControlHandler.SetPropertyValue(point, "StrokeThickness", 1.0);
                ControlHandler.AddChild(point, PaintArea);
            }

            ControlHandler.ExecuteMethod(PaintArea, "SetLeft", new object[] { point, x });
            ControlHandler.ExecuteMethod(PaintArea, "SetTop", new object[] { point, y });

            if (m_CirclesSource.ContainsKey(point))
            {
                MoveCircle(point);
            }

            if (m_Points.ContainsKey(value))
            {
                m_Points[value] = new Point(x, y);
            }
            else
            {
                m_Points.Add(value, new Point(x, y));
            }

            Label  lbl   = ControlHandler.CreateLabel(value.ToString(), null);
            double _left = x - 5;
            double _top  = y;

            _left += (x < Radius) ? -7 + (-2 * (int)Math.Log(value)) : 2;
            _top  += (y < Radius) ? -20 : 0;
            ControlHandler.ExecuteMethod(PaintArea, "SetLeft", new object[] { lbl, _left });
            ControlHandler.ExecuteMethod(PaintArea, "SetTop", new object[] { lbl, _top });
            ControlHandler.AddChild(lbl, LabelArea);
        }
Esempio n. 7
0
        //private void CreateArrow(PrimesBigInteger counter, Point from, Point to)
        //{
        //    ArrowLine l = null;
        //    if (from.X == to.X && from.Y == to.Y)
        //    {
        //        AddCircle(counter, from.X, from.Y);
        //    }
        //    else
        //    {
        //        l = ControlHandler.CreateObject(typeof(ArrowLine)) as ArrowLine;
        //        ControlHandler.SetPropertyValue(l, "Stroke", Brushes.Black);
        //        ControlHandler.SetPropertyValue(l, "StrokeThickness", 1.5);
        //        //ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.X1Property, new Binding("(Point.X)") { Source = from  }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } });
        //        //ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.Y1Property, new Binding("(Point.Y)") { Source = from }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } });
        //        //ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.X2Property, new Binding("(Point.X)") { Source = to }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } });
        //        //ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.Y2Property, new Binding("(Point.Y)") { Source = to }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } });
        //        //l.SetBinding(Line.X1Property, new Binding("(Point.X)") { Source = from, Converter = new myc() });
        //        //l.SetBinding(Line.Y1Property, new Binding("(Point.Y)") { Source = from, Converter = new myc() });
        //        //l.SetBinding(Line.X2Property, new Binding("(Point.X)") { Source = to, Converter = new myc() });
        //        //l.SetBinding(Line.Y2Property, new Binding("(Point.Y)") { Source = to, Converter = new myc() });

        //        ControlHandler.SetPropertyValue(l, "X1", from.X);
        //        ControlHandler.SetPropertyValue(l, "Y1", from.Y);
        //        ControlHandler.SetPropertyValue(l, "X2", to.X);
        //        ControlHandler.SetPropertyValue(l, "Y2", to.Y);
        //        if (!ContainsLine(l))
        //        {
        //            ControlHandler.AddChild(l, ArrowArea);
        //            m_Arrows.Add(l);
        //            m_ArrowsMark.Add(counter, l);
        //        }
        //        else
        //        {
        //            ResetLine(counter, l);
        //        }
        //    }
        //}

        private void CreateArrow(PrimesBigInteger counter, Ellipse from, Ellipse to)
        {
            if (from == to)
            {
                AddCircle(counter, from);
            }
            else
            {
                ArrowLine l = ControlHandler.CreateObject(typeof(ArrowLine)) as ArrowLine;
                ControlHandler.SetPropertyValue(l, "Stroke", Brushes.Black);
                ControlHandler.SetPropertyValue(l, "StrokeThickness", 1.5);
                //ControlHandler.SetPropertyValue(l, "X1", (double)ControlHandler.ExecuteMethod(PaintArea, "GetLeft", from)+3);
                //ControlHandler.SetPropertyValue(l, "Y1", (double)ControlHandler.ExecuteMethod(PaintArea, "GetTop", from)+3);
                //ControlHandler.SetPropertyValue(l, "X2", (double)ControlHandler.ExecuteMethod(PaintArea, "GetLeft", to)+3);
                //ControlHandler.SetPropertyValue(l, "Y2", (double)ControlHandler.ExecuteMethod(PaintArea, "GetTop", to)+3);
                ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.X1Property, new Binding("(Canvas.Left)")
                                                                             {
                                                                                 Source = from
                                                                             }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } });
                ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.Y1Property, new Binding("(Canvas.Top)")
                                                                             {
                                                                                 Source = from
                                                                             }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } });
                ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.X2Property, new Binding("(Canvas.Left)")
                                                                             {
                                                                                 Source = to
                                                                             }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } });
                ControlHandler.ExecuteMethod(l, "SetBinding", new object[] { ArrowLine.Y2Property, new Binding("(Canvas.Top)")
                                                                             {
                                                                                 Source = to
                                                                             }, new Type[] { typeof(DependencyProperty), typeof(BindingBase) } });

                Pair <Ellipse, Ellipse> pair = new Pair <Ellipse, Ellipse>(from, to);
                if (!m_SourceDestination.Contains(pair))
                {
                    m_SourceDestination.Add(pair);
                    m_ArrowsWithSourceAndDestination.Add(pair, l);
                    ControlHandler.AddChild(l, ArrowArea);
                    //m_Arrows.Add(l);
                    m_ArrowsMark.Add(counter, l);
                }
                else if (m_ArrowsWithSourceAndDestination.ContainsKey(pair))
                {
                    l = m_ArrowsWithSourceAndDestination[pair];
                    ResetLine(counter, l);
                }
            }
        }
Esempio n. 8
0
        private void DrawNumberButton(PrimesBigInteger value, double x, double y, double width, double height)
        {
            NumberButton nb = ControlHandler.CreateObject(typeof(NumberButton)) as NumberButton;

            nb.MouseEnter += new MouseEventHandler(nb_MouseMove);
            //nb.MouseLeave += new MouseEventHandler(nb_MouseLeave);
            nb.Cursor = Cursors.Hand;
            ControlHandler.SetPropertyValue(nb, "NumberButtonStyle", NumberButtonStyle.Ellipse.ToString());
            ControlHandler.SetPropertyValue(nb, "BINumber", value);
            ControlHandler.SetPropertyValue(nb, "Width", width);
            ControlHandler.SetPropertyValue(nb, "Height", height);
            ControlHandler.SetPropertyValue(nb, "BorderBrush", Brushes.Black);
            SetButtonColor(nb);

            ControlHandler.ExecuteMethod(PaintArea, "SetTop", new object[] { nb, y - height / 2 });
            ControlHandler.ExecuteMethod(PaintArea, "SetLeft", new object[] { nb, x - width / 2 });
            ControlHandler.AddChild(nb, PaintArea);
            m_Buttons.Add(nb);
            m_ButtonsDict.Add(value, nb);
        }
        private void CreateArrow(PrimesBigInteger i, Point from, Point to)
        {
            ArrowLine l = ControlHandler.CreateObject(typeof(ArrowLine)) as ArrowLine;

            ControlHandler.SetPropertyValue(l, "Stroke", Brushes.Black);
            ControlHandler.SetPropertyValue(l, "StrokeThickness", 1.0);
            ControlHandler.SetPropertyValue(l, "X1", from.X);
            ControlHandler.SetPropertyValue(l, "Y1", from.Y);
            ControlHandler.SetPropertyValue(l, "X2", to.X);
            ControlHandler.SetPropertyValue(l, "Y2", to.Y);
            if (!ContainsLine(l))
            {
                ControlHandler.AddChild(l, ArrowArea);
                m_Arrows.Add(i, l);
            }
            else
            {
                ResetLine(l);
            }
        }
Esempio n. 10
0
        private void CreatePoint(int value)
        {
            double pointsize = 4.0;
            double angle     = (360.0 / (double)m_Value.IntValue) * value;
            double top       = Radius + 25 + (Math.Sin((angle * 2 * Math.PI) / 360.0) * Radius - (pointsize / 2.0));
            double left      = Radius + 25 + (Math.Cos((angle * 2 * Math.PI) / 360.0) * Radius - (pointsize / 2.0));

            Ellipse point = ControlHandler.CreateObject(typeof(Ellipse)) as Ellipse;

            ControlHandler.SetPropertyValue(point, "Width", pointsize);
            ControlHandler.SetPropertyValue(point, "Height", pointsize);
            ControlHandler.ExecuteMethod(PaintArea, "SetTop", new object[] { point, top });
            ControlHandler.ExecuteMethod(PaintArea, "SetLeft", new object[] { point, left });
            ControlHandler.SetPropertyValue(point, "Fill", Brushes.Black);
            ControlHandler.SetPropertyValue(point, "Stroke", Brushes.Black);
            ControlHandler.SetPropertyValue(point, "StrokeThickness", 1.0);
            ControlHandler.AddChild(point, PaintArea);

            Label  lbl   = ControlHandler.CreateLabel(value.ToString(), null);
            double _top  = top;
            double _left = left - 5;

            _top  += (top < Radius) ? -20 : 0;
            _left += (left < Radius) ? -7 + (-2 * (int)Math.Log(value)) : 2;
            ControlHandler.ExecuteMethod(PaintArea, "SetTop", new object[] { lbl, _top });
            ControlHandler.ExecuteMethod(PaintArea, "SetLeft", new object[] { lbl, _left });
            ControlHandler.AddChild(lbl, PaintArea);
            if (m_Points.ContainsKey(value))
            {
                m_Points[value] = new Point(left, top);
            }
            else
            {
                m_Points.Add(value, new Point(left, top));
            }
        }