예제 #1
0
        private void dxfFromFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "dxf files (*.dxf)|*.dxf";
            if (ofd.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            var r = DxfParser.LoadDxf(ofd.FileName);

            List <NFP> nfps = new List <NFP>();

            foreach (var rr in r)
            {
                nfps.Add(new NFP()
                {
                    Points = rr.Points.Select(z => new SvgPoint(z.X, z.Y)).ToArray()
                });
            }

            for (int i = 0; i < nfps.Count; i++)
            {
                for (int j = 0; j < nfps.Count; j++)
                {
                    if (i != j)
                    {
                        var d2 = nfps[i];
                        var d3 = nfps[j];
                        var f0 = d3.Points[0];
                        if (StaticHelpers.pnpoly(d2.Points.ToArray(), f0.X, f0.Y))
                        {
                            d3.Parent = d2;
                            if (!d2.Childrens.Contains(d3))
                            {
                                d2.Childrens.Add(d3);
                            }
                        }
                    }
                }
            }

            List <HelperItem> ret = new List <HelperItem>();

            foreach (var item in nfps)
            {
                if (item.Parent != null)
                {
                    continue;
                }
                PolygonHelper phh = new PolygonHelper();
                phh.Name = new FileInfo(ofd.FileName).Name;
                ret.Add(phh);
                phh.Polygon = item;
            }

            dataModel.AddItems(ret.ToArray());
        }
예제 #2
0
        private void importSelectedToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (listView3.SelectedItems.Count > 0)
            {
                QntDialog q = new QntDialog();
                if (q.ShowDialog() == DialogResult.OK)
                {
                    foreach (var item in listView3.SelectedItems)
                    {
                        var t = (item as ListViewItem).Tag as FileInfo;

                        var svg = t.FullName.Contains("svg") ? SvgParser.LoadSvg(t.FullName) : DxfParser.loadDxf(t.FullName);
                        int src = 0;
                        if (polygons.Any())
                        {
                            src = polygons.Max(z => z.source.Value) + 1;
                        }
                        for (int i = 0; i < q.Qnt; i++)
                        {
                            context.ImportFromRawDetail(svg, src);
                        }
                    }
                    UpdateList();
                }
            }
        }
예제 #3
0
        private void listView3_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (listView3.SelectedItems.Count > 0)
            {
                for (int i = 0; i < listView3.SelectedItems.Count; i++)
                {
                    var si = listView3.SelectedItems[i].Tag;
                    if (si is DirectoryInfo)
                    {
                        UpdateFilesList((si as DirectoryInfo).FullName);
                    }
                    if (si is FileInfo)
                    {
                        var       f = (si as FileInfo);
                        QntDialog q = new QntDialog();
                        if (q.ShowDialog() == DialogResult.OK)
                        {
                            var svg = f.FullName.Contains("svg") ? SvgParser.LoadSvg(f.FullName) : DxfParser.loadDxf(f.FullName);
                            int src = 0;
                            if (polygons.Any())
                            {
                                src = polygons.Max(z => z.source.Value) + 1;
                            }
                            for (int j = 0; j < q.Qnt; j++)
                            {
                                context.ImportFromRawDetail(svg, src);
                            }

                            UpdateList();
                        }
                    }
                }
            }
        }
예제 #4
0
        private void listView3_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (listView3.SelectedItems.Count > 0 && listView3.SelectedItems[0].Tag is FileInfo)
            {
                try
                {
                    var path = (FileInfo)listView3.SelectedItems[0].Tag;
                    var svg  = path.FullName.Contains("svg") ? SvgParser.LoadSvg(path.FullName) : DxfParser.loadDxf(path.FullName);


                    Preview = svg;
                }
                catch (Exception ex)
                {
                    Preview = null;
                }
            }
        }