初始化上传
This commit is contained in:
241
常用工具集/Views/02网络相关/FTP客户端.axaml
Normal file
241
常用工具集/Views/02网络相关/FTP客户端.axaml
Normal file
@@ -0,0 +1,241 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignHeight="660" d:DesignWidth="815"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._02网络相关"
|
||||
xmlns:utils="clr-namespace:常用工具集.Utility"
|
||||
x:Class="常用工具集.FTP客户端"
|
||||
xmlns:i="clr-namespace:Avalonia.Xaml.Interactivity;assembly=Avalonia.Xaml.Interactivity"
|
||||
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:FTP客户端ViewModel">
|
||||
<!-- xmlns:b="clr-namespace:Avalonia.Xaml.Behaviors;assembly=Avalonia.Xaml.Behaviors" -->
|
||||
|
||||
<UserControl.DataContext>
|
||||
<vm:FTP客户端ViewModel />
|
||||
</UserControl.DataContext>
|
||||
<Grid>
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="IP地址:" Margin="10,16,0,0"/>
|
||||
<TextBox IsEnabled="{Binding EnableFlag1}" HorizontalAlignment="Left" Margin="60,10,0,0" TextWrapping="Wrap" Text="{Binding IpAddress}" VerticalAlignment="Top" Width="120" />
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="端口号:" Margin="200,16,0,0"/>
|
||||
<TextBox IsEnabled="{Binding EnableFlag1}" HorizontalAlignment="Left" Margin="250,10,0,0" TextWrapping="Wrap" Text="{Binding Port}" VerticalAlignment="Top" Width="105" />
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="字符编码:" Margin="369,16,0,0"/>
|
||||
<ComboBox HorizontalAlignment="Left" IsEnabled="{Binding EnableFlag1}" VerticalAlignment="Top" SelectedIndex="{Binding EncodingIndex}" ItemsSource="{Binding StrEncodingList}" Margin="439,10,0,0" Width="90" />
|
||||
<Button Content="建立连接" IsEnabled="{Binding EnableFlag1}" Command="{Binding ConnectCmd}" HorizontalAlignment="Left" Margin="557,10,0,0" VerticalAlignment="Top" Width="85" RenderTransformOrigin="0.539,0.527" />
|
||||
<Button Content="断开连接" IsEnabled="{Binding EnableFlag2}" Command="{Binding DisconnectCmd}" HorizontalAlignment="Left" Margin="655,10,0,0" VerticalAlignment="Top" Width="85" />
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="用户名:" Margin="10,56,0,0"/>
|
||||
<TextBox IsEnabled="{Binding EnableFlag1}" HorizontalAlignment="Left" Margin="60,50,0,0" TextWrapping="Wrap" Text="{Binding UserName}" VerticalAlignment="Top" Width="120" />
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="密码:" Margin="210,56,0,0"/>
|
||||
<TextBox IsEnabled="{Binding EnableFlag1}" HorizontalAlignment="Left" Margin="250,50,0,0" TextWrapping="Wrap" Text="{Binding Password}" VerticalAlignment="Top" Width="105" />
|
||||
<CheckBox IsChecked="{Binding IsAnonymous}" IsEnabled="{Binding EnableFlag1}" Content="匿名登录" Margin="425,52,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Height="24" />
|
||||
|
||||
|
||||
|
||||
<Button Width="25" Height="25" Margin="25,95,0,0" Background="#1296db" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding LocalHomeClickCommand}">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid Background="Transparent">
|
||||
<Path Fill="{TemplateBinding Button.Background}"
|
||||
Stretch="Fill" Data="M916.16 360.494L562.622 79.919C529.939 55.927 484.353 57 452.924 82.5L104.497 360.535c-19.798 16.064-31.225 39.73-31.225 64.668V919.3c0 21.173 17.164 38.337 38.337 38.337H320.31c21.173 0 38.337-17.164 38.337-38.337V682.871c0-34.874 29.614-63.407 65.809-63.407h175.289c36.195 0 65.809 28.533 65.809 63.407V919.3c0 21.173 17.164 38.337 38.337 38.337H912.39c21.173 0 38.337-17.164 38.337-38.337V427.742c0.001-26.385-12.784-51.258-34.567-67.248z" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
<Button Width="25" Height="25" Margin="65,95,0,0" Background="#1296db" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding LocalDoubleClickCommand}" CommandParameter="{Binding LocalTreeSelectedItem}">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid Background="Transparent">
|
||||
<Path Fill="{TemplateBinding Button.Background}"
|
||||
Stretch="Fill" Data="M467.86 64c47.68 0 91.95 11.98 133.27 35.7 41.33 23.72 74.1 56.25 98.55 97.57s36.68 86.32 36.68 135.48c0 37.66-7.34 73.12-22.01 105.89s-35.21 61.87-61.87 87.06l-44.02-18.83c25.19-21.03 45.24-46.46 59.91-76.54s22.01-62.6 22.01-97.57c0-40.59-9.78-78.01-29.34-112.25-19.56-34.23-46.46-61.63-80.7-81.92s-71.65-30.32-112.24-30.32c-40.59 0-78.01 10.02-112.24 30.32s-61.63 47.68-81.92 81.92c-20.3 34.23-30.32 71.65-30.32 112.25 0 44.75 12.23 85.59 36.68 122.76s56.98 64.8 97.57 82.9v48.17c-53.07-19.56-96.11-52.57-129.12-98.55-32.77-46.22-49.4-97.82-49.4-155.29 0-48.91 11.98-94.15 35.7-135.48s56.25-73.85 97.57-97.57C373.71 75.74 418.95 64 467.86 64z m0 90.24c48.91 0 90.97 17.61 125.94 52.57s52.58 77.03 52.58 125.94c0 33.51-8.07 64.07-24.21 91.21-16.14 27.39-38.15 48.66-66.03 64.07V433.5c30.81-26.66 46.22-59.42 46.22-98.55s-13.21-71.65-39.86-97.57c-26.65-25.92-58.45-38.88-95.37-38.88s-68.47 12.96-94.39 38.88-38.88 58.44-38.88 97.57 14.67 72.14 44.02 98.55v54.53c-27.88-15.4-50.13-36.68-66.03-64.07-16.14-27.39-24.21-57.71-24.21-91.21 0-48.91 17.61-90.97 52.58-125.94 34.47-35.21 77.26-52.57 127.64-52.57z m-46.22 178.27c0-12.47 4.64-22.99 13.7-31.55 9.05-8.32 20.05-12.47 32.52-12.47s22.99 4.16 31.55 12.47c8.56 8.32 12.47 18.83 12.47 31.55v199.3l54.53 6.36 220.33 98.55c12.47 5.62 22.01 13.7 28.37 24.21 6.36 10.51 9.54 22.74 9.54 36.68v195.14c0 18.1-6.6 33.51-20.05 46.22-13.21 12.47-29.1 19.56-47.2 21.03H467.86c-18.1 0-33.5-7.09-46.22-21.03L203.27 752.14l33.5-35.7c8.31-8.32 18.83-12.47 31.55-12.47h10.52l142.81 75.57-0.01-447.03z" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
|
||||
<Border Theme="{StaticResource CardBorder}" Width="320" Height="335" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="25,130,0,0">
|
||||
<Grid>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="0,-20,0,0" TextWrapping="Wrap" Text="{Binding LocalPath1}" VerticalAlignment="Top"/>
|
||||
<DataGrid HorizontalAlignment="Stretch"
|
||||
VerticalAlignment="Stretch"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding LocalTree}"
|
||||
SelectedItem="{Binding LocalTreeSelectedItem}"
|
||||
RowHeight="30"
|
||||
AutoGenerateColumns="False" GridLinesVisibility="None">
|
||||
<!--<i:Interaction.Triggers>
|
||||
<b:EventTrigger EventName="MouseLeftButtonUp">
|
||||
<b:InvokeCommandAction Command="{Binding LocalClickCommand}" CommandParameter="{Binding SelectedItem}" />
|
||||
</i:EventTrigger>
|
||||
<b:EventTrigger EventName="MouseDoubleClick">
|
||||
<b:InvokeCommandAction Command="{Binding LocalDoubleClickCommand}" CommandParameter="{Binding LocalTreeSelectedItem}" />
|
||||
</b:EventTrigger>
|
||||
</b:Interaction.Triggers>-->
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Header="名称" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Height="20">
|
||||
<Image Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" Tag="{Binding IsDirectory}">
|
||||
<Image.Styles>
|
||||
<Style Selector="Image[Tag=True]">
|
||||
<Setter Property="Source" Value="/Assets/FTP/Folder.png" />
|
||||
</Style>
|
||||
<Style Selector="Image[Tag=False]">
|
||||
<Setter Property="Source" Value="/Assets/FTP/File.png" />
|
||||
</Style>
|
||||
</Image.Styles>
|
||||
</Image>
|
||||
<TextBlock Text="{Binding Name}" Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" Tag="{Binding Path}"/>
|
||||
</StackPanel>
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
|
||||
|
||||
<Button IsEnabled="{Binding EnableFlag2}" Width="48" Height="22" Margin="369,243,0,0" Background="#1296db" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding DownloadClickCommand}">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid Background="Transparent">
|
||||
<Path Fill="{TemplateBinding Button.Background}"
|
||||
Stretch="Fill"
|
||||
Data="M185.4,87.5H95.8V56.4c0-2-0.6-3.9-1.6-5.6c-3.1-4.9-9.5-6.3-14.4-3.2L9.9,91.9c-1.3,0.8-2.5,2-3.3,3.3
|
||||
c-3,4.9-1.5,11.3,3.4,14.3L80,152.7v0c1.6,1,3.5,1.5,5.5,1.5c5.8,0,10.4-4.7,10.4-10.4v-31.3h89.6c5.8,0,10.4-4.7,10.4-10.4v-4.2
|
||||
C195.8,92.2,191.2,87.5,185.4,87.5z" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
|
||||
<Button IsEnabled="{Binding EnableFlag2}" Width="48" Height="22" Margin="369,308,0,0" Background="#1296db" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding UploadClickCommand}">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid Background="Transparent">
|
||||
<Path Fill="{TemplateBinding Button.Background}"
|
||||
Stretch="Fill"
|
||||
Data="M15.5,87.5h89.6V56.4c0-2,0.6-3.9,1.6-5.6c3.1-4.9,9.5-6.3,14.4-3.2L191,91.9c1.3,0.8,2.5,2,3.3,3.3
|
||||
c3,4.9,1.5,11.3-3.4,14.3l-69.9,43.1v0c-1.6,1-3.5,1.5-5.5,1.5c-5.8,0-10.4-4.7-10.4-10.4v-31.3H15.5c-5.8,0-10.4-4.7-10.4-10.4
|
||||
v-4.2C5.1,92.2,9.7,87.5,15.5,87.5z" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
<Button IsEnabled="{Binding EnableFlag2}" Width="25" Height="25" Margin="495,95,0,0" Background="#1296db" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding RemoteRenameClickCommand}">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid Background="Transparent">
|
||||
<Path Fill="{TemplateBinding Button.Background}"
|
||||
Stretch="Fill" Data="M105.4,137.9h-65c-3,0-5.4-2.4-5.4-5.4v-65c0-3,2.4-5.4,5.4-5.4h65c3,0,5.4,2.4,5.4,5.4s-2.4,5.4-5.4,5.4H45.8
|
||||
v54.2h59.6c3,0,5.4,2.4,5.4,5.4S108.4,137.9,105.4,137.9z M62.1,94.6c-3,0-5.4,2.4-5.4,5.4s2.4,5.4,5.4,5.4h32.5
|
||||
c3,0,5.4-2.4,5.4-5.4s-2.4-5.4-5.4-5.4H62.1z M148.8,159.6h-16.3V40.4h16.3c3,0,5.4-2.4,5.4-5.4s-2.4-5.4-5.4-5.4h-43.4
|
||||
c-3,0-5.4,2.4-5.4,5.4s2.4,5.4,5.4,5.4h16.3v119.2h-16.3c-3,0-5.4,2.4-5.4,5.4s2.4,5.4,5.4,5.4h43.4c3,0,5.4-2.4,5.4-5.4
|
||||
S151.8,159.6,148.8,159.6z M159.6,62.1h-10.8c-3,0-5.4,2.4-5.4,5.4s2.4,5.4,5.4,5.4h5.4v54.2h-5.4c-3,0-5.4,2.4-5.4,5.4
|
||||
s2.4,5.4,5.4,5.4h10.8c3,0,5.4-2.4,5.4-5.4v-65C165,64.5,162.6,62.1,159.6,62.1z" />
|
||||
</Grid>
|
||||
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
<Button IsEnabled="{Binding EnableFlag2}" Width="25" Height="25" Margin="540,95,0,0" Background="#1296db" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding RemoteDeleteClickCommand}">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid Background="Transparent">
|
||||
<Path Fill="{TemplateBinding Button.Background}"
|
||||
Stretch="Fill" Data="M160,60c-5.5,0-10,4.5-10,10l0,0v110H50V70c0-5.5-4.5-10-10-10c-5.5,0-10,4.5-10,10v120c0,5.5,4.5,10,10,10h120
|
||||
c5.5,0,10-4.5,10-10l0,0V70C170,64.5,165.5,60,160,60C160,60,160,60,160,60z M80,160V80c0-5.5-4.5-10-10-10c-5.5,0-10,4.5-10,10v80
|
||||
c0,5.5,4.5,10,10,10C75.5,170,80,165.5,80,160z M110,160V80c0-5.5-4.5-10-10-10c-5.5,0-10,4.5-10,10v80c0,5.5,4.5,10,10,10
|
||||
C105.5,170,110,165.5,110,160z M140,160V80c0-5.5-4.5-10-10-10c-5.5,0-10,4.5-10,10v80c0,5.5,4.5,10,10,10
|
||||
C135.5,170,140,165.5,140,160z M190,30h-50V20c0-11-9-20-20-20c0,0,0,0,0,0H80C69,0,60,9,60,20v10H10C4.5,30,0,34.5,0,40
|
||||
c0,5.5,4.5,10,10,10h180c5.5,0,10-4.5,10-10C200,34.5,195.5,30,190,30z M80,30V20h40v10H80z" />
|
||||
</Grid>
|
||||
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
|
||||
<Button IsEnabled="{Binding EnableFlag2}" Width="24" Height="25" Margin="448,95,0,0" Background="#1296db" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding RemoteHomeClickCommand}">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid Background="Transparent">
|
||||
<Path Fill="{TemplateBinding Button.Background}"
|
||||
Stretch="Fill" Data="M916.16 360.494L562.622 79.919C529.939 55.927 484.353 57 452.924 82.5L104.497 360.535c-19.798 16.064-31.225 39.73-31.225 64.668V919.3c0 21.173 17.164 38.337 38.337 38.337H320.31c21.173 0 38.337-17.164 38.337-38.337V682.871c0-34.874 29.614-63.407 65.809-63.407h175.289c36.195 0 65.809 28.533 65.809 63.407V919.3c0 21.173 17.164 38.337 38.337 38.337H912.39c21.173 0 38.337-17.164 38.337-38.337V427.742c0.001-26.385-12.784-51.258-34.567-67.248z" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
|
||||
|
||||
<Button Width="25" Height="25" Margin="585,95,0,0" Background="#1296db" HorizontalAlignment="Left" VerticalAlignment="Top" Command="{Binding RemoteDoubleClickCommand}" CommandParameter="{Binding RemoteTreeSelectedItem}">
|
||||
<Button.Template>
|
||||
<ControlTemplate TargetType="Button">
|
||||
<Grid Background="Transparent">
|
||||
<Path Fill="{TemplateBinding Button.Background}"
|
||||
Stretch="Fill" Data="M467.86 64c47.68 0 91.95 11.98 133.27 35.7 41.33 23.72 74.1 56.25 98.55 97.57s36.68 86.32 36.68 135.48c0 37.66-7.34 73.12-22.01 105.89s-35.21 61.87-61.87 87.06l-44.02-18.83c25.19-21.03 45.24-46.46 59.91-76.54s22.01-62.6 22.01-97.57c0-40.59-9.78-78.01-29.34-112.25-19.56-34.23-46.46-61.63-80.7-81.92s-71.65-30.32-112.24-30.32c-40.59 0-78.01 10.02-112.24 30.32s-61.63 47.68-81.92 81.92c-20.3 34.23-30.32 71.65-30.32 112.25 0 44.75 12.23 85.59 36.68 122.76s56.98 64.8 97.57 82.9v48.17c-53.07-19.56-96.11-52.57-129.12-98.55-32.77-46.22-49.4-97.82-49.4-155.29 0-48.91 11.98-94.15 35.7-135.48s56.25-73.85 97.57-97.57C373.71 75.74 418.95 64 467.86 64z m0 90.24c48.91 0 90.97 17.61 125.94 52.57s52.58 77.03 52.58 125.94c0 33.51-8.07 64.07-24.21 91.21-16.14 27.39-38.15 48.66-66.03 64.07V433.5c30.81-26.66 46.22-59.42 46.22-98.55s-13.21-71.65-39.86-97.57c-26.65-25.92-58.45-38.88-95.37-38.88s-68.47 12.96-94.39 38.88-38.88 58.44-38.88 97.57 14.67 72.14 44.02 98.55v54.53c-27.88-15.4-50.13-36.68-66.03-64.07-16.14-27.39-24.21-57.71-24.21-91.21 0-48.91 17.61-90.97 52.58-125.94 34.47-35.21 77.26-52.57 127.64-52.57z m-46.22 178.27c0-12.47 4.64-22.99 13.7-31.55 9.05-8.32 20.05-12.47 32.52-12.47s22.99 4.16 31.55 12.47c8.56 8.32 12.47 18.83 12.47 31.55v199.3l54.53 6.36 220.33 98.55c12.47 5.62 22.01 13.7 28.37 24.21 6.36 10.51 9.54 22.74 9.54 36.68v195.14c0 18.1-6.6 33.51-20.05 46.22-13.21 12.47-29.1 19.56-47.2 21.03H467.86c-18.1 0-33.5-7.09-46.22-21.03L203.27 752.14l33.5-35.7c8.31-8.32 18.83-12.47 31.55-12.47h10.52l142.81 75.57-0.01-447.03z" />
|
||||
</Grid>
|
||||
</ControlTemplate>
|
||||
</Button.Template>
|
||||
</Button>
|
||||
|
||||
<Border Theme="{StaticResource CardBorder}" Width="320" Height="335" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="445,130,0,0">
|
||||
<Grid>
|
||||
<TextBlock HorizontalAlignment="Left" Margin="0,-20,0,0" TextWrapping="Wrap" Text="{Binding RemotePath1}" VerticalAlignment="Top"/>
|
||||
<DataGrid HorizontalAlignment="Stretch"
|
||||
IsEnabled="{Binding EnableFlag2}"
|
||||
VerticalAlignment="Stretch"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding RemoteTree}"
|
||||
SelectedItem="{Binding RemoteTreeSelectedItem}"
|
||||
RowHeight="30"
|
||||
AutoGenerateColumns="False" GridLinesVisibility="None" >
|
||||
<i:Interaction.Behaviors>
|
||||
<!--<EventTriggerBehavior EventName="MouseDoubleClick">
|
||||
<InvokeCommandAction Command="{Binding RemoteDoubleClickCommand}" CommandParameter="{Binding RemoteTreeSelectedItem}"/>
|
||||
</EventTriggerBehavior>-->
|
||||
</i:Interaction.Behaviors>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Header="名称" >
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Height="20">
|
||||
<Image Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" Tag="{Binding IsDirectory}">
|
||||
<Image.Styles>
|
||||
<Style Selector="Image[Tag=True]">
|
||||
<Setter Property="Source" Value="/Assets/FTP/Folder.png" />
|
||||
</Style>
|
||||
<Style Selector="Image[Tag=False]">
|
||||
<Setter Property="Source" Value="/Assets/FTP/File.png" />
|
||||
</Style>
|
||||
</Image.Styles>
|
||||
</Image>
|
||||
<TextBlock Text="{Binding Name}" Margin="2" HorizontalAlignment="Center" VerticalAlignment="Center" Tag="{Binding Path}"/>
|
||||
</StackPanel >
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</Border>
|
||||
|
||||
<Border Theme="{StaticResource CardBorder}" Width="755" Height="160" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,460,0,0">
|
||||
<Grid>
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,-20,0,0" TextWrapping="Wrap" Text="日志信息" VerticalAlignment="Top"/>
|
||||
<TextBox x:Name="TBInfo" TextWrapping="Wrap" ScrollViewer.VerticalScrollBarVisibility="Auto" Height="100" Text="{Binding Message}" Margin="10,10,10,10" HorizontalContentAlignment="Left" VerticalContentAlignment="Top">
|
||||
<i:Interaction.Behaviors>
|
||||
<DataTriggerBehavior Binding="{Binding Text.Length, ElementName=TBInfo}" ComparisonCondition="NotEqual" Value="0">
|
||||
<ChangePropertyAction TargetObject="TBInfo" PropertyName="CaretIndex" Value="{Binding ElementName=TBInfo, Path=Text.Length}"/>
|
||||
<CallMethodAction MethodName="ScrollToEnd" />
|
||||
</DataTriggerBehavior>
|
||||
</i:Interaction.Behaviors>
|
||||
</TextBox>
|
||||
</Grid>
|
||||
</Border>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
13
常用工具集/Views/02网络相关/FTP客户端.axaml.cs
Normal file
13
常用工具集/Views/02网络相关/FTP客户端.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class FTP客户端 : UserControl
|
||||
{
|
||||
public FTP客户端()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
38
常用工具集/Views/02网络相关/FTP服务.axaml
Normal file
38
常用工具集/Views/02网络相关/FTP服务.axaml
Normal file
@@ -0,0 +1,38 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._02网络相关"
|
||||
x:Class="常用工具集.FTP服务"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:FTP服务ViewModel">
|
||||
<UserControl.DataContext>
|
||||
<vm:FTP服务ViewModel />
|
||||
</UserControl.DataContext>
|
||||
|
||||
<Grid>
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="共享路径:" Margin="23,21,0,0"/>
|
||||
<TextBox IsEnabled="{Binding Enabled1}" Text="{Binding Path}" HorizontalAlignment="Left" Margin="93,15,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="255" />
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="端口:" Margin="46,64,0,0"/>
|
||||
<TextBox IsEnabled="{Binding Enabled1}" Text="{Binding Port}" HorizontalAlignment="Left" Margin="93,58,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="255" />
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="用户名:" Margin="34,104,0,0"/>
|
||||
<TextBox IsEnabled="{Binding Enabled1}" Text="{Binding UserName}" HorizontalAlignment="Left" Margin="93,98,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="255" />
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="密码:" Margin="46,144,0,0"/>
|
||||
<TextBox IsEnabled="{Binding Enabled1}" Text="{Binding Password}" HorizontalAlignment="Left" Margin="93,138,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="255" />
|
||||
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="允许匿名:" Margin="23,184,0,0"/>
|
||||
<CheckBox IsEnabled="{Binding Enabled1}" IsChecked="{Binding Anonymous}" Content="" Margin="93,184,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" />
|
||||
|
||||
<TextBlock HorizontalAlignment="Left" VerticalAlignment="Top" Text="最大连接数:" Margin="18,224,0,0"/>
|
||||
<TextBox IsEnabled="{Binding Enabled1}" Text="{Binding MaxConnectCount}" HorizontalAlignment="Left" Margin="93,218,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="255" />
|
||||
<Button IsEnabled="{Binding Enabled1}" Content="选择" Command="{Binding SelectPathCmd}" Margin="370,15,0,0" VerticalAlignment="Top" Width="75" HorizontalAlignment="Left" />
|
||||
<Button Content="{Binding ButtonName}" Command="{Binding StartCmd}" Margin="80,264,0,0" VerticalAlignment="Top" Width="90" HorizontalAlignment="Left" />
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
13
常用工具集/Views/02网络相关/FTP服务.axaml.cs
Normal file
13
常用工具集/Views/02网络相关/FTP服务.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class FTP服务 : UserControl
|
||||
{
|
||||
public FTP服务()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
39
常用工具集/Views/02网络相关/HTTP调试.axaml
Normal file
39
常用工具集/Views/02网络相关/HTTP调试.axaml
Normal file
@@ -0,0 +1,39 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._02网络相关"
|
||||
x:Class="常用工具集.HTTP调试"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:HTTP调试ViewModel">
|
||||
<UserControl.DataContext>
|
||||
<vm:HTTP调试ViewModel />
|
||||
</UserControl.DataContext>
|
||||
<Grid>
|
||||
<Grid VerticalAlignment="Top" HorizontalAlignment="Left" Width="245" Height="45" Margin="10,25,0,0">
|
||||
<RadioButton Height="20" Content="GET" IsChecked="{Binding GetChecked}" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
|
||||
<RadioButton Height="20" Content="POST" IsChecked="{Binding PostChecked}" HorizontalAlignment="Left" Margin="65,10,0,0" VerticalAlignment="Top"/>
|
||||
<RadioButton Height="20" Content="Get下载文件" IsChecked="{Binding DownloadChecked}" HorizontalAlignment="Left" Margin="132,10,0,0" VerticalAlignment="Top"/>
|
||||
</Grid>
|
||||
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Text="URL:" Margin="255,37,0,0" />
|
||||
<TextBox Text="{Binding Url}" HorizontalAlignment="Left" Margin="285,31,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="355" />
|
||||
<Button IsEnabled="{Binding ButtonEnabled}" Content="调试" Command="{Binding ButtonCmd}" HorizontalAlignment="Left" Margin="645,31,0,0" VerticalAlignment="Top" Width="60" />
|
||||
<Grid IsVisible="{Binding Visiable}" VerticalAlignment="Top" HorizontalAlignment="Left" Width="163" Height="45" Margin="75,75,0,0">
|
||||
<RadioButton Height="20" Content="JSON" IsChecked="{Binding JsonChecked}" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
|
||||
<RadioButton Height="20" Content="表单" IsChecked="{Binding FormChecked}" HorizontalAlignment="Left" Margin="93,10,0,0" VerticalAlignment="Top"/>
|
||||
</Grid>
|
||||
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Text="超时:" Margin="255,84,0,0" />
|
||||
<TextBox Text="{Binding Timeout}" HorizontalAlignment="Left" Margin="295,79,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="160" />
|
||||
|
||||
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Text="参数:" Margin="20,131,0,0" />
|
||||
<TextBox Text="{Binding Parms}" Height="160" HorizontalAlignment="Left" Margin="60,125,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="395" VerticalContentAlignment="Top" HorizontalContentAlignment="Left" AcceptsReturn="True" AcceptsTab="True"/>
|
||||
|
||||
|
||||
<TextBlock VerticalAlignment="Top" HorizontalAlignment="Left" Text="结果:" Margin="20,321,0,0" />
|
||||
<TextBox Text="{Binding Result}" Height="160" HorizontalAlignment="Left" Margin="60,315,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="395" VerticalContentAlignment="Top" HorizontalContentAlignment="Left" />
|
||||
<TextBlock HorizontalAlignment="Left" Margin="470,125,0,0" TextWrapping="Wrap" Text="如果是JSON,请填写JSON内容" Foreground="Red" VerticalAlignment="Top" Width="177" />
|
||||
<TextBlock HorizontalAlignment="Left" Margin="470,155,0,0" TextWrapping="Wrap" Text="其他格式如下:" Foreground="Red" VerticalAlignment="Top" Width="177" />
|
||||
<TextBlock HorizontalAlignment="Left" Margin="470,190,0,0" TextWrapping="Wrap" Text="userName=zjw&password=123456" Foreground="Red" VerticalAlignment="Top" Width="212" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
13
常用工具集/Views/02网络相关/HTTP调试.axaml.cs
Normal file
13
常用工具集/Views/02网络相关/HTTP调试.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class HTTP调试 : UserControl
|
||||
{
|
||||
public HTTP调试()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
65
常用工具集/Views/02网络相关/端口占用扫描.axaml
Normal file
65
常用工具集/Views/02网络相关/端口占用扫描.axaml
Normal file
@@ -0,0 +1,65 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._02网络相关"
|
||||
x:Class="常用工具集.端口占用扫描"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:端口占用扫描ViewModel">
|
||||
<UserControl.DataContext>
|
||||
<vm:端口占用扫描ViewModel />
|
||||
</UserControl.DataContext>
|
||||
<Grid>
|
||||
<Button Content="开始扫描" IsEnabled="{Binding Enabled1}" Command="{Binding StartScanCmd}" HorizontalAlignment="Left" Margin="400,10,0,0" VerticalAlignment="Top" Width="90" />
|
||||
<Button Content="结束进程" IsEnabled="{Binding Enabled2}" Command="{Binding CloseProcessCmd}" HorizontalAlignment="Left" Margin="500,10,0,0" VerticalAlignment="Top" Width="90" />
|
||||
<DataGrid
|
||||
Height="430"
|
||||
SelectedIndex="{Binding SelectedIndex}"
|
||||
HeadersVisibility="All"
|
||||
CanUserReorderColumns="True"
|
||||
CanUserResizeColumns="True"
|
||||
CanUserSortColumns="True"
|
||||
IsReadOnly="True"
|
||||
Margin="10,70,0,0" Width="675"
|
||||
ItemsSource="{Binding DataList}">
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
x:DataType="vm:ScanResult"
|
||||
Binding="{Binding Protocol}"
|
||||
Header="协议" />
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
x:DataType="vm:ScanResult"
|
||||
Binding="{Binding LocalAddress}"
|
||||
Header="本机地址" />
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
x:DataType="vm:ScanResult"
|
||||
Binding="{Binding RemoteAddress}"
|
||||
Header="远程地址" />
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
x:DataType="vm:ScanResult"
|
||||
Binding="{Binding State}"
|
||||
Header="状态" />
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
x:DataType="vm:ScanResult"
|
||||
Binding="{Binding Port}"
|
||||
Header="端口号" />
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
x:DataType="vm:ScanResult"
|
||||
Binding="{Binding PID}"
|
||||
Header="进程ID" />
|
||||
<DataGridTextColumn
|
||||
Width="*"
|
||||
x:DataType="vm:ScanResult"
|
||||
Binding="{Binding ProcessName}"
|
||||
Header="进程名称" />
|
||||
</DataGrid.Columns>
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
13
常用工具集/Views/02网络相关/端口占用扫描.axaml.cs
Normal file
13
常用工具集/Views/02网络相关/端口占用扫描.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class 端口占用扫描 : UserControl
|
||||
{
|
||||
public 端口占用扫描()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
54
常用工具集/Views/02网络相关/端口扫描.axaml
Normal file
54
常用工具集/Views/02网络相关/端口扫描.axaml
Normal file
@@ -0,0 +1,54 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._02网络相关"
|
||||
x:Class="常用工具集.端口扫描"
|
||||
x:CompileBindings="True"
|
||||
Loaded="UserControl_Loaded"
|
||||
x:DataType="vm:端口扫描ViewModel">
|
||||
<UserControl.DataContext>
|
||||
<vm:端口扫描ViewModel />
|
||||
</UserControl.DataContext>
|
||||
<Grid>
|
||||
<Border Theme="{StaticResource CardBorder}" Width="300" Height="250" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="10,50,0,0">
|
||||
<Grid Height="220">
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,-20,0,0" TextWrapping="Wrap" Text="信息设置" VerticalAlignment="Top"/>
|
||||
<TextBlock Text="起始IP" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20,22,0,0" FontSize="10" />
|
||||
<TextBox Text="192" Name="textBox1" VerticalAlignment="Top" HorizontalAlignment="Left" Width="40" FontSize="10" Margin="70,16,0,0" />
|
||||
<TextBlock Text="." HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,26,0,0" FontSize="10"/>
|
||||
<TextBlock Text="." HorizontalAlignment="Left" VerticalAlignment="Top" Margin="111,26,0,0" FontSize="10"/>
|
||||
<TextBox Text="168" Name="textBox2" VerticalAlignment="Top" HorizontalAlignment="Left" Width="40" FontSize="10" Margin="115,16,0,0" />
|
||||
<TextBox Text="1" Name="textBox3" VerticalAlignment="Top" HorizontalAlignment="Left" Width="40" FontSize="10" Margin="166,16,0,0" />
|
||||
<TextBlock Text="." HorizontalAlignment="Left" VerticalAlignment="Top" Margin="211,26,0,0" FontSize="10"/>
|
||||
<TextBox Text="1" Name="textBox4" VerticalAlignment="Top" HorizontalAlignment="Left" Width="40" FontSize="10" Margin="222,16,0,0" />
|
||||
<TextBlock Text="." HorizontalAlignment="Left" VerticalAlignment="Top" Margin="160,25,0,0" FontSize="10"/>
|
||||
<TextBlock Text="结束IP" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="19,58,0,0" FontSize="10"/>
|
||||
<TextBox Text="192" IsEnabled="False" Name="textBox8" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="10" Width="40" Margin="69,52,0,0" />
|
||||
<TextBlock Text="." HorizontalAlignment="Left" VerticalAlignment="Top" Margin="110,62,0,0" FontSize="10"/>
|
||||
<TextBox Text="168" IsEnabled="False" Name="textBox7" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="10" Width="40" Margin="114,52,0,0" />
|
||||
<TextBox Text="1" IsEnabled="False" Name="textBox6" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="10" Width="40" Margin="165,52,0,0" />
|
||||
<TextBlock Text="." HorizontalAlignment="Left" VerticalAlignment="Top" Margin="210,62,0,0" FontSize="10" />
|
||||
<TextBox Text="1" Name="textBox5" VerticalAlignment="Top" HorizontalAlignment="Left" Width="40" FontSize="10" Margin="221,52,0,0" />
|
||||
<TextBlock Text="." HorizontalAlignment="Left" VerticalAlignment="Top" Margin="159,61,0,0" FontSize="10" />
|
||||
<TextBlock Text="端口号" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20,96,0,0" FontSize="10"/>
|
||||
<TextBox Text="80,443,400-445" Name="textBox9" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="10" Width="191" Margin="70,90,0,0" />
|
||||
<TextBlock Text="端口号" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20,135,0,0" FontSize="10"/>
|
||||
<TextBox Text="200" Name="textBox10" VerticalAlignment="Top" HorizontalAlignment="Left" Width="162" FontSize="10" Margin="70,129,0,0" />
|
||||
<TextBlock Text="毫秒" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="238,135,0,0" FontSize="10"/>
|
||||
<TextBlock Text="线程数" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="20,176,0,0" FontSize="10"/>
|
||||
<TextBox Text="10" Name="textBox11" VerticalAlignment="Top" HorizontalAlignment="Left" Width="162" Margin="70,170,0,0" FontSize="10"/>
|
||||
|
||||
</Grid>
|
||||
</Border>
|
||||
<Border Theme="{StaticResource CardBorder}" Width="280" Height="250" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="340,50,0,0">
|
||||
<Grid Height="220">
|
||||
<TextBlock HorizontalAlignment="Center" Margin="0,-20,0,0" TextWrapping="Wrap" Text="扫描结果" VerticalAlignment="Top"/>
|
||||
<TextBlock Name="textBox12" Text="" TextWrapping="Wrap" HorizontalAlignment="Center" VerticalAlignment="Top" Margin="0,22,0,0" Height="188" Width="260" />
|
||||
</Grid>
|
||||
</Border>
|
||||
<ProgressBar Name="uiProcessBar1" HorizontalAlignment="Left" Height="10" Margin="25,320,0,0" VerticalAlignment="Top" Width="595"/>
|
||||
<Button Name="button1" Content="开始扫描" HorizontalAlignment="Left" Margin="545,370,0,0" VerticalAlignment="Top" Width="90" Click="button1_Click" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
303
常用工具集/Views/02网络相关/端口扫描.axaml.cs
Normal file
303
常用工具集/Views/02网络相关/端口扫描.axaml.cs
Normal file
@@ -0,0 +1,303 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
using Avalonia.Markup.Xaml;
|
||||
using Avalonia.Threading;
|
||||
using Ursa.Controls;
|
||||
using 常用工具集.Utility.Network;
|
||||
using 常用工具集.ViewModel._02网络相关;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class 端口扫描 : UserControl
|
||||
{
|
||||
private bool stop;
|
||||
private Queue<ScanPortEntity> allScanPort;
|
||||
private object lockObj = new object();
|
||||
private object lockMsg = new object();
|
||||
public 端口扫描()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
private void UserControl_Loaded(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
allScanPort = new Queue<ScanPortEntity>();
|
||||
textBox1.TextChanged += textBox1_TextChanged;
|
||||
textBox2.TextChanged += textBox2_TextChanged;
|
||||
textBox3.TextChanged += textBox3_TextChanged;
|
||||
}
|
||||
|
||||
private void textBox1_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
textBox8.Text = textBox1.Text;
|
||||
}
|
||||
private void textBox2_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
textBox7.Text = textBox2.Text;
|
||||
}
|
||||
|
||||
private void textBox3_TextChanged(object sender, TextChangedEventArgs e)
|
||||
{
|
||||
textBox6.Text = textBox3.Text;
|
||||
}
|
||||
private void button1_Click(object sender, RoutedEventArgs e)
|
||||
{
|
||||
if ("停止" == button1.Content.ToString())
|
||||
{
|
||||
stop = true;
|
||||
button1.Content = "扫描";
|
||||
}
|
||||
else
|
||||
{
|
||||
//非空检测
|
||||
if (textBox1.Text.Trim().Length == 0 || textBox2.Text.Trim().Length == 0 || textBox3.Text.Trim().Length == 0 || textBox4.Text.Trim().Length == 0 || textBox5.Text.Trim().Length == 0)
|
||||
{
|
||||
MessageBox.ShowAsync("请填写正确的IP地址");
|
||||
return;
|
||||
}
|
||||
//数据范围检测
|
||||
if (Convert.ToInt32(textBox1.Text.Trim()) < 0 || Convert.ToInt32(textBox1.Text.Trim()) > 255)
|
||||
{
|
||||
MessageBox.ShowAsync("请填写正确的IP地址");
|
||||
return;
|
||||
}
|
||||
if (Convert.ToInt32(textBox2.Text.Trim()) < 0 || Convert.ToInt32(textBox2.Text.Trim()) > 255)
|
||||
{
|
||||
MessageBox.ShowAsync("请填写正确的IP地址");
|
||||
return;
|
||||
}
|
||||
if (Convert.ToInt32(textBox3.Text.Trim()) < 0 || Convert.ToInt32(textBox3.Text.Trim()) > 255)
|
||||
{
|
||||
MessageBox.ShowAsync("请填写正确的IP地址");
|
||||
return;
|
||||
}
|
||||
if (Convert.ToInt32(textBox4.Text.Trim()) < 0 || Convert.ToInt32(textBox4.Text.Trim()) > 255)
|
||||
{
|
||||
MessageBox.ShowAsync("请填写正确的IP地址");
|
||||
return;
|
||||
}
|
||||
if (Convert.ToInt32(textBox5.Text.Trim()) < 0 || Convert.ToInt32(textBox5.Text.Trim()) > 255)
|
||||
{
|
||||
MessageBox.ShowAsync("请填写正确的IP地址");
|
||||
return;
|
||||
}
|
||||
if (Convert.ToInt32(textBox5.Text.Trim()) < Convert.ToInt32(textBox4.Text.Trim()))
|
||||
{
|
||||
MessageBox.ShowAsync("结束IP不能小于起始IP");
|
||||
return;
|
||||
}
|
||||
if (textBox9.Text.Trim().Length == 0)
|
||||
{
|
||||
MessageBox.ShowAsync("请输入要扫描的端口号");
|
||||
return;
|
||||
}
|
||||
if (textBox10.Text.Trim().Length == 0)
|
||||
{
|
||||
MessageBox.ShowAsync("请输入超时时间");
|
||||
return;
|
||||
}
|
||||
int timeout = Convert.ToInt32(textBox10.Text.Trim());
|
||||
if (textBox11.Text.Trim().Length == 0)
|
||||
{
|
||||
MessageBox.ShowAsync("请输入线程数");
|
||||
return;
|
||||
}
|
||||
int threadCount = Convert.ToInt32(textBox11.Text.Trim());
|
||||
allScanPort.Clear();
|
||||
List<string> portList = new List<string>();
|
||||
string[] strPortArray = textBox9.Text.Trim().Split(',');
|
||||
foreach (string strPort in strPortArray)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (strPort.Trim().Length == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (strPort.Contains("-"))
|
||||
{
|
||||
string[] aa = strPort.Split('-');
|
||||
if (aa.Length > 2)
|
||||
{
|
||||
MessageBox.ShowAsync("请输入正确的端口号");
|
||||
return;
|
||||
}
|
||||
int startPort = Convert.ToInt32(aa[0]);
|
||||
int endPort = Convert.ToInt32(aa[1]);
|
||||
if (endPort < startPort)
|
||||
{
|
||||
MessageBox.ShowAsync("请输入正确的端口号范围");
|
||||
return;
|
||||
}
|
||||
if (startPort < 0 && startPort > 65535)
|
||||
{
|
||||
MessageBox.ShowAsync("端口号范围应该是0-65535");
|
||||
return;
|
||||
}
|
||||
if (endPort < 0 && endPort > 65535)
|
||||
{
|
||||
MessageBox.ShowAsync("端口号范围应该是0-65535");
|
||||
return;
|
||||
}
|
||||
for (int i = startPort; i <= endPort; i++)
|
||||
{
|
||||
string port = Convert.ToString(i);
|
||||
if (!portList.Contains(port))
|
||||
portList.Add(port);
|
||||
}
|
||||
|
||||
}
|
||||
else if (strPort.Contains("~"))
|
||||
{
|
||||
string[] aa = strPort.Split('~');
|
||||
if (aa.Length > 2)
|
||||
{
|
||||
MessageBox.ShowAsync("请输入正确的端口号");
|
||||
return;
|
||||
}
|
||||
int startPort = Convert.ToInt32(aa[0]);
|
||||
int endPort = Convert.ToInt32(aa[1]);
|
||||
if (endPort < startPort)
|
||||
{
|
||||
MessageBox.ShowAsync("请输入正确的端口号范围");
|
||||
return;
|
||||
}
|
||||
if (startPort < 0 && startPort > 65535)
|
||||
{
|
||||
MessageBox.ShowAsync("端口号范围应该是0-65535");
|
||||
return;
|
||||
}
|
||||
if (endPort < 0 && endPort > 65535)
|
||||
{
|
||||
MessageBox.ShowAsync("端口号范围应该是0-65535");
|
||||
return;
|
||||
}
|
||||
for (int i = startPort; i <= endPort; i++)
|
||||
{
|
||||
string port = Convert.ToString(i);
|
||||
if (!portList.Contains(port))
|
||||
portList.Add(port);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int startPort = Convert.ToInt32(strPort);
|
||||
if (startPort < 0 && startPort > 65535)
|
||||
{
|
||||
MessageBox.ShowAsync("端口号范围应该是0-65535");
|
||||
return;
|
||||
}
|
||||
string port = Convert.ToString(startPort);
|
||||
if (!portList.Contains(port))
|
||||
portList.Add(port);
|
||||
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
MessageBox.ShowAsync("请输入正确的端口号");
|
||||
return;
|
||||
}
|
||||
}
|
||||
string ipFront = textBox1.Text.Trim() + "." + textBox2.Text.Trim() + "." + textBox3.Text.Trim() + ".";
|
||||
int startIp = Convert.ToInt32(textBox4.Text.Trim());
|
||||
int endIp = Convert.ToInt32(textBox5.Text.Trim());
|
||||
for (int j = startIp; j <= endIp; j++)
|
||||
{
|
||||
string ipAddress = ipFront + j;
|
||||
foreach (string port in portList)
|
||||
{
|
||||
ScanPortEntity entity = new ScanPortEntity();
|
||||
entity.IP = ipAddress;
|
||||
entity.Port = Convert.ToInt32(port);
|
||||
allScanPort.Enqueue(entity);
|
||||
}
|
||||
}
|
||||
textBox12.Text = string.Empty;
|
||||
uiProcessBar1.Maximum = allScanPort.Count;
|
||||
uiProcessBar1.Value = 0;
|
||||
stop = false;
|
||||
button1.Content = "停止";
|
||||
for (int i = 0; i < threadCount; i++)
|
||||
{
|
||||
new Thread(StartScan).Start(timeout);
|
||||
}
|
||||
}
|
||||
}
|
||||
private void StartScan(object objTimeout)
|
||||
{
|
||||
int timeout = (int)objTimeout;
|
||||
while (!stop)
|
||||
{
|
||||
int count = 0;
|
||||
bool flag;
|
||||
ScanPortEntity entity = null;
|
||||
lock (lockObj)
|
||||
{
|
||||
try
|
||||
{
|
||||
entity = allScanPort.Dequeue();
|
||||
count = allScanPort.Count;
|
||||
flag = true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
flag = false;
|
||||
}
|
||||
}
|
||||
if (!flag)
|
||||
{
|
||||
break;
|
||||
}
|
||||
Dispatcher.UIThread.Invoke(new Action(() =>
|
||||
{
|
||||
if (stop)
|
||||
return;
|
||||
uiProcessBar1.Value = uiProcessBar1.Maximum - count;
|
||||
if (count == 0)
|
||||
{
|
||||
allScanPort.Clear();
|
||||
stop = true;
|
||||
button1.Content = "扫描";
|
||||
}
|
||||
}));
|
||||
if (entity == null)
|
||||
break;
|
||||
//扫描该IP和端口
|
||||
try
|
||||
{
|
||||
TimeOutSocket tc = new TimeOutSocket(entity.IP, entity.Port, timeout);
|
||||
tc.Connect();
|
||||
//通
|
||||
Dispatcher.UIThread.Invoke(new Action(() =>
|
||||
{
|
||||
lock (lockMsg)
|
||||
{
|
||||
string message = entity.IP + ":" + entity.Port;
|
||||
textBox12.Text = textBox12.Text + message + "\r\n";
|
||||
}
|
||||
}));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
//不通
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class ScanPortEntity
|
||||
{
|
||||
public ScanPortEntity() { }
|
||||
public ScanPortEntity(string ip, int port)
|
||||
{
|
||||
this.IP = ip;
|
||||
this.Port = port;
|
||||
}
|
||||
public string IP { get; set; }
|
||||
public int Port { get; set; }
|
||||
|
||||
}
|
||||
43
常用工具集/Views/02网络相关/网络状态检测.axaml
Normal file
43
常用工具集/Views/02网络相关/网络状态检测.axaml
Normal file
@@ -0,0 +1,43 @@
|
||||
<UserControl xmlns="https://github.com/avaloniaui"
|
||||
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"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
|
||||
xmlns:vm ="clr-namespace:常用工具集.ViewModel._02网络相关"
|
||||
x:Class="常用工具集.网络状态检测"
|
||||
x:CompileBindings="True"
|
||||
x:DataType="vm:网络状态检测ViewModel">
|
||||
<UserControl.DataContext>
|
||||
<vm:网络状态检测ViewModel />
|
||||
</UserControl.DataContext>
|
||||
|
||||
<Grid RowDefinitions="40,*">
|
||||
<Grid Grid.Row="0" >
|
||||
<TextBlock Text="IP地址网段" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,0,0,0" />
|
||||
<TextBox Text="{Binding IP1}" VerticalAlignment="Center" HorizontalAlignment="Left" Width="65" Margin="85,0,0,0" />
|
||||
<TextBlock Text="." HorizontalAlignment="Left" VerticalAlignment="Center" Margin="160,0,0,0" />
|
||||
<TextBox Text="{Binding IP2}" VerticalAlignment="Center" HorizontalAlignment="Left" Width="75" Margin="170,0,0,0" />
|
||||
<TextBlock Text="." HorizontalAlignment="Left" VerticalAlignment="Center" Margin="255,0,0,0" />
|
||||
<TextBox Text="{Binding IP3}" VerticalAlignment="Center" HorizontalAlignment="Left" Width="75" Margin="270,0,0,0" />
|
||||
<TextBlock Text=".??" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="354,0,0,0" />
|
||||
<Button Content="检测" Command="{Binding Button1Cmd}" HorizontalAlignment="Left" Margin="470,0,0,0" />
|
||||
<Button Content="清空" Command="{Binding Button2Cmd}" HorizontalAlignment="Left" Margin="545,0,0,0" />
|
||||
</Grid>
|
||||
|
||||
<Grid Grid.Row="1" ColumnDefinitions="625,*">
|
||||
<ItemsControl ItemsSource="{Binding PingStatus}">
|
||||
<ItemsControl.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<WrapPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Border Margin="3" Background="{Binding Color}" ToolTip.Tip="{Binding Tip}" Width="25" Height="25"/>
|
||||
</DataTemplate>
|
||||
</ItemsControl.ItemTemplate>
|
||||
</ItemsControl>
|
||||
</Grid>
|
||||
</Grid>
|
||||
|
||||
</UserControl>
|
||||
13
常用工具集/Views/02网络相关/网络状态检测.axaml.cs
Normal file
13
常用工具集/Views/02网络相关/网络状态检测.axaml.cs
Normal file
@@ -0,0 +1,13 @@
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace 常用工具集;
|
||||
|
||||
public partial class 网络状态检测 : UserControl
|
||||
{
|
||||
public 网络状态检测()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user