• 大小: 0.78M
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2024-05-02
  • 语言: C#
  • 标签: wpf  DXF  winform  

资源简介

本例程实现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\description

     文件         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-rebase.sample

     文件        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\objects\03\f507df92465c1952c24cfea8a9bd5a479da42e

     文件        951  2020-12-24 15:23  DXFMainForm\.git\objects\09\5e18a53821baa5b060fe7ae84679fbd488828d

     文件        327  2020-12-24 15:23  DXFMainForm\.git\objects\0a\e7151d300e2d006b5c554e85eced63a56cc80d

     文件       1773  2020-12-24 15:21  DXFMainForm\.git\objects\0c\2aa0feaa1030c8a03dcad54e7eaaed62733486

     文件       2257  2020-12-24 15:21  DXFMainForm\.git\objects\0d\fda161e232a1bca6fb5f26053752931557787d

     文件       1154  2020-12-24 15:21  DXFMainForm\.git\objects\11\41ac54479e01ccb0db860eac46efc5ba5397cc

     文件       1081  2020-12-24 15:21  DXFMainForm\.git\objects\14\855ad712644c3f21df46587e289d3e47a3c3a7

     文件        854  2020-12-24 15:23  DXFMainForm\.git\objects\14\fcf2878249e571d13a15b673dbf6c6cbfc814a

     文件       1206  2020-12-24 15:21  DXFMainForm\.git\objects\15\1d5e6494087d09b80c58600c8821b20ebc9b9f

     文件        329  2020-12-24 15:23  DXFMainForm\.git\objects\19\200c8ab2b14e8737a7d75841028fa6de0779f1

     文件        150  2020-12-24 15:21  DXFMainForm\.git\objects\19\3aecc675e7d4600fde2d37cf350bce7a056948

............此处省略311个文件信息

评论

共有 条评论