public InteractiveOrderingCanvas() { Width = DefaultWidth; Height = DefaultHeight; this.ClipToBounds = true; Colors.White.ToGradient(Colors.Blue, DefaultHeight / 4).Select( (c, i) => new Rectangle { Fill = new SolidColorBrush(c), Width = DefaultWidth, Height = 4, }.MoveTo(0, i * 4).AttachTo(this) ).ToArray(); var History = new AeroNavigationBar(); History.AttachContainerTo(this).MoveContainerTo(8, 8); this.Title = new TextBox { AcceptsReturn = true, Width = DefaultWidth - (16 + History.Width), Height = 96, TextWrapping = TextWrapping.Wrap, Background = Brushes.Transparent, BorderThickness = new Thickness(0), Text = "...", IsReadOnly = true, FontFamily = new FontFamily("Verdana"), FontSize = 32 }.AttachTo(this).MoveTo(16 + History.Width, 8); var DataSet1 = new LinkImages { Text = "Cars" }; var DataSet2 = new LinkImages { Text = "Bikes" }; #region wait for all to load DefaultDataSets = new[] { DataSet1, DataSet2 }; DefaultDataSets.ForEach( k => k.Loaded += delegate { if (DefaultDataSets.All(q => q.Images.Any())) { Step1_ChooseImageSet(History.History, DefaultDataSets); } } ); #endregion DataSet1.AddImages( new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_0(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_1(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_2(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_3(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_4(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_5(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet1_6() ); DataSet2.AddImages( new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_0(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_1(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_2(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_3(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_4(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_5(), new AvalonInteractiveOrderingExperiment.Avalon.Images.DataSet2_6() ); { var GoBackButton = new TextButtonControl { Text = "[Back]", Width = 50, Height = 30, }.AttachContainerTo(this).MoveContainerTo(30, 100 + 40 * 11); var GoBackButtonBG = GoBackButton.Background.ToAnimatedOpacity(); GoBackButton.Background.Fill = Brushes.White; GoBackButtonBG.Opacity = 0; GoBackButton.Overlay.MouseEnter += delegate { GoBackButtonBG.Opacity = 1; }; GoBackButton.Overlay.MouseLeave += delegate { GoBackButtonBG.Opacity = 0; }; GoBackButton.Click += delegate { if (History.History.GoBack.Any()) { History.History.GoBack.Pop()(); } }; } { var GoBackButton = new TextButtonControl { Text = "[Forward]", Width = 66, Height = 30, }.AttachContainerTo(this).MoveContainerTo(80, 100 + 40 * 11); var GoBackButtonBG = GoBackButton.Background.ToAnimatedOpacity(); GoBackButton.Background.Fill = Brushes.White; GoBackButtonBG.Opacity = 0; GoBackButton.Overlay.MouseEnter += delegate { GoBackButtonBG.Opacity = 1; }; GoBackButton.Overlay.MouseLeave += delegate { GoBackButtonBG.Opacity = 0; }; GoBackButton.Click += delegate { if (History.History.GoForward.Any()) { History.History.GoForward.Pop()(); } }; } }
public void Step2_ChooseCount( AeroNavigationBar.HistoryInfo History, LinkImages Source ) { History.AddFrame( delegate { this.Title.Text = "How many images are you willing to compare from '" + Source.Text + "'"; var UserDefinedValues_extremly_better = new ComparisionValue { Name = "extremly better", Value = 9 }; var UserDefinedValues_much_better = new ComparisionValue { Name = "much better", Value = 7 }; var UserDefinedValues_better = new ComparisionValue { Name = "better", Value = 5 }; var UserDefinedValues_slightly_better = new ComparisionValue { Name = "slightly better", Value = 3 }; var DefinedValues = new[] { UserDefinedValues_extremly_better, UserDefinedValues_much_better, UserDefinedValues_better, UserDefinedValues_slightly_better, new ComparisionValue { Name = "equal", Value = 1 }, new ComparisionValue { Name = "slightly worse", InverseOf = UserDefinedValues_slightly_better }, new ComparisionValue { Name = "worse", InverseOf = UserDefinedValues_better }, new ComparisionValue { Name = "much worse", InverseOf = UserDefinedValues_much_better }, new ComparisionValue { Name = "extremly worse", InverseOf = UserDefinedValues_extremly_better }, }; Action <int> Handler = XNumber => { var Selection = Source.Select((k, i) => new { k, i }).Where(k => k.i < XNumber).ToArray(k => k.k); var Matrix = Enumerable.Range(0, Selection.Length).SelectMany( x => Enumerable.Range(0, Selection.Length).Select( y => { var n = new ComparisionInfo { X = x, Y = y, }; if (n.X == n.Y) { n.Value = DefinedValues.Single(k => k.Value == 1); } if (n.X > n.Y) { n.WaitingForUser = true; } return(n); } ) ).Randomize().ToArray(); if (XNumber == 6) { Action <int, int, double> set = (x, y, value) => { Matrix.Single(k => k.X == x && k.Y == y).Value = DefinedValues.Single(k => k.GetCurrentValue() == value); Matrix.Single(k => k.X == y && k.Y == x).Value = DefinedValues.Single(k => k.GetCurrentValue() == 1.0 / value); }; set(0, 1, 3); set(2, 0, 3); set(3, 0, 5); set(0, 4, 3); set(5, 0, 3); set(2, 1, 7); set(3, 1, 9); set(4, 1, 1); set(5, 1, 7); set(3, 2, 3); set(2, 4, 5); set(5, 2, 1); set(3, 4, 9); set(3, 5, 3); set(5, 4, 9); } // we need to have the matrix now Step3_Compare(History, Selection, Matrix, DefinedValues); }; #region Options var Options = Enumerable.Range(3, Source.Images.Count - 2).Select( (XNumber, Index) => { var o7 = new TextButtonControl { Text = "I can only handle " + XNumber + " images from '" + Source.Text + "'", Width = 400, Height = 40, }.AttachContainerTo(this).MoveContainerTo(100, 100 + 40 * Index); o7.Content.FontSize = 20; var o7bg = o7.Background.ToAnimatedOpacity(); o7.Background.Fill = Brushes.White; o7bg.Opacity = 0; o7.Overlay.MouseEnter += delegate { o7bg.Opacity = 1; }; o7.Overlay.MouseLeave += delegate { o7bg.Opacity = 0; }; o7.Click += delegate { Handler(XNumber); }; return(o7); } ).ToArray(); #endregion return(delegate { this.Title.Text = "..."; Options.ForEach(k => k.OrphanizeContainer()); }); } ); }