private void gvMain_ContainerContentChanging(ListViewBase sender, ContainerContentChangingEventArgs args) { if (string.IsNullOrEmpty(ThumbnailFieldName)) { return; } try { //var imgs = args.ItemContainer.ContentTemplateRoot.GetFirstDescendantOfType<CompositionImage>(); //CompositionImage image = imgs.First(); CompositionImage image = args.ItemContainer.ContentTemplateRoot.GetFirstDescendantOfType <CompositionImage>(); dynamic thumbnail = args.Item as dynamic; //Uri uri = new Uri(thumbnail.SquareThumbnailUrl); var propertyInfo = thumbnail.GetType().GetProperty(ThumbnailFieldName); var value = propertyInfo.GetValue(thumbnail, null); Uri uri = new Uri(value); // Setup the brush for this image SetImageEffect(image); // Update the image URI image.Source = uri; } catch (Exception ex) { } }
//LightingTypes _selectedLight = LightingTypes.PointDiffuse; private void SetImageEffect(CompositionImage image) { if (_effectFactory == null) { return; } // Create the effect brush and bind the normal map CompositionEffectBrush brush = _effectFactory.CreateBrush(); //ComboBoxItem item = LightingSelection.SelectedValue as ComboBoxItem; //switch ((LightingTypes)item.Tag) switch (SelectedLight) { case LightingTypes.SpotLightSpecular: case LightingTypes.PointSpecular: case LightingTypes.DistantDiffuse: case LightingTypes.DistantSpecular: brush.SetSourceParameter("NormalMap", _circleNormalsBrush); break; default: brush.SetSourceParameter("NormalMap", _flatNormalsBrush); break; } // Update the CompositionImage to use the custom effect brush image.Brush = brush; }
private void UpdateEffectBrush(BrushType brushType) { if (ccMain.Content != null && ccMain.Content is CompositionImage) { //foreach (ListViewItem item in gvMain.ItemsPanelRoot.Children) //{ // CompositionImage image = item.ContentTemplateRoot.GetFirstDescendantOfType<CompositionImage>(); CompositionImage image = (CompositionImage)ccMain.Content; //var imgs = item.ContentTemplateRoot.GetDescendantsOfType<CompositionImage>(); //CompositionImage image = imgs.Last(); SetImageEffect(image, brushType); //} } }
private void UpdateEffectBrush() { if (gvMain.ItemsPanelRoot != null) { foreach (var item in gvMain.ItemsPanelRoot.Children) { if (item is ListViewItem) { CompositionImage image = ((ListViewItem)item).ContentTemplateRoot.GetFirstDescendantOfType <CompositionImage>(); //var imgs = item.ContentTemplateRoot.GetDescendantsOfType<CompositionImage>(); //CompositionImage image = imgs.Last(); SetImageEffect(image); } } } }
//LightingTypes _selectedLight = LightingTypes.PointDiffuse; private void SetImageEffect(CompositionImage image) { if (_effectFactory == null) return; // Create the effect brush and bind the normal map CompositionEffectBrush brush = _effectFactory.CreateBrush(); //ComboBoxItem item = LightingSelection.SelectedValue as ComboBoxItem; //switch ((LightingTypes)item.Tag) switch (SelectedLight) { case LightingTypes.SpotLightSpecular: case LightingTypes.PointSpecular: case LightingTypes.DistantDiffuse: case LightingTypes.DistantSpecular: brush.SetSourceParameter("NormalMap", _circleNormalsBrush); break; default: brush.SetSourceParameter("NormalMap", _flatNormalsBrush); break; } // Update the CompositionImage to use the custom effect brush image.Brush = brush; }