You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

MainPage.xaml 15 KiB

6 年之前
6 年之前
6 年之前
7 年之前
6 年之前
6 年之前
6 年之前
6 年之前
6 年之前
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. <RadioButton x:Name="UseWs4Net" GroupName="transport">WS (WebSocket4Net)</RadioButton>
  58. <CheckBox x:Name="UseTls">Use TLS</CheckBox>
  59. </StackPanel>
  60. <TextBlock Grid.Column="0" Grid.Row="7">Protocol:</TextBlock>
  61. <StackPanel Grid.Column="1" Grid.Row="7" Orientation="Horizontal">
  62. <RadioButton x:Name="UseMqtt500" GroupName="protocol">5.0.0</RadioButton>
  63. <RadioButton x:Name="UseMqtt311" GroupName="protocol" IsChecked="True">3.1.1</RadioButton>
  64. <RadioButton x:Name="UseMqtt310" GroupName="protocol">3.1.0</RadioButton>
  65. </StackPanel>
  66. </Grid>
  67. <CheckBox x:Name="CleanSession" IsChecked="True">Clean session</CheckBox>
  68. <CheckBox x:Name="UseManagedClient" IsChecked="False">Use managed client</CheckBox>
  69. <StackPanel Orientation="Horizontal">
  70. <Button Click="Connect" Width="120" Margin="0,0,10,0">Connect</Button>
  71. <Button Click="Disconnect" Width="120">Disconnect</Button>
  72. </StackPanel>
  73. </StackPanel>
  74. </PivotItem>
  75. <PivotItem Header="Publish">
  76. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  77. <Grid>
  78. <Grid.Resources>
  79. <Style TargetType="TextBlock">
  80. <Setter Property="VerticalAlignment" Value="Center"></Setter>
  81. <Setter Property="Margin" Value="0, 0, 10, 0"></Setter>
  82. </Style>
  83. </Grid.Resources>
  84. <Grid.ColumnDefinitions>
  85. <ColumnDefinition Width="Auto"></ColumnDefinition>
  86. <ColumnDefinition Width="*"></ColumnDefinition>
  87. </Grid.ColumnDefinitions>
  88. <Grid.RowDefinitions>
  89. <RowDefinition></RowDefinition>
  90. <RowDefinition></RowDefinition>
  91. <RowDefinition></RowDefinition>
  92. <RowDefinition></RowDefinition>
  93. <RowDefinition></RowDefinition>
  94. <RowDefinition></RowDefinition>
  95. <RowDefinition></RowDefinition>
  96. </Grid.RowDefinitions>
  97. <TextBlock Grid.Column="0" Grid.Row="0">Topic:</TextBlock>
  98. <TextBox Grid.Column="1" Grid.Row="0" x:Name="Topic"></TextBox>
  99. <TextBlock Grid.Column="0" Grid.Row="1">Content type:</TextBlock>
  100. <TextBox Grid.Column="1" Grid.Row="1" x:Name="ContentType"></TextBox>
  101. <TextBlock Grid.Column="0" Grid.Row="2">Payload:</TextBlock>
  102. <TextBox Grid.Column="1" Grid.Row="2" x:Name="Payload"></TextBox>
  103. <TextBlock Grid.Column="0" Grid.Row="3">Payload format:</TextBlock>
  104. <StackPanel Grid.Column="1" Grid.Row="3" Orientation="Horizontal">
  105. <RadioButton Margin="0,0,10,0" x:Name="PlainText" IsChecked="True" GroupName="payload">Plain text</RadioButton>
  106. <RadioButton Margin="0,0,10,0" x:Name="Base64" GroupName="payload">Base64 string</RadioButton>
  107. </StackPanel>
  108. <TextBlock Grid.Column="0" Grid.Row="4">QoS level:</TextBlock>
  109. <StackPanel Grid.Column="1" Grid.Row="4" Orientation="Horizontal">
  110. <RadioButton Margin="0,0,10,0" IsChecked="True" GroupName="qos">0 (At most once)</RadioButton>
  111. <RadioButton Margin="0,0,10,0" x:Name="QoS1" GroupName="qos">1 (At least once)</RadioButton>
  112. <RadioButton Margin="0,0,10,0" x:Name="QoS2" GroupName="qos">2 (Exactly once)</RadioButton>
  113. </StackPanel>
  114. <TextBlock Grid.Column="0" Grid.Row="5">Response topic:</TextBlock>
  115. <TextBox Grid.Column="1" Grid.Row="5" x:Name="ResponseTopic"></TextBox>
  116. </Grid>
  117. <CheckBox x:Name="Retain">Retain</CheckBox>
  118. <Button Click="Publish" Width="120">Publish</Button>
  119. </StackPanel>
  120. </PivotItem>
  121. <PivotItem Header="Execute RPC">
  122. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  123. <TextBlock>Method:</TextBlock>
  124. <TextBox x:Name="RpcMethod"></TextBox>
  125. <TextBlock>Payload:</TextBlock>
  126. <TextBox x:Name="RpcPayload"></TextBox>
  127. <StackPanel Orientation="Horizontal">
  128. <RadioButton x:Name="RpcText" IsChecked="True" GroupName="payload">Text</RadioButton>
  129. <RadioButton x:Name="RpcBase64" GroupName="payload">Base64</RadioButton>
  130. </StackPanel>
  131. <TextBlock>QoS:</TextBlock>
  132. <StackPanel Orientation="Horizontal">
  133. <RadioButton Margin="0,0,10,0" x:Name="RpcQoS0" GroupName="qos" IsChecked="True">0 (At most once)</RadioButton>
  134. <RadioButton Margin="0,0,10,0" x:Name="RpcQoS1" GroupName="qos">1 (At least once)</RadioButton>
  135. <RadioButton Margin="0,0,10,0" x:Name="RpcQoS2" GroupName="qos">2 (Exactly once)</RadioButton>
  136. </StackPanel>
  137. <TextBlock>Responses:</TextBlock>
  138. <ListBox MinHeight="50" MaxHeight="250" x:Name="RpcResponses" Margin="0,0,0,10">
  139. <ListBox.ItemTemplate>
  140. <DataTemplate>
  141. <ContentPresenter Content="{Binding}" FontFamily="Consolas" FontSize="12"></ContentPresenter>
  142. </DataTemplate>
  143. </ListBox.ItemTemplate>
  144. </ListBox>
  145. <StackPanel Orientation="Horizontal">
  146. <Button Click="ExecuteRpc" Width="120" Margin="0,0,10,0">Execute</Button>
  147. <Button Click="ClearRpcResponses" Width="200">Clear responses</Button>
  148. </StackPanel>
  149. </StackPanel>
  150. </PivotItem>
  151. <PivotItem Header="Subscribe">
  152. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  153. <TextBlock>Topic:</TextBlock>
  154. <TextBox x:Name="SubscribeTopic"></TextBox>
  155. <TextBlock>QoS:</TextBlock>
  156. <StackPanel Orientation="Horizontal">
  157. <RadioButton Margin="0,0,10,0" IsChecked="True" GroupName="sqos">0 (At most once)</RadioButton>
  158. <RadioButton Margin="0,0,10,0" x:Name="SubscribeQoS1" GroupName="sqos">1 (At least once)</RadioButton>
  159. <RadioButton Margin="0,0,10,0" x:Name="SubscribeQoS2" GroupName="sqos">2 (Exactly once)</RadioButton>
  160. </StackPanel>
  161. <TextBlock>Received messages:</TextBlock>
  162. <CheckBox x:Name="AddReceivedMessagesToList" IsChecked="True">Add received messages to list</CheckBox>
  163. <ListBox MinHeight="50" MaxHeight="250" x:Name="ReceivedMessages" Margin="0,0,0,10">
  164. <ListBox.ItemTemplate>
  165. <DataTemplate>
  166. <ContentPresenter Content="{Binding}" FontFamily="Consolas" FontSize="12"></ContentPresenter>
  167. </DataTemplate>
  168. </ListBox.ItemTemplate>
  169. </ListBox>
  170. <StackPanel Orientation="Horizontal">
  171. <Button Click="Subscribe" Width="120" Margin="0,0,10,0">Subscribe</Button>
  172. <Button Click="Unsubscribe" Width="120" Margin="0,0,10,0">Unsubscribe</Button>
  173. <Button Click="ClearReceivedMessages" Width="200">Clear received messages</Button>
  174. </StackPanel>
  175. </StackPanel>
  176. </PivotItem>
  177. <PivotItem Header="Server">
  178. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  179. <TextBlock>Port:</TextBlock>
  180. <TextBox x:Name="ServerPort" Text="1883"></TextBox>
  181. <CheckBox x:Name="ServerPersistRetainedMessages" IsChecked="True">Persist retained messages in JSON format</CheckBox>
  182. <CheckBox x:Name="ServerClearRetainedMessages">Clear previously retained messages on startup</CheckBox>
  183. <CheckBox x:Name="ServerAllowPersistentSessions">Allow persistent sessions</CheckBox>
  184. <StackPanel Orientation="Horizontal">
  185. <Button Width="120" Margin="0,0,10,0" Click="StartServer">Start</Button>
  186. <Button Width="120" Margin="0,0,10,0" Click="StopServer">Stop</Button>
  187. </StackPanel>
  188. </StackPanel>
  189. </PivotItem>
  190. <PivotItem Header="Sessions">
  191. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  192. <StackPanel Orientation="Horizontal">
  193. <Button Width="120" Margin="0,0,10,0" Click="RefreshSessions">Refresh</Button>
  194. <Button Width="120" Margin="0,0,10,0" Click="ClearSessions">Clear</Button>
  195. </StackPanel>
  196. <ListView ItemsSource="{Binding}" x:Name="ListViewSessions">
  197. <ListView.ItemTemplate>
  198. <DataTemplate x:DataType="status:IMqttClientStatus">
  199. <StackPanel Orientation="Horizontal">
  200. <StackPanel.Resources>
  201. <Style TargetType="TextBlock">
  202. <Setter Property="Margin" Value="0,0,10,0"></Setter>
  203. </Style>
  204. </StackPanel.Resources>
  205. <TextBlock Text="{Binding ClientId}"></TextBlock>
  206. <TextBlock Text="{Binding Endpoint}"></TextBlock>
  207. <TextBlock Text="{Binding LastPacketReceived}"></TextBlock>
  208. <TextBlock Text="{Binding LastNonKeepAlivePacketReceived}"></TextBlock>
  209. <TextBlock Text="{Binding ProtocolVersion}"></TextBlock>
  210. <TextBlock Text="{Binding Session}"></TextBlock>
  211. </StackPanel>
  212. </DataTemplate>
  213. </ListView.ItemTemplate>
  214. </ListView>
  215. </StackPanel>
  216. </PivotItem>
  217. <PivotItem Header="Log">
  218. <StackPanel Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
  219. <Button Click="ClearLog" Width="120">Clear</Button>
  220. </StackPanel>
  221. </PivotItem>
  222. </Pivot>
  223. <ScrollViewer Grid.Row="1" Margin="12,10,12,0" Background="Black" Foreground="WhiteSmoke" FontFamily="Consolas" HorizontalScrollMode="Enabled" VerticalScrollMode="Enabled" HorizontalScrollBarVisibility="Visible" VerticalScrollBarVisibility="Visible">
  224. <TextBlock x:Name="Trace" FontSize="11"></TextBlock>
  225. </ScrollViewer>
  226. </Grid>
  227. </Page>