Click here to Skip to main content
15,885,860 members
Articles / Desktop Programming / WPF

Reflection Studio - Part 1 - Introduction: Architecture and Design

Rate me:
Please Sign up or sign in to vote.
4.83/5 (23 votes)
22 Sep 2010GPL36 min read 59.9K   6.9K   111  
Reflection Studio is a "developer" application for assembly, database, performance, and code generation, written in C# under WPF 4.0.
<ucd:HeaderedDialogWindow x:Class="ReflectionStudio.Components.Dialogs.Database.DependencyDialog"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:ucd="clr-namespace:ReflectionStudio.Controls;assembly=ReflectionStudio.Controls"                          
             xmlns:local="clr-namespace:ReflectionStudio.Components.Dialogs.Database"
             Height="420" Width="310" Title="Dependencies"
             DialogDescription="Display object's dependencies"
             DialogImage="/ReflectionStudio;component/Resources/Images/32x32/information.png"                          
             ShowInTaskbar="False" ResizeMode="CanResizeWithGrip">
    <Window.Resources>

        <SolidColorBrush x:Key="GlyphBrush" Color="#444" />
        <SolidColorBrush x:Key="WhiteBrush" Color="Transparent" />

        <Style x:Key="ExpandCollapseToggleStyle" TargetType="ToggleButton">
            <Setter Property="Focusable" Value="False"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="ToggleButton">
                        <Grid
                          Width="15"
                          Height="13"
                          Background="Transparent">
                            <Path x:Name="ExpandPath"
                                HorizontalAlignment="Left" 
                                VerticalAlignment="Center" 
                                Margin="1,1,1,1"
                                Fill="{StaticResource WhiteBrush}"
                                Data="M 4 0 L 8 4 L 4 8 Z"
                                Stroke="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsChecked" Value="True">
                                <Setter Property="Data" TargetName="ExpandPath" Value="M 0 4 L 8 4 L 4 8 Z"/>
                                <Setter Property="Fill" TargetName="ExpandPath" Value="{StaticResource GlyphBrush}"/>
                                <Setter Property="Stroke" TargetName="ExpandPath" Value="{StaticResource GlyphBrush}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="TreeViewItemFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Border>
                            <Rectangle Margin="0,0,0,0" StrokeThickness="5" Stroke="Black"
                                StrokeDashArray="1 2" Opacity="0"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <Style x:Key="{x:Type TreeViewItem}" TargetType="{x:Type TreeViewItem}">
            <Setter Property="Background" Value="Transparent"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Property="FocusVisualStyle" Value="{StaticResource TreeViewItemFocusVisual}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TreeViewItem}">
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition MinWidth="19" Width="Auto"/>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition/>
                            </Grid.RowDefinitions>
                            <ToggleButton x:Name="Expander" Style="{StaticResource ExpandCollapseToggleStyle}"
                                IsChecked="{Binding Path=IsExpanded,
                                RelativeSource={RelativeSource TemplatedParent}}"
                                ClickMode="Press"/>
                            <Border Name="Bd"
                                  Grid.Column="1"
                                  Background="{TemplateBinding Background}"
                                  BorderBrush="{TemplateBinding BorderBrush}"
                                  BorderThickness="{TemplateBinding BorderThickness}"
                                  Padding="{TemplateBinding Padding}">
                                <StackPanel Orientation="Horizontal">
                                    <ContentPresenter x:Name="PART_Header"
                                          ContentSource="Header"
                                          HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"/>
                                </StackPanel>
                            </Border>
                            <ItemsPresenter x:Name="ItemsHost"
                                  Grid.Row="1"
                                  Grid.Column="1"
                                  Grid.ColumnSpan="2"/>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsExpanded" Value="false">
                                <Setter TargetName="ItemsHost" Property="Visibility" Value="Collapsed"/>
                            </Trigger>
                            <Trigger Property="HasItems" Value="false">
                                <Setter TargetName="Expander" Property="Visibility" Value="Hidden"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="false"/>
                                    <Condition Property="Width" Value="Auto"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinWidth" Value="75"/>
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="HasHeader" Value="false"/>
                                    <Condition Property="Height" Value="Auto"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="PART_Header" Property="MinHeight" Value="19"/>
                            </MultiTrigger>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.HighlightBrushKey}}"/>
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.HighlightTextBrushKey}}"/>
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true"/>
                                    <Condition Property="IsSelectionActive" Value="false"/>
                                </MultiTrigger.Conditions>
                                <Setter TargetName="Bd" Property="Background" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
                            </MultiTrigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <HierarchicalDataTemplate  x:Key="DataItemTemplate" ItemsSource="{Binding Children}" >
            <StackPanel Orientation="Horizontal">
                <ContentPresenter Margin="2,0"
                        Content="{Binding Name}" />
            </StackPanel>
        </HierarchicalDataTemplate>

    </Window.Resources>

        <Grid Margin="5">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
            <RowDefinition Height="33" />
        </Grid.RowDefinitions>

        <StackPanel Grid.Row="0" Margin="5" HorizontalAlignment="Stretch" Name="groupBox1" VerticalAlignment="Stretch">
            <StackPanel Margin="5" Orientation="Horizontal">
                <RadioButton Content="Depends on" Margin="10,0,20,0" GroupName="Mode" Checked="RadioButton_Checked" Name="rdDependsOn" IsChecked="True" />
                <RadioButton Content="Depends from" Margin="10,0,20,0" GroupName="Mode" Checked="RadioButton_Checked" IsChecked="False" />
            </StackPanel>
            <TextBlock Name="tbReference"></TextBlock>
        </StackPanel>

        <TreeView Grid.Row="1" Margin="6" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
                    x:Name="treeView"
                    ItemsSource="{Binding}"
                    ItemTemplate="{StaticResource DataItemTemplate}">
        </TreeView>
            
        <Button Content="Ok" Grid.Row="2" Height="23" HorizontalAlignment="Right" Name="btnOk" VerticalAlignment="Top" Width="75" Click="btnOk_Click" />
    </Grid>
</ucd:HeaderedDialogWindow>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Architect
France France
WPF and MVVM fan, I practice C # in all its forms from the beginning of the NET Framework without mentioning C ++ / MFC and other software packages such as databases, ASP, WCF, Web & Windows services, Application, and now Core and UWP.
In my wasted hours, I am guilty of having fathered C.B.R. and its cousins C.B.R. for WinRT and UWP on the Windows store.
But apart from that, I am a great handyman ... the house, a rocket stove to heat the jacuzzi and the last one: a wood oven for pizza, bread, and everything that goes inside

https://guillaumewaser.wordpress.com/
https://fouretcompagnie.wordpress.com/

Comments and Discussions