Show Pictures instead of default image like in ActiveDirectory.Show

Aug 24, 2009 at 1:09 PM

Hi

I am sure all of you have seen this http://code.msdn.microsoft.com/activedirectoryshow I am not a coder but I really like the idea that by changing the skin the default image of He/She is changed with real pictures of that person.

I could not investigate further his work as it is in French. Can any body please explain how he did that.

 

Thanks

Developer
Aug 30, 2009 at 12:30 AM
Edited Aug 30, 2009 at 12:34 AM

The author of ActiveDirectory.Show altered the skin file SilverResources.xaml so that a non primary node displayed a persons image.

The BlackResources.xaml file does not include the changes made so if you compare the <!-- Male node --> part of the code in the two files, you can see what has been done to make this simple alteration.

If you go to this link:

http://code.msdn.microsoft.com/activedirectoryshow/Release/ProjectReleases.aspx?ReleaseId=1623

everything was in English when I looked just now.  The new bit of code goes something like below and is almost exactly the same code used to display the image in the details panel aside from a few size changes etc.

It basically consists of  a StackPanel which holds two borders.  One border is has the persons image and is visible if they have a primary image.   The second border is a default image and is displayed when the person has no primary image. 

Hope that helps.

Code snippet:

 
                        <StackPanel>
                            <Border BorderBrush="#02747474" Background="#02000000" HorizontalAlignment="Center" Margin="10,5,10,0" VerticalAlignment="Top" BorderThickness="1,1,1,1" x:Name="AvatarPhotoBorder">
                                <Border.BitmapEffect>
                                    <DropShadowBitmapEffect ShadowDepth="7" Softness="0.75" />
                                </Border.BitmapEffect>
                                <Image x:Name="Avatar" Source="{Binding Path=Person.Avatar, Mode=OneWay}" Stretch="Uniform" VerticalAlignment="Top" MaxWidth="55" MaxHeight="40" HorizontalAlignment="Left" StretchDirection="Both" />
                            </Border>
                            <Border x:Name="NoPhotoBorder" Visibility="{Binding Path=Person.HasAvatar, Converter={StaticResource ComposingConverter}, Mode=Default}" BorderBrush="#FFFFFFFF" Background="#02FFFFFF" HorizontalAlignment="Center" Margin="10,5,10,0" VerticalAlignment="Top" BorderThickness="1,1,1,1">
                                <Rectangle Fill="{DynamicResource NoPhotoBrush}" Stroke="{x:Null}" Width="30" Height="35" x:Name="NoPhotoRectangle">
                                    <Rectangle.BitmapEffect>
                                        <DropShadowBitmapEffect ShadowDepth="7" Softness="0.75" />
                                    </Rectangle.BitmapEffect>
                                </Rectangle>
                            </Border>
                            <ContentPresenter Margin="10,0,10,3" HorizontalAlignment="Right" TextBlock.TextAlignment="Right" />
                        </StackPanel>