프로젝트

일반

사용자정보

개정판 684ef11c

ID684ef11c766d313d568ea0db90bdb1b2ce708613
상위 a74e3cbc
하위 022d64c4

이지연이(가) 5년 이상 전에 추가함

issue #719 AutoCAD 저장 작업 중

Change-Id: I46dfcaa8fb3b15907afe75a1e17ae643bef64f3f

차이점 보기:

IKCOM/IKCOM.csproj
9 9
    <AppDesignerFolder>Properties</AppDesignerFolder>
10 10
    <RootNamespace>IKCOM</RootNamespace>
11 11
    <AssemblyName>IKCOM</AssemblyName>
12
    <TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
12
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13 13
    <FileAlignment>512</FileAlignment>
14
    <TargetFrameworkProfile />
14 15
  </PropertyGroup>
15 16
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
16 17
    <DebugSymbols>true</DebugSymbols>
......
20 21
    <DefineConstants>DEBUG;TRACE</DefineConstants>
21 22
    <ErrorReport>prompt</ErrorReport>
22 23
    <WarningLevel>4</WarningLevel>
24
    <Prefer32Bit>false</Prefer32Bit>
23 25
  </PropertyGroup>
24 26
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
25 27
    <DebugType>pdbonly</DebugType>
......
28 30
    <DefineConstants>TRACE</DefineConstants>
29 31
    <ErrorReport>prompt</ErrorReport>
30 32
    <WarningLevel>4</WarningLevel>
33
    <Prefer32Bit>false</Prefer32Bit>
31 34
  </PropertyGroup>
32 35
  <ItemGroup>
33 36
    <Reference Include="PresentationCore" />
KCOM/Controls/AdornerFinal.xaml.cs
1 1
using KCOM.Common;
2 2
using MarkupToPDF.Common;
3
using MarkupToPDF.Controls.Cad;
3 4
using MarkupToPDF.Controls.Common;
4 5
using MarkupToPDF.Controls.Etc;
5 6
using MarkupToPDF.Controls.Line;
......
285 286
                        //((TextControl)member).Base_TextPath.Visibility = Visibility.Collapsed;
286 287
                    });
287 288
                    break;
289
                case "InsideWhiteControl":
290
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
291
                    break;
292
                case "OverlapWhiteControl":
293
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
294
                    break;
295
                case "ClipWhiteControl":
296
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
297
                    break;
298
                case "CoordinateControl":
299
                    MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
300
                    break;
288 301
                default:
289 302
                    break;
290 303
                    #endregion
......
392 405
                            BorderUpdate();
393 406
                        });
394 407
                        break;
408
                    case "InsideWhiteControl":
409
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.InsideWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
410
                        break;
411
                    case "OverlapWhiteControl":
412
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.OverlapWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
413
                        break;
414
                    case "ClipWhiteControl":
415
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.ClipWhite, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
416
                        break;
417
                    case "CoordinateControl":
418
                        MemberSet.Add(new AdornerMember { DrawingData = member, Drawingtype = ControlType.Coordinate, ThumbList = new List<Thumb>(), Symbol_ID = member.SymbolID, Group_ID = member.GroupID });
419
                        break;
395 420
                    default:
396 421
                        break;
397 422
                        #endregion
......
1643 1668
                            (item.DrawingData as IPath).updateControl();
1644 1669
                            BorderUpdate();
1645 1670
                            break;
1671
                        case ControlType.InsideWhite:
1672
                            ((InsideWhiteControl)item.DrawingData).Angle = AngleValue;
1673
                            (item.DrawingData as IPath).updateControl();
1674
                            BorderUpdate();
1675
                            break;
1676
                        case ControlType.OverlapWhite:
1677
                            ((OverlapWhiteControl)item.DrawingData).Angle = AngleValue;
1678
                            (item.DrawingData as IPath).updateControl();
1679
                            BorderUpdate();
1680
                            break;
1681
                        case ControlType.ClipWhite:
1682
                            ((ClipWhiteControl)item.DrawingData).Angle = AngleValue;
1683
                            (item.DrawingData as IPath).updateControl();
1684
                            BorderUpdate();
1685
                            break;
1686
                        case ControlType.Coordinate:
1687
                            ((CoordinateControl)item.DrawingData).Angle = AngleValue;
1688
                            (item.DrawingData as IPath).updateControl();
1689
                            BorderUpdate();
1690
                            break;
1646 1691
                        default:
1647 1692
                            break;
1648 1693
                    }
KCOM/Controls/CadResultViewer.xaml
1
<Window x:Class="KCOM.Controls.CadResultViewer"
2
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
5
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
6
        xmlns:local="clr-namespace:KCOM.Controls"
7
        mc:Ignorable="d"
8
        Height="Auto" Width="Auto">
9

  
10

  
11
    <Grid>
12
        <Grid.ColumnDefinitions>
13
            <ColumnDefinition Width="66*"/>
14
            <ColumnDefinition Width="29*"/>
15
        </Grid.ColumnDefinitions>
16
        <Grid Name="grid1" Grid.ColumnSpan="2">
17
            <Grid.ColumnDefinitions>
18
                <ColumnDefinition Width="1*"/>
19
            </Grid.ColumnDefinitions>
20

  
21
            <Grid Name="grid2">
22
                <Grid.RowDefinitions>
23
                    <RowDefinition Height="30"/>
24
                    <RowDefinition Height="100*"/>
25
                </Grid.RowDefinitions>
26
                <Grid Name="grid3" Grid.Row="0">
27
                    <Grid.ColumnDefinitions>
28
                        <ColumnDefinition Width="2.5*"/>
29
                        <ColumnDefinition Width="7.5*"/>
30
                    </Grid.ColumnDefinitions>
31
                    <Button Content="open" Grid.Column="0" Padding="5" Background="#3d3d3d" Foreground="White" x:Name="button1" Click="button1_Click"/>
32
                    <!-- &#10; -->
33
                    <TextBox Margin="10,2,0,-2" Background="#FFF3F3F3" Grid.Column="1" BorderThickness="0.5" VerticalContentAlignment="Center" Text="" x:Name="filepath"/>
34
                </Grid>
35
                <local:CustomImage2 Grid.Row="1" x:Name="dwgControl" Grid.Column="0" SizeChanged="dwgControl_SizeChanged"  MouseDown="DwgControl_MouseDown" Background="Azure"/>
36
            </Grid>
37
        </Grid>
38
    </Grid>
39
</Window>
KCOM/Controls/CadResultViewer.xaml.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Windows;
6
using System.Windows.Controls;
7
using System.Windows.Data;
8
using System.Windows.Documents;
9
using System.Windows.Input;
10
using System.Windows.Media;
11
using System.Windows.Media.Imaging;
12
using System.Windows.Navigation;
13
using System.Windows.Shapes;
14
using Teigha.Core;
15
using Teigha.TD;
16
using System.Windows.Interop;
17
using System.Windows.Forms;
18
using System.Reflection;
19
using System.Windows.Markup;
20

  
21
namespace KCOM.Controls
22
{
23
    public partial class CadResultViewer : Window
24
    {
25
        private static Window win = null;
26
        SaveFileDialog SaveDig = new SaveFileDialog(); //파일 세이브 다이얼로그
27
        public static DrawType drawType;
28

  
29
        public CadResultViewer()
30
        {
31
            drawType = DrawType.nothing;
32
            this.Loaded += CadResultViewer_Loaded;
33
        }
34

  
35
        private void CadResultViewer_Loaded(object sender, RoutedEventArgs e)
36
        {
37
            InitializeComponent();
38
            dwgControl.DeleteContext();
39

  
40
            win = new Window();
41
            win.Owner = (Window)this;
42
            win.Visibility = System.Windows.Visibility.Hidden;
43
            win.WindowStyle = System.Windows.WindowStyle.None;
44
            win.ShowInTaskbar = false;
45
            win.Background = Brushes.Transparent;
46
            win.AllowsTransparency = true;
47
            win.Show();
48
            win.Hide();
49
            dwgControl.SetInvisibleWin(win);
50

  
51
            if (this.Title == "Result")
52
            {
53
                // filename = this.cadPanel_Instance.setResultPath();
54
                dwgControl.FilePath = filename;
55
                filepath.Text = filename;
56
                grid3.Visibility = System.Windows.Visibility.Collapsed;
57
            }
58
            else
59
            {
60
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
61
                dlg.DefaultExt = ".dwg";
62
                dlg.Filter = "DWG files (.dwg)|*.dwg";
63
                OdGePoint3d[] aa = new OdGePoint3d[4];
64
                Nullable<bool> result = dlg.ShowDialog();
65
                if (result == true)
66
                {
67
                    filename = dlg.FileName;
68
                    //mTeighaD3DImage.FilePath = filename;
69
                    dwgControl.FilePath = filename;
70
                    filepath.Text = filename;
71
                }
72
            }
73
            win.Closed += Win_Closed;
74
            //this.dwgControl.MouseDown += DwgControl_MouseDown;
75
        }
76

  
77
        public string filename = null;
78

  
79
        private void button1_Click(object sender, RoutedEventArgs e)
80
        {
81

  
82
            win = new Window();
83
            // win.Owner = cadViewer;
84
            win.Visibility = System.Windows.Visibility.Hidden;
85
            win.WindowStyle = System.Windows.WindowStyle.None;
86
            win.ShowInTaskbar = false;
87
            win.Background = Brushes.Transparent;
88
            win.AllowsTransparency = true;
89
            win.Show();
90
            win.Hide();
91
            dwgControl.SetInvisibleWin(win);
92
            //    }
93
            // Create OpenFileDialog 
94
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
95

  
96
            dlg.DefaultExt = ".dwg";
97
            dlg.Filter = "DWG files (.dwg)|*.dwg";
98

  
99
            Nullable<bool> result = dlg.ShowDialog();
100

  
101
            if (result == true)
102
            {
103
                dwgControl.DeleteContext();
104
                CadResultViewer cadResultViewer = new CadResultViewer();
105
                filename = dlg.FileName;
106
                //mTeighaD3DImage.FilePath = filename;
107
                dwgControl.FilePath = filename;
108
                filepath.Text = filename;
109
            }
110
            win.Closed += Win_Closed;
111
        }
112

  
113
        private void Win_Closed(object sender, EventArgs e)
114
        {
115
            dwgControl.DeleteContext();
116
        }
117

  
118
        protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
119
        {
120
            base.OnRenderSizeChanged(sizeInfo);
121
        }
122

  
123
        private void dwgControl_SizeChanged(object sender, SizeChangedEventArgs e)
124
        {
125
            if (e.NewSize != e.PreviousSize)
126
            {
127
                dwgControl.ControlSizeChanged(e.NewSize);
128
            }
129
        }
130

  
131

  
132

  
133
        private void DwgControl_MouseDown(object sender, MouseButtonEventArgs e)
134
        {
135
            //OdGsDCPoint[] pts = dwgControl.SelectionPointsByPointOnScreen(e.X, e.Y);
136
            OdGePoint3d point = dwgControl.PointCheck(sender, e, drawType);
137
            if (drawType == DrawType.sp)
138
            {
139
                //  this.cadPanel_Instance.spLabel.Text = "(" + point.x + ", " + point.y + ")";
140
                //  this.cadPanel_Instance.startPoint = new Point(point.x, point.y);
141
                dwgControl.DrawPoint(point, drawType);
142
                drawType = DrawType.nothing;
143
                CustomImage2.mDown = false;
144
            }
145
            else if (drawType == DrawType.ep)
146
            {
147
                // this.cadPanel_Instance.epLabel.Text = "(" + point.x + ", " + point.y + ")";
148
                //  this.cadPanel_Instance.endPoint = new Point(point.x, point.y);
149
                dwgControl.DrawPoint(point, drawType);
150
                drawType = DrawType.nothing;
151
                CustomImage2.mDown = false;
152
            }
153
            else
154
            {
155
                CustomImage2.mDown = true;
156
            }
157
        }
158
    }
159
}
KCOM/Controls/CadViewer.xaml
1
<Window x:Class="KCOM.Controls.CadViewer"
2
        xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation" 
3
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7
        xmlns:local="clr-namespace:KCOM.Controls"
8
        xmlns:controls="clr-namespace:KCOM.Controls"
9
        mc:Ignorable="d"
10
        Height="Auto" Width="Auto">
11

  
12
    <Grid Name="test">
13
        <Grid Name="grid1">
14
            <Grid.ColumnDefinitions>
15
                <ColumnDefinition Width="1*"/>
16
                <ColumnDefinition Width="250" />
17
            </Grid.ColumnDefinitions>
18

  
19
            <Grid Name="grid2">
20
                <Grid.RowDefinitions>
21
                    <RowDefinition Height="30"/>
22
                    <RowDefinition Height="100*"/>
23
                </Grid.RowDefinitions>
24
                <Grid Name="grid3" Grid.Row="0">
25
                    <Grid.ColumnDefinitions>
26
                        <ColumnDefinition Width="2.5*"/>
27
                        <ColumnDefinition Width="7.5*"/>
28
                    </Grid.ColumnDefinitions>
29
                    <Button Content="open" Grid.Column="0" Padding="5" Background="#3d3d3d" Foreground="White" x:Name="button1" Click="button1_Click"/>
30
                    <!-- &#10; -->
31
                    <TextBox Margin="10,2,0,-2" Background="#FFF3F3F3" Grid.Column="1" BorderThickness="0.5" VerticalContentAlignment="Center" Text="" x:Name="filepath"/>
32
                </Grid>
33
                <local:CustomImage1 Grid.Row="1" x:Name="dwgControl" Grid.Column="0" SizeChanged="dwgControl_SizeChanged"  MouseDown="DwgControl_MouseDown" Background="Azure"/>
34
            </Grid>
35
            <telerik:RadPaneGroup telerik:StyleManager.Theme="Office2016" Grid.Column="1">
36
                <telerik:RadPane Margin="0,10,0,0" Header=" CAD Area Info" HeaderForeground="{DynamicResource KCOMColor_MarkerBrush}" FontSize="10" CanFloat="False" CanUserClose="False"  ContextMenuTemplate="{x:Null}" IsPinned="False" telerik:StyleManager.Theme="Office2016" x:Name="cadPanel">
37
                    <controls:cadPanel  x:Name="cadPanel_Instance"/>
38
                </telerik:RadPane>
39
            </telerik:RadPaneGroup>
40
        </Grid>
41
    </Grid>
42
</Window>
43
<!-- 
44
                <Grid Name="grid3" Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
45
                    <Grid.RowDefinitions>
46
                        <RowDefinition Height="20*" />
47
                        <RowDefinition Height="20*" />
48
                        <RowDefinition Height="20*" />
49
                        <RowDefinition Height="20*" />
50
                    </Grid.RowDefinitions>
51
                    <Grid Name="grid7" Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
52
                        <Grid.RowDefinitions>
53
                            <RowDefinition Height="20*"/>
54
                        </Grid.RowDefinitions>
55
                        <Button Grid.Row="0" Click="button1_Click" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="button1">Open</Button>
56
                    </Grid>
57
                    <Grid Name="grid4" Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
58
                        <Grid.RowDefinitions>
59
                            <RowDefinition Height="67*"/>
60
                            <RowDefinition Height="84*"/>
61
                        </Grid.RowDefinitions>
62
                        <Grid.ColumnDefinitions>
63
                            <ColumnDefinition Width="10*"/>
64
                            <ColumnDefinition Width="10*"/>
65
                        </Grid.ColumnDefinitions>
66
                        <Button Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" x:Name="sp" Click="Sp_Click" Grid.RowSpan="2">(Left, Top)</Button>
67
                        <Label Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" x:Name="spLabel" VerticalContentAlignment="Center" Grid.RowSpan="2">(0, 0)</Label>
68
                    </Grid>
69
                    <Grid Name="grid5" Grid.Row="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
70
                        <Grid.ColumnDefinitions>
71
                            <ColumnDefinition Width="10*"/>
72
                            <ColumnDefinition Width="10*"/>
73
                        </Grid.ColumnDefinitions>
74
                        <Button Grid.Column="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" x:Name="ep" Click="Ep_Click" >(Right, Bottom)</Button>
75
                        <Label Grid.Column="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" x:Name="epLabel" VerticalContentAlignment="Center">(0, 0)</Label>
76
                    </Grid>
77
                    <Grid Name="grid6" Grid.Row="3" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
78
                        <Grid.RowDefinitions>
79
                            <RowDefinition Height="20*"/>
80
                            <RowDefinition Height="20*"/>
81
                        </Grid.RowDefinitions>
82
                        <Button Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="Clear" Click="Clear_Click">Clear</Button>
83
                        <Button Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="Export" Click="Export_Click">Export</Button>
84
                    </Grid>
85

  
86

  
87
                     <Button Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="test1" Click="test1_Click">
88
                        <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">
89
                            Draw <LineBreak/> Line
90
                        </TextBlock>
91
                    </Button>
92

  
93
                  <Button Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="test2" Click="test2_Click">
94
                        <TextBlock VerticalAlignment="Center" HorizontalAlignment="Center">
95
                            Export <LineBreak/> to PDF
96
                        </TextBlock>
97
                    </Button>-->
98

  
99
<!-- <Button Grid.Row="0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="lineAdd" Click="lineAdd_Click">lineAdd</Button>
100
                    <Button Grid.Row="1" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="rectAdd" Click="rectAdd_Click">rectAdd</Button>
101
                    <Button Grid.Row="2" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Name="export" Click="Export_Click">Export</Button>
102
                </Grid>-->
103

  
KCOM/Controls/CadViewer.xaml.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Windows;
6
using System.Windows.Controls;
7
using System.Windows.Data;
8
using System.Windows.Documents;
9
using System.Windows.Input;
10
using System.Windows.Media;
11
using System.Windows.Media.Imaging;
12
using System.Windows.Navigation;
13
using System.Windows.Shapes;
14
using Teigha.Core;
15
using Teigha.TD;
16
using System.Windows.Interop;
17
using System.Windows.Forms;
18
using System.Reflection;
19
using System.Windows.Markup;
20

  
21
namespace KCOM.Controls
22
{
23
    public enum DrawType { nothing, sp, ep };
24
    public partial class CadViewer : Window
25
    {
26
        private static Window win = null;
27
        SaveFileDialog SaveDig = new SaveFileDialog(); //파일 세이브 다이얼로그
28
        public static DrawType drawType;
29

  
30
        public CadViewer()
31
        {
32
            drawType = DrawType.nothing;
33
            this.Loaded += CadViewer_Loaded;
34
        }
35

  
36
        private void CadViewer_Loaded(object sender, RoutedEventArgs e)
37
        {
38
            InitializeComponent();
39
            dwgControl.DeleteContext();
40

  
41
            win = new Window();
42
            win.Owner = (Window)this;
43
            win.Visibility = System.Windows.Visibility.Hidden;
44
            win.WindowStyle = System.Windows.WindowStyle.None;
45
            win.ShowInTaskbar = false;
46
            win.Background = Brushes.Transparent;
47
            win.AllowsTransparency = true;
48
            win.Show();
49
            win.Hide();
50
            dwgControl.SetInvisibleWin(win);
51

  
52
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
53
            dlg.DefaultExt = ".dwg";
54
            dlg.Filter = "DWG files (.dwg)|*.dwg";
55
            OdGePoint3d[] aa = new OdGePoint3d[4];
56
            Nullable<bool> result = dlg.ShowDialog();
57
            if (result == true)
58
            {
59
                filename = dlg.FileName;
60
                //mTeighaD3DImage.FilePath = filename;
61
                dwgControl.FilePath = filename;
62
                filepath.Text = filename;
63
                aa = dwgControl.PointLoad();
64

  
65
                if (aa != null)
66
                {
67
                    this.cadPanel_Instance.setCadPath(filename);
68
                    this.cadPanel_Instance.spLabel.Text = "(" + aa[1].x + ", " + aa[1].y + ")";
69
                    this.cadPanel_Instance.epLabel.Text = "(" + aa[3].x + ", " + aa[3].y + ")";
70
                    this.cadPanel_Instance.startPoint = new Point(aa[1].x, aa[1].y);
71
                    this.cadPanel_Instance.endPoint = new Point(aa[3].x, aa[3].y);
72
                }
73
            }
74
            win.Closed += Win_Closed;
75
            //this.dwgControl.MouseDown += DwgControl_MouseDown;
76
        }
77

  
78
        private void Win_Closed(object sender, EventArgs e)
79
        {
80
            dwgControl.DeleteContext();
81
        }
82

  
83
        public string filename = null;
84

  
85
        private void button1_Click(object sender, RoutedEventArgs e)
86
        {
87
            win = new Window();
88
            // win.Owner = cadViewer;
89
            win.Visibility = System.Windows.Visibility.Hidden;
90
            win.WindowStyle = System.Windows.WindowStyle.None;
91
            win.ShowInTaskbar = false;
92
            win.Background = Brushes.Transparent;
93
            win.AllowsTransparency = true;
94
            win.Show();
95
            win.Hide();
96
            dwgControl.SetInvisibleWin(win);
97
            //    }
98
            // Create OpenFileDialog 
99
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
100

  
101
            dlg.DefaultExt = ".dwg";
102
            dlg.Filter = "DWG files (.dwg)|*.dwg";
103

  
104
            // Nullable<bool> result = dlg.ShowDialog();
105

  
106
            OdGePoint3d[] aa = new OdGePoint3d[4];
107
            Nullable<bool> result = dlg.ShowDialog();
108
            if (result == true)
109
            {
110

  
111
                dwgControl.DeleteContext();
112
                //    if (null == win)
113
                //     {
114
                CadViewer cadViewer = new CadViewer();
115
                filename = dlg.FileName;
116
                //mTeighaD3DImage.FilePath = filename;
117
                dwgControl.FilePath = filename;
118
                filepath.Text = filename;
119
                aa = dwgControl.PointLoad();
120

  
121
                if (aa != null)
122
                {
123
                    this.cadPanel_Instance.setCadPath(filename);
124
                    this.cadPanel_Instance.spLabel.Text = "(" + aa[1].x + ", " + aa[1].y + ")";
125
                    this.cadPanel_Instance.epLabel.Text = "(" + aa[3].x + ", " + aa[3].y + ")";
126
                    this.cadPanel_Instance.startPoint = new Point(aa[1].x, aa[1].y);
127
                    this.cadPanel_Instance.endPoint = new Point(aa[3].x, aa[3].y);
128
                }
129
            }
130
            win.Closed += Win_Closed;
131
        }
132

  
133
        protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
134
        {
135
            base.OnRenderSizeChanged(sizeInfo);
136
        }
137

  
138
        private void dwgControl_SizeChanged(object sender, SizeChangedEventArgs e)
139
        {
140
            if (e.NewSize != e.PreviousSize)
141
            {
142
                dwgControl.ControlSizeChanged(e.NewSize);
143
            }
144
        }
145

  
146
        private void FileExport()
147
        {
148
            //SaveDig.FileName = "commentstring"; // Default file name
149
            // SaveDig.DefaultExt = ".json"; // Default file exte1nsion
150
            SaveDig.FilterIndex = 1;
151
            // SaveDig.Filter = "JSON Configuration|*.json";
152

  
153
            SaveDig.DefaultExt = ".dwg";
154
            SaveDig.Filter = "DWG files (.dwg)|*.dwg";
155

  
156
            SaveDig.InitialDirectory = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "configuration");
157

  
158
            SaveDig.ShowDialog();
159

  
160
            if (!string.IsNullOrEmpty(SaveDig.FileName))
161
            {
162
                //  File.WriteAllText(SaveDig.FileName, data);
163
                // File.WriteAllLines(SaveDig.FileName, data);
164
            }
165
        }
166

  
167
        private void DwgControl_MouseDown(object sender, MouseButtonEventArgs e)
168
        {
169
            //OdGsDCPoint[] pts = dwgControl.SelectionPointsByPointOnScreen(e.X, e.Y);
170
            OdGePoint3d point = dwgControl.PointCheck(sender, e, drawType);
171
            if (drawType == DrawType.sp)
172
            {
173
                this.cadPanel_Instance.spLabel.Text = "(" + point.x + ", " + point.y + ")";
174
                this.cadPanel_Instance.startPoint = new Point(point.x, point.y);
175
                dwgControl.DrawPoint(point, drawType);
176
                drawType = DrawType.nothing;
177
                CustomImage1.mDown = false;
178
            }
179
            else if (drawType == DrawType.ep)
180
            {
181
                this.cadPanel_Instance.epLabel.Text = "(" + point.x + ", " + point.y + ")";
182
                this.cadPanel_Instance.endPoint = new Point(point.x, point.y);
183
                dwgControl.DrawPoint(point, drawType);
184
                drawType = DrawType.nothing;
185
                CustomImage1.mDown = false;
186
            }
187
            else
188
            {
189
                CustomImage1.mDown = true;
190
            }
191
        }
192
    }
193

  
194
    class Srv : ExHostAppServices
195
    {
196
        public override bool getPassword(string dwgName, bool isXref, ref string password)
197
        {
198
            Console.WriteLine("Enter password to open drawing: {0}", dwgName);
199
            password = Console.ReadLine().ToUpper();
200
            return password != "";
201
        }
202

  
203
        public override String product()
204
        {
205
            return String.Format("Teigha.NET");
206
        }
207
    }
208
}
KCOM/Controls/CustomImage1.xaml
1
<UserControl x:Class="KCOM.Controls.CustomImage1"
2
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
5
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
6
             xmlns:local="clr-namespace:KCOM.Controls"
7
             mc:Ignorable="d">
8

  
9
        <Canvas  x:Name="canvas">
10
            <Image x:Name="renderImage" Source="oda.bmp" />
11
        </Canvas>
12

  
13
</UserControl>
KCOM/Controls/CustomImage1.xaml.cs
1
using System;
2
using System.Windows;
3
using System.Windows.Controls;
4
using System.Windows.Input;
5
using System.Windows.Media;
6
using System.Windows.Shapes;
7
using System.Windows.Interop;
8
using Teigha.Core;
9
using System.IO;
10
using System.Reflection;
11
using Teigha.TD;
12

  
13
namespace KCOM.Controls
14
{
15
    /// <summary>
16
    /// CustomImage1.xaml에 대한 상호 작용 논리
17
    /// </summary>
18
    public partial class CustomImage1 : UserControl
19
    {
20
        private Point startPoint = new Point(0, 0);
21
        private Point curPoint = new Point(0, 0);
22
        private Point endPoint = new Point(0, 0);
23
        private TeighaD3DImage mTeighaD3DImage = null;
24
        public String FilePath
25
        {
26
            get
27
            {
28
                if (null == mTeighaD3DImage)
29
                {
30
                    return pFilePath;
31
                }
32
                return mTeighaD3DImage.FilePath;
33
            }
34
            set
35
            {
36
                if (null != mTeighaD3DImage)
37
                {
38
                    if (String.Empty == pFilePath)
39
                    {
40
                        renderImage.Source = mTeighaD3DImage;
41
                    }
42
                    mTeighaD3DImage.FilePath = value;
43
                }
44
                pFilePath = value;
45
            }
46
        }
47

  
48
        public void DeleteContext()
49
        {
50
            mTeighaD3DImage.DeleteContext();
51
        }
52

  
53
        public void PointClear()
54
        {
55
            startPoint = new Point(0, 0);
56
            endPoint = new Point(0, 0);
57
            mTeighaD3DImage.ClearPoint();
58
        }
59

  
60
        public void DrawPoint(OdGePoint3d point, DrawType drawType)
61
        {
62
            mTeighaD3DImage.DrawPoint(point, drawType);
63
        }
64

  
65
        public OdGePoint3d PointCheck(object sender, MouseButtonEventArgs e, DrawType drawType)
66
        {
67
            OdGePoint3d odaPoint = new OdGePoint3d(0, 0, 0);
68
            startPoint = e.GetPosition(renderImage);
69
            if (drawType == DrawType.sp)
70
            {
71
                //curPoint = e.GetPosition(renderImage);                
72
                odaPoint = mTeighaD3DImage.ScreenPointToWorld(startPoint);
73
                //odaPoint = mTeighaD3DImage.SelectionPointsByPointOnScreen(startPoint.X, startPoint.Y);
74
            }
75
            else if (drawType == DrawType.ep)
76
            {
77
                //curPoint = e.GetPosition(renderImage);
78
                odaPoint = mTeighaD3DImage.ScreenPointToWorld(startPoint);
79
                //odaPoint = mTeighaD3DImage.SelectionPointsByPointOnScreen(endPoint.X, endPoint.Y);
80
            }
81

  
82
            return odaPoint;
83
        }
84

  
85
        public OdGePoint3d[] PointLoad()
86
        {
87
            return mTeighaD3DImage.PointLoad();
88
        }
89

  
90
        private String pFilePath = String.Empty;
91
        public void SetInvisibleWin(Window win)
92
        {
93
            HwndSource source = PresentationSource.FromVisual(win) as HwndSource;
94
            mTeighaD3DImage.wndSource = source;
95
        }
96

  
97
        public CustomImage1()
98
        {
99
            InitializeComponent();
100
            mTeighaD3DImage = new TeighaD3DImage();
101
        }
102

  
103
        public void ControlSizeChanged(Size size)
104
        {
105
            mTeighaD3DImage.OnRenderSizeChanged(size);
106
        }
107

  
108
        public override void EndInit()
109
        {
110
            base.EndInit();
111
            if (String.Empty != pFilePath)
112
            {
113
                mTeighaD3DImage.FilePath = pFilePath;
114
                renderImage.Source = mTeighaD3DImage;
115
            }
116
        }
117

  
118
        protected override void OnMouseWheel(MouseWheelEventArgs e)
119
        {
120
            startPoint = e.GetPosition(renderImage);
121
            mTeighaD3DImage.OnMouseWheel(e, startPoint);
122
            //mTeighaD3DImage.Zoom(e.Delta > 0);
123
        }
124
        public static bool mDown = false;
125
        protected override void OnMouseMove(MouseEventArgs e)
126
        {
127
            curPoint = e.GetPosition(renderImage);
128

  
129
            if (mDown)
130
            {
131
                //mTeighaD3DImage.Dolly(startPoint.X - curPoint.X, curPoint.Y - startPoint.Y, 0);
132
                mTeighaD3DImage.OnMouseDolly(e, startPoint, curPoint);
133
                startPoint = curPoint;
134
            }
135
            base.OnMouseMove(e);
136
        }
137
        protected override void OnMouseDown(MouseButtonEventArgs e)
138
        {
139
            mDown = true;
140
            //  curPoint = e.GetPosition(renderImage);
141
            curPoint = e.GetPosition(renderImage);
142
            // startPoint = e.GetPosition(renderImage);
143
            base.OnMouseDown(e);
144
        }
145
        protected override void OnMouseUp(MouseButtonEventArgs e)
146
        {
147
            mDown = false;
148
            base.OnMouseUp(e);
149
        }
150

  
151
    }
152
}
KCOM/Controls/CustomImage2.xaml
1
<UserControl x:Class="KCOM.Controls.CustomImage2"
2
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
5
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
6
             xmlns:local="clr-namespace:KCOM.Controls"
7
             mc:Ignorable="d" >
8
    <Canvas  x:Name="canvas">
9
        <Image x:Name="renderImage" Source="oda.bmp" />
10
    </Canvas>
11
</UserControl>
KCOM/Controls/CustomImage2.xaml.cs
1
using System;
2
using System.Windows;
3
using System.Windows.Controls;
4
using System.Windows.Input;
5
using System.Windows.Media;
6
using System.Windows.Shapes;
7
using System.Windows.Interop;
8
using Teigha.Core;
9
using System.IO;
10
using System.Reflection;
11
using Teigha.TD;
12

  
13
namespace KCOM.Controls
14
{
15
    public partial class CustomImage2 : UserControl
16
    {
17
        private Point startPoint = new Point(0, 0);
18
        private Point curPoint = new Point(0, 0);
19
        private Point endPoint = new Point(0, 0);
20
        private TeighaD3DImageResult mTeighaD3DImageResult = null;
21
        public String FilePath
22
        {
23
            get
24
            {
25
                if (null == mTeighaD3DImageResult)
26
                {
27
                    return pFilePath;
28
                }
29
                return mTeighaD3DImageResult.FilePath;
30
            }
31
            set
32
            {
33
                if (null != mTeighaD3DImageResult)
34
                {
35
                    if (String.Empty == pFilePath)
36
                    {
37
                        renderImage.Source = mTeighaD3DImageResult;
38
                    }
39
                    mTeighaD3DImageResult.FilePath = value;
40
                }
41
                pFilePath = value;
42
            }
43
        }
44

  
45
        public void DeleteContext()
46
        {
47
            mTeighaD3DImageResult.DeleteContext();
48
        }
49

  
50
        public void PointClear()
51
        {
52
            startPoint = new Point(0, 0);
53
            endPoint = new Point(0, 0);
54
            mTeighaD3DImageResult.ClearPoint();
55
        }
56

  
57
        public void DrawPoint(OdGePoint3d point, DrawType drawType)
58
        {
59
            mTeighaD3DImageResult.DrawPoint(point, drawType);
60
        }
61

  
62
        public OdGePoint3d PointCheck(object sender, MouseButtonEventArgs e, DrawType drawType)
63
        {
64
            OdGePoint3d odaPoint = new OdGePoint3d(0, 0, 0);
65
            startPoint = e.GetPosition(renderImage);
66
            if (drawType == DrawType.sp)
67
            {
68
                //curPoint = e.GetPosition(renderImage);                
69
                odaPoint = mTeighaD3DImageResult.ScreenPointToWorld(startPoint);
70
                //odaPoint = mTeighaD3DImageResult.SelectionPointsByPointOnScreen(startPoint.X, startPoint.Y);
71
            }
72
            else if (drawType == DrawType.ep)
73
            {
74
                //curPoint = e.GetPosition(renderImage);
75
                odaPoint = mTeighaD3DImageResult.ScreenPointToWorld(startPoint);
76
                //odaPoint = mTeighaD3DImageResult.SelectionPointsByPointOnScreen(endPoint.X, endPoint.Y);
77
            }
78

  
79
            return odaPoint;
80
        }
81

  
82
        public OdGePoint3d[] PointLoad()
83
        {
84
            return mTeighaD3DImageResult.PointLoad();
85
        }
86

  
87
        private String pFilePath = String.Empty;
88
        public void SetInvisibleWin(Window win)
89
        {
90
            HwndSource source = PresentationSource.FromVisual(win) as HwndSource;
91
            mTeighaD3DImageResult.wndSource = source;
92
        }
93

  
94
        public CustomImage2()
95
        {
96
            InitializeComponent();
97
            mTeighaD3DImageResult = new TeighaD3DImageResult();
98
        }
99

  
100
        public void ControlSizeChanged(Size size)
101
        {
102
            mTeighaD3DImageResult.OnRenderSizeChanged(size);
103
        }
104

  
105
        public override void EndInit()
106
        {
107
            base.EndInit();
108
            if (String.Empty != pFilePath)
109
            {
110
                mTeighaD3DImageResult.FilePath = pFilePath;
111
                renderImage.Source = mTeighaD3DImageResult;
112
            }
113
        }
114

  
115
        protected override void OnMouseWheel(MouseWheelEventArgs e)
116
        {
117
            startPoint = e.GetPosition(renderImage);
118
            mTeighaD3DImageResult.OnMouseWheel(e, startPoint);
119
            //mTeighaD3DImageResult.Zoom(e.Delta > 0);
120
        }
121
        public static bool mDown = false;
122
        protected override void OnMouseMove(MouseEventArgs e)
123
        {
124
            curPoint = e.GetPosition(renderImage);
125

  
126
            if (mDown)
127
            {
128
                //mTeighaD3DImageResult.Dolly(startPoint.X - curPoint.X, curPoint.Y - startPoint.Y, 0);
129
                mTeighaD3DImageResult.OnMouseDolly(e, startPoint, curPoint);
130
                startPoint = curPoint;
131
            }
132
            base.OnMouseMove(e);
133
        }
134
        protected override void OnMouseDown(MouseButtonEventArgs e)
135
        {
136
            mDown = true;
137
            //  curPoint = e.GetPosition(renderImage);
138
            curPoint = e.GetPosition(renderImage);
139
            // startPoint = e.GetPosition(renderImage);
140
            base.OnMouseDown(e);
141
        }
142
        protected override void OnMouseUp(MouseButtonEventArgs e)
143
        {
144
            mDown = false;
145
            base.OnMouseUp(e);
146
        }
147

  
148
    }
149
}
KCOM/Controls/OdActivationInfo.cs
1
///////////////////////////////////////////////////////////////////////////////
2
// Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3
// All rights reserved.
4
//
5
// This software and its documentation and related materials are owned by
6
// the Alliance. The software may only be incorporated into application
7
// programs owned by members of the Alliance, subject to a signed
8
// Membership Agreement and Supplemental Software License Agreement with the
9
// Alliance. The structure and organization of this software are the valuable
10
// trade secrets of the Alliance and its suppliers. The software is also
11
// protected by copyright law and international treaty provisions. Application
12
// programs incorporating this software must include the following statement
13
// with their copyright notices:
14
//
15
//   This application incorporates Teigha(R) software pursuant to a license
16
//   agreement with Open Design Alliance.
17
//   Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18
//   All rights reserved.
19
//
20
// By use of this software, its documentation or related materials, you
21
// acknowledge and accept the above terms.
22
///////////////////////////////////////////////////////////////////////////////
23
using System;
24
#pragma warning disable 618
25

  
26
public sealed class ActivationData
27
{
28
    public const string userInfo = "RE9GVEVDSA==";
29
    public const string userSignature = "IzeEY3SfLJEP6xxOKqTg5PVH7T/y3y5QQ9pn13R+It3C7nlBpCq5nOU3eeWwFFyxs2TFptaLwzL9sU04ddz8oY7pId8IF9Tb/Dq5MqQMWIxZFvA3hcxVRizR/0lIZrL4C3fbyBCYpa0KRAgsikZ0fwD9/Cgc5t6Yf531c0wxxZoEKKLKWri+WZVivftFbdOUv4RgyekQmrbECJAmtVksOfMZovzBnwPaCNkyREuoyBg82uiAawiuCP7kkVNJ9z1kt23b2ZmG2F0UPlsm9pFFcZgVBNTBEChGyZPYa/dzJrwjZ6yVjlD3JOdMfrnU/MIL6UdhWqaEMDKkjUyILSCMla+NpR+gXQG6a0pAVW5hVMTVcLSLOtaF7OSx4ih3/QfWTmtnHdBfxMhAKTnp4aSGTqEiTimYxFfDAwwiSk2HqBsR9w03hMygbwV1bgMZaGmQuHyQMBQ9k02fk/JNNVqIqns637/6HXS+kMWLkXs5gdci6bpal8OB5Z2AmXltRWlhy5Fjfo+gsx3wjC7+UmZ8O4V+7kBjOKvY0X25bGb2jNixdKpYN3z9clkSKe6Mzn/lYCy28yyuWN3iGztwIcrRqM2Fe87rYuslPQT9p7d6DPcFU/GZ6VuwfnpG4Ltak/A4LSvqsozCZ9ryaHoYaWXiUh8SaijgcnFasO0E9Gnh5gk=";
30
};
KCOM/Controls/SymbolPrompt.xaml
1
<UserControl x:Class="KCOM.Controls.SymbolPrompt"
2
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
3
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
4
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
5
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
6
             xmlns:local="clr-namespace:KCOM.Controls"
7
             mc:Ignorable="d" 
8
             Height="100" d:DesignWidth="400">
9
    <Grid Background="#FFEEEEF2">
10
        <Grid.ColumnDefinitions>
11
            <ColumnDefinition Width="50"/>
12
            <ColumnDefinition Width="350">
13
            </ColumnDefinition>
14
        </Grid.ColumnDefinitions>
15
<!--
16
        <Grid.RowDefinitions>
17
            <RowDefinition Height="35"/>
18
            <RowDefinition Height="25"/>
19
            <RowDefinition Height="1"/>
20
            <RowDefinition/>
21
        </Grid.RowDefinitions>
22
-->
23
        <StackPanel Grid.Column="0" Margin="0,10,0,0">
24
            <Image Height="40" Source="/KCOM;component/Resources/Images/MenuImage_New/selectInk.png"/>
25
        </StackPanel>
26
        <StackPanel Grid.Column="1">
27
            <DockPanel Grid.Row="0" Margin="0,10,0,0" HorizontalAlignment="Left">
28
                <Label>Name :</Label>
29
                <TextBox Margin="5" Width="300" x:Name="symbolName" />
30
            </DockPanel>
31
            <DockPanel Grid.Row="1" Margin="0,0,0,0" HorizontalAlignment="Left" >
32
                <RadioButton Content="SVG" Name="svgRadioBox" IsChecked="True" Margin="5"/>
33
                <RadioButton Content="PNG" Name="pngRadioBox" Margin="5"/>                
34
                <!-- IsEnabled="{Binding ElementName=DeleteEverythingCheckbox, Path=IsChecked}" Text="Here is some text to edit" -->
35
            </DockPanel>
36
            <StackPanel Grid.Row="2" Background="#FFCCCEDB"></StackPanel>
37
            <StackPanel Grid.Row="3" Margin="0,0,10,0" HorizontalAlignment="Right" VerticalAlignment="Center">
38
                <Button Width="70" x:Name="BtnOK" PreviewKeyDown="BtnOK_PreviewKeyDown" PreviewMouseLeftButtonDown="BtnOK_MouseLeftButtonDown">OK</Button>
39
            </StackPanel>
40

  
41
        </StackPanel>
42
       
43
    </Grid>
44
</UserControl>
KCOM/Controls/SymbolPrompt.xaml.cs
1
using System;
2
using System.Collections.Generic;
3
using System.Linq;
4
using System.Text;
5
using System.Threading.Tasks;
6
using System.Windows;
7
using System.Windows.Controls;
8
using System.Windows.Data;
9
using System.Windows.Documents;
10
using System.Windows.Input;
11
using System.Windows.Media;
12
using System.Windows.Media.Imaging;
13
using System.Windows.Navigation;
14
using System.Windows.Shapes;
15

  
16
namespace KCOM.Controls
17
{
18
    /// <summary>
19
    /// SymbolPopup.xaml에 대한 상호 작용 논리
20
    /// </summary>
21
    public partial class SymbolPrompt : UserControl
22
    {
23
        public SymbolPrompt()
24
        {
25
            InitializeComponent();
26
            //t;
27
        }
28
        
29
        private void BtnOK_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
30
        {
31
            Window window = Window.GetWindow(this);
32
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.symbolname = symbolName.Text;
33
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.symbolsvg = svgRadioBox.IsChecked.Value;
34
            Common.ViewerDataModel.Instance.SystemMain.dzMainMenu.symbolpng = pngRadioBox.IsChecked.Value;
35
            window.Close();
36
        }
37

  
38
        private void BtnOK_PreviewKeyDown(object sender, KeyEventArgs e)
39
        {
40
            Window window = Window.GetWindow(this);
41
            window.Close();
42
        }
43
    }
44
}
KCOM/Controls/TeighaD3DImage.cs
1
/////////////////////////////////////////////////////////////////////////////// 
2
// Copyright (C) 2002-2018, Open Design Alliance (the "Alliance"). 
3
// All rights reserved. 
4
// 
5
// This software and its documentation and related materials are owned by 
6
// the Alliance. The software may only be incorporated into application 
7
// programs owned by members of the Alliance, subject to a signed 
8
// Membership Agreement and Supplemental Software License Agreement with the
9
// Alliance. The structure and organization of this software are the valuable  
10
// trade secrets of the Alliance and its suppliers. The software is also 
11
// protected by copyright law and international treaty provisions. Application  
12
// programs incorporating this software must include the following statement 
13
// with their copyright notices:
14
//   
15
//   This application incorporates Teigha(R) software pursuant to a license 
16
//   agreement with Open Design Alliance.
17
//   Teigha(R) Copyright (C) 2002-2018 by Open Design Alliance. 
18
//   All rights reserved.
19
//
20
// By use of this software, its documentation or related materials, you 
21
// acknowledge and accept the above terms.
22
///////////////////////////////////////////////////////////////////////////////
23
///
24
using System;
25
using System.Windows.Interop;
26
using Teigha.Core;
27
using Teigha.TD;
28
using System.Windows;
29
using System.Diagnostics;
30
using System.Windows.Controls;
31
using System.Threading;
32
using Newtonsoft.Json;
33
using System.IO;
34
using System.Reflection;
35
using System.Windows.Input;
36

  
37
namespace KCOM.Controls
38
{
39
    internal class TeighaD3DImage : D3DImage
40
    {
41
        public static Size NewSize = new Size(0, 0);
42
        private static OdDbDatabase TDDatabase = null;
43

  
44
        public delegate void LoadFileDelegate(String fPath);
45
        public delegate void RunTestDelegate();
46

  
47
        public LoadFileDelegate loadFile = null;
48

  
49
        private OdRxObject odRxObjectSurface = null;
50
        private OdRxVariantValue surfaceVariantValue = null;
51

  
52
        class SystemServices : RxSystemServicesImpl
53
        {
54
            public SystemServices()
55
            {
56
                Teigha.Core.Globals.odActivate(ActivationData.userInfo, ActivationData.userSignature);
57
            }
58
        }
59

  
60
        public String FilePath
61
        {
62
            get { return pFilePath; }
63
            set
64
            {
65
                pFilePath = value;
66
                if (null != loadFile)
67
                {
68
                    loadFile(pFilePath);
69
                }
70
            }
71
        }
72

  
73
        public OdGeExtents3d extents { get; private set; }
74

  
75
        public String pFilePath = String.Empty;
76
        private SystemServices Serv = null;
77
        public ExHostAppServices HostApp = null;
78
        uint[] curPalette;
79
        public static OdGsView pView = null;
80

  
81
        OdGsModule pGs = null;
82
        public static OdGsDevice mDevice = null;
83
        public static OdGsLayoutHelper mHelper = null;
84

  
85
        public OdGePoint3d[] PointLoad()
86
        {
87
            OdGePoint3d[] pt = new OdGePoint3d[4];
88
            OdGePoint3d extMax = TDDatabase.getEXTMAX();
89
            OdGePoint3d extMin = TDDatabase.getEXTMIN();
90

  
91
            pt[0] = extMin; //left, bottom
92
            pt[1] = new OdGePoint3d(0.0, extMax.y, 0.0); //left, top
93
            pt[2] = extMax; //right, top
94
            pt[3] = new OdGePoint3d(extMax.x, 0.0, 0.0); //right, bottom            
95

  
96
            if (pView != null)
97
            {
98
                Lock();
99
                using (startPolyLine = OdDbPolyline.createObject())
100
                {
101
                    startPolyLine.addVertexAt(0, new OdGePoint2d(pt[1].x - 4, pt[1].y - 4));
102
                    startPolyLine.addVertexAt(1, new OdGePoint2d(pt[1].x - 4, pt[1].y + 4));
103
                    startPolyLine.addVertexAt(2, new OdGePoint2d(pt[1].x + 4, pt[1].y + 4));
104
                    startPolyLine.addVertexAt(3, new OdGePoint2d(pt[1].x + 4, pt[1].y - 4));
105
                    startPolyLine.setClosed(true);
106
                    startPolyLine.setLineWeight(LineWeight.kLnWt211);
107
                    startPolyLine.setColorIndex((ushort)(OdCmEntityColor.ACIcolorMethod.kACIGreen));
108

  
109
                    OdDbBlockTableRecord model = (OdDbBlockTableRecord)TDDatabase.getModelSpaceId().safeOpenObject(OpenMode.kForWrite);
110
                    startOdDbObjectId = model.appendOdDbEntity(startPolyLine);
111
                }
112

  
113
                using (endPolyLine = OdDbPolyline.createObject())
114
                {
115
                    endPolyLine.addVertexAt(0, new OdGePoint2d(pt[3].x - 4, pt[3].y - 4));
116
                    endPolyLine.addVertexAt(1, new OdGePoint2d(pt[3].x - 4, pt[3].y + 4));
117
                    endPolyLine.addVertexAt(2, new OdGePoint2d(pt[3].x + 4, pt[3].y + 4));
118
                    endPolyLine.addVertexAt(3, new OdGePoint2d(pt[3].x + 4, pt[3].y - 4));
119
                    endPolyLine.setClosed(true);
120
                    endPolyLine.setLineWeight(LineWeight.kLnWt211);
121
                    endPolyLine.setColorIndex((ushort)(OdCmEntityColor.ACIcolorMethod.kACIGreen));
122
                    OdDbBlockTableRecord model = (OdDbBlockTableRecord)TDDatabase.getModelSpaceId().safeOpenObject(OpenMode.kForWrite);
123
                    endOdDbObjectId = model.appendOdDbEntity(endPolyLine);
124
                }
125

  
126
                mDevice.invalidate();
127
                mDevice.update(new OdGsDCRect(0, (int)NewSize.Width, (int)NewSize.Height, 0));//mDevice.update();
128
                UpdateDirtyRect();
129
                Unlock();
130
            }
131
            return pt;
132
        }
133

  
134
        public HwndSource wndSource = null;
135

  
136
        public TeighaD3DImage()
137
        {
138
            Serv = new SystemServices();
139
            HostApp = new CustomServices();
140
            TD_Db.odInitialize(Serv);
141
            Globals.odgsInitialize();
142
            InitializeGDIModule();
143
            loadFile = new LoadFileDelegate(LoadDWGFile);
144

  
145
            if (String.Empty != pFilePath)
146
            {
147
                loadFile(pFilePath);
148
                //InitializeSurface();
149
            }
150
        }
151
        private static OdGePoint3d getWorldCoordinateByScreen(OdGsLayoutHelper hDevice, OdGePoint2d screenPoint)
152
        {
153
            pView = hDevice.activeView();
154

  
155
            //directions, origin, etc
156
            OdGePoint3d target = pView.target();
157
            OdGeVector3d direction = target - pView.position();
158
            OdGeVector3d yVector = pView.upVector();
159
            OdGeVector3d xVector = direction.crossProduct(yVector).normal();
160

  
161
            OdGePoint3d center, stepX, stepY;
162
            {
163
                center = new OdGePoint3d(target);
164
                stepX = target + xVector;
165
                stepY = target + yVector;
166

  
167
                OdGeMatrix3d matrix = pView.worldToDeviceMatrix();
168
                stepX.transformBy(matrix);
169
                stepY.transformBy(matrix);
170
                center.transformBy(matrix);
171
            }
172

  
173
            //make the calculation
174
            OdGePoint3d result;
175
            {
176
                double x, y;
177
                x = (screenPoint.x - center.x) / (stepX.x - center.x);
178
                y = (screenPoint.y - center.y) / (stepY.y - center.y);
179

  
180
                result = target + xVector * x + yVector * y;
181
            }
182

  
183
            return result;
184
        }
185

  
186

  
187
        public void OnMouseWheel(MouseWheelEventArgs e, Point cp)
188
        {
189
            if (mDevice == null)
190
                return;
191
            OdGePoint2d correctScreenPoint = new OdGePoint2d(cp.X, cp.Y);
192

  
193
            OdGePoint3d worldPoint = getWorldCoordinateByScreen(mHelper, correctScreenPoint);
194

  
195
            //OnZoom(e.Delta / 120);
196
            Zoom(e.Delta > 0);
197
            //shift back
198
            pView = mHelper.activeView();
199

  
200
            //get new screen point of the same world point
201
            OdGeMatrix3d worldToDevice = pView.worldToDeviceMatrix();
202
            OdGePoint3d newScreenPoint = worldToDevice * worldPoint;
203

  
204
            //get world points on the focal plane
205
            OdGePoint3d movingPoint = getWorldCoordinateByScreen(mHelper, new OdGePoint2d(newScreenPoint.x, newScreenPoint.y));
206
            OdGePoint3d destinationPoint = getWorldCoordinateByScreen(mHelper, correctScreenPoint);
207

  
208
            OdGePoint3d position = pView.position(), target = pView.target();
209
            OdGeVector3d upVector = pView.upVector();
210
            double width = pView.fieldWidth(), height = pView.fieldHeight();
211
            bool isPerspective = pView.isPerspective();
212

  
213
            //shift the camera so points coincide
214
            OdGeVector3d offset = destinationPoint - movingPoint;
215
            position -= offset;
216
            target -= offset;
217

  
218
            pView.setView(position, target, upVector, width, height, isPerspective ? OdGsView.Projection.kPerspective : OdGsView.Projection.kParallel);
219

  
220
        }
221

  
222
        public void LoadDWGFile(String filePath)
223
        {
224
            TDDatabase = HostApp.readFile(filePath);
225
            if (null == TDDatabase)
226
            {
227
                return;
228
            }
229
            // Create a new OdGsDevice object, and associate with the vectorization GsDevice
230
            mDevice = pGs.createDevice();
231
            // use the wndSource to set the WindowHWND parameter of device - we put the handle of auxiliary invisible window
232
            mDevice.properties().putAt("WindowHWND", new OdRxVariantValue(wndSource.Handle.ToInt32()));
233
            // Set the device background color and palette
234
            curPalette = AllPalettes.getLightPalette();
235
            mDevice.setBackgroundColor(curPalette[0]);
236
            mDevice.setLogicalPalette(curPalette, 256);
237

  
238
            OdGiContextForDbDatabase ctx1 = OdGiContextForDbDatabase.createObject();
239
            ctx1.enableGsModel(true);
240
            ctx1.setDatabase(TDDatabase);
241
            mDevice.setUserGiContext(ctx1);
242
            //   mDevice = (OdGsDevice)TD_Db.setupActiveLayoutViews(mDevice, ctx1);
243
            mHelper = CreateLayoutHelper(mDevice, ctx1);
244

  
245

  
246
            bool bModelSpace = TDDatabase.getTILEMODE();
247

  
248
            pView = mDevice.viewAt(0);
249
            OdAbstractViewPE pViewPe = OdAbstractViewPE.cast(pView);
250
            pViewPe.zoomExtents(pView);
251
            //  OdDbObject pView = TDDatabase.activeViewportId().openObject();
252
            //  OdDbAbstractViewportData pViewPE = OdDbAbstractViewportData.cast(pView);
253
            //   pViewPE.zoomExtents(pView);
254

  
255
            if ((NewSize.Width != 0) && (NewSize.Height != 0))
256
            {
257
                mDevice.onSize(new OdGsDCRect(0, (int)NewSize.Width, (int)NewSize.Height, 0));
258
            }
259
            else
260
            {
261
                mDevice.onSize(new OdGsDCRect(0, 300, 300, 0));
262
            }
263
            InitializeSurface();
264
            // call OnRnderSizeChanged to adjust drawing to size of control, not to size of invisible window
265
            OnRenderSizeChanged(NewSize);
266
        }
267

  
268
        public static OdGiContextForDbDatabase CreateContextForDbDatabase(OdDbDatabase db)
269
        {
270
            OdGiContextForDbDatabase ctx = OdGiContextForDbDatabase.createObject();
271

  
272
            ctx.enableGsModel(true);
273

  
274
            ctx.setDatabase(db);
275

  
276
            return ctx;
277
        }
278
        public static OdGsLayoutHelper CreateLayoutHelper(OdGsDevice pDevice, OdGiContextForDbDatabase ctx)
279
        {
280
            OdGsLayoutHelper hDevice = TD_Db.setupActiveLayoutViews(pDevice, ctx);
281
            OdDbDatabase db = ctx.getDatabase();
282

  
283
            // Set the device background color and palette
284
            uint[] CurPalette = Teigha.Core.AllPalettes.getLightPalette();
285
            hDevice.setBackgroundColor(CurPalette[0]);
286
            hDevice.setLogicalPalette(CurPalette, 256);
287

  
288
            // Return true if and only the current layout is a paper space layout
289
            bool bModelSpace = db.getTILEMODE();
290

  
291
            // Set the viewport border properties
292
            SetViewportBorderProperties(hDevice, !bModelSpace, CurPalette[7]);
293

  
294
            //Set render mode
295
            hDevice.activeView().setMode(OdGsView.RenderMode.kFlatShadedWithWireframe);
296

  
297
            return hDevice;
298
        }
299

  
300
        private static void SetViewportBorderProperties(OdGsLayoutHelper pDevice, bool bModel, uint color7)
301
        {
302
            int n = pDevice.numViews();
303

  
304
            if (n > 1)
305
            {
306
                for (int i = bModel ? 0 : 1; i < n; ++i)
307
                {
308
                    // Get the viewport
309
                    pView = pDevice.viewAt(i);
310

  
311
                    // Make it visible
312
                    pView.setViewportBorderVisibility(true);
313

  
314
                    // Set the color and width
315
                    pView.setViewportBorderProperties(color7, 1);
316
                }
317
            }
318
        }
319

  
320
        private static OdGsDCPoint[] SelectionPointsByPointOnScreen(OdGsLayoutHelper dev, OdDbDatabase db, int x, int y)
321
        {
322
            OdGePoint3d pt = ScreenPointToWorld(dev, x, y);
323
            pt = pt.transformBy(dev.activeView().worldToDeviceMatrix());
324
            short pb = db.getSysVar("PICKBOX").getInt16();
325
            OdGsDCPoint pt1 = new OdGsDCPoint((int)pt.x - pb, (int)pt.y - pb);
326
            OdGsDCPoint pt2 = new OdGsDCPoint((int)pt.x + pb, (int)pt.y + pb);
327
            OdGsDCPoint[] pts = new OdGsDCPoint[] { pt1, pt2 };
328
            return pts;
329
        }
330

  
331
        public static OdGePoint3d ScreenPointToWorld(OdGsLayoutHelper helperDevice, double x, double y)
332
        {
333
            MemoryTransaction tr = MemoryManager.GetMemoryManager().StartTransaction();
334
            OdGsView pView = helperDevice.activeView();
335
            OdGePoint3d wcsPt = new OdGePoint3d(x, y, 0.0);
336
            wcsPt = wcsPt.transformBy((pView.screenMatrix() * pView.projectionMatrix()).inverse());
337
            wcsPt = new OdGePoint3d(wcsPt.x, wcsPt.y, 0.0);
338
            OdAbstractViewPE pVpPE = OdAbstractViewPE.cast(pView);
339
            OdGePoint3d result = wcsPt.transformBy(pVpPE.eyeToWorld(pView));
340
            MemoryManager.GetMemoryManager().StopTransaction(tr);
341
            return result;
342
        }
343

  
344
        private void InitializeGDIModule()
345
        {
346
            try
347
            {
348
                pGs = (OdGsModule)Globals.odrxDynamicLinker().loadModule("WinDirectX.txv", false);
349
            }
350
            catch (Exception err)
351
            {
352
                MessageBox.Show(err.Message, "Error1");
353
                return;
354
            }
355
        }
356

  
357
        public void OnRenderSizeChanged(Size size)
358
        {
359
            NewSize = size;
360
            if (null != mDevice)
... 이 차이점은 표시할 수 있는 최대 줄수를 초과해서 이 차이점은 잘렸습니다.

내보내기 Unified diff

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