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) Microsoft Corporation.  All rights reserved.using System;using System.Collections;using System.Threading;using Microsoft.SPOT;using Microsoft.SPOT.Input;using Microsoft.SPOT.Hardware;using Microsoft.SPOT.Presentation;using Microsoft.SPOT.Presentation.Media;using Microsoft.SPOT.Presentation.Controls;using Microsoft.SPOT.Presentation.Shapes;using PresentationDemo;//public sealed class MyApp : Application {// This static field prevents the object from being GC'dprivate static GpioButtonInputProvider s_gpioInputProvider;public Font NinaBFont;public Font SmallFont;public Bitmap Snowflake;private MyApp() {// Initialize the Buttons/Pins dispatchers_gpioInputProvider = new GpioButtonInputProvider(this.Dispatcher, null);// Load some resourcesNinaBFont = Resources.GetFont(Resources.FontResources.NinaBFont);SmallFont = Resources.GetFont(Resources.FontResources.SmallFont);Snowflake = Resources.GetBitmap(Resources.BitmapResources.Snowflake);}protected override void OnStartup(EventArgs e) {// Create and set the application's main windowthis.MainWindow = new MainMenuWindow(this);base.OnStartup(e);}public void GoHome() {Buttons.Focus(this.MainWindow); // Set focus back to the main window}public static void Main() {new MyApp().Run();   // Start the app's main window}}//// This is the base class of all our windows; it makes every window visible,// sets the window's size to the full size of the LCD, and give the window focusinternal class PresentationWindow : Window {protected MyApp m_app;protected PresentationWindow(MyApp app) {m_app = app;// Make the window visible and the size of the LCDthis.Visibility = Visibility.Visible;this.Width = SystemMetrics.ScreenWidth;this.Height = SystemMetrics.ScreenHeight;Buttons.Focus(this); // Set focus to this window}protected override void OnButtonDown(ButtonEventArgs e) {// Remove this window form the Window Managerthis.Close();// When any button is pressed, go back to the Home pagem_app.GoHome();}}//internal sealed class MainMenuWindow : PresentationWindow {private ListBox m_listbox;public ListBox MainListBox { get { return m_listbox; } }public MainMenuWindow(MyApp app): base(app) {Color instructionTextColor = ColorUtility.ColorFromRGB(192, 192, 192);Color backgroundColor = ColorUtility.ColorFromRGB(26, 118, 183); Color unselectedItemColor = ColorUtility.ColorFromRGB(192, 192, 255);   // Unselected listbox item colorColor selectedItemColor = Colors.White;                                 // Selected listbox item color// The Main window contains a veritcal StackPanelStackPanel panel = new StackPanel(Orientation.Vertical);this.Child = panel;// The top child contains text with instructionsTextFlow textflow = new TextFlow();textflow.TextAlignment = TextAlignment.Center;textflow.Visibility = Visibility.Visible;textflow.TextRuns.Add(new TextRun(Resources.GetString(Resources.StringResources.SelectAnItemFromBelow),app.NinaBFont, instructionTextColor));panel.Children.Add(textflow);// Add a blank line to the stackpanel.Children.Add(textflow = new TextFlow());textflow.TextRuns.Add(" ", app.NinaBFont, instructionTextColor);textflow.Visibility = Visibility.Visible;// The next child contains a listbox with optionsm_listbox = new ListBox();// Prepare the listboxButtons.Focus(m_listbox);panel.Children.Add(m_listbox);this.Background = m_listbox.Background = new SolidColorBrush(backgroundColor);m_listbox.SelectionChanged += delegate(Object sender, SelectionChangedEventArgs e) {Int32 previousSelectedIndex = e.PreviousSelectedIndex;if (previousSelectedIndex != -1) {  // If there was a previous index// Change previously-selected listbox item color to unselected color((Text)m_listbox.Items[previousSelectedIndex].Child).ForeColor = unselectedItemColor;}// Change newly-selected listbox item color to selected color((Text)m_listbox.Items[e.SelectedIndex].Child).ForeColor = selectedItemColor;};// Add the items to the listboxforeach (String s in new String[] { "Vertical Stack", "Horizontal Stack", "Canvas", "Diagonal" }) {Text text = new Text(m_app.NinaBFont, s + " Panel Demo");text.ForeColor = unselectedItemColor;text.TextAlignment = TextAlignment.Center;text.Width = this.Width;ListBoxItem lbi = new ListBoxItem();lbi.Background = m_listbox.Background;lbi.Child = text;m_listbox.Items.Add(lbi);}m_listbox.SelectedIndex = 0;// Add a blank line in the stackpanel.Children.Add(textflow = new TextFlow());textflow.TextRuns.Add(" ", app.NinaBFont, instructionTextColor);textflow.Visibility = Visibility.Visible;// The bottom child contains text with return instructionstextflow = new TextFlow();textflow.TextAlignment = TextAlignment.Center;textflow.Visibility = Visibility.Visible;textflow.TextRuns.Add(new TextRun("(After viewing a Panel Demo, hit Enter to return to this screen)",app.NinaBFont, instructionTextColor));panel.Children.Add(textflow);}protected override void OnButtonDown(ButtonEventArgs e) {// If <Enter> button is pressed, go into the selected demoif (e.Button == Button.Select) {switch (MainListBox.SelectedIndex) {case 0:  // Vertical Stack Panel Demonew StackPanelDemo(m_app, Orientation.Vertical);break;case 1:  // Horizontal Stack Panel Demonew StackPanelDemo(m_app, Orientation.Horizontal);break;case 2:  // Canvas Panel Demonew CanvasPanelDemo(m_app);break;case 3:  // Diagonal Panel Demonew DiagonalPanelDemo(m_app);break;}}// Don't call base implementation (base.OnButtonDown) or we'll go back Home}protected override void OnGotFocus(FocusChangedEventArgs e) {// Whenever this window gets focus, it gives it to its listboxButtons.Focus(m_listbox);base.OnGotFocus(e);}}//internal sealed class StackPanelDemo : PresentationWindow {// This class shows how to build your own shape drawing in a DrawingContextprivate sealed class Cross : Shape {public Cross() { }public override void OnRender(DrawingContext dc) {// Draw a line from top, left to bottom, rightdc.DrawLine(base.Stroke, 0, 0, Width, Height);// Draw a line from top, right to bottom, leftdc.DrawLine(base.Stroke, Width, 0, 0, Height);}}public StackPanelDemo(MyApp app, Orientation orientation): base(app) {StackPanel panel = new StackPanel(orientation);this.Child = panel;panel.Visibility = Visibility.Visible;Shape[] shapes = new Shape[] {new Ellipse(),new Line(),new Polygon(new Int32[] { 0, 0,    50, 0,    50, 50,    0, 50 }), // A Squarenew Rectangle(),new Cross() // Our own custom shape};for (Int32 x = 0; x < shapes.Length; x++) {Shape s = shapes[x];s.Fill = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 255, 0));s.Stroke = new Pen(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;elses.Height /= shapes.Length;panel.Children.Add(s);}}}//internal sealed class CanvasPanelDemo : PresentationWindow {public CanvasPanelDemo(MyApp app): base(app) {Canvas canvas = new Canvas();this.Child = canvas;this.Background = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 255, 255));for (Int32 x = 0; x < Width; x += Width / 4) {for (Int32 y = 0; y < Height; y += Height / 4) {Text text = new Text(m_app.SmallFont, " (" + x + "," + y + ")");Canvas.SetLeft(text, x);Canvas.SetTop(text, y);canvas.Children.Add(text);}}}}//internal sealed class DiagonalPanelDemo : PresentationWindow {public DiagonalPanelDemo(MyApp app): base(app) {DiagonalPanel panel = new DiagonalPanel();this.Child = panel;this.Background = new LinearGradientBrush(ColorUtility.ColorFromRGB(192, 0, 0), ColorUtility.ColorFromRGB(32, 0, 0), 0, 0, Width, Height);for (Int32 x = 0; x < 4; x++) {Bitmap b = new Bitmap(Width / 4, Height / 4);b.StretchImage(0, 0, app.Snowflake, b.Width, b.Height, (UInt16)((x + 1) * 50));Image image = new Image(b);panel.Children.Add(image);}}// This class shows how to build your own Panelprivate sealed class DiagonalPanel : Panel {public DiagonalPanel() {}protected override void MeasureOverride(int availableWidth, int availableHeight, out int desiredWidth, out int desiredHeight) {// Called to calculate the width/height desireddesiredWidth = 0;desiredHeight = 0;foreach (UIElement child in Children) {if (child.Visibility != Visibility.Collapsed) {child.Measure(Int32.MaxValue, Int32.MaxValue);Int32 childWidth, childHeight;child.GetDesiredSize(out childWidth, out childHeight);desiredWidth += childWidth;desiredHeight += childHeight;}}}protected override void ArrangeOverride(int arrangeWidth, int arrangeHeight) {Int32 x = 0, y = 0;foreach (UIElement child in Children) {if (child.Visibility != Visibility.Collapsed) {Int32 childWidth, childHeight;child.GetDesiredSize(out childWidth, out childHeight);child.Arrange(x, y, childWidth, childHeight);x += childWidth;y += childHeight;}}}}}

稿件来源:阿里云开发者社区

.Net Mirco Framework 2007技术大会相关推荐

  1. Tech·ED2007微软技术大会鲍尔默演讲实录

    11月7日早间,微软2007技术大会在北京正式开幕,抵达北京的微软全球CEO鲍尔默也在这次大会上做出其主题发言.这次他演讲的主题是"软件+服务(S+S)".以下为其演讲实录: 高玉 ...

  2. 【原】2009.NET年技术大会总结,有图片,说说我理解的技术大会 【下】

    在阅读本篇之前,请先看上篇,上篇地址是: http://www.cnblogs.com/OceanChen/archive/2009/02/27/1399192.html 首先来回答上篇遗留的问题, ...

  3. 海洋工作室——网站建设专家:【原】2009.NET年技术大会总结,有图片,说说我理解的技术大会【上】...

    阅读建议:一定要好好看完,然后做出你的评价,同时建议您留意高亮部分. 本来打算好好总结一下2009.NET年技术大会的.刚刚看到同事[LanceZhang]的博客,总结的挺快,挺酷的!而且总结的全面的 ...

  4. 2022 SDCon 全球软件研发技术大会,19大技术主题破企业之寒

    随着信息革命的飞速发展,软件已深入人类生活的方方面面,深刻而彻底地改造了人类世界.Boolan秉承"全球专家.卓越智慧"的宗旨,我们特邀近40位全球软件领域的技术领袖以及一线实战专 ...

  5. 2014 Container技术大会:未来Linux Container会是PaaS平台的核心

    不应错过2014 Container技术大会的九大理由. 一.Docker官方人员再次来到北京,首次向中国布道Docker技术.2013年Docker高级软件工程师Jerome Petazzoni,曾 ...

  6. Tech.Ed 2011微软技术大会(二)之专题讲座

    Thmoas said:"New Technology ,New Times" 托马斯说过:"新技术,新时代"     衍生下:"新技术,云时代&qu ...

  7. Tech.Ed 2011微软技术大会(三)之课程回顾

    "All good things must come to an end, There's no feast which could go on and on" -----天下无不 ...

  8. 提升技术认知,参加2021上海QCon技术大会

    文章首发于公众号[看点代码再上班],欢迎围观,获取更多好文. 原文地址:提升技术认知,参加2021上海QCon技术大会! 全文共计6499字,预计阅读时间15分钟 目录 开篇 第一天-上午 签到&am ...

  9. 前端业界各类技术大会或论坛

    随时更新中- 稀土开发者大会2021 GMTC GMTC 全球大前端技术大会是由极客邦科技旗下 InfoQ 中国主办的技术盛会,关注前端.移动.AI 应用等多个技术领域,促进全球技术交流,推动国内技术 ...

最新文章

  1. DL之决策树(Decision tree)
  2. 【Excel】VBA批量修改文件名
  3. Mybatis-自定义类型处理器
  4. UICollectionView的sectionHeader悬浮效果
  5. jquery实现多级下拉菜单
  6. php 判断两个数组差集,php array_udiff_assoc 计算两个数组的差集实例
  7. python给定一个整数n、判断n是否为素数_输入一个大于3的整数n,判断它是否为素数...
  8. 云存储精华问答 | 云存储是如何工作的?
  9. Custom.pll : ZOOM小测试
  10. 培养女人味的12条妙方
  11. 2017.9.28 CF #R2 B 思考记录
  12. 在unity用shaderGraph做出类似动物之森的柱面场景,甚至球面场景。
  13. 【转载】固态硬盘的S.M.A.R.T详解
  14. apache cxf之 一个简单的JAX-WS服务程序
  15. 公式编辑器如何打出空格
  16. pandas学习之电影评分(利用python进行统计分析)的学习笔记
  17. 不仅仅是Google,您必须知道的全球十大地图API
  18. 权威发布:《麻省理工科技评论》2020年“全球十大突破性技术”
  19. 数字图像处理中的Region与XLD
  20. JavaScript中split()方法详解

热门文章

  1. MySQL获取当前年份月份日期
  2. openresty+lua在反向代理服务中的玩法 | WooYun知识库
  3. Linux使用常见问题汇总
  4. 博苑股份冲刺创业板上市:上半年净利润约1亿元,李成林为董事长
  5. Hyperledger Fabric和FISCO BCOS技术对比
  6. cmake实现Blib引用Alib, C.exe引用Blib
  7. 小学生上计算机课心得,开展小学生机器人校本课程心得体会.docx
  8. android通用ui库设计,Android(常用)主流UI开源库整理
  9. GLM联合go-cqhttp实现qq群GLM机器人服务器的本地化部署笔记
  10. 凯撒加密caesar