public void LockAll() { rangeinputcontrol.LockControls(); //ControlHandler.SetPropertyValue(ircRandomChooseXRange, "IsEnabled", false); //ControlHandler.SetPropertyValue(icNumberOfFormulars, "IsEnabled", false); //ControlHandler.SetPropertyValue(ircSystematicChooseXRange, "IsEnabled", false); //ControlHandler.SetPropertyValue(rbChooseRandom, "IsEnabled", false); //ControlHandler.SetPropertyValue(rbChooseRange, "IsEnabled", false); UIElementCollection childs = ControlHandler.GetPropertyValue(pnlFactors, "Children") as UIElementCollection; if (childs != null) { IEnumerator _enum = ControlHandler.ExecuteMethod(childs, "GetEnumerator") as IEnumerator; while ((bool)ControlHandler.ExecuteMethod(_enum, "MoveNext")) { UIElement element = ControlHandler.GetPropertyValue(_enum, "Current") as UIElement; if (element.GetType() == typeof(InputSingleControl)) { (element as InputSingleControl).LockControls(); } } } }
//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); } }
public void AddToGrid(Grid g, string text, int row, int col, int rowspan = 0, int columnspan = 0) { ControlHandler.ExecuteMethod( this, "_AddToGrid", new object[] { g, text, row, col, rowspan, columnspan }); }
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); }
private void Step1() { long sqrt = (long)Math.Floor(Math.Sqrt(m_Value)) + 1; ControlHandler.SetPropertyValue( lblInfoStep1, "Text", string.Format(Primes.Resources.lang.WpfControls.Factorization.Factorization.qs_step1_squareroot, new object[] { m_Value.ToString("D"), Math.Sqrt(m_Value).ToString("N"), sqrt })); int counter = 0; ControlHandler.ExecuteMethod(this, "PrepareStep1"); for (long i = Math.Min(m_Count, 0); i <= Math.Abs(m_Count); i++) { ControlHandler.AddRowDefintion(gridFirstStep, 1, GridUnitType.Auto); string a = (sqrt + counter).ToString("N") + "²"; string aminus1 = (Math.Pow((sqrt + counter), 2) - m_Value).ToString("N"); ControlHandler.ExecuteMethod( this, "AddToGrid", new object[] { gridFirstStep, a, counter + 1, 0, 0, 0 }); ControlHandler.ExecuteMethod( this, "AddToGrid", new object[] { gridFirstStep, aminus1, counter + 1, 1, 0, 0 }); counter++; } }
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); }
public void MoveCircle(Ellipse source) { Polyline pl = m_CirclesSource[source]; double x = (double)ControlHandler.ExecuteMethod(PaintArea, "GetLeft", source); double y = (double)ControlHandler.ExecuteMethod(PaintArea, "GetTop", source); ControlHandler.ExecuteMethod(ArrowArea, "SetLeft", new object[] { pl, x }); ControlHandler.ExecuteMethod(ArrowArea, "SetTop", new object[] { pl, y }); }
public TextBoxValidator(IValidator <T> validator, TextBox tbSource, string defaultvalue) : this(validator, tbSource) { if (string.IsNullOrEmpty(tbSource.Text)) { Validator.Value = defaultvalue; ControlHandler.SetPropertyValue(tbSource, "Text", defaultvalue); ControlHandler.ExecuteMethod(tbSource, "SelectAll"); } }
//class myc : IValueConverter //{ // #region IValueConverter Members // public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) // { // return value; // } // public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture) // { // return value; // } // #endregion //} private void ResetLine(PrimesBigInteger counter, ArrowLine l) { if (l != null) { m_ArrowsMark.Add(counter, l); UIElementCollection children = ControlHandler.GetPropertyValue(ArrowArea, "Children") as UIElementCollection; ControlHandler.ExecuteMethod(children, "Remove", new object[] { l }); Thread.Sleep(100); ControlHandler.ExecuteMethod(children, "Add", new object[] { l }); } }
private void ClearArrows() { UIElementCollection childs = ControlHandler.GetPropertyValue(ArrowArea, "Children") as UIElementCollection; ControlHandler.ExecuteMethod(childs, "Clear"); //m_Arrows.Clear(); //m_Circles.Clear(); m_ArrowsWithSourceAndDestination.Clear(); m_CirclesSource.Clear(); m_ArrowsMark.Clear(); m_CirclesMark.Clear(); }
private void ResetCircle(PrimesBigInteger counter, Polyline p) { if (p != null) { m_CirclesMark.Add(counter, p); UIElementCollection children = ControlHandler.GetPropertyValue(ArrowArea, "Children") as UIElementCollection; ControlHandler.ExecuteMethod(children, "Remove", new object[] { p }); Thread.Sleep(100); ControlHandler.ExecuteMethod(children, "Add", new object[] { p }); } }
private void DrawThread() { FireEvent_StartDrawing(); double size = CalculateSize() * m_UnitWidth; ControlHandler.SetPropertyValue(PaintArea, "Width", size); ControlHandler.SetPropertyValue(PaintArea, "Height", size); double sawidth = (double)ControlHandler.GetPropertyValue(PaintArea, "Width"); double saheight = (double)ControlHandler.GetPropertyValue(PaintArea, "Height"); ControlHandler.ExecuteMethod(sv, "ScrollToVerticalOffset", new object[] { sawidth / 2.0 }); ControlHandler.ExecuteMethod(sv, "ScrollToHorizontalOffset", new object[] { saheight / 2.0 }); int direction = 0; double x1 = size / 2.0; double y1 = size / 2.0; int lenghtFactor = 0; long value = m_From.LongValue; while (value <= m_To.LongValue) { if (direction % 2 == 0) { lenghtFactor++; } double x2 = x1, y2 = y1; Calculate(x1, y1, (Direction)direction, lenghtFactor, ref x2, ref y2); DrawLine(x1, x2, y1, y2); for (int j = 0; j < lenghtFactor; j++) { if (value > m_To) { break; } x2 = x1; y2 = y1; Calculate(x1, y1, (Direction)direction, 1, ref x2, ref y2); if (PrimeNumbers.isprime.Contains(value)) { DrawNumberButton(value, x1, y1); } value = value + 1; x1 = x2; y1 = y2; } direction = (direction + 1) % 4; } FireEvent_StopDrawing(); }
private void ResetLine(ArrowLine l) { ArrowLine ltmp = GetLine(l); if (ltmp != null) { UIElementCollection children = ControlHandler.GetPropertyValue(ArrowArea, "Children") as UIElementCollection; ControlHandler.ExecuteMethod(children, "Remove", new object[] { ltmp }); Thread.Sleep(100); ControlHandler.ExecuteMethod(children, "Add", new object[] { ltmp }); } }
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); }
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); }
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); }
public void Reset() { items.Clear(); m_MapEllipseItems.Clear(); m_FactorTree.Clear(); m_Manager.Clear(); UIElementCollection childs = ControlHandler.GetPropertyValue(PaintArea, "Children") as UIElementCollection; ControlHandler.ExecuteMethod(childs, "Clear"); ControlHandler.SetPropertyValue(PaintArea, "Height", 0); ControlHandler.SetPropertyValue(PaintArea, "Width", 0); ControlHandler.SetPropertyValue(lblActualDivisor, "Text", ""); //sv.ScrollToRightEnd(); //sv.ScrollToBottom(); }
//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); } } }
private void DrawButtons() { double x1 = 0; double x2 = 8; if (m_Buttons.Count > 0) { x1 = (double)ControlHandler.ExecuteMethod(PaintArea, "GetLeft", new object[] { m_Buttons[0] }); x2 = (double)ControlHandler.ExecuteMethod(PaintArea, "GetLeft", new object[] { m_Buttons[1] }); } UIElementCollection children = ControlHandler.GetPropertyValue(PaintArea, "Children") as UIElementCollection; ControlHandler.ExecuteMethod(children, "Clear"); m_Buttons.Clear(); m_ButtonsDict.Clear(); double width = (double)ControlHandler.GetPropertyValue(LineArea, "ActualWidth"); double len = width - (PADDINGLEFT + PADDINGRIGHT); if (len < 0) { len = 100; } m_UnitSize = len / (m_ButtonScale - 1); ControlHandler.ExecuteMethod(LineArea, "SetLeft", new object[] { numberline, PADDINGLEFT }); ControlHandler.SetPropertyValue(numberline, "Width", len); double y = (double)ControlHandler.ExecuteMethod(LineArea, "GetTop", new object[] { numberline }) + numberline.Height / 2; int buttonsize = Math.Max(3, Math.Min(20, (int)(len / m_ButtonScale))); for (int i = 0; i < m_ButtonScale; i++) { double x = i * m_UnitSize + PADDINGLEFT; DrawNumberButton(m_Start.Add(PrimesBigInteger.ValueOf(i)), x, y, buttonsize, buttonsize); } if (m_Buttons != null && m_Buttons.Count > 0) { NumberButton nb = m_Buttons[m_Buttons.Count - 1]; Canvas.SetLeft(pToNumber, Canvas.GetLeft(nb) - 6); lblCountPoints.Text = m_Buttons.Count.ToString(); SetEdgeButtonColor(); } }
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); }
public void Clear() { ColumnDefinitionCollection columnDefinitions = ControlHandler.GetPropertyValue(gridMessages, "ColumnDefinitions") as ColumnDefinitionCollection; ControlHandler.ExecuteMethod(columnDefinitions, "Clear"); RowDefinitionCollection rowDefinitions = ControlHandler.GetPropertyValue(gridMessages, "RowDefinitions") as RowDefinitionCollection; ControlHandler.ExecuteMethod(rowDefinitions, "Clear"); UIElementCollection childs = ControlHandler.GetPropertyValue(gridMessages, "Children") as UIElementCollection; ControlHandler.ExecuteMethod(childs, "Clear"); m_CurrentRow = m_FormerRow = -1; counter = 1; }
private TextBlock Get(int colum, int row) { UIElementCollection childs = ControlHandler.GetPropertyValue(gridMessages, "Children") as UIElementCollection; if (childs != null) { IEnumerator _enum = ControlHandler.ExecuteMethod(childs, "GetEnumerator") as IEnumerator; while ((bool)ControlHandler.ExecuteMethod(_enum, "MoveNext")) { UIElement element = ControlHandler.GetPropertyValue(_enum, "Current") as UIElement; if (element.GetType() == typeof(TextBlock)) { int _row = (int)ControlHandler.ExecuteMethod(gridMessages, "GetRow", new object[] { element }); int _col = (int)ControlHandler.ExecuteMethod(gridMessages, "GetColumn", new object[] { element }); if (_row == row && _col == colum) { return(element as TextBlock); } } } } return(null); }
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)); } }
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 }); } }
public override QSResult Execute(ref QSData data) { IList <int> m_Factors = data.CalculateFactorBase(); StringBuilder fb = new StringBuilder(); foreach (int i in m_Factors) { if (fb.Length > 0) { fb.Append(","); } fb.Append(i); } ControlHandler.SetPropertyValue( m_lblInfo, "Text", string.Format(Primes.Resources.lang.WpfControls.Factorization.Factorization.qs_step2_B, data.B, fb.ToString())); IList <long> list = new List <long>(); int counter = 1; foreach (QuadraticPair pair in data) { ControlHandler.AddRowDefintion(Grid, 1, GridUnitType.Auto); AddToGrid(Grid, pair.A.ToString(), counter, 0, 0, 0); AddToGrid(Grid, pair.B.ToString(), counter, 1, 0, 0); TextBlock tb = AddTextBlock(counter, 2); StringBuilder sb = new StringBuilder(); long b = pair.B; if (b < 0) { b = -b; pair.AddExponent(-1, 1); sb.Append("-1"); } if (b != 0) { for (int i = 0; i < m_Factors.Count; i++) { int f = m_Factors[i]; int exp = 0; while (b % f == 0) { b /= f; exp++; } if (exp > 0) { if (sb.Length > 0) { sb.Append(" * "); } sb.Append(f); if (exp > 1) { sb.Append("^" + exp); } } pair.AddExponent(f, exp); } } if (b > 1 && sb.Length > 0) { sb.Append(" * " + b); } ControlHandler.SetPropertyValue(tb, "Text", sb.ToString()); pair.IsBSmooth = (b == 1) || (b == 0); string s = pair.IsBSmooth ? Primes.Resources.lang.WpfControls.Factorization.Factorization.qs_step2_yes : Primes.Resources.lang.WpfControls.Factorization.Factorization.qs_step2_no; ControlHandler.ExecuteMethod(this, "AddToGrid", new object[] { Grid, s, counter++, 3, 0, 0 }); Thread.Sleep(m_Delay); } return(QSResult.Ok); }
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"); } } }
private void AddMessage(string message, Brush color, int column, int row) { ControlHandler.ExecuteMethod(this, "_AddMessage", new object[] { message, color, column, row }); }
private Ellipse GetEllipseAt(Point p) { return((Ellipse)ControlHandler.ExecuteMethod(this, "_GetEllipseAt", new object[] { p })); }
private void SetupStop() { ControlHandler.ExecuteMethod(this, "_SetupStop"); }
private void ClearLabels() { UIElementCollection childs = ControlHandler.GetPropertyValue(LabelArea, "Children") as UIElementCollection; ControlHandler.ExecuteMethod(childs, "Clear"); }