コード例 #1
0
        public void Step5_ShowMistakeMatrix(
            AeroNavigationBar.HistoryInfo History,
            LinkImage[] Source,
            ComparisionInfo[] Comparision,
            ComparisionValue[] Values)
        {
            History.AddFrame(
                delegate
            {
                var More = Comparision.Count(k => k.WaitingForUser && k.Value == null);



                #region headers
                var o = Source.Select <LinkImage, Action>(
                    (k, i) =>
                {
                    k.SizeTo(0.15);
                    k.AttachContainerTo(this);
                    k.MoveContainerTo(60, 150 + i * 60);

                    var kx = new TextButtonControl
                    {
                        Text   = "#" + (1 + i),
                        Width  = 40,
                        Height = 32
                    };

                    kx.AttachContainerTo(this);
                    kx.MoveContainerTo(130, 160 + i * 60);
                    kx.Background.Fill    = Brushes.White;
                    kx.Background.Opacity = 0.3;

                    var ky = new TextButtonControl
                    {
                        Text   = "#" + (1 + i),
                        Width  = 40,
                        Height = 32
                    };

                    ky.AttachContainerTo(this);
                    ky.MoveContainerTo(200 + i * 60, 100);
                    ky.Background.Fill    = Brushes.White;
                    ky.Background.Opacity = 0.3;

                    var kxr = new Rectangle
                    {
                        Fill   = Brushes.Black,
                        Width  = Source.Length * 60 + 140,
                        Height = 1
                    };

                    kxr.AttachTo(this);
                    kxr.MoveTo(60, 200 + i * 60);


                    var kyr = new Rectangle
                    {
                        Fill   = Brushes.Black,
                        Height = Source.Length * 60 + 60,
                        Width  = 1
                    };

                    kyr.AttachTo(this);
                    kyr.MoveTo(250 + i * 60, 100);

                    return(delegate
                    {
                        k.OrphanizeContainer();
                        kx.OrphanizeContainer();
                        ky.OrphanizeContainer();
                        kxr.Orphanize();
                        kyr.Orphanize();
                    });
                }
                    ).ToArray();
                #endregion

                #region values

                var Mistakes = Comparision.Where(q => q.WaitingForUser).ToArray(
                    q =>
                {
                    var x_cells =
                        Comparision.Where(k => k.X == q.Y).OrderBy(k => k.Y).ToArray();

                    var x_product =
                        x_cells.Product(k => k.GetCurrentValue());

                    var y_cells =
                        Comparision.Where(k => k.Y == q.X).OrderBy(k => k.X).ToArray();

                    var y_product =
                        y_cells.Product(k => k.GetCurrentValue());


                    var z = Math.Pow(q.GetCurrentValue(), Source.Length);

                    return(new { q, Mistake = 1.0 / Math.Pow(x_product * y_product * z, 1.0 / (Source.Length - 2)) });

                    /*
                     *
                     * 1/POWER(PRODUCT(R4C2:R9C2)*PRODUCT(R9C2:R9C7)*POWER(R[-46]C;veerge);1/(veerge-2))
                     * 1/POWER(x_product*y_product*POWER(R[-46]C;veerge);1/(veerge-2))
                     * 1/POWER(x_product*y_product*z;1/(veerge-2))
                     *
                     */
                }
                    ).OrderBy(
                    ContextMistakes =>
                {
                    var Mistakes_Max = ContextMistakes.Max(k => k.Mistake);
                    var Mistakes_Min = ContextMistakes.Min(k => k.Mistake);

                    var Mistake_Value = Mistakes_Min;

                    if (Mistakes_Max * Mistakes_Min > 1.0)
                    {
                        Mistake_Value = Mistakes_Max;
                    }

                    return(ContextMistakes.First(k => k.Mistake == Mistake_Value));
                }
                    ).ToArray();

                var Gradient = Colors.Red.ToGradient(Colors.Blue, Mistakes.Length).ToArray();



                Title.Text = "Biggest mistake was made at " + Mistakes.First().q.ToVersusString() + ". Click on a cell to recompare.";


                var v = Mistakes.Select(
                    (k, k_index) =>
                {
                    var kt = new TextButtonControl
                    {
                        Text   = "",
                        Width  = 60 - 4,
                        Height = 32
                    };

                    kt.AttachContainerTo(this);
                    kt.MoveContainerTo(192 + k.q.X * 60, 160 + k.q.Y * 60);

                    kt.Background.Fill = new SolidColorBrush(Gradient[k_index]);


                    kt.Text = k.Mistake.ToString();

                    kt.Click +=
                        delegate
                    {
                        var NewComparision = Comparision.ToArray(
                            oo =>
                        {
                            var n = new ComparisionInfo
                            {
                                WaitingForUser = oo.WaitingForUser,
                                Value          = oo.Value,
                                X = oo.X,
                                Y = oo.Y
                            };

                            if (oo == k.q)
                            {
                                n.Value = null;
                            }



                            return(n);
                        }
                            );


                        Step3_Compare(History, Source, NewComparision, Values);
                    };

                    return(new Action(
                               delegate
                    {
                        kt.OrphanizeContainer();
                    }
                               ));
                }
                    ).ToArray();

                #endregion

                return(delegate
                {
                    this.Title.Text = "...";

                    o.ForEach(h => h());
                    v.ForEach(h => h());
                });
            }
                );
        }
コード例 #2
0
        public void Step4_ShowMatrix(
            AeroNavigationBar.HistoryInfo History,
            LinkImage[] Source,
            ComparisionInfo[] Comparision,
            ComparisionValue[] Values)
        {
            History.AddFrame(
                delegate
            {
                var More = Comparision.Count(k => k.WaitingForUser && k.Value == null);

                this.Title.Text = "The Matrix. You have " + More + " image pairs to compare...";

                #region headers
                var o = Source.Select <LinkImage, Action>(
                    (k, i) =>
                {
                    k.SizeTo(0.15);
                    k.AttachContainerTo(this);
                    k.MoveContainerTo(60, 150 + i * 60);

                    var kx = new TextButtonControl
                    {
                        Text   = "#" + (1 + i),
                        Width  = 40,
                        Height = 32
                    };

                    kx.AttachContainerTo(this);
                    kx.MoveContainerTo(130, 160 + i * 60);
                    kx.Background.Fill    = Brushes.White;
                    kx.Background.Opacity = 0.3;

                    var ky = new TextButtonControl
                    {
                        Text   = "#" + (1 + i),
                        Width  = 40,
                        Height = 32
                    };

                    ky.AttachContainerTo(this);
                    ky.MoveContainerTo(200 + i * 60, 100);
                    ky.Background.Fill    = Brushes.White;
                    ky.Background.Opacity = 0.3;

                    var kxr = new Rectangle
                    {
                        Fill   = Brushes.Black,
                        Width  = Source.Length * 60 + 140,
                        Height = 1
                    };

                    kxr.AttachTo(this);
                    kxr.MoveTo(60, 200 + i * 60);


                    var kyr = new Rectangle
                    {
                        Fill   = Brushes.Black,
                        Height = Source.Length * 60 + 60,
                        Width  = 1
                    };

                    kyr.AttachTo(this);
                    kyr.MoveTo(250 + i * 60, 100);

                    return(delegate
                    {
                        k.OrphanizeContainer();
                        kx.OrphanizeContainer();
                        ky.OrphanizeContainer();
                        kxr.Orphanize();
                        kyr.Orphanize();
                    });
                }
                    ).ToArray();
                #endregion

                #region values

                var v = Comparision.Select <ComparisionInfo, Action>(
                    k =>
                {
                    var kt = new TextButtonControl
                    {
                        Text   = "",
                        Width  = 40,
                        Height = 32
                    };

                    kt.AttachContainerTo(this);
                    kt.MoveContainerTo(200 + k.X * 60, 160 + k.Y * 60);

                    kt.Background.Fill    = Brushes.White;
                    kt.Background.Opacity = 0.3;

                    if (k.Value == null)
                    {
                        if (k.WaitingForUser)
                        {
                            kt.Background.Fill    = Brushes.Yellow;
                            kt.Background.Opacity = 0.5;
                        }
                    }
                    else
                    {
                        kt.Text = k.Value.ToString();

                        if (k.Value.Value == 1)
                        {
                            kt.Background.Fill    = Brushes.Cyan;
                            kt.Background.Opacity = 0.5;
                        }
                    }

                    return(delegate
                    {
                        kt.OrphanizeContainer();
                    });
                }
                    ).ToArray();

                #endregion

                return(delegate
                {
                    this.Title.Text = "...";

                    o.ForEach(h => h());
                    v.ForEach(h => h());
                });
            }
                );
        }