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

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

    </DockPanel>
</UserControl>
