.Net Micro Framework研究—窗体控件

本文介绍了.Net Micro Framework(MF)模拟器中的控件使用情况,包括Panel、Text、Image等,并展示了测试代码示例。同时提及MF对于TCP协议的支持现状及未来版本的发展计划。
AI助手已提取文章相关产品:

试验平台:.Net Micro Framework 模拟器

Microsoft.SPOT.Presentation.Controls命名空间里,也就如下几个控件(姑且称为控件吧),PanelStackPanelTextTextFlowImageListBoxScrollViewer 其中仅有PanelTextImage控件完成度相对较好,其他的实现并不完整,甚至只是一个空接口。

下面是测试代码:

using System;

using Microsoft.SPOT;

using Microsoft.SPOT.Input;

using Microsoft.SPOT.Presentation;

using Microsoft.SPOT.Presentation.Controls;

using Microsoft.SPOT.Presentation.Media;

using Microsoft.SPOT.Presentation.Shapes;

namespace MFWindow

{

public class Program : Microsoft.SPOT.Application

{

public static void Main()

{

//创建窗体

WindowsDrawing win = new WindowsDrawing();

//程序运行

new Program().Run(win);

}

internal sealed class WindowsDrawing : Window

{

public WindowsDrawing()

{

this.Width = SystemMetrics.ScreenWidth;

this.Height = SystemMetrics.ScreenHeight;

//可设置显示方向(水平,垂直)

//StackPanel panel = new StackPanel(Orientation.Vertical);

StackPanel panel = new StackPanel(Orientation.Horizontal);

//设置对象堆叠的方式

panel.HorizontalAlignment = HorizontalAlignment.Left;

panel.VerticalAlignment = VerticalAlignment.Top;

this.Child = panel;

//Text控件

Text txt = new Text(Resources.GetFont(Resources.FontResources.small), "yefan");

txt.Width = 100;

txt.Height = 30;

txt.ForeColor = Colors.Green;

panel.Children.Add(txt);

//TextFlow控件 不支持滚动条,实现还不完整

TextFlow txtf = new TextFlow();

txtf.ScrollingStyle = ScrollingStyle.LineByLine;

txtf.TextAlignment = TextAlignment.Left;

txtf.Height = 200;

txtf.Width = 50;

for (int i = 0; i < 10; i++)

{

txtf.TextRuns.Add(new TextRun("yefan123", Resources.GetFont(Resources.FontResources.small), Colors.Blue));

//注意:换行这么写,可不是/r/n

txtf.TextRuns.Add(TextRun.EndOfLine);

txtf.TextRuns.Add(new TextRun("yefan456", Resources.GetFont(Resources.FontResources.small), Colors.Red));

txtf.TextRuns.Add(TextRun.EndOfLine);

txtf.TextRuns.Add(new TextRun("yefan789", Resources.GetFont(Resources.FontResources.small), Colors.Green));

txtf.TextRuns.Add(TextRun.EndOfLine);

}

panel.Children.Add(txtf);

//image

Image img = new Image();

img.Bitmap = Resources.GetBitmap(Resources.BitmapResources.yfmvp);

panel.Children.Add(img);

//ListBox 仅实现了一个空接口

ListBox lst = new ListBox();

lst.Font = Resources.GetFont(Resources.FontResources.small);

lst.Items.Add(new ListBoxItem());

//panel.Children.Add(lst);

//ScrollViewer 仅实现了一个空接口

ScrollViewer sv = new ScrollViewer();

sv.Width = 30;

sv.Height = 50;

//panel.Children.Add(sv);

//sv.Child = txtf;

}

}

}

}

目前版本的MFTCP协议栈支持也并不完善(对串口也谈不上完善,毕竟不支持奇偶校验、停止位设置),Digi的以太网口是加入了自己的处理方案,明年二月份微软将要发布的MF V3.0版,就已经完全支持TCP了,到时候MF最理想的应用也许就是通信转换了。

从本篇内容中可以看出,微软MF之旅尚在出发点不远的地方,MF研发人员任重而道远啊!

您可能感兴趣的与本文相关内容

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值