<UserControl xmlns="https://github.com/avaloniaui"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:vm="using:ZB.MOM.WW.OtOpcUa.Client.UI.ViewModels"
             x:Class="ZB.MOM.WW.OtOpcUa.Client.UI.Views.AlarmsView"
             x:DataType="vm:AlarmsViewModel">
    <DockPanel Margin="8">
        <!-- Controls -->
        <StackPanel DockPanel.Dock="Top" Spacing="8">
            <TextBlock Text="Alarm Monitoring" FontWeight="Bold" />
            <StackPanel Orientation="Horizontal" Spacing="8">
                <TextBox Text="{Binding MonitoredNodeIdText}" Width="250" Watermark="Source Node ID (optional)" />
                <NumericUpDown Value="{Binding Interval}" Minimum="100" Maximum="60000" Width="120" />
                <Button Content="Subscribe" Command="{Binding SubscribeCommand}" />
                <Button Content="Unsubscribe" Command="{Binding UnsubscribeCommand}" />
                <Button Content="Refresh" Command="{Binding RefreshCommand}" />
            </StackPanel>
        </StackPanel>

        <!-- Alarm Events -->
        <DataGrid Name="AlarmsGrid"
                  ItemsSource="{Binding AlarmEvents}"
                  AutoGenerateColumns="False"
                  IsReadOnly="True"
                  HorizontalScrollBarVisibility="Auto"
                  Margin="0,8,0,0"
                  LoadingRow="OnDataGridLoadingRow">
            <DataGrid.Columns>
                <DataGridTextColumn Header="Time" Binding="{Binding Time, StringFormat='{}{0:yyyy-MM-dd HH:mm:ss}'}" Width="Auto" />
                <DataGridTextColumn Header="Source" Binding="{Binding SourceName}" Width="Auto" />
                <DataGridTextColumn Header="Condition" Binding="{Binding ConditionName}" Width="Auto" />
                <DataGridTextColumn Header="Severity" Binding="{Binding Severity}" Width="Auto" />
                <DataGridTextColumn Header="Message" Binding="{Binding Message}" Width="Auto" />
                <DataGridCheckBoxColumn Header="Active" Binding="{Binding ActiveState}" Width="Auto" />
                <DataGridCheckBoxColumn Header="Acked" Binding="{Binding AckedState}" Width="Auto" />
                <DataGridCheckBoxColumn Header="Retain" Binding="{Binding Retain}" Width="Auto" />
            </DataGrid.Columns>
        </DataGrid>
    </DockPanel>
</UserControl>
