日韩无码专区无码一级三级片|91人人爱网站中日韩无码电影|厨房大战丰满熟妇|AV高清无码在线免费观看|另类AV日韩少妇熟女|中文日本大黄一级黄色片|色情在线视频免费|亚洲成人特黄a片|黄片wwwav色图欧美|欧亚乱色一区二区三区

RELATEED CONSULTING
相關(guān)咨詢
選擇下列產(chǎn)品馬上在線溝通
服務(wù)時(shí)間:8:30-17:00
你可能遇到了下面的問(wèn)題
關(guān)閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
WPF繪圖方式詳解

WPF工具作為一種新的開發(fā)工具,主要是用來(lái)幫助我們實(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ù)雜的操作(沒(méi)有事件)。

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

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等??磗dk就ok了,記錄下

另外使用DrawingGroup也可以,不過(guò)容器變成了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)方法的具體介紹。


當(dāng)前名稱:WPF繪圖方式詳解
轉(zhuǎn)載來(lái)源:http://www.5511xx.com/article/djpdios.html