<ui:ContentDialog x:Class="DMS.WPF.Views.Dialogs.MqttDialog"
                  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                  xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                  xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                  xmlns:ikw="http://schemas.inkore.net/lib/ui/wpf"
                  xmlns:hc="https://handyorg.github.io/handycontrol"
                  xmlns:ui="http://schemas.inkore.net/lib/ui/wpf/modern"
                  xmlns:vmd="clr-namespace:DMS.WPF.ViewModels.Dialogs"
                  xmlns:ex="clr-namespace:DMS.Extensions"
                  xmlns:enums="clr-namespace:DMS.Core.Enums;assembly=DMS.Core"
                  xmlns:valueConverts="clr-namespace:DMS.WPF.ValueConverts"
                  Title="{Binding Title}"
                  CloseButtonText="取消"
                  DefaultButton="Primary"
                  PrimaryButtonText="{Binding PrimaryButText}"
                  PrimaryButtonCommand="{Binding PrimaryButtonCommand}"
                  CloseButtonCommand="{Binding CancelButtonCommand}"
                  d:DataContext="{d:DesignInstance vmd:MqttDialogViewModel}"
                  mc:Ignorable="d">
    <ui:ContentDialog.Resources>
        <ex:EnumBindingSource x:Key="mqttPlatform"
                              EnumType="{x:Type enums:MqttPlatform}" />
        <valueConverts:EnumDescriptionConverter x:Key="EnumDescriptionConverter" />
        
        <Style x:Key="LabelStyle" TargetType="TextBlock">
            <Setter Property="VerticalAlignment" Value="Center" />
            <Setter Property="HorizontalAlignment" Value="Right" />
            <Setter Property="Margin" Value="0,0,10,0" />
        </Style>
    </ui:ContentDialog.Resources>

    <StackPanel Margin="16">
        <!-- 基本信息 -->
        <Grid>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="*" />
                <ColumnDefinition Width="20" />
                <ColumnDefinition Width="*" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>

            <!-- Row 0 -->
            <hc:TextBox
                Grid.Row="0"
                Grid.Column="0"
                hc:InfoElement.Title="MQTT名称:"
                Text="{Binding MqttServer.ServerName, UpdateSourceTrigger=PropertyChanged}" />

            <hc:TextBox
                Grid.Row="0"
                Grid.Column="2"
                hc:InfoElement.Title="客户端ID:"
                Text="{Binding MqttServer.ClientId, UpdateSourceTrigger=PropertyChanged}" />

            <hc:TextBox
                Grid.Row="1"
                Grid.Column="0"
                Margin="0,15,0,0"
                hc:InfoElement.Title="服务器地址:"
                Text="{Binding MqttServer.ServerUrl, UpdateSourceTrigger=PropertyChanged}" />

            <hc:TextBox
                Grid.Row="1"
                Grid.Column="2"
                Margin="0,15,0,0"
                hc:InfoElement.Title="端口:"
                Text="{Binding MqttServer.Port, UpdateSourceTrigger=PropertyChanged}" />

            <!-- Row 2 -->
            <hc:TextBox
                Grid.Row="2"
                Grid.Column="0"
                Margin="0,15,0,0"
                hc:InfoElement.Title="用户名:"
                Text="{Binding MqttServer.Username, UpdateSourceTrigger=PropertyChanged}" />

            <hc:TextBox
                Grid.Row="2"
                Grid.Column="2"
                Margin="0,15,0,0"
                hc:InfoElement.Title="密码:"
                Text="{Binding MqttServer.Password, UpdateSourceTrigger=PropertyChanged}" />

            <!-- Row 3 -->
            <hc:TextBox
                Grid.Row="3"
                Grid.Column="0"
                Margin="0,15,0,0"
                hc:InfoElement.Title="发布主题:"
                Text="{Binding MqttServer.PublishTopic, UpdateSourceTrigger=PropertyChanged}" />

            <hc:TextBox
                Grid.Row="3"
                Grid.Column="2"
                Margin="0,15,0,0"
                hc:InfoElement.Title="订阅主题:"
                Text="{Binding MqttServer.SubscribeTopic, UpdateSourceTrigger=PropertyChanged}" />
            
            
            <!-- Row 5 -->
            <hc:TextBox
                Grid.Row="4"
                Grid.Column="0"
                Grid.ColumnSpan="3"
                Margin="0,15,0,0"
                hc:InfoElement.Title="消息头:"
                Text="{Binding MqttServer.MessageHeader, UpdateSourceTrigger=PropertyChanged}"
                TextWrapping="Wrap"
                AcceptsReturn="True"
                VerticalContentAlignment="Top" />
            
            <hc:TextBox
                Grid.Row="5"
                Grid.Column="0"
                Grid.ColumnSpan="3"
                Margin="0,15,0,0"
                hc:InfoElement.Title="消息内容:"
                Text="{Binding MqttServer.MessageContent, UpdateSourceTrigger=PropertyChanged}"
                TextWrapping="Wrap"
                AcceptsReturn="True"
                VerticalContentAlignment="Top" />
            
            <!-- Row 6 -->
            <hc:TextBox
                Grid.Row="6"
                Grid.Column="0"
                Grid.ColumnSpan="3"
                Margin="0,15,0,0"
                hc:InfoElement.Title="消息尾:"
                Text="{Binding MqttServer.MessageFooter, UpdateSourceTrigger=PropertyChanged}"
                TextWrapping="Wrap"
                AcceptsReturn="True"
                VerticalContentAlignment="Top" />
            
            <!-- Row 4 -->
            <CheckBox
                Grid.Row="7"
                Grid.Column="0"
                Margin="0,20,0,0"
                Content="是否启用"
                IsChecked="{Binding MqttServer.IsActive}" />
        </Grid>
    </StackPanel>
</ui:ContentDialog>