資源簡介
本例程實現dxf文件的加載及顯示,其中顯示部門通過winform加載WPF控件實現
代碼片段和文件信息
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows;
using?System.Windows.Forms;
using?System.Windows.Media;
using?netDxf;
using?netDxf.Entities;
using?System.Globalization;
using?System.Windows.Input;
namespace?DXFMaiform
{
????public?partial?class?MainForm?:?Form
????{
????????
????????private?DxfDocument?dxf;
????????public?MainForm()
????????{
????????????InitializeComponent();
????????????
????????????WindowState?=?FormWindowState.Maximized;
????????????
????????}
????????private?void?MainForm_Load(object?sender?EventArgs?e)
????????{
????????????//??wpfUserControl.MouseWheel?+=?new?MouseWheelEventHandler(onmousewheel);
??????????//??base.onload(e);
????????}
????????
????????protected?override?void?onmousewheel(System.Windows.Forms.MouseEventArgs?e)
????????{
??????????//??wpfUserControl.On_MouseWheel((System.Windows.Input.MouseWheelEventArgs)e);
????????}
????????protected?override?void?onmousemove(System.Windows.Forms.MouseEventArgs?e)
????????{
???????????
????????}
????????private?void?openToolStripMenuItem_Click(object?sender?EventArgs?e)
????????{
????????????string?filename?=?string.Empty;
????????????using?(OpenFileDialog?openDlg?=?new?OpenFileDialog())
????????????{
????????????????openDlg.InitialDirectory?=?“C:\\“;
????????????????openDlg.Filter?=?“DXF?文件?|*.dxf“;
????????????????if?(openDlg.ShowDialog()?==?DialogResult.OK)
????????????????{
????????????????????filename?=?openDlg.FileName;
????????????????????if?(wpfUserControl.MyCanvas.Children.Count?!=?0)
????????????????????{
????????????????????????wpfUserControl.MyCanvas.Children.Clear();
????????????????????}
????????????????????dxf?=?new?DxfDocument();
????????????????????dxf.Load(filename);
????????????????}
????????????}
????????????Addlayers();
????????????AddGraph();
????????????AdjustGraph();
????????}
????????private?void?Addlayers()
????????{
????????????foreach(var?lay?in?dxf.layers)
????????????{
????????????????System.Windows.Shapes.Path?path?=?new?System.Windows.Shapes.Path();
????????????????path.Stroke?=?new?SolidColorBrush(System.Windows.Media.Color.FromArgb(lay.Color.ToColor().A?lay.Color.ToColor().R?lay.Color.ToColor().G?lay.Color.ToColor().B));
????????????????path.Tag?=?lay.Name;
????????????????GeometryGroup?GeoGroup?=?new?GeometryGroup();
????????????????path.Data?=?GeoGroup;
????????????????wpfUserControl.MyCanvas.Children.Add(path);
????????????}
????????????System.Windows.Shapes.Path?label?=?new?System.Windows.Shapes.Path();
????????????GeometryGroup?Character?=?new?GeometryGroup();
????????????label.Data?=?Character;
????????????label.Tag?=?“Character“;
????????????wpfUserControl.MyCanvas.Children.Add(label);
????????}
????????private?void?AddGraph()
????????{
????????????AddCircle();
??????
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件?????????47??2020-12-24?15:23??DXFMainForm\.git\COMMIT_EDITMSG
?????文件????????130??2020-12-24?15:11??DXFMainForm\.git\config
?????文件?????????73??2020-12-24?15:11??DXFMainForm\.git\desc
?????文件?????????23??2020-12-24?15:11??DXFMainForm\.git\HEAD
?????文件????????478??2020-12-24?15:11??DXFMainForm\.git\hooks\applypatch-msg.sample
?????文件????????896??2020-12-24?15:11??DXFMainForm\.git\hooks\commit-msg.sample
?????文件???????3327??2020-12-24?15:11??DXFMainForm\.git\hooks\fsmonitor-watchman.sample
?????文件????????189??2020-12-24?15:11??DXFMainForm\.git\hooks\post-update.sample
?????文件????????424??2020-12-24?15:11??DXFMainForm\.git\hooks\pre-applypatch.sample
?????文件???????1638??2020-12-24?15:11??DXFMainForm\.git\hooks\pre-commit.sample
?????文件???????1348??2020-12-24?15:11??DXFMainForm\.git\hooks\pre-push.sample
?????文件???????4898??2020-12-24?15:11??DXFMainForm\.git\hooks\pre-reba
?????文件????????544??2020-12-24?15:11??DXFMainForm\.git\hooks\pre-receive.sample
?????文件???????1492??2020-12-24?15:11??DXFMainForm\.git\hooks\prepare-commit-msg.sample
?????文件???????3610??2020-12-24?15:11??DXFMainForm\.git\hooks\update.sample
?????文件???????9013??2020-12-24?15:23??DXFMainForm\.git\index
?????文件????????240??2020-12-24?15:11??DXFMainForm\.git\info\exclude
?????文件????????349??2020-12-24?15:23??DXFMainForm\.git\logs\HEAD
?????文件????????349??2020-12-24?15:23??DXFMainForm\.git\logs\refs\heads\master
?????文件????????992??2020-12-24?15:21??DXFMainForm\.git\ob
?????文件????????951??2020-12-24?15:23??DXFMainForm\.git\ob
?????文件????????327??2020-12-24?15:23??DXFMainForm\.git\ob
?????文件???????1773??2020-12-24?15:21??DXFMainForm\.git\ob
?????文件???????2257??2020-12-24?15:21??DXFMainForm\.git\ob
?????文件???????1154??2020-12-24?15:21??DXFMainForm\.git\ob
?????文件???????1081??2020-12-24?15:21??DXFMainForm\.git\ob
?????文件????????854??2020-12-24?15:23??DXFMainForm\.git\ob
?????文件???????1206??2020-12-24?15:21??DXFMainForm\.git\ob
?????文件????????329??2020-12-24?15:23??DXFMainForm\.git\ob
?????文件????????150??2020-12-24?15:21??DXFMainForm\.git\ob
............此處省略311個文件信息
- 上一篇:C# 俄羅斯方塊(winform)
- 下一篇:C# 抽獎系統源碼
評論
共有 條評論