您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

266 行
15 KiB

  1. <Page
  2. x:Class="MQTTnet.TestApp.UniversalWindows.MainPage"
  3. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  4. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  5. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
  6. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
  7. xmlns:server="using:MQTTnet.Server"
  8. xmlns:status="using:MQTTnet.Server.Status"
  9. d:DesignHeight="800"
  10. d:DesignWidth="800"
  11. mc:Ignorable="d">
  12. <Grid Margin="10">
  13. <Grid.RowDefinitions>
  14. <RowDefinition Height="Auto" />
  15. <RowDefinition Height="*" />
  16. </Grid.RowDefinitions>
  17. <Pivot Grid.Row="0">
  18. <PivotItem Header="Connection">
  19. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  20. <Grid>
  21. <Grid.Resources>
  22. <Style TargetType="TextBlock">
  23. <Setter Property="VerticalAlignment" Value="Center"></Setter>
  24. <Setter Property="Margin" Value="0, 0, 10, 0"></Setter>
  25. </Style>
  26. </Grid.Resources>
  27. <Grid.ColumnDefinitions>
  28. <ColumnDefinition Width="Auto"></ColumnDefinition>
  29. <ColumnDefinition Width="*"></ColumnDefinition>
  30. </Grid.ColumnDefinitions>
  31. <Grid.RowDefinitions>
  32. <RowDefinition></RowDefinition>
  33. <RowDefinition></RowDefinition>
  34. <RowDefinition></RowDefinition>
  35. <RowDefinition></RowDefinition>
  36. <RowDefinition></RowDefinition>
  37. <RowDefinition></RowDefinition>
  38. <RowDefinition></RowDefinition>
  39. <RowDefinition></RowDefinition>
  40. </Grid.RowDefinitions>
  41. <TextBlock Grid.Column="0" Grid.Row="0">Server:</TextBlock>
  42. <TextBox Grid.Column="1" Grid.Row="0" x:Name="Server" Text="localhost"></TextBox>
  43. <TextBlock Grid.Column="0" Grid.Row="1">Port:</TextBlock>
  44. <TextBox Grid.Column="1" Grid.Row="1" x:Name="Port" Text="1883"></TextBox>
  45. <TextBlock Grid.Column="0" Grid.Row="2">Username:</TextBlock>
  46. <TextBox Grid.Column="1" Grid.Row="2" x:Name="User"></TextBox>
  47. <TextBlock Grid.Column="0" Grid.Row="3">Password:</TextBlock>
  48. <TextBox Grid.Column="1" Grid.Row="3" x:Name="Password"></TextBox>
  49. <TextBlock Grid.Column="0" Grid.Row="4">Client ID:</TextBlock>
  50. <TextBox Grid.Column="1" Grid.Row="4" x:Name="ClientId"></TextBox>
  51. <TextBlock Grid.Column="0" Grid.Row="5">Keep Alive interval:</TextBlock>
  52. <TextBox Grid.Column="1" Grid.Row="5" x:Name="KeepAliveInterval" Text="5"></TextBox>
  53. <TextBlock Grid.Column="0" Grid.Row="6">Transport:</TextBlock>
  54. <StackPanel Grid.Column="1" Grid.Row="6" Orientation="Horizontal">
  55. <RadioButton x:Name="UseTcp" IsChecked="True" GroupName="transport">TCP</RadioButton>
  56. <RadioButton x:Name="UseWs" GroupName="transport">WS</RadioButton>
  57. <CheckBox x:Name="UseTls">Use TLS</CheckBox>
  58. </StackPanel>
  59. <TextBlock Grid.Column="0" Grid.Row="7">Protocol:</TextBlock>
  60. <StackPanel Grid.Column="1" Grid.Row="7" Orientation="Horizontal">
  61. <RadioButton x:Name="UseMqtt500" GroupName="protocol">5.0.0</RadioButton>
  62. <RadioButton x:Name="UseMqtt311" GroupName="protocol" IsChecked="True">3.1.1</RadioButton>
  63. <RadioButton x:Name="UseMqtt310" GroupName="protocol">3.1.0</RadioButton>
  64. </StackPanel>
  65. </Grid>
  66. <CheckBox x:Name="CleanSession" IsChecked="True">Clean session</CheckBox>
  67. <CheckBox x:Name="UseManagedClient" IsChecked="False">Use managed client</CheckBox>
  68. <StackPanel Orientation="Horizontal">
  69. <Button Click="Connect" Width="120" Margin="0,0,10,0">Connect</Button>
  70. <Button Click="Disconnect" Width="120">Disconnect</Button>
  71. </StackPanel>
  72. </StackPanel>
  73. </PivotItem>
  74. <PivotItem Header="Publish">
  75. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  76. <Grid>
  77. <Grid.Resources>
  78. <Style TargetType="TextBlock">
  79. <Setter Property="VerticalAlignment" Value="Center"></Setter>
  80. <Setter Property="Margin" Value="0, 0, 10, 0"></Setter>
  81. </Style>
  82. </Grid.Resources>
  83. <Grid.ColumnDefinitions>
  84. <ColumnDefinition Width="Auto"></ColumnDefinition>
  85. <ColumnDefinition Width="*"></ColumnDefinition>
  86. </Grid.ColumnDefinitions>
  87. <Grid.RowDefinitions>
  88. <RowDefinition></RowDefinition>
  89. <RowDefinition></RowDefinition>
  90. <RowDefinition></RowDefinition>
  91. <RowDefinition></RowDefinition>
  92. <RowDefinition></RowDefinition>
  93. <RowDefinition></RowDefinition>
  94. <RowDefinition></RowDefinition>
  95. </Grid.RowDefinitions>
  96. <TextBlock Grid.Column="0" Grid.Row="0">Topic:</TextBlock>
  97. <TextBox Grid.Column="1" Grid.Row="0" x:Name="Topic"></TextBox>
  98. <TextBlock Grid.Column="0" Grid.Row="1">Content type:</TextBlock>
  99. <TextBox Grid.Column="1" Grid.Row="1" x:Name="ContentType"></TextBox>
  100. <TextBlock Grid.Column="0" Grid.Row="2">Payload:</TextBlock>
  101. <TextBox Grid.Column="1" Grid.Row="2" x:Name="Payload"></TextBox>
  102. <TextBlock Grid.Column="0" Grid.Row="3">Payload format:</TextBlock>
  103. <StackPanel Grid.Column="1" Grid.Row="3" Orientation="Horizontal">
  104. <RadioButton Margin="0,0,10,0" x:Name="PlainText" IsChecked="True" GroupName="payload">Plain text</RadioButton>
  105. <RadioButton Margin="0,0,10,0" x:Name="Base64" GroupName="payload">Base64 string</RadioButton>
  106. </StackPanel>
  107. <TextBlock Grid.Column="0" Grid.Row="4">QoS level:</TextBlock>
  108. <StackPanel Grid.Column="1" Grid.Row="4" Orientation="Horizontal">
  109. <RadioButton Margin="0,0,10,0" IsChecked="True" GroupName="qos">0 (At most once)</RadioButton>
  110. <RadioButton Margin="0,0,10,0" x:Name="QoS1" GroupName="qos">1 (At least once)</RadioButton>
  111. <RadioButton Margin="0,0,10,0" x:Name="QoS2" GroupName="qos">2 (Exactly once)</RadioButton>
  112. </StackPanel>
  113. <TextBlock Grid.Column="0" Grid.Row="5">Response topic:</TextBlock>
  114. <TextBox Grid.Column="1" Grid.Row="5" x:Name="ResponseTopic"></TextBox>
  115. </Grid>
  116. <CheckBox x:Name="Retain">Retain</CheckBox>
  117. <Button Click="Publish" Width="120">Publish</Button>
  118. </StackPanel>
  119. </PivotItem>
  120. <PivotItem Header="Execute RPC">
  121. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  122. <TextBlock>Method:</TextBlock>
  123. <TextBox x:Name="RpcMethod"></TextBox>
  124. <TextBlock>Payload:</TextBlock>
  125. <TextBox x:Name="RpcPayload"></TextBox>
  126. <StackPanel Orientation="Horizontal">
  127. <RadioButton x:Name="RpcText" IsChecked="True" GroupName="payload">Text</RadioButton>
  128. <RadioButton x:Name="RpcBase64" GroupName="payload">Base64</RadioButton>
  129. </StackPanel>
  130. <TextBlock>QoS:</TextBlock>
  131. <StackPanel Orientation="Horizontal">
  132. <RadioButton Margin="0,0,10,0" x:Name="RpcQoS0" GroupName="qos" IsChecked="True">0 (At most once)</RadioButton>
  133. <RadioButton Margin="0,0,10,0" x:Name="RpcQoS1" GroupName="qos">1 (At least once)</RadioButton>
  134. <RadioButton Margin="0,0,10,0" x:Name="RpcQoS2" GroupName="qos">2 (Exactly once)</RadioButton>
  135. </StackPanel>
  136. <TextBlock>Responses:</TextBlock>
  137. <ListBox MinHeight="50" MaxHeight="250" x:Name="RpcResponses" Margin="0,0,0,10">
  138. <ListBox.ItemTemplate>
  139. <DataTemplate>
  140. <ContentPresenter Content="{Binding}" FontFamily="Consolas" FontSize="12"></ContentPresenter>
  141. </DataTemplate>
  142. </ListBox.ItemTemplate>
  143. </ListBox>
  144. <StackPanel Orientation="Horizontal">
  145. <Button Click="ExecuteRpc" Width="120" Margin="0,0,10,0">Execute</Button>
  146. <Button Click="ClearRpcResponses" Width="200">Clear responses</Button>
  147. </StackPanel>
  148. </StackPanel>
  149. </PivotItem>
  150. <PivotItem Header="Subscribe">
  151. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  152. <TextBlock>Topic:</TextBlock>
  153. <TextBox x:Name="SubscribeTopic"></TextBox>
  154. <TextBlock>QoS:</TextBlock>
  155. <StackPanel Orientation="Horizontal">
  156. <RadioButton Margin="0,0,10,0" IsChecked="True" GroupName="sqos">0 (At most once)</RadioButton>
  157. <RadioButton Margin="0,0,10,0" x:Name="SubscribeQoS1" GroupName="sqos">1 (At least once)</RadioButton>
  158. <RadioButton Margin="0,0,10,0" x:Name="SubscribeQoS2" GroupName="sqos">2 (Exactly once)</RadioButton>
  159. </StackPanel>
  160. <TextBlock>Received messages:</TextBlock>
  161. <CheckBox x:Name="AddReceivedMessagesToList" IsChecked="True">Add received messages to list</CheckBox>
  162. <ListBox MinHeight="50" MaxHeight="250" x:Name="ReceivedMessages" Margin="0,0,0,10">
  163. <ListBox.ItemTemplate>
  164. <DataTemplate>
  165. <ContentPresenter Content="{Binding}" FontFamily="Consolas" FontSize="12"></ContentPresenter>
  166. </DataTemplate>
  167. </ListBox.ItemTemplate>
  168. </ListBox>
  169. <StackPanel Orientation="Horizontal">
  170. <Button Click="Subscribe" Width="120" Margin="0,0,10,0">Subscribe</Button>
  171. <Button Click="Unsubscribe" Width="120" Margin="0,0,10,0">Unsubscribe</Button>
  172. <Button Click="ClearReceivedMessages" Width="200">Clear received messages</Button>
  173. </StackPanel>
  174. </StackPanel>
  175. </PivotItem>
  176. <PivotItem Header="Server">
  177. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  178. <TextBlock>Port:</TextBlock>
  179. <TextBox x:Name="ServerPort" Text="1883"></TextBox>
  180. <CheckBox x:Name="ServerPersistRetainedMessages" IsChecked="True">Persist retained messages in JSON format</CheckBox>
  181. <CheckBox x:Name="ServerClearRetainedMessages">Clear previously retained messages on startup</CheckBox>
  182. <CheckBox x:Name="ServerAllowPersistentSessions">Allow persistent sessions</CheckBox>
  183. <StackPanel Orientation="Horizontal">
  184. <Button Width="120" Margin="0,0,10,0" Click="StartServer">Start</Button>
  185. <Button Width="120" Margin="0,0,10,0" Click="StopServer">Stop</Button>
  186. </StackPanel>
  187. </StackPanel>
  188. </PivotItem>
  189. <PivotItem Header="Sessions">
  190. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  191. <StackPanel Orientation="Horizontal">
  192. <Button Width="120" Margin="0,0,10,0" Click="RefreshSessions">Refresh</Button>
  193. <Button Width="120" Margin="0,0,10,0" Click="ClearSessions">Clear</Button>
  194. </StackPanel>
  195. <ListView ItemsSource="{Binding}" x:Name="ListViewSessions">
  196. <ListView.ItemTemplate>
  197. <DataTemplate x:DataType="status:IMqttClientStatus">
  198. <StackPanel Orientation="Horizontal">
  199. <StackPanel.Resources>
  200. <Style TargetType="TextBlock">
  201. <Setter Property="Margin" Value="0,0,10,0"></Setter>
  202. </Style>
  203. </StackPanel.Resources>
  204. <TextBlock Text="{Binding ClientId}"></TextBlock>
  205. <TextBlock Text="{Binding Endpoint}"></TextBlock>
  206. <TextBlock Text="{Binding LastPacketReceived}"></TextBlock>
  207. <TextBlock Text="{Binding LastNonKeepAlivePacketReceived}"></TextBlock>
  208. <TextBlock Text="{Binding ProtocolVersion}"></TextBlock>
  209. <TextBlock Text="{Binding Session}"></TextBlock>
  210. </StackPanel>
  211. </DataTemplate>
  212. </ListView.ItemTemplate>
  213. </ListView>
  214. </StackPanel>
  215. </PivotItem>
  216. <PivotItem Header="Log">
  217. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  218. <Button Click="ClearLog" Width="120">Clear</Button>
  219. </StackPanel>
  220. </PivotItem>
  221. </Pivot>
  222. <ScrollViewer Grid.Row="1" Margin="12,10,12,0" Background="Black" Foreground="WhiteSmoke" FontFamily="Consolas" HorizontalScrollMode="Enabled" VerticalScrollMode="Enabled" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
  223. <TextBlock x:Name="Trace" FontSize="11"></TextBlock>
  224. </ScrollViewer>
  225. </Grid>
  226. </Page>