.Net Mirco Framework 2007技术大会
2006年在《程序员》杂志上通过看马宁的专栏文章,第一次知道了.Net MF。一年后的今天终于近距离地接触了.Net Mirco Frmaework,对MF有了一定的感性认识。
最近公司很多项目都有大量嵌入式设备使用,由于WinCE系统相对较大,对硬件平台要求过高,所以对.Net MF一直比较关注。今天总算大开眼界了。

微软公司的Colin Miller和Digi公司的John Leier在上午的演讲拉开了.Net MF序幕,针对嵌入式领域,一个从软件角度进行阐述,另一个从硬件平台角度进行呼应,一软一硬,二者强强联合,恐怕未来嵌入式智能设备一半以上的项目开发要被其收入囊中了。下午的中文演讲给人感觉有些干瘪,两三个演讲,平均短短十几分钟就草草收场。后来微软公司杜伟的演讲,从VS2005一行行难以看清的代码,到一个个令人惊艳的样例把MF开发技术推向最前台。

Digi公司很是有魄力,免费送出15套开发套件(5个作为回答问题的奖品,10个抽奖),自己即没有回答问题的勇气,也没有好的运气,只好剩下羡慕的份了。
最后为每个人送出的1G优盘(类似微软今年MVP大礼包中的优盘)很有分量,不仅是1G的容量,并且里面竟然把所有的幻灯片拷贝其中,更没有想到的是,MF 的SDK也在里面,真棒!
回到家迫不及待装了一份MF SDK(MicroFrameworkSDK.MSI 区区只有5998 kb,强!),有模拟器,也有示例。

其中几个示例不知道为什么编译成功,就是运行失败,对第二示例比较感兴趣,可以绘制图形,并且可以贴图。



相关代码如下:
//Copyright(C)MicrosoftCorporation.Allrightsreserved.

usingSystem;
usingSystem.Collections;
usingSystem.Threading;

usingMicrosoft.SPOT;
usingMicrosoft.SPOT.Input;
usingMicrosoft.SPOT.Hardware;
usingMicrosoft.SPOT.Presentation;
usingMicrosoft.SPOT.Presentation.Media;
usingMicrosoft.SPOT.Presentation.Controls;
usingMicrosoft.SPOT.Presentation.Shapes;

usingPresentationDemo;



/**///////////////////////////////////////////////////////////////////////////////


publicsealedclassMyApp:Application...{
//ThisstaticfieldpreventstheobjectfrombeingGC'd
privatestaticGpioButtonInputProviders_gpioInputProvider;

publicFontNinaBFont;
publicFontSmallFont;
publicBitmapSnowflake;


privateMyApp()...{
//InitializetheButtons/Pinsdispatcher
s_gpioInputProvider=newGpioButtonInputProvider(this.Dispatcher,null);

//Loadsomeresources
NinaBFont=Resources.GetFont(Resources.FontResources.NinaBFont);
SmallFont=Resources.GetFont(Resources.FontResources.SmallFont);
Snowflake=Resources.GetBitmap(Resources.BitmapResources.Snowflake);
}


protectedoverridevoidOnStartup(EventArgse)...{
//Createandsettheapplication'smainwindow
this.MainWindow=newMainMenuWindow(this);
base.OnStartup(e);
}


publicvoidGoHome()...{
Buttons.Focus(this.MainWindow);//Setfocusbacktothemainwindow
}


publicstaticvoidMain()...{
newMyApp().Run();//Starttheapp'smainwindow
}
}



/**///////////////////////////////////////////////////////////////////////////////

//Thisisthebaseclassofallourwindows;itmakeseverywindowvisible,
//setsthewindow'ssizetothefullsizeoftheLCD,andgivethewindowfocus

internalclassPresentationWindow:Window...{
protectedMyAppm_app;


protectedPresentationWindow(MyAppapp)...{
m_app=app;

//MakethewindowvisibleandthesizeoftheLCD
this.Visibility=Visibility.Visible;
this.Width=SystemMetrics.ScreenWidth;
this.Height=SystemMetrics.ScreenHeight;
Buttons.Focus(this);//Setfocustothiswindow
}


protectedoverridevoidOnButtonDown(ButtonEventArgse)...{
//RemovethiswindowformtheWindowManager
this.Close();

//Whenanybuttonispressed,gobacktotheHomepage
m_app.GoHome();
}
}


/**///////////////////////////////////////////////////////////////////////////////


internalsealedclassMainMenuWindow:PresentationWindow...{
privateListBoxm_listbox;


publicListBoxMainListBox...{get...{returnm_listbox;}}

publicMainMenuWindow(MyAppapp)

:base(app)...{

ColorinstructionTextColor=ColorUtility.ColorFromRGB(192,192,192);
ColorbackgroundColor=ColorUtility.ColorFromRGB(26,118,183);
ColorunselectedItemColor=ColorUtility.ColorFromRGB(192,192,255);//Unselectedlistboxitemcolor
ColorselectedItemColor=Colors.White;//Selectedlistboxitemcolor

//TheMainwindowcontainsaveritcalStackPanel
StackPanelpanel=newStackPanel(Orientation.Vertical);
this.Child=panel;

//Thetopchildcontainstextwithinstructions
TextFlowtextflow=newTextFlow();
textflow.TextAlignment=TextAlignment.Center;
textflow.Visibility=Visibility.Visible;
textflow.TextRuns.Add(
newTextRun(Resources.GetString(Resources.StringResources.SelectAnItemFromBelow),
app.NinaBFont,instructionTextColor));
panel.Children.Add(textflow);

//Addablanklinetothestack
panel.Children.Add(textflow=newTextFlow());
textflow.TextRuns.Add("",app.NinaBFont,instructionTextColor);
textflow.Visibility=Visibility.Visible;

//Thenextchildcontainsalistboxwithoptions
m_listbox=newListBox();

//Preparethelistbox
Buttons.Focus(m_listbox);
panel.Children.Add(m_listbox);
this.Background=m_listbox.Background=newSolidColorBrush(backgroundColor);


m_listbox.SelectionChanged+=delegate(Objectsender,SelectionChangedEventArgse)...{
Int32previousSelectedIndex=e.PreviousSelectedIndex;

if(previousSelectedIndex!=-1)...{//Iftherewasapreviousindex
//Changepreviously-selectedlistboxitemcolortounselectedcolor
((Text)m_listbox.Items[previousSelectedIndex].Child).ForeColor=unselectedItemColor;
}

//Changenewly-selectedlistboxitemcolortoselectedcolor
((Text)m_listbox.Items[e.SelectedIndex].Child).ForeColor=selectedItemColor;
};

//Addtheitemstothelistbox

foreach(StringsinnewString[]...{"VerticalStack","HorizontalStack","Canvas","Diagonal"})...{
Texttext=newText(m_app.NinaBFont,s+"PanelDemo");
text.ForeColor=unselectedItemColor;
text.TextAlignment=TextAlignment.Center;
text.Width=this.Width;
ListBoxItemlbi=newListBoxItem();
lbi.Background=m_listbox.Background;
lbi.Child=text;
m_listbox.Items.Add(lbi);
}
m_listbox.SelectedIndex=0;

//Addablanklineinthestack
panel.Children.Add(textflow=newTextFlow());
textflow.TextRuns.Add("",app.NinaBFont,instructionTextColor);
textflow.Visibility=Visibility.Visible;

//Thebottomchildcontainstextwithreturninstructions
textflow=newTextFlow();
textflow.TextAlignment=TextAlignment.Center;
textflow.Visibility=Visibility.Visible;
textflow.TextRuns.Add(
newTextRun("(AfterviewingaPanelDemo,hitEntertoreturntothisscreen)",
app.NinaBFont,instructionTextColor));
panel.Children.Add(textflow);
}


protectedoverridevoidOnButtonDown(ButtonEventArgse)...{
//If<Enter>buttonispressed,gointotheselecteddemo

if(e.Button==Button.Select)...{

switch(MainListBox.SelectedIndex)...{
case0://VerticalStackPanelDemo
newStackPanelDemo(m_app,Orientation.Vertical);
break;
case1://HorizontalStackPanelDemo
newStackPanelDemo(m_app,Orientation.Horizontal);
break;
case2://CanvasPanelDemo
newCanvasPanelDemo(m_app);
break;
case3://DiagonalPanelDemo
newDiagonalPanelDemo(m_app);
break;
}
}

//Don'tcallbaseimplementation(base.OnButtonDown)orwe'llgobackHome
}


protectedoverridevoidOnGotFocus(FocusChangedEventArgse)...{
//Wheneverthiswindowgetsfocus,itgivesittoitslistbox
Buttons.Focus(m_listbox);
base.OnGotFocus(e);
}
}



/**///////////////////////////////////////////////////////////////////////////////


internalsealedclassStackPanelDemo:PresentationWindow...{
//ThisclassshowshowtobuildyourownshapedrawinginaDrawingContext

privatesealedclassCross:Shape...{

publicCross()...{}


publicoverridevoidOnRender(DrawingContextdc)...{
//Drawalinefromtop,lefttobottom,right
dc.DrawLine(base.Stroke,0,0,Width,Height);

//Drawalinefromtop,righttobottom,left
dc.DrawLine(base.Stroke,Width,0,0,Height);
}
}

publicStackPanelDemo(MyAppapp,Orientationorientation)

:base(app)...{
StackPanelpanel=newStackPanel(orientation);
this.Child=panel;
panel.Visibility=Visibility.Visible;


Shape[]shapes=newShape[]...{
newEllipse(),
newLine(),

newPolygon(newInt32[]...{0,0,50,0,50,50,0,50}),//ASquare
newRectangle(),
newCross()//Ourowncustomshape
};


for(Int32x=0;x<shapes.Length;x++)...{
Shapes=shapes[x];
s.Fill=newSolidColorBrush(ColorUtility.ColorFromRGB(0,255,0));
s.Stroke=newPen(Color.Black,2);
s.Visibility=Visibility.Visible;
s.HorizontalAlignment=HorizontalAlignment.Center;
s.VerticalAlignment=VerticalAlignment.Center;
s.Height=Height-1;
s.Width=Width-1;

if(panel.Orientation==Orientation.Horizontal)
s.Width/=shapes.Length;
else
s.Height/=shapes.Length;

panel.Children.Add(s);
}
}
}



/**///////////////////////////////////////////////////////////////////////////////


internalsealedclassCanvasPanelDemo:PresentationWindow...{
publicCanvasPanelDemo(MyAppapp)

:base(app)...{
Canvascanvas=newCanvas();
this.Child=canvas;
this.Background=newSolidColorBrush(ColorUtility.ColorFromRGB(0,255,255));


for(Int32x=0;x<Width;x+=Width/4)...{

for(Int32y=0;y<Height;y+=Height/4)...{
Texttext=newText(m_app.SmallFont,"("+x+","+y+")");
Canvas.SetLeft(text,x);
Canvas.SetTop(text,y);
canvas.Children.Add(text);
}
}
}
}



/**///////////////////////////////////////////////////////////////////////////////


internalsealedclassDiagonalPanelDemo:PresentationWindow...{
publicDiagonalPanelDemo(MyAppapp)

:base(app)...{
DiagonalPanelpanel=newDiagonalPanel();
this.Child=panel;
this.Background=newLinearGradientBrush(
ColorUtility.ColorFromRGB(192,0,0),ColorUtility.ColorFromRGB(32,0,0),0,0,Width,Height);


for(Int32x=0;x<4;x++)...{
Bitmapb=newBitmap(Width/4,Height/4);
b.StretchImage(0,0,app.Snowflake,b.Width,b.Height,(UInt16)((x+1)*50));
Imageimage=newImage(b);
panel.Children.Add(image);
}
}

//ThisclassshowshowtobuildyourownPanel

privatesealedclassDiagonalPanel:Panel...{

publicDiagonalPanel()...{
}


protectedoverridevoidMeasureOverride(intavailableWidth,intavailableHeight,outintdesiredWidth,outintdesiredHeight)...{
//Calledtocalculatethewidth/heightdesired
desiredWidth=0;
desiredHeight=0;

foreach(UIElementchildinChildren)...{

if(child.Visibility!=Visibility.Collapsed)...{
child.Measure(Int32.MaxValue,Int32.MaxValue);
Int32childWidth,childHeight;
child.GetDesiredSize(outchildWidth,outchildHeight);
desiredWidth+=childWidth;
desiredHeight+=childHeight;
}
}
}


protectedoverridevoidArrangeOverride(intarrangeWidth,intarrangeHeight)...{
Int32x=0,y=0;

foreach(UIElementchildinChildren)...{

if(child.Visibility!=Visibility.Collapsed)...{
Int32childWidth,childHeight;
child.GetDesiredSize(outchildWidth,outchildHeight);
child.Arrange(x,y,childWidth,childHeight);
x+=childWidth;
y+=childHeight;
}
}
}
}
}



/**///////////////////////////////////////////////////////////////////////////////
后记:此外在会上还遇到了我的偶像马宁、马琪、张欣(还是张欣强,通过回答问题获得一个MF开放套件),如果他们不介意附上照片作个留念:-)

分享到:
相关推荐
"Micro-framework:我的mirco框架"是一个基于Java语言开发的微型框架项目,旨在提供轻量级、高效且易于上手的开发环境。在微型框架中,开发者通常关注于核心功能,如路由处理、依赖注入、模板引擎等,以实现快速构建...
但网上它的价格太高,不利于学生、工程师们的学习、使用,而且MicroPython完全开源,遵循MIT协议,可以被用来商业化,故此希望可以帮助到大家对micro python的学习、利用,将mirco python这一物联网、嵌入式学习利器...
GD包装机MIRCO2程序是针对特定型号的GD包装机使用的微型程序,用于监测和维护机器的关键性能...需要注意的是,由于文档是通过OCR技术扫描得到的,可能存在文字识别错误或遗漏,需要结合实际情况对内容进行理解和校正。
《Mirco2440裸机篇之按键中断测试程序详解》 在嵌入式系统开发领域,Micro2440是一款广泛使用的S3C2440微处理器开发板,它提供了丰富的外设接口,使得开发者能够在硬件层面上进行深入的学习与实践。本文将深入探讨...
博客附件。stm32虚拟串口(VPC)工程,基于stm32F103C8,HAL库 博客地址:https://blog.csdn.net/mirco_mcu/article/details/106081950
本文将深入探讨在Micro2440上进行触摸屏测试的技术细节,包括单击、双击和移动等基本操作的实现。 首先,我们需要了解S3C2440处理器与触摸屏之间的交互机制。S3C2440内含中断控制器,能够处理来自外部设备的中断...
创建第一个Windows Presentation Foundation应用程序构建用户界面(UI),验证数据输入管理错误和处理异常使用垃圾回收来管理内存资源使用泛型,构建新的类型,创建可重用的组件使用LINQ和ADO.NET来查询和操作数据...
在micro USB图档的背景下,该公司可能扮演了制造micro USB连接器的角色,或是提供与之相关的技术支持和服务。通过图档,客户和合作伙伴可以了解公司产品的具体规格和性能,便于在设计阶段做出合适的选择。 ### 结论...
安装 $ npm install mirco用法查看测试以获取有关使用 mirco 可以做什么的更多信息。服务器 'use strict' ;let service = require ( 'mirco' ) ;let server = service ( { hello : function ( payload ) { return '...
根据提供的文件信息,本文将详细解释u-boot-2009.11在Mirco2440, Mini2440, TQ2440等开发板上的移植过程及涉及的关键知识点。 ### 一、u-boot简介 u-boot(Universal Boot Loader)是一个开源的嵌入式系统引导加载...
Micro-USB的优点在于其小巧的尺寸和良好的耐用性,但随着技术的发展,它的速度和功能已经无法满足新设备的需求。 Type-C是USB 3.1标准的一部分,设计更为先进,支持更高的数据传输速率和更大的功率传输。Type-C接口...
Micro USB是一种广泛应用于移动设备和小型电子产品的接口标准,它以其小巧的尺寸和较高的数据传输速度而备受青睐。本资源包含AD(Allegro Design)软件的Micro USB封装库,适用于电路设计者在进行硬件设计时参考和...
软件开发设计:应用软件开发、系统软件开发、移动应用开发、网站开发C++、Java、python、web、C#等语言的项目开发与学习资料 硬件与设备:单片机、EDA、proteus、RTOS、包括计算机硬件、服务器、网络设备、存储设备...
Micro USB是USB 2.0标准的一个便携版本,比部分手机使用的Mini USB接口更小,Micro-USB是Mini-USB的下一代规格,由USB标准化组织美国USB Implementers Forum(USB-IF)于2007年1月4日制定完成。Micro-USB 支持OTG,...
这个网站的源代码可能需要更新和重构,这通常意味着网站的维护者或开发者认为当前的代码结构可能存在效率低下、过时或者不安全的问题,需要通过更新来提升性能,增强可维护性,或者适应新的技术标准。 描述中提到的...
西门子PLC编辑汉化软件STEP 7 MicroWIN 32汉化软件 西门子PLC编辑汉化软件STEP 7 MicroWIN 32汉化软件 西门子PLC编辑汉化软件STEP 7 MicroWIN 32汉化软件 西门子PLC编辑汉化软件STEP 7 MicroWIN 32汉化软件 ...
micro2440用户手册 -2010-6-9 友善之臂,分卷文件1
总的来说,这个项目涉及到嵌入式系统、微控制器编程、模拟电子技术以及USB通信等多个IT领域的知识点。通过这个项目,学习者不仅可以掌握Pro Micro的使用,还能了解到如何将物理输入(电位器)转化为数字信号,并通过...
用户在使用过程中遇到任何问题或疑问,可以通过手册提供的技术支持信息与西门子的技术支持部门联系,获取更专业的帮助和服务。西门子的技术支持包括电话、传真、电子邮件等多种方式,并在工作时间内提供服务。 最后...
MicroPower Direct公司的双输出G100E系列微型DC/DC转换器输出功率1W,适用于程度空间有限的应用。作为该公司的“省钱”系列产品,该系列转换器是为处理/机器控制系统、板级数据获取系统、便携式/电池供电设备、...