zoukankan      html  css  js  c++  java
  • Socket 简易静态服务器 WPF MVVM模式(一)

    整体代码下载

    主要实现功能:

    Socket的简单应用

    可修改IP和端口

    显示来访信息

    界面设计:

    界面采用MVVM设计,很简陋。

    前台的主要目的是

    输入IP地址

    输入端口

    输入文件目录

    开启监听和停止监听

    主页面的XAML代码:

    <Window x:Class="简易静态服务器.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            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"      
            xmlns:local="clr-namespace:简易静态服务器"    
            xmlns:data="clr-namespace:简易静态服务器.ViewModels"
            mc:Ignorable="d"
            Title="小型静态服务器" Height="450" Width="800" MinHeight="450" MinWidth="800" MaxHeight="450" MaxWidth="800">
        <Window.DataContext>
            <data:MainViewModels/>
        </Window.DataContext>
        <Grid>
            <Grid.RowDefinitions>
                <RowDefinition Height="58*"/>
                <RowDefinition Height="54*"/>
                <RowDefinition Height="50*"/>
                <RowDefinition Height="143*"/>
                <RowDefinition Height="57*"/>
                <RowDefinition Height="57*"/>
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="102*"/>
                <ColumnDefinition Width="107*"/>
                <ColumnDefinition Width="93*"/>
                <ColumnDefinition Width="94*"/>
                <ColumnDefinition Width="396*"/>
            </Grid.ColumnDefinitions>
            <TextBlock Text="端口:" IsEnabled="{Binding Input}"  Grid.Row="1"   HorizontalAlignment="Center" VerticalAlignment="Center"/>
            <TextBlock Text="文件:" IsEnabled="{Binding Input}" Grid.Row="2"   HorizontalAlignment="Center" VerticalAlignment="Center"/>
            <TextBlock Text="IP地址:" IsEnabled="{Binding Input}"  Grid.Row="0"   HorizontalAlignment="Center" VerticalAlignment="Center"/>
            <TextBox  Text="{Binding Prot}"  Grid.Column="1" Grid.Row="1" Margin="0,8.5,0,8.5"/>
            <TextBox  Text="{Binding FileUrl}" Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="2"  Margin="0,6.5,0,6.5"/>
            <TextBox  Text="{Binding IP}" Grid.Column="1" Grid.ColumnSpan="3" Grid.Row="0"  Margin="0,10,0,10"/>
            <Button  IsEnabled="{Binding Run}" Command="{Binding  StatrCommand}"  Grid.Row="4" Grid.Column="1" Content="启动" Margin="0,0,13,0"/>
            <Button Command="{Binding StopCommand}" Grid.Row="4" Grid.Column="3" Content="停止" />
            <ListView ItemsSource="{Binding MainClass}"   Grid.Column="4" Grid.RowSpan="6" Margin="5">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <Grid Width="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=ListView,AncestorLevel=1},Path=ActualWidth}" >
                            <TextBlock  Text="{Binding  StocketSting}"/>
                        </Grid>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </Grid>
    </Window>
  • 相关阅读:
    html5+css3酷炫音频播放器代码
    js/html/css做一个简单的图片自动(auto)轮播效果//带注释
    gVIM+zencoding快速开发HTML/CSS/JS(适用WEB前端)
    使用libcurl,根据url下载对应html页面
    CSS+HTML+JQuery简单菜单
    【POJ1845】Sumdiv(数论/约数和定理/等比数列二分求和)
    【CodeForces727E/CF727E】Games on a CD (字符串哈希)
    【洛谷3224/BZOJ2733】[HNOI2012]永无乡 (Splay启发式合并)
    【BZOJ2565】最长双回文串 (Manacher算法)
    【洛谷2926/BZOJ1607】[USACO08DEC]Patting Heads拍头(筛法)
  • 原文地址:https://www.cnblogs.com/T-ARF/p/9933517.html
Copyright © 2011-2022 走看看