Micro Framework 3.0模拟器改造

Micro Framework 3.0SDK去年十月份就已经发布了,本打算在该SDK发布之后就把我以前开发的,可支持GPIOI2CSPI测试的模拟器同步升级为3.0版,以便早点支持VS2008Micro Framework v2.x仅支持VS2005Micro Framework v3.0仅支持VS2008)。不过前段时间太忙了,现在趁着年假,花了一两天的工夫,终于达成了心愿。

新的模拟器相对于以前的模拟器有了两部分改变,下面详细说一下:

一、由于Micro Framework v3.0 SDK已经含有触摸屏组件,所以新模拟器中去掉了以前的SPI通道的鼠标模块,添加了最新的触摸屏支持。

this.lcdDisplay.TouchPort = (TouchGpioPort)_emulator.GpioPorts[TouchGpioPort.DefaultTouchPin];

protected override void OnMouseDown(MouseEventArgs e)

{

base.OnMouseDown(e);

flags = TouchSampleValidFlag | TouchSampleDownFlag;

_touchPort.WriteTouchData(flags, e.X, e.Y);

}

protected override void OnMouseUp(MouseEventArgs e)

{

base.OnMouseUp(e);

flags = TouchSampleValidFlag | TouchSamplePreviousDownFlag;

_touchPort.WriteTouchData(flags, e.X, e.Y);

}

protected override void OnMouseMove(MouseEventArgs e)

{

base.OnMouseMove(e);

if ((flags & (TouchSampleValidFlag | TouchSampleDownFlag)) == (TouchSampleValidFlag | TouchSampleDownFlag))

{

flags = TouchSampleValidFlag | TouchSamplePreviousDownFlag | TouchSampleDownFlag;

if ((e.X >= 0) && (e.Y >= 0))

{

_touchPort.WriteTouchData(flags, e.X, e.Y);

}

}

}

二、3.0 SDK已经支持文件系统,所以新模拟器添加了这部分功能支持,不过新功能有些讨巧,不像虚拟机能支持真正的磁盘镜像文件,而是引用了windows自身文件操作API,把windows的文件操作封装到模拟器中。

List<EmulatorRemovableBlockStorageDevice> bsdList = new List<EmulatorRemovableBlockStorageDevice>();

removableBSDs = new Dictionary<string, EmulatorRemovableBlockStorageDevice>();

foreach (BlockStorageDevice bsd in _emulator.BlockStorageDevices)

{

if (bsd is EmulatorRemovableBlockStorageDevice)

{

bsdList.Add((EmulatorRemovableBlockStorageDevice)bsd);

}

}

if (bsdList.Count > 0)

{

insertEjectMenuItem.Visible = true;

foreach (EmulatorRemovableBlockStorageDevice removableBSD in bsdList)

{

ToolStripItem item = new ToolStripMenuItem(GetItemText(removableBSD), null, InsertEjectOnClick);

item.Name = removableBSD.Namespace;

insertEjectMenuItem.DropDownItems.Add(item);

removableBSDs.Add(removableBSD.Namespace, removableBSD);

}

}

mf3.0

模拟器V3.0

mffile

新模拟器改进了注册机制,下载后解压到任一目录,直接运行YFMFEmulator.exe文件即可完成注册。

至于模拟器如何使用,请参见我以前写的文章:

1[MSDN Webcast]Windows Embedded从入门到精通系列课程(18):用模拟器零成本体验MF开发

2.Net Micro Framework研究—模拟器改造

3用模拟器零成本体验MF开发

关于Micro Framework 3.0 SDK的几点问题

1、下载链接:http://www.microsoft.com/downloads/details.aspx?FamilyId=9356ED6F-F1F0-43EF-B21A-4644DD089B4A&displaylang=en

2、几个bug

其实这几个bug在安装SDK3.0后的Micro Framework SDK Release Notes.txt中已经有了说明。

主要有如下两个问题:

(1) 非英文版VS2008安装SDK3.0后,在新建项目中无micro Framework选项

解决办法:

If you are running a non-English version of Visual Studio, you will need to

move the Micro Framework project and item template files to a new location.

Assuming the default installation directory, you would need to copy all files

from

\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\

CSharp\Micro Framework\1033 to

\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ProjectTemplates\

CSharp\Micro Framework

and all MicroFramework* files from

\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\

1033 to

\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\ItemTemplates\CSharp\

注意:进行以上操作以后,一定要运行如下指令:X:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe /setup

(2) V2.x的应用程序升级为V3.0时失败

解决办法:

If you have existing projects written for previous versions of the Micro

Framework, follow these steps to update them to version 3.

1) Open the .csproj file for each of your projects and update the value of the

TargetFrameworkVersion from

<TargetFrameworkVersion>v2.0</TargetFrameworkVersion> to

<TargetFrameworkVersion>v3.0</TargetFrameworkVersion>

2) Open the project (or solution) in Visual Studio 2008 and complete the

Conversion Wizard.

3) Review the "New behavior" section below and update code as needed.

你可能感兴趣的:(windows,.net,Microsoft,ide)