//private void Scroll(int factor) //{ // DateTime start = DateTime.Now; // foreach (Rectangle nb in m_Buttons) // { // PrimesBigInteger c = nb.Tag as PrimesBigInteger; // c = c.Add(PrimesBigInteger.ValueOf(this.Columns * factor)); // if (c.IsPrime(10)) // { // nb.Fill = Brushes.Red; // } // else // { // nb.Fill = Brushes.White; // } // nb.Tag = c; // (nb.ToolTip as ToolTip).Content = c.ToString(); // } // TimeSpan diff = DateTime.Now - start; // Debug.WriteLine(string.Format("Scroll: Std={0}, Min={1}, sek={2}, MS={3}", new object[] { diff.Hours, diff.Minutes, diff.Seconds, diff.Milliseconds })); //} private void Scroll(int factor) { //DateTime start = DateTime.Now; PrimesBigInteger sa = PrimesBigInteger.ValueOf(this.Columns * factor); m_start = PrimesBigInteger.Max(m_start.Add(sa), PrimesBigInteger.One); DrawButtons(); //TimeSpan diff = DateTime.Now - start; //Debug.WriteLine(string.Format("Scroll: Std={0}, Min={1}, sek={2}, MS={3}", new object[] { diff.Hours, diff.Minutes, diff.Seconds, diff.Milliseconds })); }
private void SetTwinPrimes(PrimesBigInteger value) { PrimesBigInteger twin1 = value.Subtract(PrimesBigInteger.One); PrimesBigInteger twin2 = value.Add(PrimesBigInteger.One); PrimesBigInteger tmp = null; if (twin1.IsPrime(20) && twin2.IsPrime(20)) { lblTwinPrimes.Text = string.Format(Distribution.numberline_insidetwinprime, value, twin1, twin2); lblTwinPrimes.Visibility = Visibility.Visible; } else if (value.IsTwinPrime(ref tmp)) { twin1 = PrimesBigInteger.Min(value, tmp); twin2 = PrimesBigInteger.Max(value, tmp); if (m_ButtonsDict.ContainsKey(twin1)) { MarkNumber(m_ButtonsDict[twin1]); } if (m_ButtonsDict.ContainsKey(twin2)) { MarkNumber(m_ButtonsDict[twin2]); } lblTwinPrimes.Text = string.Format(Distribution.numberline_istwinprime, twin1, twin2); lblTwinPrimes.Visibility = Visibility.Visible; } PrimesBigInteger a = null; PrimesBigInteger b = null; string text = ""; twin1.PriorTwinPrime(ref a, ref b); if (a.CompareTo(twin1) < 0) { text = string.Format(Distribution.numberline_priortwinprime, a, b) + " "; } twin1.Add(PrimesBigInteger.One).NextTwinPrime(ref a, ref b); text += string.Format(Distribution.numberline_nexttwinprime, a, b); lblTwinPrimes2.Text = text; }