@@ -19,6 +19,14 @@ namespace Microsoft.CmdPal.Ext.System.Helpers;
19
19
/// </summary>
20
20
internal sealed class NetworkConnectionProperties
21
21
{
22
+ /// <summary>
23
+ /// Decimal unicode value for green circle emoji.
24
+ /// We need to generate it in the code because it does not render using Markdown emoji syntax or Unicode character syntax.
25
+ /// </summary>
26
+ /// <seealso cref="https://github.com/CommunityToolkit/Labs-Windows/blob/main/components/MarkdownTextBlock/samples/MarkdownTextBlock.md"/>
27
+ /// <seealso cref="https://github.com/xoofx/markdig/blob/master/src/Markdig/Extensions/Emoji/EmojiMapping.cs"/>
28
+ private const int GreenCircleCharacter = 128994 ;
29
+
22
30
/// <summary>
23
31
/// Gets the name of the adapter
24
32
/// </summary>
@@ -161,12 +169,12 @@ internal static List<NetworkConnectionProperties> GetList()
161
169
/// <returns>String with the details</returns>
162
170
internal string GetAdapterDetails ( )
163
171
{
164
- return $ "{ Resources . Microsoft_plugin_sys_AdapterName } : { Adapter } " +
165
- $ "\n { Resources . Microsoft_plugin_sys_PhysicalAddress } : { PhysicalAddress } " +
166
- $ "\n { Resources . Microsoft_plugin_sys_Speed } : { GetFormattedSpeedValue ( Speed ) } " +
167
- $ "\n { Resources . Microsoft_plugin_sys_Type } : { GetAdapterTypeAsString ( Type ) } " +
168
- $ "\n { Resources . Microsoft_plugin_sys_State } : " + ( State == OperationalStatus . Up ? Resources . Microsoft_plugin_sys_Connected : Resources . Microsoft_plugin_sys_Disconnected ) +
169
- $ "\n { Resources . Microsoft_plugin_sys_ConnectionName } : { ConnectionName } ";
172
+ return $ "** { Resources . Microsoft_plugin_sys_AdapterName } :** { Adapter } " +
173
+ $ "\n \n ** { Resources . Microsoft_plugin_sys_State } :** " + ( State == OperationalStatus . Up ? char . ConvertFromUtf32 ( GreenCircleCharacter ) + " " + Resources . Microsoft_plugin_sys_Connected : ":red_circle: " + Resources . Microsoft_plugin_sys_Disconnected ) +
174
+ $ "\n \n ** { Resources . Microsoft_plugin_sys_PhysicalAddress } :** { PhysicalAddress } " +
175
+ $ "\n \n ** { Resources . Microsoft_plugin_sys_Speed } :** { GetFormattedSpeedValue ( Speed ) } " +
176
+ $ "\n \n ** { Resources . Microsoft_plugin_sys_Type } :** { GetAdapterTypeAsString ( Type ) } " +
177
+ $ "\n \n ** { Resources . Microsoft_plugin_sys_ConnectionName } :** { ConnectionName } ";
170
178
}
171
179
172
180
/// <summary>
@@ -175,24 +183,24 @@ internal string GetAdapterDetails()
175
183
/// <returns>String with the details</returns>
176
184
internal string GetConnectionDetails ( )
177
185
{
178
- return $ "{ Resources . Microsoft_plugin_sys_ConnectionName } : { ConnectionName } " +
179
- $ "\n { Resources . Microsoft_plugin_sys_State } : " + ( State == OperationalStatus . Up ? Resources . Microsoft_plugin_sys_Connected : Resources . Microsoft_plugin_sys_Disconnected ) +
180
- $ "\n { Resources . Microsoft_plugin_sys_Type } : { GetAdapterTypeAsString ( Type ) } " +
181
- $ "\n { Resources . Microsoft_plugin_sys_Suffix } : { Suffix } " +
182
- CreateIpInfoForDetailsText ( $ "{ Resources . Microsoft_plugin_sys_Ip4Address } : ", IPv4 ) +
183
- CreateIpInfoForDetailsText ( $ "{ Resources . Microsoft_plugin_sys_Ip4SubnetMask } : ", IPv4Mask ) +
184
- CreateIpInfoForDetailsText ( $ "{ Resources . Microsoft_plugin_sys_Ip6Address } :\n \t ", IPv6Global ) +
185
- CreateIpInfoForDetailsText ( $ "{ Resources . Microsoft_plugin_sys_Ip6Temp } :\n \t ", IPv6Temporary ) +
186
- CreateIpInfoForDetailsText ( $ "{ Resources . Microsoft_plugin_sys_Ip6Link } :\n \t ", IPv6LinkLocal ) +
187
- CreateIpInfoForDetailsText ( $ "{ Resources . Microsoft_plugin_sys_Ip6Site } :\n \t ", IPv6SiteLocal ) +
188
- CreateIpInfoForDetailsText ( $ "{ Resources . Microsoft_plugin_sys_Ip6Unique } :\n \t ", IPv6UniqueLocal ) +
189
- CreateIpInfoForDetailsText ( $ "{ Resources . Microsoft_plugin_sys_Gateways } :\n \t ", Gateways ) +
190
- CreateIpInfoForDetailsText ( $ "{ Resources . Microsoft_plugin_sys_Dhcp } :\n \t ", DhcpServers == null ? string . Empty : DhcpServers ) +
191
- CreateIpInfoForDetailsText ( $ "{ Resources . Microsoft_plugin_sys_Dns } :\n \t ", DnsServers == null ? string . Empty : DnsServers ) +
192
- CreateIpInfoForDetailsText ( $ "{ Resources . Microsoft_plugin_sys_Wins } :\n \t ", WinsServers == null ? string . Empty : WinsServers ) +
193
- $ "\n \n { Resources . Microsoft_plugin_sys_AdapterName } : { Adapter } " +
194
- $ "\n { Resources . Microsoft_plugin_sys_PhysicalAddress } : { PhysicalAddress } " +
195
- $ "\n { Resources . Microsoft_plugin_sys_Speed } : { GetFormattedSpeedValue ( Speed ) } ";
186
+ return $ "** { Resources . Microsoft_plugin_sys_ConnectionName } :** { ConnectionName } " +
187
+ $ "\n \n ** { Resources . Microsoft_plugin_sys_State } :** " + ( State == OperationalStatus . Up ? char . ConvertFromUtf32 ( GreenCircleCharacter ) + " " + Resources . Microsoft_plugin_sys_Connected : ":red_circle: " + Resources . Microsoft_plugin_sys_Disconnected ) +
188
+ $ "\n \n ** { Resources . Microsoft_plugin_sys_Type } :** { GetAdapterTypeAsString ( Type ) } " +
189
+ $ "\n \n ** { Resources . Microsoft_plugin_sys_Suffix } :** { Suffix } " +
190
+ CreateIpInfoForDetailsText ( $ "** { Resources . Microsoft_plugin_sys_Ip4Address } :** ", IPv4 ) +
191
+ CreateIpInfoForDetailsText ( $ "** { Resources . Microsoft_plugin_sys_Ip4SubnetMask } :** ", IPv4Mask ) +
192
+ CreateIpInfoForDetailsText ( $ "** { Resources . Microsoft_plugin_sys_Ip6Address } :** \n \n * ", IPv6Global ) +
193
+ CreateIpInfoForDetailsText ( $ "** { Resources . Microsoft_plugin_sys_Ip6Temp } :** \n \n * ", IPv6Temporary ) +
194
+ CreateIpInfoForDetailsText ( $ "** { Resources . Microsoft_plugin_sys_Ip6Link } :** \n \n * ", IPv6LinkLocal ) +
195
+ CreateIpInfoForDetailsText ( $ "** { Resources . Microsoft_plugin_sys_Ip6Site } :** \n \n * ", IPv6SiteLocal ) +
196
+ CreateIpInfoForDetailsText ( $ "** { Resources . Microsoft_plugin_sys_Ip6Unique } :** \n \n * ", IPv6UniqueLocal ) +
197
+ CreateIpInfoForDetailsText ( $ "** { Resources . Microsoft_plugin_sys_Gateways } :** \n \n * ", Gateways ) +
198
+ CreateIpInfoForDetailsText ( $ "** { Resources . Microsoft_plugin_sys_Dhcp } :** \n \n * ", DhcpServers == null ? string . Empty : DhcpServers ) +
199
+ CreateIpInfoForDetailsText ( $ "** { Resources . Microsoft_plugin_sys_Dns } :** \n \n * ", DnsServers == null ? string . Empty : DnsServers ) +
200
+ CreateIpInfoForDetailsText ( $ "** { Resources . Microsoft_plugin_sys_Wins } :** \n \n * ", WinsServers == null ? string . Empty : WinsServers ) +
201
+ $ "\n \n ** { Resources . Microsoft_plugin_sys_AdapterName } :** { Adapter } " +
202
+ $ "\n \n ** { Resources . Microsoft_plugin_sys_PhysicalAddress } :** { PhysicalAddress } " +
203
+ $ "\n \n ** { Resources . Microsoft_plugin_sys_Speed } :** { GetFormattedSpeedValue ( Speed ) } ";
196
204
}
197
205
198
206
/// <summary>
@@ -304,13 +312,13 @@ private static string CreateIpInfoForDetailsText(string title, dynamic property)
304
312
switch ( property )
305
313
{
306
314
case string :
307
- return $ " \n { title } { property } ";
315
+ return string . IsNullOrWhiteSpace ( property ) ? string . Empty : $ " \n \n { title } { property } ";
308
316
case List < string > listString :
309
- return listString . Count == 0 ? string . Empty : $ "\n { title } { string . Join ( "\n \t " , property ) } ";
317
+ return listString . Count == 0 ? string . Empty : $ "\n \n { title } { string . Join ( "\n \n * " , property ) } ";
310
318
case List < IPAddress > listIP :
311
- return listIP . Count == 0 ? string . Empty : $ "\n { title } { string . Join ( "\n \t " , property ) } ";
319
+ return listIP . Count == 0 ? string . Empty : $ "\n \n { title } { string . Join ( "\n \n * " , property ) } ";
312
320
case IPAddressCollection collectionIP :
313
- return collectionIP . Count == 0 ? string . Empty : $ "\n { title } { string . Join ( "\n \t " , property ) } ";
321
+ return collectionIP . Count == 0 ? string . Empty : $ "\n \n { title } { string . Join ( "\n \n * " , property ) } ";
314
322
case null :
315
323
return string . Empty ;
316
324
default :
0 commit comments