<UserControl x:Class="MECF.Framework.UI.Client.Ctrlib.Controls.ModuleStatusIndicator"
             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:local="clr-namespace:MECF.Framework.UI.Client.Ctrlib.Controls"
             xmlns:converters="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
             xmlns:lex="http://wpflocalizeextension.codeplex.com"
             mc:Ignorable="d" 
             d:DesignHeight="50" d:DesignWidth="800"
             lex:LocalizeDictionary.DesignCulture="en"
             lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
             lex:ResxLocalizationProvider.DefaultDictionary="lang_terms"
             SnapsToDevicePixels="True">
    <UserControl.Resources>
        <converters:BoolReverseConverter x:Key="BoolReverseConverter"/>
        <converters:BoolVisibilityConverter x:Key="BoolVisibilityConverter"/>
        <local:ModuleIsOnlineToBgColorConverter x:Key="IsOnlineToBdrColor"/>
        <local:ModuleStatusToBackgroundColorConverter x:Key="StatusToBgColor"/>
    </UserControl.Resources>
    <DockPanel LastChildFill="True" DataContext="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=UserControl}, Mode=OneTime}">
        <Label
            DockPanel.Dock="Left"
            HorizontalContentAlignment="Center"
            VerticalContentAlignment="Center"
            Width="{Binding CaptionWidth}"
            BorderBrush="{Binding IsOnline, Converter={StaticResource IsOnlineToBdrColor}}"
            Content="{Binding Caption}"
            ToolTip="{Binding ModuleDescription}"
            Style="{StaticResource TopLable_LeftTop}" 
            HorizontalAlignment="Left"
            d:Content="Caption"
            d:BorderBrush="{SolidColorBrush LawnGreen}">
            <Label.ContextMenu>
                <ContextMenu>
                    <MenuItem 
                        x:Name="CmSetOnline" 
                        Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.Content}" 
                        HeaderStringFormat="Set {0} Online"
                        IsEnabled="{Binding IsOnline, Converter={StaticResource BoolReverseConverter}}" 
                        Click="CmSetOnline_OnClick"/>
                    <MenuItem 
                        x:Name="CmSetOffline" 
                        Header="{Binding RelativeSource={RelativeSource AncestorType=ContextMenu}, Path=PlacementTarget.Content}" 
                        HeaderStringFormat="Set {0} Offline"
                        IsEnabled="{Binding IsOnline}"
                        Click="CmSetOffline_OnClick"/>
                </ContextMenu>
            </Label.ContextMenu>
        </Label>

        <Grid>
            <Image 
                Source="pack://application:,,,/MECF.Framework.UI.Core;component/Resources/SystemLog/Warning.png"
                HorizontalAlignment="Right"
                Margin="0 0 10 0"
                Height="16"
                Width="16"
                Visibility="{Binding HasWarning, Converter={StaticResource BoolVisibilityConverter}, ConverterParameter=True}"
                ToolTip="{Binding WarningTip}"
                Panel.ZIndex="999"/>
            <TextBox
                VerticalContentAlignment="Center"
                Background="{Binding Status, Converter={StaticResource StatusToBgColor}}"
                BorderBrush="{Binding IsOnline, Converter={StaticResource IsOnlineToBdrColor}}"
                Style="{StaticResource TextBox_Top}"
                Text="{lex:Loc {Binding Status, Mode=OneWay}}"
                IsReadOnly="True"
                TextWrapping="Wrap"/>
        </Grid>
        
    </DockPanel>
</UserControl>
