Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version
Go to top

Resolving Symbolic References in a CodeDOM (Part 7)

, 2 Dec 2012
Resolving symbolic references in a CodeDOM.
Nova.0.6.exe.zip
Mono.Cecil.dll
Nova.CLI.exe
Nova.CodeDOM.dll
Nova.Examples.exe
Nova.Studio.exe
Nova.Test.exe
Nova.UI.dll
Nova.0.6.zip
Nova.CLI
Properties
Nova.CodeDOM
CodeDOM
Annotations
Base
Comments
Base
DocComments
CodeRef
Base
List
Name
Base
Other
Simple
CompilerDirectives
Base
Conditionals
Base
Messages
Base
Pragmas
Base
Symbols
Base
Base
Interfaces
Expressions
AnonymousMethods
Base
Operators
Base
Binary
Arithmetic
Base
Assignment
Base
Bitwise
Base
Conditional
Relational
Base
Shift
Base
Other
Base
Unary
Base
Other
References
Base
GotoTargets
Base
Methods
Namespaces
Other
Properties
Types
Base
Variables
Base
Projects
Assemblies
Namespaces
References
Base
Statements
Base
Conditionals
Base
Exceptions
Generics
Constraints
Base
Iterators
Base
Jumps
Loops
Methods
OperatorDecls
Miscellaneous
Namespaces
Properties
Base
Events
Types
Base
Variables
Base
Parsing
Base
Properties
Rendering
Resolving
Utilities
Mono.Cecil
Reflection
Nova.Examples
Properties
Nova.Studio
Images
About.png
Configuration.png
EditCopy.png
EditCut.png
EditDelete.png
EditPaste.png
EditRedo.png
EditUndo.png
Error.png
Exit.png
FileNew.png
FileOpen.png
FileSave.png
FileSaveAll.png
FileSaveAs.png
Find.png
Help.png
Info.png
Logo.png
Options.png
Print.png
PrintPreview.png
Properties.png
Todo.png
Warning.png
Objects.ico
Properties
Settings.settings
Nova.Test
Properties
Nova.UI
CodeDOM
Annotations
Base
Comments
Base
DocComments
CodeRef
Base
List
Name
Base
Other
Simple
CompilerDirectives
Base
Conditionals
Base
Messages
Base
Pragmas
Base
Symbols
Base
Base
Expressions
AnonymousMethods
Base
Operators
Base
Binary
Arithmetic
Base
Assignment
Base
Bitwise
Base
Conditional
Relational
Base
Shift
Base
Other
Base
Unary
Base
Other
References
Base
GotoTargets
Base
Methods
Namespaces
Other
Properties
Types
Base
Variables
Base
Projects
Namespaces
References
Base
Statements
Base
Conditionals
Base
Exceptions
Generics
Constraints
Base
Iterators
Base
Jumps
Loops
Methods
OperatorDecls
Miscellaneous
Namespaces
Properties
Base
Events
Types
Base
Variables
Base
Properties
Resolving
Utilties
<Window x:Class="Nova.Studio.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:Nova.Studio"
    xmlns:sys="clr-namespace:System;assembly=mscorlib"
    xmlns:mwt="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
    Title="Nova Studio" Height="1024" Width="1378" SnapsToDevicePixels="False" ResizeMode="CanResizeWithGrip" MouseMove="Window_MouseMove" Deactivated="Window_Deactivated">
    
    <Window.Resources>
        
        <Style TargetType="{x:Type Image}" x:Key="toolBarImageStyle">
            <Style.Triggers>
                <DataTrigger Binding="{Binding RelativeSource={RelativeSource AncestorType={x:Type Button}, AncestorLevel=1}, Mode=OneWay, Path=IsEnabled}" Value="False">
                    <Setter Property="Opacity" Value="0.33"></Setter>
                </DataTrigger>
            </Style.Triggers>
        </Style>
        
        <ControlTemplate x:Key="errorImage">
            <Image Source="Images/Error.png" ToolTip="Error" />
        </ControlTemplate>
        <ControlTemplate x:Key="warningImage">
            <Image Source="Images/Warning.png" ToolTip="Warning" />
        </ControlTemplate>
        <ControlTemplate x:Key="infoImage">
            <Image Source="Images/Info.png" ToolTip="Information" />
        </ControlTemplate>
        <ControlTemplate x:Key="todoImage">
            <Image Source="Images/Todo.png" ToolTip="ToDo" />
        </ControlTemplate>
        <DataTemplate x:Key="MessageGraphic">
            <StackPanel>
                <Control x:Name="messageIcon" Height="12" Width="12" Margin="0,2,0,0" Template="{StaticResource errorImage}" />
            </StackPanel>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding Path=Category}" Value="Error">
                    <Setter TargetName="messageIcon" Property="Template" Value="{StaticResource errorImage}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=Category}" Value="Warning">
                    <Setter TargetName="messageIcon" Property="Template" Value="{StaticResource warningImage}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=Category}" Value="Suggestion">
                    <Setter TargetName="messageIcon" Property="Template" Value="{StaticResource infoImage}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=Category}" Value="Hint">
                    <Setter TargetName="messageIcon" Property="Template" Value="{StaticResource infoImage}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=Category}" Value="Information">
                    <Setter TargetName="messageIcon" Property="Template" Value="{StaticResource infoImage}" />
                </DataTrigger>
                <DataTrigger Binding="{Binding Path=Category}" Value="ToDo">
                    <Setter TargetName="messageIcon" Property="Template" Value="{StaticResource todoImage}" />
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
        
        <Style x:Key="ListViewItemStyle" TargetType="{x:Type ListViewItem}">
            <Setter Property="VerticalContentAlignment" Value="Top" />
            <Setter Property="Margin" Value="0" />
        </Style>
        
        <local:StringConverterTrim x:Key="trimConverter" />

        <!-- ********** START OF TAB CONTROL RESOURCES ********** -->

        <LinearGradientBrush x:Key="ButtonNormalBackground" StartPoint="0,0" EndPoint="0,1">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="#F3F3F3" Offset="0" />
                <GradientStop Color="#EBEBEB" Offset="0.5" />
                <GradientStop Color="#DDDDDD" Offset="0.5" />
                <GradientStop Color="#CDCDCD" Offset="1" />
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>

        <Color x:Key="TabItem_ForegroundColor_Base">#4971A3</Color>
        <SolidColorBrush x:Key="TabItem_TextBrush_Selected" Color="#0D3288" />

        <!-- The colors that will be used when assembling the brushes for the LineButtons-->
        <Color x:Key="LineButtonBackgroundColor_Bright">LightGoldenrodYellow</Color>
        <Color x:Key="LineButtonBackgroundColor_Dark">#FAEEB1</Color>
        <Color x:Key="LineButtonBackgroundColorDisabled_Bright">#EEE</Color>
        <Color x:Key="LineButtonBackgroundColorDisabled_Dark">#999</Color>

        <!-- Color of the border around the scrollbar-thumb -->
        <SolidColorBrush x:Key="LineButtonBorderBrush" Color="#FF8693BD" />

        <SolidColorBrush x:Key="LineButtonBrush" Color="#FF14273D" />
        <LinearGradientBrush x:Key="LineButtonHoverBrush" StartPoint="0.5,0" EndPoint="0.5,1">
            <GradientStop Color="#FFFFD5A0" Offset="0.3" />
            <GradientStop Color="#FFFFA335" Offset="0.51" />
            <GradientStop Color="#FFFFC14A" Offset="0.986" />
        </LinearGradientBrush>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="LineButtonBackgroundBrush">
            <GradientStop Offset="0.3" Color="{StaticResource LineButtonBackgroundColor_Bright}" />
            <GradientStop Offset="0.4" Color="{StaticResource LineButtonBackgroundColor_Dark}" />
            <GradientStop Offset="1" Color="{StaticResource LineButtonBackgroundColor_Bright}" />
        </LinearGradientBrush>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="LineButtonPressedBrush">
            <GradientStop Offset="0" Color="{StaticResource LineButtonBackgroundColor_Bright}" />
            <GradientStop Offset="0.6" Color="{StaticResource LineButtonBackgroundColor_Dark}" />
            <GradientStop Offset="0.7" Color="{StaticResource LineButtonBackgroundColor_Bright}" />
        </LinearGradientBrush>
        <LinearGradientBrush StartPoint="0,0" EndPoint="0,1" x:Key="LineButtonDisabledBrush">
            <GradientStop Offset="0" Color="{StaticResource LineButtonBackgroundColorDisabled_Bright}" />
            <GradientStop Offset="1" Color="{StaticResource LineButtonBackgroundColorDisabled_Dark}" />
        </LinearGradientBrush>

        <!-- The background color of the TabItems popup-menu -->
        <LinearGradientBrush x:Key="TabItemMenuBackcolor" StartPoint="0,0" EndPoint="1,1">
            <GradientStop Offset="0" Color="White" />
            <GradientStop Offset="1" Color="#EEE" />
        </LinearGradientBrush>

        <!-- This determines how wide/high the LineButtons and the TabMenu button will be rendered -->
        <sys:Double x:Key="ButtonWidthAndHeight">16</sys:Double>

        <!-- This determines how wide/high the CloseButtons on TabItems will be rendered -->
        <sys:Double x:Key="CloseButtonWidthAndHeight">14</sys:Double>

        <!-- Styles for the LineButtons -->
        <Style x:Key="LineButtonStyle" TargetType="{x:Type RepeatButton}">
            <Setter Property="Focusable" Value="False" />
            <Setter Property="Height" Value="{StaticResource ButtonWidthAndHeight}" />
            <Setter Property="Width" Value="{StaticResource ButtonWidthAndHeight}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type RepeatButton}">
                        <Border Name="ButtonBorder" Margin="1" BorderBrush="{StaticResource LineButtonBorderBrush}" 
                          Background="{StaticResource LineButtonBackgroundBrush}" CornerRadius="1" BorderThickness="1">
                            <ContentPresenter HorizontalAlignment="Stretch" VerticalAlignment="Stretch" />
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="ButtonBorder" Property="Background" Value="{StaticResource LineButtonHoverBrush}" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter TargetName="ButtonBorder" Property="Background" Value="{StaticResource LineButtonPressedBrush}" />
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter TargetName="ButtonBorder" Property="Background" Value="{StaticResource LineButtonDisabledBrush}" />
                                <Setter TargetName="ButtonBorder" Property="Opacity" Value="0.4" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- The style for the MenuItem that represents the clickable portion for opening the sub-menu that itself will contain the list of TabItems -->
        <Style x:Key="TabMenuButtonStyle" TargetType="{x:Type MenuItem}">
            <Setter Property="Focusable" Value="False" />
            <Setter Property="Height" Value="{StaticResource ButtonWidthAndHeight}" />
            <Setter Property="Width" Value="{StaticResource ButtonWidthAndHeight}" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type MenuItem}">
                        <Border Name="ButtonBorder" Margin="1" BorderBrush="{StaticResource LineButtonBorderBrush}"
                                Background="{StaticResource LineButtonBackgroundBrush}" CornerRadius="1" BorderThickness="1" ToolTip="List Tabs">
                            <Grid>
                                <ContentPresenter ContentSource="Header" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                                    <ContentPresenter.Content>
                                        <Path Margin="3" Data="M0,0 L5,10 10,0Z" Stroke="{StaticResource LineButtonBrush}" Fill="{StaticResource LineButtonBrush}"
                                              Stretch="Fill" VerticalAlignment="Center" HorizontalAlignment="Center" />
                                    </ContentPresenter.Content>
                                </ContentPresenter>
                                <Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
                                    <!-- Since we override the ControlTemplate, we're also responsible for drawing stuff like the shadow around the popup-menu.
                                     Here, I'll use a Chrome that's provided in the Aero assembly. Note that, in order to use this (that is, the namespace defined
                                     at the very top of this window), a reference to PresentationFramework.Aero is required.
                                    -->
                                    <mwt:SystemDropShadowChrome Color="#71000000" CornerRadius="1" Margin="0,0,8,8" SnapsToDevicePixels="True">
                                        <Border Name="SubmenuBorder" Margin="1" SnapsToDevicePixels="True" BorderBrush="{StaticResource LineButtonBorderBrush}" 
                                                Background="{StaticResource TabItemMenuBackcolor}" CornerRadius="1" BorderThickness="1">
                                            <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
                                        </Border>
                                    </mwt:SystemDropShadowChrome>
                                </Popup>
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsHighlighted" Value="true">
                                <Setter TargetName="ButtonBorder" Property="Background" Value="{StaticResource LineButtonHoverBrush}" />
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="False">
                                <Setter TargetName="ButtonBorder" Property="Background" Value="{StaticResource LineButtonDisabledBrush}" />
                                <Setter TargetName="ButtonBorder" Property="Opacity" Value="0.4" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- The style for MenuItems that represent TabItems -->
        <Style x:Key="TabMenuItem" TargetType="{x:Type MenuItem}">
            <!-- In order to not further pollute the sample with more ControlTemplates, I'll stick with simply overriding
            the HighlightBrushKey for the hovered MenuItem. Poor man's Style. -->
            <Style.Resources>
                <LinearGradientBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" StartPoint="0.5,0" EndPoint="0.5,1">
                    <GradientStop Color="#FFFFD5A0" Offset="0.3" />
                    <GradientStop Color="#FFEFA335" Offset="0.51" />
                    <GradientStop Color="#FFFFC14A" Offset="0.986" />
                </LinearGradientBrush>
            </Style.Resources>

            <!-- This will help us bind to the Header of a TabItem -->
            <Setter Property="Header" Value="{Binding Path=Header.Text}" />
            <!-- By making the MenuItems checkable AND binding the IsChecked property to the IsSelected property of the TabItems, we'll 
            efficiently allow to pick the selected TabItem from the Menu with a simple two-way binding. -->
            <Setter Property="IsCheckable" Value="{Binding Path=IsEnabled}" />
            <Setter Property="IsChecked" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
            <Setter Property="Foreground" Value="{StaticResource TabItem_TextBrush_Selected}" />
        </Style>

        <!--******** Stuff for the TabItemCloseButton ************-->
        <SolidColorBrush x:Key="TabItemCloseButtonNormalForegroundBrush" Color="{StaticResource TabItem_ForegroundColor_Base}" />
        <SolidColorBrush x:Key="TabItemCloseButtonHoverForegroundBrush" Color="White" />
        <SolidColorBrush x:Key="TabItemCloseButtonPressedForegroundBrush" Color="#EEEE" />

        <LinearGradientBrush x:Key="TabItemCloseButtonNormalBackgroundBrush" StartPoint="0,0" EndPoint="1,0">
            <GradientBrush.GradientStops>
                <GradientStopCollection>
                    <GradientStop Color="#5FFF" Offset="0.0" />
                    <GradientStop Color="#5CCC" Offset="1.0" />
                </GradientStopCollection>
            </GradientBrush.GradientStops>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="TabItemCloseButtonNormalBorderBrush" StartPoint="0,0" EndPoint="1,1">
            <GradientBrush.GradientStops>
                <GradientStopCollection>
                    <GradientStop Color="#5CCC" Offset="0.0" />
                    <GradientStop Color="#5444" Offset="1.0" />
                </GradientStopCollection>
            </GradientBrush.GradientStops>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="TabItemCloseButtonHoverBackgroundBrush" StartPoint="0,1" EndPoint="1,0">
            <GradientBrush.GradientStops>
                <GradientStopCollection>
                    <GradientStop Color="#FFDF2B1E" Offset="0.0" />
                    <GradientStop Color="#FFA41F00" Offset="1.0" />
                </GradientStopCollection>
            </GradientBrush.GradientStops>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="TabItemCloseButtonPressedBackgroundBrush" StartPoint="0,0" EndPoint="1,1">
            <GradientBrush.GradientStops>
                <GradientStopCollection>
                    <GradientStop Color="#FFA41F00" Offset="0.0" />
                    <GradientStop Color="#FFDF2B1E" Offset="1.0" />
                </GradientStopCollection>
            </GradientBrush.GradientStops>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="TabItemCloseButtonPressedBorderBrush" StartPoint="0,0" EndPoint="1,1">
            <GradientBrush.GradientStops>
                <GradientStopCollection>
                    <GradientStop Color="#5444" Offset="0.0" />
                    <GradientStop Color="#5CCC" Offset="1.0" />
                </GradientStopCollection>
            </GradientBrush.GradientStops>
        </LinearGradientBrush>

        <Style x:Key="TabItemCloseButtonStyle" TargetType="{x:Type Button}">
            <!-- The default value for SnapsToDevicePixels actually is False (so this setter really wouldn't be required). However, I'm 
            adding this nevertheless in order to explicitly point out that, in this case, it is required (see below). -->
            <Setter Property="SnapsToDevicePixels" Value="false" />
            <Setter Property="Height" Value="{StaticResource CloseButtonWidthAndHeight}" />
            <Setter Property="Width" Value="{StaticResource CloseButtonWidthAndHeight}" />
            <Setter Property="Cursor" Value="Hand" />
            <Setter Property="Focusable" Value="False" />
            <Setter Property="OverridesDefaultStyle" Value="true" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Button}">
                        <Border x:Name="ButtonBorder" CornerRadius="2" BorderThickness="1" Background="{StaticResource TabItemCloseButtonNormalBackgroundBrush}"
                                BorderBrush="{StaticResource TabItemCloseButtonNormalBorderBrush}" ToolTip="Close">
                            <Grid>
                                <!-- The Path below will render the button's X. -->
                                <Path x:Name="ButtonPath" Margin="2" Data="M0,0 L10,10 M0,10 L10,0" Stroke="{StaticResource TabItemCloseButtonNormalForegroundBrush}" 
                                      StrokeThickness="2" StrokeStartLineCap="Round" StrokeEndLineCap="Round" Stretch="Uniform" VerticalAlignment="Center" HorizontalAlignment="Center" />
                            </Grid>
                        </Border>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="True">
                                <Setter TargetName="ButtonBorder" Property="Background" Value="{StaticResource TabItemCloseButtonHoverBackgroundBrush}" />
                                <Setter TargetName="ButtonPath" Property="Stroke" Value="{StaticResource TabItemCloseButtonHoverForegroundBrush}" />
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Visibility" Value="Collapsed" />
                            </Trigger>
                            <Trigger Property="IsPressed" Value="true">
                                <Setter TargetName="ButtonBorder" Property="Background" Value="{StaticResource TabItemCloseButtonPressedBackgroundBrush}" />
                                <Setter TargetName="ButtonBorder" Property="BorderBrush" Value="{StaticResource TabItemCloseButtonPressedBorderBrush}" />
                                <Setter TargetName="ButtonPath" Property="Stroke" Value="{StaticResource TabItemCloseButtonPressedForegroundBrush}" />
                                <!-- Simulate a pressed-effect by moving the contents down and to the right. Since the button is pretty small, the trick here is to only shift things
                                     just a tiny little bit, hence the fractional values below.  Note that, in order for this to work as expected, SnapsToDevicePixels
                                     must be set to "false" (see the setter at the top of this style). -->
                                <Setter TargetName="ButtonPath" Property="Margin" Value="2.5,2.5,1.5,1.5" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <SolidColorBrush x:Key="TabControlNormalBorderBrush" Color="#8C8E94" />
        
        <!-- The TabControl's Style -->
        <Style TargetType="{x:Type TabControl}">
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}" />
            <Setter Property="Padding" Value="4,4,4,4" />
            <Setter Property="BorderThickness" Value="1" />
            <Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}" />
            <Setter Property="Background" Value="#F9F9F9" />
            <Setter Property="HorizontalContentAlignment" Value="Center" />
            <Setter Property="VerticalContentAlignment" Value="Center" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabControl}">
                        <Grid KeyboardNavigation.TabNavigation="Local" SnapsToDevicePixels="True" ClipToBounds="True">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" Name="RowDefinition0" />
                                <RowDefinition Height="*" Name="RowDefinition1" />
                            </Grid.RowDefinitions>
                            <Grid Name="TabPanel" Grid.Row="0" Panel.ZIndex="1" Margin="2,2,2,0">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*" />
                                    <ColumnDefinition Width="Auto" />
                                </Grid.ColumnDefinitions>
                                <!--ScrollViewer Name="ScrollViewer" Margin="0" Padding="0" CanContentScroll="True" VerticalScrollBarVisibility="Disabled" HorizontalScrollBarVisibility="Hidden"
                                              IsDeferredScrollingEnabled="False" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ClipToBounds="False"-->
                                    <TabPanel x:Name="HeaderPanel" KeyboardNavigation.TabIndex="1" IsItemsHost="True" />
                                <!--/ScrollViewer-->
                                <StackPanel Name="ButtonPanel" Grid.Column="1" Orientation="Horizontal" Margin="2,1,0,1" VerticalAlignment="Bottom">
                                    <!-- The RepeatButtons below provide the left/right scroll functionality for the TabItems -->
                                    <!--RepeatButton x:Name="cmdScrollLeft" Focusable="False" Style="{StaticResource LineButtonStyle}" CommandTarget="{Binding ElementName=HeaderPanel}"
                                        Command="ScrollBar.LineLeftCommand" IsEnabled="{Binding ElementName=PART_ScrollContentPresenter, Path=CanScrollLeft}">
                                        <RepeatButton.Content>
                                            <Path Margin="3" Data="M0,5 L10,10 10,0Z" Stroke="{StaticResource LineButtonBrush}" Fill="{StaticResource LineButtonBrush}"
                                                  Stretch="Fill" VerticalAlignment="Center" HorizontalAlignment="Center" />
                                        </RepeatButton.Content>
                                    </RepeatButton-->
                                    <!--RepeatButton x:Name="cmdScrollRight" Focusable="False" Style="{StaticResource LineButtonStyle}" CommandTarget="{Binding ElementName=HeaderPanel}"
                                        Command="ScrollBar.LineRightCommand" IsEnabled="{Binding ElementName=PART_ScrollContentPresenter, Path=CanScrollRight}">
                                        <Path Margin="3" Data="M0,0 L10,5 0,10Z" Stroke="{StaticResource LineButtonBrush}" Fill="{StaticResource LineButtonBrush}"
                                              Stretch="Fill" VerticalAlignment="Center" HorizontalAlignment="Center" />
                                    </RepeatButton-->
                                    <!-- Represents another "button" which will open up a Menu containing all TabItems, with the selected one being checked.
                                         Clicking an item here will select the respective TabItem. -->
                                    <Menu Background="Transparent">
                                        <MenuItem Style="{StaticResource TabMenuButtonStyle}" ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, 
                                            AncestorType={x:Type TabControl}}, Path=Items}" ItemContainerStyle="{StaticResource TabMenuItem}" IsEnabled="{Binding RelativeSource={RelativeSource FindAncestor, 
                                            AncestorType={x:Type TabControl}}, Path=Items.Count}">
                                        </MenuItem>
                                    </Menu>
                                </StackPanel>
                            </Grid>
                            <Border x:Name="ContentPanel" Grid.Row="1" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}" BorderBrush="{TemplateBinding BorderBrush}"
                                    KeyboardNavigation.TabNavigation="Local" KeyboardNavigation.DirectionalNavigation="Contained" KeyboardNavigation.TabIndex="2">
                                <ContentPresenter x:Name="PART_SelectedContentHost" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="{TemplateBinding Padding}" ContentSource="SelectedContent" />
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="TabControl.TabStripPlacement" Value="Bottom">
                                <Setter TargetName="TabPanel" Property="Grid.Row" Value="1" />
                                <Setter TargetName="ContentPanel" Property="Grid.Row" Value="0" />
                                <Setter TargetName="RowDefinition0" Property="RowDefinition.Height" Value="*" />
                                <Setter TargetName="RowDefinition1" Property="RowDefinition.Height" Value="Auto" />
                                <Setter TargetName="TabPanel" Property="Margin" Value="2,0,2,2" />
                                <Setter TargetName="ButtonPanel" Property="VerticalAlignment" Value="Top" />
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- This is required in order to appropriately draw the focus-visual -->
        <Style x:Key="TabItemFocusVisual">
            <Setter Property="Control.Template">
                <Setter.Value>
                    <ControlTemplate>
                        <Rectangle Margin="3,3,3,1" StrokeThickness="1" Stroke="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"
                                   StrokeDashArray="1 2" SnapsToDevicePixels="true" />
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <LinearGradientBrush x:Key="TabItemHotBackground" StartPoint="0,0" EndPoint="0,1">
            <LinearGradientBrush.GradientStops>
                <GradientStop Color="#EAF6FD" Offset="0.15" />
                <GradientStop Color="#D9F0FC" Offset=".5" />
                <GradientStop Color="#BEE6FD" Offset=".5" />
                <GradientStop Color="#A7D9F5" Offset="1" />
            </LinearGradientBrush.GradientStops>
        </LinearGradientBrush>
        <SolidColorBrush x:Key="TabItemSelectedBackground" Color="#F9F9F9" />
        <SolidColorBrush x:Key="TabItemDisabledBackground" Color="#F4F4F4" />
        <SolidColorBrush x:Key="TabItemHotBorderBrush" Color="#3C7FB1" />
        <SolidColorBrush x:Key="TabItemDisabledBorderBrush" Color="#FFC9C7BA" />

        <!-- The Style for TabItems -->
        <Style TargetType="{x:Type TabItem}">
            <Setter Property="FocusVisualStyle" Value="{StaticResource TabItemFocusVisual}" />
            <Setter Property="Foreground" Value="Black" />
            <Setter Property="Padding" Value="4,1,3,1" />
            <Setter Property="BorderBrush" Value="{StaticResource TabControlNormalBorderBrush}" />
            <Setter Property="Background" Value="{StaticResource ButtonNormalBackground}" />
            <Setter Property="HorizontalContentAlignment" Value="Stretch" />
            <Setter Property="VerticalContentAlignment" Value="Stretch" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type TabItem}">
                        <Grid SnapsToDevicePixels="true">
                            <Border Name="Bd" Padding="{TemplateBinding Padding}" BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="1,1,1,0">
                                <StackPanel x:Name="Content" Orientation="Horizontal">
                                    <ContentPresenter x:Name="TabContent" ContentSource="Header" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                                      HorizontalAlignment="Center" VerticalAlignment="Center" RecognizesAccessKey="True" />
                                    <Button x:Name="TabItemCloseButton" Grid.Column="1" Style="{StaticResource TabItemCloseButtonStyle}" Command="Close"
                                            CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type TabItem}}}" Margin="3,1,0,1" />
                                </StackPanel>
                            </Border>
                        </Grid>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsMouseOver" Value="true">
                                <Setter TargetName="Bd" Property="Background" Value="{StaticResource TabItemHotBackground}" />
                            </Trigger>
                            <Trigger Property="IsSelected" Value="true">
                                <Setter Property="Panel.ZIndex" Value="1" />
                                <Setter TargetName="Bd" Property="Background" Value="{StaticResource TabItemSelectedBackground}" />
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="false" />
                                    <Condition Property="IsMouseOver" Value="true" />
                                </MultiTrigger.Conditions>
                                <Setter TargetName="Bd" Property="BorderBrush" Value="{StaticResource TabItemHotBorderBrush}" />
                            </MultiTrigger>
                            <Trigger Property="TabStripPlacement" Value="Bottom">
                                <Setter TargetName="Bd" Property="BorderThickness" Value="1,0,1,1" />
                            </Trigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true" />
                                    <Condition Property="TabStripPlacement" Value="Top" />
                                </MultiTrigger.Conditions>
                                <Setter Property="Margin" Value="-2,-2,-2,-1" />
                                <Setter TargetName="Content" Property="Margin" Value="0,0,0,1" />
                            </MultiTrigger>
                            <MultiTrigger>
                                <MultiTrigger.Conditions>
                                    <Condition Property="IsSelected" Value="true" />
                                    <Condition Property="TabStripPlacement" Value="Bottom" />
                                </MultiTrigger.Conditions>
                                <Setter Property="Margin" Value="-2,-1,-2,-2" />
                                <Setter TargetName="Content" Property="Margin" Value="0,1,0,0" />
                            </MultiTrigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter TargetName="Bd" Property="Background" Value="{StaticResource TabItemDisabledBackground}" />
                                <Setter TargetName="Bd" Property="BorderBrush" Value="{StaticResource TabItemDisabledBorderBrush}" />
                                <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}" />
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>

        <!-- ********** END OF TAB CONTROL RESOURCES ********** -->

    </Window.Resources>
    
    <Window.CommandBindings>
        <CommandBinding Command="Open" Executed="OnFileOpen" CanExecute="CanAlwaysExecute" />
        <CommandBinding Command="Close" Executed="OnFileClose" CanExecute="CanCloseExecute" />
        <CommandBinding Command="Save" Executed="OnFileSave" CanExecute="CanSaveExecute" />
        <CommandBinding Command="SaveAs" Executed="OnFileSaveAs" CanExecute="CanSaveExecute" />
    </Window.CommandBindings>
    
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" MinHeight="22" />
            <RowDefinition Height="Auto" MinHeight="26" />
            <RowDefinition/>
            <RowDefinition Height="Auto" MinHeight="23" />
        </Grid.RowDefinitions>
        
        <Menu Height="22" Grid.Row="0" Name="menu">
            <MenuItem Header="_File">
                <MenuItem Header="_New" Command="New">
                    <MenuItem.Icon>
                        <Image Source="Images\FileNew.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="_Open" Command="Open">
                    <MenuItem.Icon>
                        <Image Source="Images\FileOpen.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator/>
                <MenuItem Header="_Close" InputGestureText="Ctrl+F4" Command="Close" />
                <MenuItem Header="Close Solu_tion" Command="local:MainWindow.CloseSolutionCommand" />
                <Separator/>
                <MenuItem Header="_Save" Command="Save">
                    <MenuItem.Icon>
                        <Image Source="Images\FileSave.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Save As..." Command="SaveAs">
                    <MenuItem.Icon>
                        <Image Source="Images\FileSaveAs.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Save All" Command="local:MainWindow.SaveAllCommand" InputGestureText="Ctrl+Shift+S">
                    <MenuItem.Icon>
                        <Image Source="Images\FileSaveAll.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator/>
                <MenuItem Header="_Print" Command="Print">
                    <MenuItem.Icon>
                        <Image Source="Images\Print.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Print Pre_view" Command="PrintPreview">
                    <MenuItem.Icon>
                        <Image Source="Images\PrintPreview.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator/>
                <MenuItem Header="E_xit" Click="Exit_Click">
                    <MenuItem.Icon>
                        <Image Source="Images\Exit.png" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="_Edit">
                <MenuItem Header="_Undo" Command="Undo">
                    <MenuItem.Icon>
                        <Image Source="Images\EditUndo.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="_Redo" Command="Redo">
                    <MenuItem.Icon>
                        <Image Source="Images\EditRedo.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator/>
                <MenuItem Header="Cu_t" Command="Cut">
                    <MenuItem.Icon>
                        <Image Source="Images\EditCut.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="_Copy" Command="Copy">
                    <MenuItem.Icon>
                        <Image Source="Images\EditCopy.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="_Paste" Command="Paste">
                    <MenuItem.Icon>
                        <Image Source="Images\EditPaste.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="Delete" Command="Delete">
                    <MenuItem.Icon>
                        <Image Source="Images\EditDelete.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <Separator/>
                <MenuItem Header="Select _All" Command="SelectAll" />
                <Separator/>
                <MenuItem Header="_Find" Command="Find">
                    <MenuItem.Icon>
                        <Image Source="Images\Find.png" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="_Tools">
                <MenuItem Header="_Configuration Manager" Command="local:MainWindow.ConfigurationManagerCommand">
                    <MenuItem.Icon>
                        <Image Source="Images\Configuration.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="_Options" IsEnabled="False">
                    <MenuItem.Icon>
                        <Image Source="Images\Options.png" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
            <MenuItem Header="_Help">
                <MenuItem Header="_Contents" IsEnabled="False">
                    <MenuItem.Icon>
                        <Image Source="Images\Help.png" />
                    </MenuItem.Icon>
                </MenuItem>
                <MenuItem Header="_Index" IsEnabled="False" />
                <MenuItem Header="_Search" Command="Search" />
                <Separator/>
                <MenuItem Header="_About..." Command="local:MainWindow.AboutCommand">
                    <MenuItem.Icon>
                        <Image Source="Images\About.png" />
                    </MenuItem.Icon>
                </MenuItem>
            </MenuItem>
        </Menu>
        
        <ToolBarTray Grid.Row="1" Name="toolBarTray1">
            <ToolBar Name="toolBarMain" VerticalAlignment="Top" HorizontalAlignment="Left">
                <Button ToolTip="New" Command="New">
                    <Image Source="Images\FileNew.png" Style="{StaticResource toolBarImageStyle}" />
                </Button>
                <Button ToolTip="Open" Command="Open">
                    <Image Source="Images\FileOpen.png" Style="{StaticResource toolBarImageStyle}" />
                </Button>
                <Button ToolTip="Save" Command="Save">
                    <Image Source="Images\FileSave.png" Style="{StaticResource toolBarImageStyle}" />
                </Button>
                <Button ToolTip="Save All" Command="local:MainWindow.SaveAllCommand">
                    <Image Source="Images\FileSaveAll.png" Style="{StaticResource toolBarImageStyle}" />
                </Button>
                <Separator/>
                <Button ToolTip="Cut" Command="Cut">
                    <Image Source="Images\EditCut.png" Style="{StaticResource toolBarImageStyle}" />
                </Button>
                <Button ToolTip="Copy" Command="Copy">
                    <Image Source="Images\EditCopy.png" Style="{StaticResource toolBarImageStyle}" />
                </Button>
                <Button ToolTip="Paste" Command="Paste">
                    <Image Source="Images\EditPaste.png" Style="{StaticResource toolBarImageStyle}" />
                </Button>
                <Separator/>
                <Button ToolTip="Find" Command="Find">
                    <Image Source="Images\Find.png" Style="{StaticResource toolBarImageStyle}" />
                </Button>
                <Separator/>
                <Button Name="buttonActiveConfigurationPlatform" Command="local:MainWindow.ConfigurationManagerCommand" BorderBrush="LightBlue" ToolTip="Active Configuration / Platform" MinWidth="100" MinHeight="21" IsEnabled="False" />
            </ToolBar>
            <ToolBar Height="35" Name="toolBarFont" VerticalAlignment="Top" HorizontalAlignment="Left">
                <ComboBox Name="comboBoxFonts" Width="200" MaxDropDownHeight="240" ToolTip="Display Font" SelectionChanged="comboBoxFonts_SelectionChanged" />
                <TextBox Name="textBoxFontSize" Width="30" ToolTip="Font Size" TextChanged="textBoxFontSize_TextChanged" />
            </ToolBar>
        </ToolBarTray>
        
        <Grid Grid.Row="2">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="270" />
            </Grid.ColumnDefinitions>
            <Grid Grid.Column="0" Margin="0,0,4,0">
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition Height="200" />
                </Grid.RowDefinitions>
                
                <TabControl Name="tabControlFiles" Grid.Row="0" Margin="0,0,0,4" Loaded="tabControlFiles_Loaded" SelectionChanged="tabControlFiles_SelectionChanged" />
                
                <GridSplitter ResizeDirection="Rows" Height="4" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" />
                
                <TabControl Name="tabControlOutput" Grid.Row="1" TabStripPlacement="Bottom" SelectionChanged="tabControlOutput_SelectionChanged">
                    <TabItem Name="tabItemOutput">
                        <TabItem.Header>
                            <TextBlock Text="Output" />
                        </TabItem.Header>
                        <ListView Name="listViewOutput" />
                    </TabItem>
                    <TabItem Name="tabItemMessages">
                        <TabItem.Header>
                            <TextBlock Text="Messages (0)" />
                        </TabItem.Header>
                        <ListView Name="listViewMessages" ItemsSource="{Binding}" ItemContainerStyle="{StaticResource ListViewItemStyle}"
                                  ScrollViewer.HorizontalScrollBarVisibility="Disabled" MouseDoubleClick="listViewMessages_MouseDoubleClick">
                            <ListView.View>
                                <GridView>
                                    <GridViewColumn Width="24" CellTemplate="{StaticResource MessageGraphic}" />
                                    <GridViewColumn Header="Message" Width="606">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Text="{Binding Path=Annotation.Text, Converter={StaticResource trimConverter}}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="File" Width="180">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock TextTrimming="CharacterEllipsis" Text="{Binding Path=CodeUnit.Name}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="Line-Col" Width="64">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock TextTrimming="CharacterEllipsis" Text="{Binding Path=LineCol}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                    <GridViewColumn Header="Project" Width="180">
                                        <GridViewColumn.CellTemplate>
                                            <DataTemplate>
                                                <TextBlock TextTrimming="CharacterEllipsis" Text="{Binding Path=Project.Name}" />
                                            </DataTemplate>
                                        </GridViewColumn.CellTemplate>
                                    </GridViewColumn>
                                </GridView>
                            </ListView.View>
                        </ListView>
                    </TabItem>
                </TabControl>
                
            </Grid>
            <GridSplitter ResizeDirection="Columns" Width="4" HorizontalAlignment="Right" />
            <Grid Grid.Column="1">
                <Grid.RowDefinitions>
                    <RowDefinition Height="*" />
                </Grid.RowDefinitions>
                
                <TreeView Name="treeViewSolutionFiles" Margin="0,0,0,4" MinHeight="200" MouseDoubleClick="treeViewSolutionFiles_MouseDoubleClick" ContextMenuOpening="treeViewSolutionFiles_ContextMenuOpening">
                    <TreeView.Resources>
                        <Style TargetType="TreeViewItem">
                            <EventSetter Event="MouseRightButtonDown" Handler="treeViewSolutionFiles_MouseRightButtonDown" />
                        </Style>
                    </TreeView.Resources>
                </TreeView>
                
                <GridSplitter ResizeDirection="Rows" Height="4" VerticalAlignment="Bottom" HorizontalAlignment="Stretch" />
            </Grid>
        </Grid>
        
        <StatusBar Grid.Row="4" Height="23" Name="statusBar">
            <StatusBarItem>
                <WrapPanel>
                    <TextBlock Name="textBlockStatus"></TextBlock>
                    <ProgressBar Name="progressBarStatus" IsIndeterminate="True" Width="500" Visibility="Hidden" Margin="12,0,0,0"></ProgressBar>
                </WrapPanel>
            </StatusBarItem>
            <StatusBarItem HorizontalAlignment="Right">
                <Button Name="btnHeapSize" Content="0 MB" FontSize="10" Padding="1,0,1,0" Margin="0,0,12,0" Click="btnHeapSize_Click">
                    <Button.ToolTip>
                        <TextBlock>Heap Size<LineBreak/>(Click to Collect)</TextBlock>
                    </Button.ToolTip>
                </Button>
            </StatusBarItem>
        </StatusBar>
    </Grid>
</Window>

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 Common Development and Distribution License (CDDL)

Share

About the Author

KenBeckett
Software Developer (Senior)
United States United States
I've been writing software since the late 70's, currently focusing mainly on C#.NET. I also like to travel around the world, and I own a Chocolate Factory (sadly, none of my employees are oompa loompas).

| Advertise | Privacy | Mobile
Web01 | 2.8.140916.1 | Last Updated 2 Dec 2012
Article Copyright 2012 by KenBeckett
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid