private void OnLoaded(object sender, object e) { PropertyInfo[] props = typeof(Brushes).GetProperties(); List <object> data = new List <object>(17); data.Add(new UI()); SampleImageHelper.GetPicturePaths().Take(8).ForEach(path => data.Add(new Picture(path))); for (int i = 0; i < Math.Min(props.Length, 8); i++) { if (props[i].Name != "Transparent") { data.Add(new Swatch(props[i].Name)); } } this.DataContext = _data.ItemsSource = data; // Setup 2 way transitions Transition[] transitions = (Transition[])FindResource("ForwardBackTransitions"); for (int i = 0; i < transitions.Length; i += 2) { ListTransitionSelector selector = new ListTransitionSelector(transitions[i], transitions[i + 1], data); TextSearch.SetText(selector, TextSearch.GetText(transitions[i])); _selectors.Items.Add(selector); } }
private static ReadOnlyCollection <DiffuseMaterial> GetSamplePictures() { IList <string> files = SampleImageHelper.GetPicturePaths().ToList(); if (files.Count > 0) { return(files .Select(file => { BitmapImage bitmapImage = new BitmapImage(); bitmapImage.BeginInit(); bitmapImage.UriSource = new Uri(file); bitmapImage.DecodePixelWidth = 320; bitmapImage.DecodePixelHeight = 240; bitmapImage.EndInit(); bitmapImage.Freeze(); ImageBrush imageBrush = new ImageBrush(bitmapImage); imageBrush.Stretch = Stretch.UniformToFill; imageBrush.ViewportUnits = BrushMappingMode.Absolute; imageBrush.Freeze(); return new DiffuseMaterial(imageBrush); }) .ToReadOnlyCollection()); } else { return((new Brush[] { Brushes.LightBlue, Brushes.Pink, Brushes.LightGray, Brushes.Yellow, Brushes.Orange, Brushes.LightGreen }) .Select(brush => new DiffuseMaterial(brush)) .ToReadOnlyCollection()); } }