Example #1
0
        private void Factorize(PrimesBigInteger value)
        {
            ClearInfoPanel();
            string inputvalue = m_Integer.ToString();

            if (lblInput.ToolTip == null)
            {
                lblInput.ToolTip = new ToolTip();
            }
            (lblInput.ToolTip as ToolTip).Content = StringFormat.FormatString(inputvalue, 80);

            if (inputvalue.Length > 7)
            {
                inputvalue = inputvalue.Substring(0, 6) + "...";
            }
            System.Windows.Documents.Underline ul = new Underline();

            if (CurrentFactorizer == _bruteforce)
            {
                BF.lblInput = inputvalue;
            }
            else
            {
                QS.lblInput = inputvalue;
            }

            UpdateMessages();

            CurrentFactorizer.Execute(value);
        }
        private void InvokeAddEllipseItem(EllipseItem item)
        {
            if (!items.Contains(item))
            {
                ToolTip tt = new ToolTip();
                tt.Content = StringFormat.FormatString(item.Value.ToString(), 80);

                items.Add(item);

                Ellipse result = new Ellipse();
                result.ToolTip         = tt;
                result.Width           = item.Width;
                result.Height          = item.Height;
                result.Stroke          = Brushes.Black;
                result.StrokeThickness = 1;
                result.Fill            = Brushes.LightCyan;
                if (item.IsPrime)
                {
                    result.Fill = Brushes.LightGreen;
                }
                Canvas.SetLeft(result, item.X);
                Canvas.SetTop(result, item.Y);
                if (item.Y > PaintArea.Height - item.Height)
                {
                    PaintArea.Height = item.Y + m_Manager.ItemSize * 2;
                }
                if (item.X > PaintArea.Width - item.Width)
                {
                    PaintArea.Width = item.X + m_Manager.ItemSize * 10;
                }
                m_MapEllipseItems.Add(result, item);
                PaintArea.Children.Add(result);

                Label  l        = new Label();
                string lContent = item.Value.ToString();
                if (lContent.Length > 7)
                {
                    lContent  = lContent.Substring(0, 6);
                    lContent += "...";
                }
                l.Content = lContent;
                l.ToolTip = tt;
                Canvas.SetLeft(l, item.X + item.Width);
                Canvas.SetTop(l, item.Y);
                PaintArea.Children.Add(l);

                if (item.Parent != null)
                {
                    AddConnector(new EllipseConnector(item.Parent, item));
                }
            }
        }