示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#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);
        }
示例#7
0
        public int NewLine()
        {
            m_CurrentRow++;
            RowDefinitionCollection rowDefinitions =
                ControlHandler.GetPropertyValue(gridMessages, "RowDefinitions") as RowDefinitionCollection;
            RowDefinition rd = ControlHandler.CreateObject(typeof(RowDefinition)) as RowDefinition;

            GridLength gl = (GridLength)ControlHandler.CreateObject(typeof(GridLength), new Type[] { typeof(double), typeof(GridUnitType) }, new object[] { 1, GridUnitType.Auto });

            ControlHandler.SetPropertyValue(rd, "Height", gl);

            ControlHandler.ExecuteMethod(rowDefinitions, "Add", new object[] { rd });
            return(m_CurrentRow);
        }
示例#8
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);
                }
            }
        }
示例#9
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);
        }
示例#10
0
        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);
            }
        }
示例#11
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));
            }
        }
示例#12
0
        private void DrawGrid()
        {
            UIElementCollection childs = ControlHandler.GetPropertyValue(this.NumberRectangle, "Children") as UIElementCollection;

            ControlHandler.ExecuteMethod(childs, "Clear");

            RowDefinitionCollection rowdefs = ControlHandler.GetPropertyValue(this.NumberRectangle, "RowDefinitions") as RowDefinitionCollection;

            ControlHandler.ExecuteMethod(rowdefs, "Clear");

            ColumnDefinitionCollection coldefs = ControlHandler.GetPropertyValue(this.NumberRectangle, "ColumnDefinitions") as ColumnDefinitionCollection;

            ControlHandler.ExecuteMethod(coldefs, "Clear");

            for (int i = 0; i < this.Rows + this.Rows - 1; i++)
            {
                GridLength gl = GridLength.Auto;
                if (i % 2 == 0)
                {
                    gl = (GridLength)ControlHandler.CreateObject(typeof(GridLength), new Type[] { typeof(double), typeof(GridUnitType) }, new object[] { 1.0 / this.Rows, GridUnitType.Star });
                }
                else
                {
                    gl = (GridLength)ControlHandler.CreateObject(typeof(GridLength), new Type[] { typeof(double), typeof(GridUnitType) }, new object[] { 1, GridUnitType.Pixel });
                    //rd.Height = new GridLength();
                    //Rectangle rect = new Rectangle();
                    //rect.Height = 1.0;
                    //rect.Fill = Brushes.Black;
                    //Grid.SetColumnSpan(rect, this.Columns + this.Columns - 1);
                    //Grid.SetRow(rect, i);
                    //this.NumberRectangle.Children.Add(rect);
                }
                RowDefinition rd = ControlHandler.CreateObject(typeof(RowDefinition)) as RowDefinition;
                ControlHandler.SetPropertyValue(rd, "Height", gl);
                ControlHandler.ExecuteMethod(rowdefs, "Add", new object[] { rd });

                //this.NumberRectangle.RowDefinitions.Add(rd);
            }

            for (int i = 0; i < this.Columns + this.Columns - 1; i++)
            {
                GridLength gl = GridLength.Auto;
                if (i % 2 == 0)
                {
                    gl = (GridLength)ControlHandler.CreateObject(typeof(GridLength), new Type[] { typeof(double), typeof(GridUnitType) }, new object[] { 1.0 / this.Columns, GridUnitType.Star });
                }
                else
                {
                    gl = (GridLength)ControlHandler.CreateObject(typeof(GridLength), new Type[] { typeof(double), typeof(GridUnitType) }, new object[] { 1, GridUnitType.Pixel });
                    //Rectangle rect = new Rectangle();
                    //rect.Width = 1.0;
                    //rect.Fill = Brushes.Black;
                    //Grid.SetRowSpan(rect, this.Rows + this.Rows - 1);
                    //Grid.SetColumn(rect, i);
                    //this.NumberRectangle.Children.Add(rect);
                }
                ColumnDefinition cd = ControlHandler.CreateObject(typeof(ColumnDefinition)) as ColumnDefinition;
                ControlHandler.SetPropertyValue(cd, "Width", gl);

                ControlHandler.ExecuteMethod(coldefs, "Add", new object[] { cd });
            }
        }
示例#13
0
        public void _AddMessage(string message, Brush color, int column, int row)
        {
            lock (logobjext)
            {
                if (message != null)
                {
                    UIElementCollection childs = ControlHandler.GetPropertyValue(gridMessages, "Children") as UIElementCollection;
                    column++;
                    TextBlock tb = null;
                    if (m_OverrideText)
                    {
                        TextBlock _tb = this.Get(column, row);
                        if (_tb != null)
                        {
                            tb = _tb;
                            gridMessages.Children.Remove(tb);
                        }
                        else
                        {
                            tb = ControlHandler.CreateObject(typeof(TextBlock)) as TextBlock;
                        }
                    }
                    else
                    {
                        tb = ControlHandler.CreateObject(typeof(TextBlock)) as TextBlock;
                    }
                    ControlHandler.SetPropertyValue(tb, "TextWrapping", TextWrapping.Wrap);
                    ControlHandler.SetPropertyValue(tb, "Text", message);
                    ControlHandler.SetPropertyValue(tb, "Foreground", color);
                    //ControlHandler.SetPropertyValue(tb, "Width", Math.Max(this.ActualWidth - 100, 50));
                    ControlHandler.SetPropertyValue(tb, "FontSize", 12);
                    ControlHandler.SetPropertyValue(tb, "HorizontalAlignment", HorizontalAlignment.Left);
                    tb.Padding = new Thickness(10, 5, 10, 5);

                    if (!string.IsNullOrEmpty(message.Trim()))
                    {
                        tb.MouseLeftButtonDown += new MouseButtonEventHandler(tb_MouseLeftButtonDown);
                        tb.MouseMove           += new MouseEventHandler(tb_MouseMove);
                        tb.MouseLeave          += new MouseEventHandler(tb_MouseLeave);
                    }
                    Grid.SetColumn(tb, column);
                    Grid.SetRow(tb, row);
                    gridMessages.Children.Add(tb);
                    //ControlHandler.ExecuteMethod(gridMessages, "SetColumn", new object[] { tb, column });
                    //ControlHandler.ExecuteMethod(gridMessages, "SetRow", new object[] { tb, row });
                    //ControlHandler.AddChild(tb, gridMessages);
                    //ControlHandler.ExecuteMethod(childs, "Add", new object[] { tb });
                    if (m_FormerRow != m_CurrentRow)
                    {
                        NewLine();
                        if (m_ShowCounter)
                        {
                            TextBlock tb1 = ControlHandler.CreateObject(typeof(TextBlock)) as TextBlock;
                            ControlHandler.SetPropertyValue(tb1, "TextWrapping", TextWrapping.Wrap);
                            ControlHandler.SetPropertyValue(tb1, "Text", counter.ToString() + ". ");
                            ControlHandler.SetPropertyValue(tb1, "Foreground", color);
                            ControlHandler.SetPropertyValue(tb1, "FontSize", 12);
                            ControlHandler.SetPropertyValue(tb1, "HorizontalAlignment", HorizontalAlignment.Left);

                            Grid.SetColumn(tb1, 0);
                            Grid.SetRow(tb1, row);
                            gridMessages.Children.Add(tb1);

                            //ControlHandler.ExecuteMethod(gridMessages, "SetColumn", new object[] { tb1, 0 });
                            //ControlHandler.ExecuteMethod(gridMessages, "SetRow", new object[] { tb1, row });
                            //ControlHandler.AddChild(tb1, gridMessages);
                        }
                        Rectangle rec = (Rectangle)ControlHandler.CreateObject(typeof(Rectangle));
                        ControlHandler.SetPropertyValue(rec, "Width", Math.Max(this.ActualWidth - 100, 50));
                        ControlHandler.SetPropertyValue(rec, "Fill", Brushes.LightGray);
                        ControlHandler.SetPropertyValue(rec, "Height", 1.0);
                        ControlHandler.SetPropertyValue(rec, "HorizontalAlignment", HorizontalAlignment.Left);
                        ControlHandler.SetPropertyValue(rec, "VerticalAlignment", VerticalAlignment.Bottom);

                        if (m_Columns > 0)
                        {
                            Grid.SetColumnSpan(rec, m_Columns);
                        }
                        Grid.SetRow(rec, m_CurrentRow);
                        gridMessages.Children.Add(rec);

                        //ControlHandler.ExecuteMethod(gridMessages, "SetColumnSpan", new object[] { rec, m_Columns });
                        //ControlHandler.ExecuteMethod(gridMessages, "SetRow", new object[] { rec, m_CurrentRow });
                        //ControlHandler.AddChild(rec, gridMessages);
                        counter++;
                        m_FormerRow = m_CurrentRow;
                    }

                    ControlHandler.ExecuteMethod(scroller, "ScrollToEnd");
                }
            }
        }