using System;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.GraphicsInterface;
using Autodesk.Windows;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
using System.Windows.Markup;
using System.Xml;
using System.IO;
using iDwgFieldMgd;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;
using WinApp = System.Windows.Forms.Application;
public class Script
{
private ObjectId _idField;
private ObjectId _idFrom;
private ObjectId _idTo;
private Window wintest;
public string Regen(string hField, string hFrom, string hTo)
{
Document doc = AcadApp.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
try
{
Database db = doc.Database;
long ln1 = Convert.ToInt64(hField, 16);
Handle hn1 = new Handle(ln1);
_idField = db.GetObjectId(false, hn1, 0);
long ln2 = Convert.ToInt64(hFrom, 16);
if (ln2 > 0)
{
Handle hn2 = new Handle(ln2);
_idFrom = db.GetObjectId(false, hn2, 0);
}
long ln3 = Convert.ToInt64(hTo, 16);
if (ln3 > 0)
{
Handle hn3 = new Handle(ln3);
_idTo = db.GetObjectId(false, hn3, 0);
}
}
catch (Autodesk.AutoCAD.Runtime.Exception e)
{
return e.Message;
}
return "로딩됨";
}
public string Open(string hField, string hFrom, string hTo)
{
try {
//[XAML코드]Kaxaml 테스트 포스트 아이디
String codes = iDwgUtils.GetXamlCode("1658519126633352894");
StringReader sr = new StringReader(codes);
XmlReader reader = XmlReader.Create(sr);
wintest = (Window)XamlReader.Load(reader);
wintest.Title = "Kaxaml";
wintest.Show();
wintest.SizeChanged += wintest_Changed;
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message);
}
return Regen(hField, hFrom, hTo);
}
private void wintest_Changed(object sender, RoutedEventArgs e)
{
// MessageBox.Show("Dynamic windows loaded from XAML string");
}
public bool Exit(string str)
{
wintest.Close();
return true;
}
}