.NET MAUI进行UDP通信(二)

上篇文章有写过一个简单的demo,本次对项目进行进一步的扩展,添加tabbar功能。

1.修改AppShell.xaml文件,如下所示:

csharp 复制代码
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
    x:Class="mauiDemo.AppShell"
    xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
    xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
    xmlns:local="clr-namespace:mauiDemo"
    xmlns:minePage ="clr-namespace:mauiDemo.Page"
    Shell.FlyoutBehavior="Disabled"
    Title="mauiDemo">

    <!--<ShellContent
        Title="Home"
        ContentTemplate="{DataTemplate local:MainPage}"
        Route="MainPage" />-->

    <TabBar>
        <ShellContent Title="Home" 
                      ContentTemplate="{DataTemplate minePage:Mine}"
                      Route="Page/Mine">
            <!--<ContentPage>
                <StackLayout>
                    <Label Text="Welcome to the Home Page"
                           VerticalOptions="CenterAndExpand" 
                           HorizontalOptions="CenterAndExpand" />
                </StackLayout>
            </ContentPage>-->
        </ShellContent>
        <ShellContent Title="Search">
            <ContentPage>
                <StackLayout>
                    <Label Text="Search Page"
                           VerticalOptions="CenterAndExpand" 
                           HorizontalOptions="CenterAndExpand" />
                </StackLayout>
            </ContentPage>
        </ShellContent>
        <ShellContent Title="Settings">
            <ContentPage>
                <StackLayout>
                    <Label Text="Settings Page"
                           VerticalOptions="CenterAndExpand" 
                           HorizontalOptions="CenterAndExpand" />
                </StackLayout>
            </ContentPage>
        </ShellContent>
    </TabBar>
1).将MainPage注释掉
2).添加tabbar功能
3).第一个ShellConten的路由设置为Mine文件,注意到ContentTemplate="{DataTemplate minePage:Mine}",当前不是local,是因为我们引用了命名空间并命名为minePage: xmlns:minePage ="clr-namespace:mauiDemo.Page".
路由 Route="Page/Mine" 可结合上篇文章了解,在下面会贴出完整项目结构图

</Shell>

2.运行查看效果如下:

3.项目完整结构图如下:

4.关于后续项目的计划

csharp 复制代码
1).添加sqlite帮助类,以方便数据存储到手机本身
2).可将UDP通信换成mqtt通信,并结合http将数据放置服务器,以实现远程控制设备功能
3).添加低功耗蓝牙BLE通信功能,对于无网络情况下近距离与仪器设备进行通信
4).IOS包的发布与实机测验
5).桌面端UI与移动端UI美化,目前未考虑UI,简单的横竖布局
6).添加图表数据展示
7).和uniapp进行性能上比较(了解到目前APP端uniapp需要下载第三方UDP插件,在UTS下可以编写调用原生UDP通信的插件,但UTS属于uniAPP x,demo暂时还开始,不过uniapp支持混用UTS插件,目前已实现在uniapp中调用UTS分享自定义插件,年后测验一下UTS自定义udp插件)
相关推荐
mudtools10 小时前
搭建一套.net下能落地的飞书考勤系统
后端·c#·.net
玩泥巴的20 小时前
搭建一套.net下能落地的飞书考勤系统
c#·.net·二次开发·飞书
gihigo19981 天前
基于TCP协议实现视频采集与通信
网络协议·tcp/ip·音视频
白太岁1 天前
通信:(5) 电路交换、报文交换与分组交换
运维·服务器·网络·网络协议
EasyGBS1 天前
国标安全升级:GB28181平台EasyGBS支持GB35114协议的应用场景与核心优势
网络协议·安全·gb28181·gb35114
快乐非自愿1 天前
C# 中的 Span 和内存:.NET 中的高性能内存处理
java·c#·.net
Traced back1 天前
【.NET7 WinForm 实战】三层架构+EF Core+多数据库+完整功能(源码+教程+脚本)
数据库·架构·.net
凯酱1 天前
Windows防火墙入站规则IP白名单
windows·网络协议·tcp/ip
稻草猫.1 天前
TCP与UDP:传输层协议深度解析
笔记·后端·网络协议