自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

.Net Micro Framework中的Shapes命名空間

開發(fā) 后端
Net Micro Framework中的Shapes命名空間下,包含幾個形狀對象,主要有Ellipse、Line、Polygon、Rectangle。

在Microsoft.SPOT.Presentation.Shapes命名空間下,包含幾個形狀對象,主要有Ellipse、Line、Polygon、Rectangle,同樣也只有Rectangle實現(xiàn)的***,其他形狀都不支持填充色,雖然每個對象都有Fill屬性。

讓人奇怪的是,每個形狀對象都不能設(shè)置left和top坐標(biāo),僅能設(shè)置寬度和高度,用起來很不習(xí)慣。

StackPanel類是Panel的派生類,從字面意思上看,就是可以堆疊的面板。意如其名,它可以包含多個子對象,不過每一對象都不能重疊,以特有的方式堆疊在一起。

有如下幾個屬性方法控制堆疊方式:

1、Orientation屬性,有兩種方式:Orientation.Horizontal,Orientation.Vertical。設(shè)置該屬性后,StackPanel的子對象的坐標(biāo)系就會發(fā)生變化(很可惜字體的方向并沒有從根本上改變)。

2、HorizontalAlignment、VerticalAlignment屬性,設(shè)置子對象的堆疊方式。枚舉定義如下。

  1. public enum HorizontalAlignment  
  2.  
  3.     {  
  4.  
  5.         Left = 0,  
  6.  
  7.         Center = 1,  
  8.  
  9.         Right = 2,  
  10.  
  11.         Stretch = 3,  
  12.  
  13. }  
  14.  
  15.     public enum VerticalAlignment  
  16.  
  17.     {  
  18.  
  19.         Top = 0,  
  20.  
  21.         Center = 1,  
  22.  
  23.         Bottom = 2,  
  24.  
  25.         Stretch = 3,  
  26.  
  27.  } 

3、SetMargin方法,設(shè)置邊界空白大小。

完整的代碼如下,

  1. using System;  
  2.  
  3. using Microsoft.SPOT;  
  4.  
  5. using Microsoft.SPOT.Input;  
  6.  
  7. using Microsoft.SPOT.Presentation;  
  8.  
  9. using Microsoft.SPOT.Presentation.Controls;  
  10.  
  11. using Microsoft.SPOT.Presentation.Media;  
  12.  
  13. using Microsoft.SPOT.Presentation.Shapes;  
  14.  
  15.    
  16.  
  17. namespace MFWindow  
  18.  
  19. {  
  20.  
  21.     public class Program : Microsoft.SPOT.Application  
  22.  
  23.     {  
  24.  
  25.         public static void Main()  
  26.  
  27.         {     
  28.  
  29.             //創(chuàng)建窗體  
  30.  
  31.             WindowsDrawing win = new WindowsDrawing();            
  32.  
  33.             //程序運(yùn)行  
  34.  
  35.             new Program().Run(win);  
  36.  
  37.         }  
  38.  
  39.           
  40.  
  41.         internal sealed class WindowsDrawing : Window  
  42.  
  43.         {  
  44.  
  45.             public  WindowsDrawing()  
  46.  
  47.             {  
  48.  
  49.                 this.Width = SystemMetrics.ScreenWidth;  
  50.  
  51.                 this.Height = SystemMetrics.ScreenHeight;  
  52.  
  53.    
  54.  
  55.                 //可設(shè)置顯示方向(水平,垂直)  
  56.  
  57.                 //StackPanel panel = new StackPanel(Orientation.Vertical);  
  58.  
  59.                 StackPanel panel = new StackPanel(Orientation.Horizontal);  
  60.  
  61.                   
  62.  
  63.                 //設(shè)置邊界空白  
  64.  
  65.                 panel.SetMargin(10);  
  66.  
  67.     
  68.  
  69.                 //設(shè)置對象堆疊的方式  
  70.  
  71.                 panel.HorizontalAlignment = HorizontalAlignment.Center;  
  72.  
  73.                 panel.VerticalAlignment = VerticalAlignment.Center;  
  74.  
  75.                                 
  76.  
  77.                 this.Child = panel;  
  78.  
  79.    
  80.  
  81.                 //添加文本  
  82.  
  83.                 Text txt = new Text(Resources.GetFont(Resources.FontResources.small), "yefan");  
  84.  
  85.    
  86.  
  87.                 //不能設(shè)置left,top坐標(biāo)  
  88.  
  89.                 txt.Width = 100;  
  90.  
  91.                 txt.Height = 30;  
  92.  
  93.                 panel.Children.Add(txt);  
  94.  
  95.                   
  96.  
  97.                 //添加不同的形狀對象  
  98.  
  99.                 Shape[] shapes = new Shape[]   
  100.  
  101.                                 {  
  102.  
  103.                                      new Ellipse(),  
  104.  
  105.                                      new Line(),  
  106.  
  107.                                      new Polygon(new Int32[] { 0, 0,    10, 0,    10, 10,    0, 10 }),   
  108.  
  109.                                      new Rectangle()  
  110.  
  111.                                 };  
  112.  
  113.    
  114.  
  115.                 //設(shè)置形狀對象必要的參數(shù)(各對象不能重疊,只能堆疊在一起)  
  116.  
  117.                 foreach (Shape s in shapes)  
  118.  
  119.                 {  
  120.  
  121.                     s.Fill = new SolidColorBrush(ColorUtility.ColorFromRGB(0, 255, 0));  
  122.  
  123.                     s.Stroke = new Pen(Color.Black, 2);  
  124.  
  125.    
  126.  
  127.                     //不能設(shè)置left,top坐標(biāo)  
  128.  
  129.                     s.Height = 40;  
  130.  
  131.                     s.Width = 40;  
  132.  
  133.    
  134.  
  135.                     panel.Children.Add(s);  
  136.  
  137.                 }                
  138.  
  139.             }  
  140.  
  141.         }  
  142.  
  143.     }  
  144.  

僅修改這句代碼 StackPanel panel = new StackPanel(Orientation.Horizontal);中的參數(shù)就可以實現(xiàn)兩種不同的效果,如下面兩圖所示:

總的來說,我覺得MF提供的圖像對象還很不完善,不僅一些基本功能沒有完成(如填充、線寬),并且無法設(shè)置形狀對象的絕對坐標(biāo)(left,top),同時總類也特別少,希望以后的版本中能有很大的提升。

【編輯推薦】

  1. Micro Framework 3.0模擬器改造
  2. 詳解.Net Micro Framework窗體控件
  3. 在.Net Micro Framework中訪問硬件
  4. 在.Net Micro Framework中支持鼠標(biāo)操作
  5. 詳解.Net Micro Framework中的TCP/IP通信
責(zé)任編輯:佚名 來源: 葉帆工作室
相關(guān)推薦

2009-07-17 13:56:44

.Net Micro

2009-07-17 13:46:52

.Net Micro

2009-07-09 09:28:19

.Net Micro

2009-06-29 10:19:42

.NET Micro性能優(yōu)化

2010-10-08 17:03:59

.NET Micro Visual Stud

2009-11-17 10:29:39

.NET Micro

2009-07-17 14:51:22

.Net Micro

2009-07-17 13:35:12

IO模擬器研究.Net Micro

2009-05-11 09:24:53

微軟.Net Micro 源代碼

2009-07-17 14:38:49

Micro Frame

2013-08-21 16:48:42

.Net命名空間

2009-04-11 15:12:24

.Net MicroI2C總線模擬器

2011-05-20 14:54:46

ADO.NET命名空間

2010-01-15 10:47:15

VB.NET命名空間

2011-05-20 14:54:46

ADO.NET

2009-08-18 11:08:24

.Net Framew

2009-11-04 16:31:40

ADO.NET Ora

2020-07-13 07:00:21

Kubernetes

2009-10-23 14:54:07

VB.NET命名空間

2009-05-26 09:09:50

.NET FramewStream.Read基礎(chǔ)類
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號