資源簡介
svg矢量圖的使用,將svg矢量圖展示在pictureBox上,拖動可以應用到其他設計軟件上

代碼片段和文件信息
using?Svg;
using?SvgApplyDemo.Properties;
using?System;
using?System.Drawing;
using?System.Drawing.Drawing2D;
using?System.IO;
using?System.Net;
using?System.Windows.Forms;
namespace?SvgApplyDemo
{
????public?partial?class?Form1?:?Form
????{
????????public?Form1()
????????{
????????????InitializeComponent();
????????????InitForm();
????????????InitContent();
????????}
????????#region?property
????????private?SvgDocument?_document;
????????private?int?_effectScaleWidth?=?252;
????????private?int?_effectScaleHeight?=?40;
????????public?static?string?ApplicationDataTempPath
????????{
????????????get
????????????{
????????????????var?path?=?Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData)?+?“\\SystemData\\Temp1\\“;
????????????????if?(!Directory.Exists(path))?Directory.CreateDirectory(path);
????????????????return?path;
????????????}
????????}
????????#endregion
????????#region?method???????
????????///?
????????///?將SVG文件轉換為位圖圖像。
????????///?
????????///?SVG圖像的全路徑。
????????///?返回轉換位圖圖像。
????????public?Image?GetImageFromSVG(string?filePath)
????????{
????????????try
????????????{
????????????????_document?=?SvgDocument.Open(filePath);
????????????????return?ZoomImage(_document.Draw()?_effectScaleWidth?_effectScaleHeight);
????????????}
????????????catch?(Exception)
????????????{
????????????????return?null;
????????????}
????????}
????????///?
????????///?等比例縮放圖片
????????///?
????????///?
????????///?
????????///?
????????///?
????????private?Bitmap?ZoomImage(Bitmap?bitmap?int?destWidth?int?destHeight)
????????{
????????????try
????????????{
????????????????Image?sourImage?=?bitmap;
????????????????int?width?=?0?height?=?0;
????????????????//按比例縮放???????????
????????????????int?sourWidth?=?sourImage.Width;
????????????????int?sourHeight?=?sourImage.Height;
????????????????if?(sourHeight?>?destHeight?||?sourWidth?>?destWidth)
????????????????{
????????????????????if?((sourWidth?*?destHeight)?>?(sourHeight?*?destWidth))
????????????????????{
????????????????????????width?=?destWidth;
????????????????????????height?=?(destWidth?*?sourHeight)?/?sourWidth;
????????????????????}
????????????????????else
????????????????????{
????????????????????????height?=?destHeight;
????????????????????????width?=?(sourWidth?*?destHeight)?/?sourHeight;
????????????????????}
????????????????}
????????????????else
????????????????{
????????????????????width?=?sourWidth;
????????????????????height?=?sourHeight;
????????????????}
????????????????Bitmap?destBitmap?=?new?Bitmap(destWidth?destHeight);
????????????????Graphics?g?=?Graphics.FromImage(destBitmap);
????????????????g.Clear(Color.Transparent);
????????????????//設置畫布的描繪質量?????????
????????????????g
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2019-04-12?13:35??WinFormSvgApplyDemo\
?????目錄???????????0??2019-04-12?13:37??WinFormSvgApplyDemo\.git\
?????文件?????????107??2019-04-12?13:37??WinFormSvgApplyDemo\.git\COMMIT_EDITMSG
?????文件?????????311??2019-04-12?13:34??WinFormSvgApplyDemo\.git\config
?????文件??????????73??2019-04-12?13:34??WinFormSvgApplyDemo\.git\desc
?????文件??????????23??2019-04-12?13:34??WinFormSvgApplyDemo\.git\HEAD
?????目錄???????????0??2019-04-12?13:34??WinFormSvgApplyDemo\.git\hooks\
?????文件?????????478??2019-04-12?13:34??WinFormSvgApplyDemo\.git\hooks\applypatch-msg.sample
?????文件?????????896??2019-04-12?13:34??WinFormSvgApplyDemo\.git\hooks\commit-msg.sample
?????文件?????????189??2019-04-12?13:34??WinFormSvgApplyDemo\.git\hooks\post-update.sample
?????文件?????????424??2019-04-12?13:34??WinFormSvgApplyDemo\.git\hooks\pre-applypatch.sample
?????文件????????1642??2019-04-12?13:34??WinFormSvgApplyDemo\.git\hooks\pre-commit.sample
?????文件????????1239??2019-04-12?13:34??WinFormSvgApplyDemo\.git\hooks\prepare-commit-msg.sample
?????文件????????1348??2019-04-12?13:34??WinFormSvgApplyDemo\.git\hooks\pre-push.sample
?????文件????????4951??2019-04-12?13:34??WinFormSvgApplyDemo\.git\hooks\pre-reba
?????文件?????????544??2019-04-12?13:34??WinFormSvgApplyDemo\.git\hooks\pre-receive.sample
?????文件????????3610??2019-04-12?13:34??WinFormSvgApplyDemo\.git\hooks\update.sample
?????文件????????5530??2019-04-12?13:37??WinFormSvgApplyDemo\.git\index
?????目錄???????????0??2019-04-12?13:34??WinFormSvgApplyDemo\.git\info\
?????文件?????????240??2019-04-12?13:34??WinFormSvgApplyDemo\.git\info\exclude
?????目錄???????????0??2019-04-12?13:34??WinFormSvgApplyDemo\.git\logs\
?????文件?????????444??2019-04-12?13:37??WinFormSvgApplyDemo\.git\logs\HEAD
?????目錄???????????0??2019-04-12?13:34??WinFormSvgApplyDemo\.git\logs\refs\
?????目錄???????????0??2019-04-12?13:34??WinFormSvgApplyDemo\.git\logs\refs\heads\
?????文件?????????444??2019-04-12?13:37??WinFormSvgApplyDemo\.git\logs\refs\heads\master
?????目錄???????????0??2019-04-12?13:34??WinFormSvgApplyDemo\.git\logs\refs\remotes\
?????目錄???????????0??2019-04-12?13:34??WinFormSvgApplyDemo\.git\logs\refs\remotes\origin\
?????文件?????????195??2019-04-12?13:34??WinFormSvgApplyDemo\.git\logs\refs\remotes\origin\HEAD
?????文件?????????149??2019-04-12?13:37??WinFormSvgApplyDemo\.git\logs\refs\remotes\origin\master
?????目錄???????????0??2019-04-12?13:34??WinFormSvgApplyDemo\.git\ob
?????目錄???????????0??2019-04-12?13:37??WinFormSvgApplyDemo\.git\ob
............此處省略178個文件信息
- 上一篇:C#Windows窗口人事管理系統
- 下一篇:C#界面設計教程
評論
共有 條評論