M3系統更新到STM32F207後,主頻提升為120M,運作WPF和System.Windows.Froms庫基本上問題不大了,是以對原先的System.Windows.Froms庫又進行了更新改進。
以前的System.Windows.Froms庫主要模仿WINCE界面開發的,需要用觸摸筆才能操作,目前這種操作方式早就淘汰了,是以為了支援手指直接操作,主要從以下幾個方面入手進行了改造。
(1)、重新編寫了軟鍵盤,支援手指單擊輸入;
(2)、預設字型由原來的12變為16,為了便于操控,控件也進行了擴大處理;
(3)、去掉了工作列;
(4)、去掉任務菜單;
(5)、窗體界面大小覆寫全屏;
System.Windows.Form目前包括Button、TextBox、ListBox、ComboBox、CheckBox、GroupBox、RadioButton、PictureBox、ProgressBar、VScrollBar、HScrollBar等11種常用控件,此外還提供了MessageBox方法,使用方法和Windows平台的winform保持一緻。
包含兩類窗體、普通窗體及模式窗體,含義和windows平台相同。
軟鍵盤一共四個不同界面,通過上面的功能鍵進行切換。
目前還不支援中文輸入。
Graphics類的聲明如下:
public sealed class Graphics : Microsoft.SPOT.DispatcherObject, IDisposable
{
public bool EmptyClipRect;
publicGraphics(Bitmap bmp);
publicGraphics(int width, intheight);
public Bitmap Bitmap { get;}
public Rectangle Clip { get;set; }
public int Height { get; }
public int Width { get; }
public void BlendImage(Bitmapsource, int destinationX, int destinationY, intsourceX, int sourceY, intsourceWidth, int sourceHeight, ushort opacity);
public void Clear(Colorcolor);
public static SizeComputeTextExtent(string text, Font font);
public static SizeComputeTextExtent(string text, Font font, intavailableWidth);
public void Dispose();
public void DrawEllipse(Penpen, Rectangle rect);
public void DrawEllipse(Penpen, int x, inty, int width, intheight);
public void DrawImage(Bitmapimage, int x, inty);
public void DrawImage(Bitmapimage, int destinationX, int destinationY, intsourceX, int sourceY, intsourceWidth, int sourceHeight);
public void DrawLine(Penpen, int x0, inty0, ushort Data);
public void DrawLine(Penpen, int x0, inty0, int x1, inty1);
public void DrawPolygon(Penpen, Point[] points);
public void DrawPolygon(Penpen, Point[] points, bool Sealed);
public void DrawRectangle(Penpen, Rectangle rect);
public void DrawRectangle(Penpen, int x, inty, int width, intheight);
public void DrawRoundRect(Penpen, Rectangle rect, int rx, int ry);
public void DrawRoundRect(Penpen, int x, inty, int width, intheight, int rx, intry);
public void DrawString(strings, Font font, Brushbrush, Rectangle rect);
public void DrawString(strings, Font font, Brushbrush, int x, inty);
public void DrawString(strings, Font font, Brushbrush, Rectangle rect, StringFormat format);
public void FillEllipse(Brushbrush, Rectangle rect);
public void FillEllipse(Brushbrush, int x, inty, int width, intheight);
public void FillPolygon(Brushbrush, Point[] points);
public void FillRectangle(Brushbrush, Rectangle rect);
public void FillRectangle(Brushbrush, int x, inty, int width, intheight);
public void GetTranslation(outint x, out int y);
public void ResetClip();
public void RotateImage(intangle, int destinationX, int destinationY, Bitmapbitmap, int sourceX, intsourceY, int sourceWidth, int sourceHeight, ushortopacity);
public void Scale9Image(intxDst, int yDst, intwidthDst, int heightDst, Bitmap bitmap, intleftBorder, int topBorder, int rightBorder, intbottomBorder, ushort opacity);
public void SetPixel(Colorcolor, int x, inty);
public void StretchImage(intxDst, int yDst, intwidthDst, int heightDst, Bitmap bitmap, intxSrc, int ySrc, intwidthSrc, int heightSrc, ushort opacity);
public void TileImage(intxDst, int yDst, Bitmapbitmap, int width, intheight, ushort opacity);
public void Translate(intdx, int dy);
}
由于.Net Micro Framework的IDE開發環境并不支援所見即所得的窗體設計功能,是以我們可以用.Net Framework和.Net Compact Framework開發環境設計窗體,然後把相關窗體檔案(如Form1.cs和Form1.designer.cs檔案)直接導入到.Net Micro Framework工程中,稍加删減即可為.Net Micro Framework所用。
(window 控件的字型可以設定為:字型"Arial" 大小11.25F,這種字型和底層裝置的字型大小比較接近 )
由于字型檔案相對較大,是以YFSoft.Font庫檔案是全開源的,使用者可以根據需要自行定義字型,設定好進行編譯,替換系統所提供的YFSoft.Font.*檔案即可。
public Font(string name, float emSize, FontStylestyle)
{
switch(this._name)
{
default:
case"Arial":
switch(style)
{
//case FontStyle.Bold:
//_value = YFResource.GetFont(YFResource.FontResources.YFArial16B);
//break;
default:
case FontStyle.Regular:
_value = YFResource.GetFont(YFResource.FontResources.YFArial16);
break;
}
break;
}
this._size = emSize;
this._style= style;
}
根據需要上述代碼進行必要的調整,理論上可以支援任意字型了。
(1)、采用組态軟體進行界面設計,并自動生成界面相關的代碼。
(2)、再擴充幾個工業用控件,比如動态曲線,表格,儀表盤顯示等等。
從示範效果上看,添加比較多的控件,性能還不盡人意。不過這是基于STM32F207(主頻120M)測試的,後續采用STM32F407(主頻168M)的晶片,性能會有比較大的改善(當然本架構從軟體角度還會繼續進行性能優化),想以前在STM32F103(主頻72M)晶片上,這個架構根本跑步起來。期待ST推出性能更強大的Cortex-M3或Cortex-M4晶片。
<a href="http://weibo.com/1804832611?s=6uyXnP"></a>