프로젝트

일반

사용자정보

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

markus / KCOM / Controls / CAD / cadPanel.xaml.cs @ 2a824927

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

1 684ef11c ljiyeon
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
86
        public void Export_Click(object sender, RoutedEventArgs e)
87
        {
88
            try
89
            {
90
                if (startPoint != new Point(0, 0) && endPoint != new Point(0, 0))
91
                {
92
                    if (MessageBox.Show("설정한 영역으로 export 하시겠습니까?", "MarkUS", MessageBoxButton.YesNoCancel) == MessageBoxResult.Yes)
93
                    {
94
                        /*
95
                        string FileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "commentstring.json"); // Default file name
96
                        aa.startPoint = startPoint;
97
                        aa.endPoint = endPoint;
98
                        string data = JsonConvert.SerializeObject(aa);
99
                        File.AppendAllText(FileName, data);
100
                        */
101
102 d62c0439 humkyung
                        /*string Data = ViewerDataModel.Instance.MyMarkupList.Where(d => d.PageNumber == Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.pageNavigator.CurrentPage.PageNumber
103 684ef11c ljiyeon
                                        && d.Data_Type == Convert.ToInt32(MarkupToPDF.Controls.Common.ControlType.Coordinate)).FirstOrDefault().Data;
104
                                        */
105
106
                        List<Point3d> coordinates = new List<Point3d>();
107
108
                        coordinates.Add(new Point3d(0.0, 0.0, 0.0));
109
                        coordinates.Add(new Point3d(ViewerDataModel.Instance.ImageViewWidth, ViewerDataModel.Instance.ImageViewHeight, 0.0));
110
                        coordinates.Add(new Point3d(startPoint.X, startPoint.Y, 0.0));
111
                        coordinates.Add(new Point3d(endPoint.X, endPoint.Y, 0.0));
112
113
                        string sResult = MarkUsToDWG.ODACLASSIC.CreateDrawing(AppDomain.CurrentDomain.BaseDirectory + "Cad", "commentstring.json", _cadpath, coordinates);//, startPoint, endPoint
114
                        string sourceFileName = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory + "Cad\\" + "commentstring.json"),
115
                                System.IO.Path.GetFileNameWithoutExtension(AppDomain.CurrentDomain.BaseDirectory + "Cad\\" + "commentstring.json") + ".dwg");
116
                        destFile = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(_cadpath), System.IO.Path.GetFileNameWithoutExtension(_cadpath) + "_output.dwg");
117
                        System.IO.File.Copy(sourceFileName, destFile, true);
118
                        System.IO.File.Delete(AppDomain.CurrentDomain.BaseDirectory + "Cad\\commentstring.json");
119
                        //MessageBox.Show(sResult);             
120
                        if (sResult == "SUCCESS")
121
                        {
122
                            CadResultViewer check = new CadResultViewer();
123
                            check.WindowStartupLocation = WindowStartupLocation.CenterScreen;
124
                            check.filename = destFile;
125
                            check.Title = "Result";
126
                            check.Show();
127
                        }
128
                        else
129
                        {
130
                            MessageBox.Show(sResult, "MARKUS");
131
                        }
132
                    }
133
                }
134
                else
135
                {
136
                    MessageBox.Show("영역을 설정하세요", "MarkUS", MessageBoxButton.OK);
137
                }
138
                //CustomImage1.Export(startPoint, endPoint);
139
                //CadViewer.Export();
140
                //FileExport();
141
            }
142
            catch (Exception ee)
143
            {
144
                MessageBox.Show(ee + "", "MARKUS");
145
            }
146
147
        }
148
    }
149
}
클립보드 이미지 추가 (최대 크기: 500 MB)