public static bool Jig(BlockReference ent)
            {
                try
                {
                    Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
                    BlockMovingRotating jigger = new BlockMovingRotating(ent);
                    PromptResult        pr;
                    do
                    {
                        pr = ed.Drag(jigger);
                    } while (pr.Status != PromptStatus.Cancel &&
                             pr.Status != PromptStatus.Error &&
                             pr.Status != PromptStatus.Keyword &&
                             jigger.mCurJigFactorNumber++ <= 2);

                    return(pr.Status == PromptStatus.OK);
                }
                catch
                {
                    return(false);
                }
            }
        private static void LibraryAction(Editor ed)
        {
            if (MessageHandler.LibraryToAppActions.Count > 0)
            {
                string action = MessageHandler.LibraryToAppActions.Dequeue();
                //MessageBox.Show(action);
                Dictionary <string, string> actionD = JsonConvert.DeserializeObject <Dictionary <string, string> >(action);

                if (actionD["option"] == "OPEN")
                {
                    List <string> files = Directory.GetFiles(actionD["hyperlink"]).ToList();
                    string        dwg   = "";
                    foreach (string file in files)
                    {
                        if (file.Contains(".dwg"))
                        {
                            dwg = file;
                        }
                    }
                    if (dwg != "")
                    {
                        DocumentCollection docMgr = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
                        DocumentCollectionExtension.Open(docMgr, dwg, false);
                    }
                }
                else if (actionD["option"] == "LOAD")
                {
                    List <string> files = Directory.GetFiles(actionD["hyperlink"]).ToList();
                    string        dwg   = "";
                    foreach (string file in files)
                    {
                        if (file.Contains(".dwg"))
                        {
                            dwg = file;
                        }
                    }
                    if (dwg != "")
                    {
                        Database sourceDb = new Database(false, true);
                        Document doc      = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
                        Database cDB      = doc.Database;
                        sourceDb.ReadDwgFile(dwg, FileOpenMode.OpenForReadAndAllShare, true, ""); //Read the DWG into a side database
                        String fileName = Path.GetFileNameWithoutExtension(dwg);
                        cDB.Insert(fileName, sourceDb, false);

                        Autodesk.AutoCAD.DatabaseServices.TransactionManager tm = cDB.TransactionManager;

                        try
                        {
                            ObjectIdCollection blockIds = new ObjectIdCollection();
                            using (Transaction myT = tm.StartTransaction())
                            {
                                // Open the block table
                                BlockTable bt =
                                    (BlockTable)tm.GetObject(cDB.BlockTableId,
                                                             OpenMode.ForRead,
                                                             false);

                                BlockTableRecord btr = myT.GetObject(bt[fileName], OpenMode.ForRead) as BlockTableRecord;

                                BlockReference br = new BlockReference(Point3d.Origin, btr.ObjectId);

                                if (BlockMovingRotating.Jig(br))
                                {
                                    BlockTableRecord modelspace = myT.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
                                    modelspace.AppendEntity(br);
                                    myT.AddNewlyCreatedDBObject(br, true);
                                    myT.Commit();
                                }
                                else
                                {
                                    myT.Abort();
                                }
                                btr.Dispose();
                            }
                        }
                        catch (System.Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                    }
                }
                else if (actionD["option"] == "VIEW")
                {
                    MessageBox.Show("VIEW");
                }

                // do your AutoCAD tasks here
                //MessageBox.Show("Text received from the Library window: " + actionD);

                // reply something back
                //MessageHandler.AppToLibraryActions.Enqueue("A message from the AutoCAD plugin - " + DateTime.Now.ToString());
            }
        }