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

MainPage.xaml 14 KiB

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