av激情亚洲男人的天堂国语,日韩欧美精品一中文字幕,无码av一区二区三区无码,国产又色又爽又刺激的a片,国产又色又爽又刺激的a片

WPF繪圖方式詳解

WPF工具作為一種新的開發(fā)工具,主要是用來幫助我們實(shí)現(xiàn)與圖形處理相關(guān)方面的操作。那么今天我們將會(huì)了解到有關(guān)WPF繪圖的相關(guān)方法。#t#

海北州網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián)公司,海北州網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為海北州1000多家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)營(yíng)銷網(wǎng)站建設(shè)要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的海北州做網(wǎng)站的公司定做!

WPF繪圖提供了Ellipse等標(biāo)簽畫圖形,不僅如此而且還提供了許多的事件(因?yàn)槠淅^承自FrameworkElement).在某些情況下,我們可以不采用這些標(biāo)簽。

僅僅用于呈現(xiàn),并不復(fù)雜的操作(沒有事件)。

DrawingVisual是一個(gè)輕量繪圖類,在上述情況成立下可以采用DrawingVisual類來繪圖提高性能。

WPF繪圖方法如下

1.使用DrawingVisual必須創(chuàng)建一個(gè)容器(從FrameworkElement繼承創(chuàng)建一個(gè)容器)

 
 
 
  1. public class MyVisualHost 
    : FrameworkElement  
  2. {  

2.創(chuàng)建一個(gè)全局可視對(duì)象的集合(VisualCollection)

 
 
 
  1. private VisualColl
    ection _children;  
  2. public MyVisualHost()  
  3. {  
  4. _children = new 
    VisualCollection(this);  

3.創(chuàng)建DrawingVisual

先初始化一個(gè)DrawingVisual類,然后使用RenderOpen()獲取其DrawingContext 對(duì)象(DrawingContext 不可以以new方式初始化),DrawingContext 提供了一些以Draw開頭的繪圖方法,繪制完成以后必須調(diào)用Close方法(不然不會(huì)呈現(xiàn))

 
 
 
  1. private DrawingVisual 
    CreateDrawingVisualRectangle()  
  2. {  
  3. DrawingVisual drawingVisual = 
    new DrawingVisual();  
  4. // Retrieve the DrawingContext 
    in order to create new drawing 
    content.  
  5. DrawingContext drawingContext = 
    drawingVisual.RenderOpen();  
  6. // Create a rectangle and 
    draw it in the DrawingContext.  
  7. Rect rect = new Rect(new 
    Point(160, 100), new Size(320, 80));  
  8. drawingContext.DrawRectangle
    (Brushes.LightBlue, (Pen)null, rect);  
  9. // Persist the drawing content.  
  10. drawingContext.Close();  
  11. return drawingVisual;  

WPF繪圖DrawingContext還包含一些以Push開頭的方法,可以為圖形設(shè)置透明度,effect等。看sdk就ok了,記錄下

另外使用DrawingGroup也可以,不過容器變成了Image

 
 
 
  1. // Display the drawing 
    using an image control.  
  2. Image theImage = new Image();  
  3. DrawingImage dImageSource = 
    new DrawingImage(dGroup);  
  4. theImage.Source = dImageSource;  
  5. panel.Children.Add(theImage); 

以上就是對(duì)WPF繪圖的相關(guān)方法的具體介紹。


網(wǎng)站名稱:WPF繪圖方式詳解
轉(zhuǎn)載來源:http://uogjgqi.cn/article/djpdios.html
掃二維碼與項(xiàng)目經(jīng)理溝通

我們?cè)谖⑿派?4小時(shí)期待你的聲音

解答本文疑問/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流