.Net Micro Framework研究—窗体控件

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

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

 

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

下面是测试代码:

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;               

            }

        }

    }

}

image.png

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

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

相关文章
.Net Micro Framework研究—Digi开发板初探
写的比较基础全面,由于我们北航的研发团队先研究了Digi的开发板,所以直到今天Digi开发板才到我的手上,我的《Micro Framework研究》系列文章以后也会陆续推出
706 0
.Net Micro Framework研究—IO读写
试验平台:Digi MF开发板
439 0
.Net Micro Framework研究—串口操作
试验平台:Digi MF开发板,Digi提供的示例中包含了串口的示例程序
559 0
|
网络协议
.Net Micro Framework研究—TCP/IP通信
关于网络通信方面,Digi提供了两个程序,一个是TCP Server运行在Digi的开发板上,一个是TCP Client程序,运行在PC上,通过网络,上位机很容易控制Digi开发的IO信号
626 0
.Net Micro Framework研究—模拟器改造
由于Digi提供的开发板没有LCD显示屏,所以有关绘图方面的操作,只好在模拟器上进行了。
542 0
|
3月前
|
开发框架 前端开发 .NET
ASP.NET CORE 3.1 MVC“指定的网络名不再可用\企图在不存在的网络连接上进行操作”的问题解决过程
ASP.NET CORE 3.1 MVC“指定的网络名不再可用\企图在不存在的网络连接上进行操作”的问题解决过程
42 0
|
1月前
|
开发框架 前端开发 .NET
进入ASP .net mvc的世界
进入ASP .net mvc的世界
29 0
|
1月前
mvc.net分页查询案例——mvc-paper.css
mvc.net分页查询案例——mvc-paper.css
5 0
|
1月前
|
开发框架 前端开发 .NET
C# .NET面试系列六:ASP.NET MVC
<h2>ASP.NET MVC #### 1. MVC 中的 TempData\ViewBag\ViewData 区别? 在ASP.NET MVC中,TempData、ViewBag 和 ViewData 都是用于在控制器和视图之间传递数据的机制,但它们有一些区别。 <b>TempData:</b> 1、生命周期 ```c# TempData 的生命周期是短暂的,数据只在当前请求和下一次请求之间有效。一旦数据被读取,它就会被标记为已读,下一次请求时就会被清除。 ``` 2、用途 ```c# 主要用于在两个动作之间传递数据,例如在一个动作中设置 TempData,然后在重定向到另
100 5
|
3月前
|
XML 前端开发 定位技术
C#(NET Core3.1 MVC)生成站点地图(sitemap.xml)
C#(NET Core3.1 MVC)生成站点地图(sitemap.xml)
25 0