public SortView(LazyAlgorithm algorithm) { DataContext = this; InitializeComponent(); m_SortName.Text = algorithm.GetType().Name; _viewModel = new SortViewModel(algorithm); _viewModel.PropertyChanged += delegate(object sender, PropertyChangedEventArgs args1) { InitializeGrid(); _viewModel.Array.OperationExecuted += delegate(object sender2, NumericArrayModelEventArgs args) { if (args.Operation == "Reset") { InitializeGrid(); } else if (args.Operation == "Compare") { ClearLatestArgs(); SetElementColor(args.Indexes[0], ElementCompareColor); SetElementColor(args.Indexes[1], ElementCompareColor); ComparisonCount = ComparisonCount + 1; _latestArgs = args; } else if (args.Operation == "Swap") { ClearLatestArgs(); SetElementColor(args.Indexes[0], ElementSwapColor); SetElementColor(args.Indexes[1], ElementSwapColor); Swap(args.Indexes[0], args.Indexes[1]); _latestArgs = args; } else if (args.Operation == "Complete") { ClearLatestArgs(); SetElementColor(args.Indexes[0], ElementCompleteColor); } }; }; }
public SortViewModel(LazyAlgorithm algorithm) { Algorithm = algorithm; }