프로젝트

일반

사용자정보

통계
| 브랜치(Branch): | 개정판:

markus / KCOM / Controls / cadPanel.xaml.cs @ e52385b9

이력 | 보기 | 이력해설 | 다운로드 (5.9 KB)

1
using KCOM.Common;
2
using Newtonsoft.Json;
3
using System;
4
using System.Collections.Generic;
5
using System.IO;
6
using System.Linq;
7
using System.Reflection;
8
using System.Text;
9
using System.Windows;
10
using System.Windows.Controls;
11
using System.Windows.Data;
12
using System.Windows.Documents;
13
using System.Windows.Input;
14
using System.Windows.Media;
15
using System.Windows.Media.Imaging;
16
using System.Windows.Shapes;
17
using Teigha.Geometry;
18

    
19
namespace KCOM.Controls
20
{
21
    /// <summary>
22
    /// cadPanel.xaml에 대한 상호 작용 논리
23
    /// </summary>
24
    public partial class cadPanel : UserControl
25
    {
26
        //  private DrawType drawType;
27

    
28
        private string _cadpath = string.Empty;
29
        private static string destFile = string.Empty;
30
        public cadPanel()
31
        {
32
            this.Loaded += CadPanel_Loaded;
33

    
34
        }
35
        public void setCadPath(string path)
36
        {
37
            this._cadpath = path;
38
        }
39
        public string setResultPath()
40
        {
41
            return destFile;
42
        }
43

    
44
        public Point startPoint = new Point(0, 0);
45
        public Point endPoint = new Point(0, 0);
46

    
47
        private void CadPanel_Loaded(object sender, RoutedEventArgs e)
48
        {
49
            InitializeComponent();
50
            if (CadViewer.TitleProperty.Name == "Viewer")
51
            {
52
                this.export.Visibility = System.Windows.Visibility.Hidden;
53
            }
54
        }
55

    
56
        private void Ep_Click(object sender, RoutedEventArgs e)
57
        {
58
            CadViewer.drawType = DrawType.ep;
59
        }
60

    
61
        private void Sp_Click(object sender, RoutedEventArgs e)
62
        {
63
            CadViewer.drawType = DrawType.sp;
64
        }
65
        CustomImage1 CustomImage1 = new CustomImage1();
66
        private void Clear_Click(object sender, RoutedEventArgs e)
67
        {
68
            CustomImage1.PointClear();
69
            startPoint = new Point(0, 0);
70
            endPoint = new Point(0, 0);
71
            spLabel.Text = "(0, 0)";
72
            epLabel.Text = "(0, 0)";
73
        }
74

    
75

    
76

    
77
        CadRectData aa = new CadRectData();
78

    
79
        [Serializable]
80
        public class CadRectData
81
        {
82
            public Point startPoint { get; set; }
83
            public Point endPoint { get; set; }
84
        }
85
        MarkupToPDF.Controls.Parsing.LayerControl layer = new MarkupToPDF.Controls.Parsing.LayerControl();
86

    
87
        public void Export_Click(object sender, RoutedEventArgs e)
88
        {
89
            try
90
            {
91
                if (startPoint != new Point(0, 0) && endPoint != new Point(0, 0))
92
                {
93
                    if (MessageBox.Show("설정한 영역으로 export 하시겠습니까?", "MarkUS", MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes)
94
                    {
95
                        /*
96
                        string FileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "commentstring.json"); // Default file name
97
                        aa.startPoint = startPoint;
98
                        aa.endPoint = endPoint;
99
                        string data = JsonConvert.SerializeObject(aa);
100
                        File.AppendAllText(FileName, data);
101
                        */
102

    
103
                        /*string Data = ViewerDataModel.Instance.MarkupList_USER.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
104
                                        && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).FirstOrDefault().Data;
105
                                        */
106

    
107
                        List<Point3d> coordinates = new List<Point3d>();
108

    
109
                        coordinates.Add(new Point3d(0.0, 0.0, 0.0));
110
                        coordinates.Add(new Point3d(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight, 0.0));
111
                        coordinates.Add(new Point3d(startPoint.X, startPoint.Y, 0.0));
112
                        coordinates.Add(new Point3d(endPoint.X, endPoint.Y, 0.0));
113

    
114
                        string sResult = MarkUsToDWG.ODACLASSIC.CreateDrawing(AppDomain.CurrentDomain.BaseDirectory + "Cad", "commentstring.json", _cadpath, coordinates);//, startPoint, endPoint
115
                        string sourceFileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + "Cad\\" + "commentstring.json"),
116
                                System.IO.Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.BaseDirectory + "Cad\\" + "commentstring.json") + ".dwg");
117
                        destFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(_cadpath), System.IO.Path.GetFileNameWithoutExtension(_cadpath) + "_output.dwg");
118
                        System.IO.File.Copy(sourceFileName, destFile, true);
119
                        System.IO.File.Delete(AppDomain.CurrentDomain.BaseDirectory + "Cad\\commentstring.json");
120
                        //MessageBox.Show(sResult);             
121
                        if (sResult == "SUCCESS")
122
                        {
123
                            CadResultViewer check = new CadResultViewer();
124
                            check.WindowStartupLocation = WindowStartupLocation.CenterScreen;
125
                            check.filename = destFile;
126
                            check.Title = "Result";
127
                            check.Show();
128
                        }
129
                        else
130
                        {
131
                            MessageBox.Show(sResult, "MARKUS");
132
                        }
133
                    }
134
                }
135
                else
136
                {
137
                    MessageBox.Show("영역을 설정하세요", "MarkUS", MessageBoxButton.OK);
138
                }
139
                //CustomImage1.Export(startPoint, endPoint);
140
                //CadViewer.Export();
141
                //FileExport();
142
            }
143
            catch (Exception ee)
144
            {
145
                MessageBox.Show(ee + "", "MARKUS");
146
            }
147

    
148
        }
149
    }
150
}
클립보드 이미지 추가 (최대 크기: 500 MB)