<UserControl x:Class="FlexSheetSample.FlexSheetDemo"
             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:c1="http://schemas.componentone.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:FlexSheetSample"
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <UserControl.Resources>
        <local:ProtectedConverter x:Key="protectedConverter"></local:ProtectedConverter>
        <Style TargetType="c1:C1ToolbarButton">
            <Setter Property="IsEnabled" Value="{Binding IsProtected, Converter={StaticResource protectedConverter}}" />
        </Style>
        <Style TargetType="ComboBox" x:Key="comboRotate">
            <Setter Property="IsEnabled" Value="{Binding IsProtected, Converter={StaticResource protectedConverter}}" />
        </Style>
        <Style x:Key="Pictures" TargetType="c1:C1ToolbarButton">
            <Setter Property="MinHeight" Value="68" />
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid Margin="2">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Grid Height="30" Width="30">
                                <Rectangle Fill="#FFFFFBFF">
                                    <Rectangle.Stroke>
                                        <LinearGradientBrush EndPoint="0.958,0.952" StartPoint="0.023,0.039">
                                            <GradientStop Color="#FF99A7BB" Offset="0.349" />
                                            <GradientStop Color="#FF5B6F82" Offset="0.64" />
                                        </LinearGradientBrush>
                                    </Rectangle.Stroke>
                                </Rectangle>
                                <Rectangle Fill="#FFC8E9FF" Stroke="#FF6B696B" Margin="3,3,3,7" />
                                <Ellipse Fill="#FFFFFFEC" Stroke="#FFFFB69F" HorizontalAlignment="Right" Margin="0,6,6,0" VerticalAlignment="Top" Width="7" Height="7" />
                                <Path Stretch="Fill" Stroke="#FF6A88B4" HorizontalAlignment="Right" Margin="0,0,3.5,7" VerticalAlignment="Bottom" Width="12.5" Height="8" Data="M7.5157213,0.50003147 C7.7821407,0.50205714 8.0433197,0.60179216 8.220891,0.79316014 9.2323208,1.7883756 10.674407,3.2958273 11.921554,4.6299407 L12,4.7140047 12,7.5000002 0.5,7.5000002 C0.5102697,7.2906582 4.635251,3.0045552 6.7791095,0.79316014 6.9776416,0.59369022 7.2493014,0.49800617 7.5157213,0.50003147 z">
                                    <Path.Fill>
                                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                            <GradientStop Color="#FFE9F3FD" Offset="0.4" />
                                            <GradientStop Color="#FF7DA5E8" Offset="0.6" />
                                        </LinearGradientBrush>
                                    </Path.Fill>
                                </Path>
                                <Path Stretch="Fill" Stroke="#FF6A88B4" HorizontalAlignment="Left" Margin="3,0,0,7" VerticalAlignment="Bottom" Width="18" Height="10.393" Data="M8.1246327,0.5 C8.6067815,-0.035343007 9.444124,-0.013598815 9.8753673,0.5 12.495453,3.3490518 17.495494,9.326433 17.5,9.5 L0.5,9.5 C0.51247038,9.2190814 5.5213761,3.4675011 8.1246327,0.5 z">
                                    <Path.Fill>
                                        <LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
                                            <GradientStop Color="#FFE9F3FD" Offset="0.4" />
                                            <GradientStop Color="#FF7DA5E8" Offset="0.6" />
                                        </LinearGradientBrush>
                                    </Path.Fill>
                                </Path>
                                <Rectangle Stroke="#FF6B696B" Margin="3,3,3,7" />
                            </Grid>
                            <TextBlock Grid.Row="1" Text="Picture" TextAlignment="Center" Margin="0 6 0 0" TextWrapping="Wrap" LineStackingStrategy="BlockLineHeight" LineHeight="12" />
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="IsEnabled" Value="{Binding IsProtected, Converter={StaticResource protectedConverter}}" />
        </Style>
        <Style x:Key="FindAndReplace" TargetType="c1:C1ToolbarButton">
            <Setter Property="MinHeight" Value="68" />
            <Setter Property="ContentTemplate">
                <Setter.Value>
                    <DataTemplate>
                        <Grid Margin="2" MaxWidth="75">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto" />
                                <RowDefinition />
                            </Grid.RowDefinitions>
                            <Grid Margin="4" Height="26" Width="30">
                                <Path Stretch="Fill" Data="M6,0 L12,0 12,4.0000001 14,4.0000001 14,9.6510001 16,9.6510001 16,4.0000001 18,4.0000001 18,0 24,0 24,4.0000001 26,4.0000001 26,9.4308072 27.392088,9.4308078 27.392088,14 30,14 30,26 17.996,26 17.996,14.49118 12,14.49118 12,26 0,26 0,14 2.681179,14&#xD;&#xA;2.681179,9.4308081 4,9.4308072 4,4.0000001 6,4.0000001 z">
                                    <Path.Fill>
                                        <LinearGradientBrush EndPoint="0.979,0.734" StartPoint="-0.019,0.488">
                                            <GradientStop Color="White" Offset="0.2" />
                                            <GradientStop Color="#FF6C7BBD" Offset="0.465" />
                                            <GradientStop Color="#FFB3BDEC" Offset="0.524" />
                                            <GradientStop Color="White" Offset="0.75" />
                                            <GradientStop Color="#FF6C7BBD" Offset="1" />
                                        </LinearGradientBrush>
                                    </Path.Fill>
                                </Path>
                                <Path Stretch="Fill" Data="M19,15 L19,25 29,25 29,15 z M0.99999994,15 L0.99999994,25 11,25 11,15 z M17,10 L17,14 18,14 20,14 26,14 27,14 27,10 26,10 24,10 23,10 18,10 z M14,10 L14,14 16,14 16,10 z M2.9999998,10 L2.9999998,14 4,14 10,14 12,14 13,14 13,10 12,10 7,10 6,10 4,10 z M17,5.0000002 L17,9.0000002 23,9.0000002 25,9.0000002 25,5.0000002 z M5,5.0000002 L5,9.0000002 7,9.0000002 13,9.0000002 13,5.0000002 z M19,0.99999994 L19,4.0000002 20,4.0000002 22,4.0000002 23,4.0000002 23,0.99999994 z M7,0.99999994 L7,4.0000002 8,4.0000002 10,4.0000002 11,4.0000002 11,0.99999994 z M6,0 L8,0 10,0 12,0 12,2.0000007 12,4.0000002 14,4.0000002 14,6.0000002 14,8.0000002 14,9.0000002 16,9.0000002 16,8.0000002 16,6.0000002 16,4.0000002 18,4.0000002 18,2.0000007 18,0 20,0 22,0 24,0 24,2.0000007 24,3.9999997 26,3.9999997 26,6.0000002&#xD;&#xA;26,8.0000002 26,9.0000002 28,9.0000002 28,9.9799997 28,10 28,14 30,14 30,16 30,24 30,26 28,26 20,26 18,26 18,24 18,16 18,15 12,15 12,16 12,24 12,26 10,26 1.9999999,26 0,26&#xD;&#xA;0,24 0,16 0,14 1.9999999,14 1.9999999,10 1.9999999,9.9799997 1.9999999,9.0000002 4,9.0000002 4,8.0000002 4,6.0000002 4,4.0000002 6,4.0000002 6,2.0000007 z" Fill="#FF55609B" />
                            </Grid>
                            <TextBlock Grid.Row="1" Text="Find and Replace" TextAlignment="Center" Margin="0 4 0 1" TextWrapping="Wrap" TextTrimming="WordEllipsis" LineStackingStrategy="BlockLineHeight" LineHeight="12" />
                        </Grid>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
            <Setter Property="IsEnabled" Value="{Binding IsProtected, Converter={StaticResource protectedConverter}}" />
        </Style>
    </UserControl.Resources>
    <!-- layout root -->
    <Grid Name="LayoutRoot" Background="#D6DCE7">

        <!-- title, ribbon, book, status -->
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="auto" />
            <RowDefinition Height="auto" />
            <RowDefinition />
            <RowDefinition Height="auto" />
        </Grid.RowDefinitions>

        <!-- title -->
        <TextBlock Text="ComponentOne FlexSheet Sample" Foreground="#50000000" FontWeight="Bold" FontSize="14" Margin="0 4"/>

        <!-- ribbon -->
        <c1:C1Toolbar Name="_ribbon" Grid.Row="1" FontSize="11">
            <c1:C1ToolbarTabItem  Header="Home">
                <c1:C1ToolbarGroup Header="File">
                    <c1:C1ToolbarGroup.GroupSizeDefinitions>
                        <c1:C1ToolbarGroupSizeDefinition>
                            <c1:C1ToolbarControlSize>Large</c1:C1ToolbarControlSize>
                        </c1:C1ToolbarGroupSizeDefinition>
                    </c1:C1ToolbarGroup.GroupSizeDefinitions>
                    <c1:C1ToolbarButton Name="_btnOpen" LabelTitle="Open" LargeImageSource="./Resources/Open_large.png" Click="_btnOpen_Click" />
                    <c1:C1ToolbarButton Name="_btnSave" LabelTitle="Save" LargeImageSource="./Resources/SaveAs_large.png" Click="_btnSave_Click"/>
                </c1:C1ToolbarGroup>
                <c1:C1ToolbarGroup Header="Clipboard">
                    <c1:C1ToolbarButton Name="_btnPaste" LabelTitle="Paste" LargeImageSource="./Resources/Paste_large.png" Click="_btnPaste_Click" />
                    <c1:C1ToolbarButton Name="_btnCut" LabelTitle="Cut" SmallImageSource="./Resources/Cut_small.png" Click="_btnCut_Click" />
                    <c1:C1ToolbarButton Name="_btnCopy" LabelTitle="Copy" SmallImageSource="./Resources/Copy_small.png" Click="_btnCopy_Click" />
                    <c1:C1ToolbarStrip HorizontalAlignment="Right">
                        <c1:C1ToolbarButton Name="_btnUndo" Click="_btnUndo_Click" ToolTipService.ToolTip="Undo" IsEnabled="{Binding CanUndo, ElementName=_flex }">
                            <Image Source="./Resources/Undo_small.png" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnRedo" Click="_btnRedo_Click" ToolTipService.ToolTip="Redo" IsEnabled="{Binding CanRedo, ElementName=_flex }">
                            <Image Source="./Resources/Redo_small.png" />
                        </c1:C1ToolbarButton>
                    </c1:C1ToolbarStrip>
                </c1:C1ToolbarGroup>
                <c1:C1ToolbarGroup Header="Format">
                    <c1:C1ToolbarStrip>
                        <c1:C1ToolbarButton Name="_btnBold" Click="_btnBold_Click" ToolTipService.ToolTip="Bold">
                            <Image Source="./Resources/Bold_small.png" Stretch="None"/>
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnItalic" Click="_btnItalic_Click" ToolTipService.ToolTip="Italic">
                            <Image Source="./Resources/Italic_small.png" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnUnderline" Click="_btnUnderline_Click" ToolTipService.ToolTip="Underline">
                            <Image Source="./Resources/Underline_small.png" />
                        </c1:C1ToolbarButton>

                        <ComboBox Name="_cmbRotate" SelectedIndex="2" Margin="3" 
                              Style="{StaticResource comboRotate}"
                              ToolTipService.ToolTip="Text Rotate" SelectionChanged="_cmbRotate_SelectionChanged">
                            <ComboBox.Items>
                                <ComboBoxItem Content="90 degree" />
                                <ComboBoxItem Content="45 degree" />
                                <ComboBoxItem Content="0 degree" />
                                <ComboBoxItem Content="-45 degree" />
                                <ComboBoxItem Content="-90 degree" />
                            </ComboBox.Items>
                        </ComboBox>

                    </c1:C1ToolbarStrip>
                    <c1:C1ToolbarStrip>
                        <c1:C1ToolbarButton Name="_btnLeft" Click="_btnLeft_Click" ToolTipService.ToolTip="Align Left">
                            <Image Source="./Resources/AlignTextLeft_small.png" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnCenter" Click="_btnCenter_Click" ToolTipService.ToolTip="Align Center" >
                            <Image Source="./Resources/AlignTextCenter_small.png" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnRight" Click="_btnRight_Click" ToolTipService.ToolTip="Align Right" >
                            <Image Source="./Resources/AlignTextRight_small.png" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnDecreaseIndent" Click="_btnDecreaseIndent_Click" ToolTipService.ToolTip="Decrease Indent">
                            <Image Source="./Resources/Indent_decrease.png" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnIncreaseIndent" Click="_btnIncreaseIndent_Click" ToolTipService.ToolTip="Increase Indent" >
                            <Image Source="./Resources/indent_increase.png" />
                        </c1:C1ToolbarButton>
                    </c1:C1ToolbarStrip>
                    <c1:C1ToolbarStrip>
                        <c1:C1ToolbarButton Name="_btnTop" Click="_btnTop_Click" ToolTipService.ToolTip="Align Top" >
                            <Image Source="./Resources/AlignTextTop_small.png" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnMiddle" Click="_btnMiddle_Click" ToolTipService.ToolTip="Align Middle" >
                            <Image Source="./Resources/AlignTextMiddle_small.png" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnBottom" Click="_btnBottom_Click" ToolTipService.ToolTip="Align Bottom" >
                            <Image Source="./Resources/AlignTextBottom_small.png" />
                        </c1:C1ToolbarButton>
                    </c1:C1ToolbarStrip>
                </c1:C1ToolbarGroup>
                <c1:C1ToolbarGroup Header="Background">
                    <c1:C1ToolbarStrip>
                        <c1:C1ToolbarButton Name="_btnBlue" Click="_btnBlue_Click" ToolTipService.ToolTip="Blue Background" >
                            <Rectangle Fill="Blue" Width="20" Height="16" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnYellow" Click="_btnYellow_Click" ToolTipService.ToolTip="Yellow Background" >
                            <Rectangle Fill="Yellow" Width="20" Height="16" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnOrange" Click="_btnOrange_Click" ToolTipService.ToolTip="Orange Background" >
                            <Rectangle Fill="Orange" Width="20" Height="16" />
                        </c1:C1ToolbarButton>
                    </c1:C1ToolbarStrip>
                    <c1:C1ToolbarStrip>
                        <c1:C1ToolbarButton Name="_btnRed" Click="_btnRed_Click" ToolTipService.ToolTip="Red Background" >
                            <Rectangle Fill="Red" Width="20" Height="16" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnGreen" Click="_btnGreen_Click" ToolTipService.ToolTip="Green Background" >
                            <Rectangle Fill="Green" Width="20" Height="16" />
                        </c1:C1ToolbarButton>
                        <c1:C1ToolbarButton Name="_btnNoColor" Click="_btnNoColor_Click" ToolTipService.ToolTip="No Background" >
                            <Rectangle Fill="White" Width="20" Height="16" />
                        </c1:C1ToolbarButton>
                    </c1:C1ToolbarStrip>
                </c1:C1ToolbarGroup>

                <c1:C1ToolbarGroup Header="Group">
                    <c1:C1ToolbarGroup.GroupSizeDefinitions>
                        <c1:C1ToolbarGroupSizeDefinition>
                            <c1:C1ToolbarControlSize>Large</c1:C1ToolbarControlSize>
                        </c1:C1ToolbarGroupSizeDefinition>
                    </c1:C1ToolbarGroup.GroupSizeDefinitions>
                    <c1:C1ToolbarButton Name="_btnGroup" LabelTitle="Group" LargeImageSource="./Resources/GroupData_large.png" Click="_btnGroup_Click" />
                    <c1:C1ToolbarButton Name="_btnUngroup" LabelTitle="Ungroup" LargeImageSource="./Resources/UngroupData_large.png" Click="_btnUngroup_Click" />
                    <c1:C1ToolbarButton Name="_btnMerge" LabelTitle="Merge" LargeImageSource="./Resources/HideDetail_small.png" Click="_btnMerge_Click" VerticalAlignment="Center"  />
                </c1:C1ToolbarGroup>

                <c1:C1ToolbarGroup Header="Editing">
                    <c1:C1ToolbarGroup.GroupSizeDefinitions>
                        <c1:C1ToolbarGroupSizeDefinition>
                            <c1:C1ToolbarControlSize>Large</c1:C1ToolbarControlSize>
                        </c1:C1ToolbarGroupSizeDefinition>
                    </c1:C1ToolbarGroup.GroupSizeDefinitions>
                    <c1:C1ToolbarButton Name="_btnSort" LabelTitle="Sort" LargeImageSource="./Resources/Sort_large.png" Click="_btnSort_Click" />
                    <c1:C1ToolbarButton Name="_btnFilter" LabelTitle="Filter" LargeImageSource="./Resources/SortAndFilter_large.png" Click="_btnFilter_Click" />
                    <c1:C1ToolbarButton Name="_btnFind" Style="{StaticResource FindAndReplace}" Click="_btnFind_Click" />
                </c1:C1ToolbarGroup>
                <c1:C1ToolbarGroup Header="Data Tools">
                    <c1:C1ToolbarButton Name="_btnRemoveDul" LabelTitle="Remove duplicates" LargeImageSource="./Resources/RemoveDul.png"  Click="_btnRemoveDul_Click" />
                </c1:C1ToolbarGroup>
            </c1:C1ToolbarTabItem>
            <c1:C1ToolbarTabItem  Header="Insert">
                <c1:C1ToolbarGroup Header="Insert">
                    <c1:C1ToolbarGroup.GroupSizeDefinitions>
                        <c1:C1ToolbarGroupSizeDefinition>
                            <c1:C1ToolbarControlSize>Large</c1:C1ToolbarControlSize>
                        </c1:C1ToolbarGroupSizeDefinition>
                    </c1:C1ToolbarGroup.GroupSizeDefinitions>
                    <c1:C1ToolbarButton Name="_btnInsertChart" LabelTitle="Chart" LargeImageSource="./Resources/BarChart.png" Click="_btnInsertChart_Click" />
                    <c1:C1ToolbarButton Name="_btnInsertPicture" Style="{StaticResource Pictures}" Click="_btnInsertPicture_Click" />
                    <c1:C1ToolbarButton Name="_btnInsertSL" LabelTitle="SparkLines" LargeImageSource="./Resources/Sparkline.png" Click="_btnInsertSL_Click" />
                </c1:C1ToolbarGroup>
                <c1:C1ToolbarGroup Header="Comment">
                    <c1:C1ToolbarGroup.GroupSizeDefinitions>
                        <c1:C1ToolbarGroupSizeDefinition>
                            <c1:C1ToolbarControlSize>Large</c1:C1ToolbarControlSize>
                        </c1:C1ToolbarGroupSizeDefinition>
                    </c1:C1ToolbarGroup.GroupSizeDefinitions>
                    <c1:C1ToolbarButton Name="_btnInsertComment" LabelTitle="Comment" LargeImageSource="./Resources/Comment.png"  Click="_btnInsertComment_Click" />
                    <c1:C1ToolbarButton Name="_btnGetComment" LabelTitle="Get Comment" LargeImageSource="./Resources/GetComment.png"  Click="_btnGetComment_Click" />
                    <c1:C1ToolbarButton Name="_btnRemoveComment" LabelTitle="Remove Comment" LargeImageSource="./Resources/Delete_Comment.png"  Click="_btnRemoveComment_Click" />
                </c1:C1ToolbarGroup>
            </c1:C1ToolbarTabItem>
            <c1:C1ToolbarTabItem  Header="View">
                <c1:C1ToolbarGroup Header="Print Preview">
                    <c1:C1ToolbarGroup.GroupSizeDefinitions>
                        <c1:C1ToolbarGroupSizeDefinition>
                            <c1:C1ToolbarControlSize>Large</c1:C1ToolbarControlSize>
                        </c1:C1ToolbarGroupSizeDefinition>
                    </c1:C1ToolbarGroup.GroupSizeDefinitions>
                    <c1:C1ToolbarButton Name="_btnPrint" LabelTitle="Preview" LargeImageSource="./Resources/Print_large.png" Click="_btnPrint_Click" />
                    <c1:C1ToolbarButton Name="_btnPrintPageWidth" LabelTitle="Page Width" SmallImageSource="./Resources/PageWidth_small.png" Click="_btnPrint_Click" />
                    <c1:C1ToolbarButton Name="_btnPrintSinglePage" LabelTitle="Single Page" SmallImageSource="./Resources/PageBorders_small.png" Click="_btnPrint_Click" />
                    <c1:C1ToolbarButton Name="_btnPrintSelection" LabelTitle="Selection" SmallImageSource="./Resources/Select_small.png" Click="_btnPrint_Click" />
                </c1:C1ToolbarGroup>
                <c1:C1ToolbarGroup Header="Show">
                    <c1:C1ToolbarButton Name="_btnFreeze" LabelTitle="Freeze" LargeImageSource="./Resources/FreezePanes_large.png" Click="_btnFreeze_Click" />
                    <CheckBox Name="_chkGridlines" Content="Gridlines" IsChecked="True" Margin="3" Click="_chkGridlines_Click"/>
                    <CheckBox Name="_chkHeadings" Content="Headings" IsChecked="True" Margin="3" Click="_chkHeadings_Click"/>
                </c1:C1ToolbarGroup>
            </c1:C1ToolbarTabItem>
        </c1:C1Toolbar>

        <!-- formula bar -->
        <c1:C1FormulaBar Grid.Row="2" Name="_formulaBar" FlexSheet="{Binding ElementName=_flex}"/>

        <!-- book -->
        <c1:C1FlexSheet Name="_flex" Grid.Row="3" Background="DarkGray" Margin="0 4 0 0" BorderThickness="1" BorderBrush="#c0000000" />

        <!-- status bar -->
        <TextBlock Name="_tbStatus" Grid.Row="5" Text="Ready" Margin="6 2" HorizontalAlignment="Right" />

    </Grid>
</UserControl>
