private void ShowFactors_Click(object sender, RoutedEventArgs e)
        {
            double       diameter;
            bool         critfulfilled;
            ComplFactors CurrentFactors;

            //make button unavailable
            ShowFactors.IsEnabled = false;

            //clean up from possible previous drawing
            CleanUpDrawingElements();
            SelectedProd = null;

            //actual new drawing
            diameter = GetCurrentDiameter();


            //actual show action
            FoundProducts    = new Ellipse[2 * size + 1, 2 * size + 1];
            FoundFactors     = new Ellipse[2 * size + 1, 2 * size + 1];
            CorrectFactorNum = new bool[2 * size + 1, 2 * size + 1];
            for (long i = 0; i < ((2 * size) + 1); i++)
            {
                for (long j = 0; j < ((2 * size) + 1); j++)
                {
                    CorrectFactorNum[i, j] = false; // general assumption: current number does *not* fulfill the search criterion for the number of factor pairs.
                    if ((j - size == 0) && (i - size == 0))
                    {
                        // special marking for origin
                        FoundProducts[i, j]         = ResultIndicator(diameter, smallmargfract, i, j, 100, 255, 100, true, NumGrid);
                        FoundProducts[i, j].ToolTip = "0+0i (origin, #of factor pairs infinite)";
                        FoundFactors[i, j]          = ResultIndicator(diameter, bigmargfract, i, j, 50, 255, 50, false, NumGrid);
                    }
                    else
                    {
                        ComplNum CurProd = new ComplNum(j - size, i - size);
                        if (this.Factors != null)
                        {
                            CurrentFactors = Factors.GetFactors(CurProd);
                            if (SearchLEq)
                            {
                                critfulfilled = ((CurrentFactors.NumFactors >= minfactors) && (CurrentFactors.NumFactors <= maxfactors));
                            }
                            else
                            {
                                critfulfilled = (CurrentFactors.NumFactors == maxfactors);
                            }
                            //if ((CurrentFactors.NumFactors>=minfactors)&& (CurrentFactors.NumFactors <= maxfactors))
                            if (critfulfilled)
                            {
                                // actions if current number turns out to fulfill the search criterion
                                FoundProducts[i, j]    = ResultIndicator(diameter, smallmargfract, i, j, 100, 100, 255, true, NumGrid);
                                CorrectFactorNum[i, j] = true;
                            }
                            else
                            {
                                FoundProducts[i, j] = ResultIndicator(diameter, smallmargfract, i, j, 150, 150, 150, true, NumGrid);
                            }
                            FoundFactors[i, j]          = ResultIndicator(diameter, bigmargfract, i, j, 100, 100, 100, false, NumGrid);
                            FoundProducts[i, j].ToolTip = CurProd.ToString() + " # Factor Pairs: " + CurrentFactors.NumFactors + ".\nClick to show factor pairs.";
                        }
                        else
                        {
                            // fall-back if something is wrong with the data base
                            FoundProducts[i, j]         = ResultIndicator(diameter, smallmargfract, i, j, 255, 100, 100, true, NumGrid);
                            FoundProducts[i, j].ToolTip = CurProd.ToString() + " (No Info on Factors found)";
                            FoundFactors[i, j]          = ResultIndicator(diameter, bigmargfract, i, j, 255, 50, 50, false, NumGrid);
                        }
                    }
                }
            }
        }
        private void RecolorFactors(ComplNum Prod, ComplFactors Factors)
        {
            if (FoundFactors != null)
            {
                // cleanup before special coloring
                StandardColorFactors();
                StandardOutlineFactors();
                StandardOutlineProducts();
                StandardToolTipFactors();

                //actual re-color action
                double diameter = GetCurrentDiameter();
                // mark the selected product
                if (FoundProducts != null)
                {
                    FoundProducts[Prod.Im + size, Prod.Re + size].StrokeThickness = diameter * smallmargfract;
                }
                //mark factors
                long FactNum = Factors.NumFactors;
                SolidColorBrush[] BrushList = Colors(FactNum);
                long       ColInd           = 0;
                FactorList CurFactPair      = Factors.First;
                while (CurFactPair != null)
                {
                    if (CurFactPair.val1.Equal(CurFactPair.val2))
                    {
                        long i = CurFactPair.val1.Im + size;
                        long j = CurFactPair.val1.Re + size;
                        if (FoundFactors[i, j] != null)
                        {
                            FoundFactors[i, j].StrokeThickness = diameter * smallmargfract;
                            FoundFactors[i, j].Fill            = BrushList[ColInd];
                            FoundFactors[i, j].ToolTip         = "Factor " + CurFactPair.val1.ToString() +
                                                                 " (both factors of " + Prod.ToString() + " identical)";
                        }
                    }
                    else
                    {
                        long i = CurFactPair.val1.Im + size;
                        long j = CurFactPair.val1.Re + size;
                        if (FoundFactors[i, j] != null)
                        {
                            FoundFactors[i, j].Fill = BrushList[ColInd];
                        }
                        FoundFactors[i, j].ToolTip = "Factor " + CurFactPair.val1.ToString() +
                                                     " (corresponding factor of " + Prod.ToString() + ": "
                                                     + CurFactPair.val2.ToString() + ").\n Click to show corresponding factor.";
                        i = CurFactPair.val2.Im + size;
                        j = CurFactPair.val2.Re + size;
                        if (FoundFactors[i, j] != null)
                        {
                            FoundFactors[i, j].Fill = BrushList[ColInd];
                        }
                        FoundFactors[i, j].ToolTip = "Factor " + CurFactPair.val2.ToString() +
                                                     " (corresponding factor of " + Prod.ToString() + ": "
                                                     + CurFactPair.val1.ToString() + ").\n Click to show corresponding factor.";
                    }
                    ColInd++;
                    CurFactPair = CurFactPair.next;
                }
            }
        }