//this is the method that the deleagte will execute
 public void UpdateDWGRun(DWGFileModel objDWG, int recordCount)
 {
     //Update Datacontext
     _DWGRun.MainGrid.DataContext = objDWG;
     //Increment progressbar
     _DWGRun.progressBar.Value = recordCount;
 }
        private void btAddDWG_Click(object sender, RoutedEventArgs e)
        {
            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Multiselect = true;
            dlg.Title       = "Add DWG";
            dlg.Filter      = "DWG files (*.dwg)|*.dwg";

            if (dlg.ShowDialog() == true)
            {
                foreach (string DWGFile in dlg.FileNames)
                {
                    DWGFileModel objDWG = new DWGFileModel(DWGFile);
                    ArCaDWGEdController.DWGCollection.LstDWG.Add(objDWG);
                }
            }
        }
        public static void DoProcedures(DWGFileModel objDWG)
        {
            //Restart change status
            objDWG.IsChanged = false;

            Database db = new Database(false, true);

            using (db)
            {
                try
                {
                    objDWG.MessageProcess = "Open file: " + objDWG.Name;

                    db.ReadDwgFile(objDWG.FilePath, FileShare.ReadWrite, false, "");
                    _bmp = db.ThumbnailBitmap;
                    objDWG.MessageProcess = "Processing file: " + objDWG.Name;

                    using (Transaction trans = db.TransactionManager.StartTransaction())
                    {
                        foreach (Procedure objProcedure in _ListProcedures)
                        {
                            objProcedure.Run(db, trans, objDWG);
                        }

                        trans.Commit();
                    }

                    if (objDWG.IsChanged)
                    {
                        db.ThumbnailBitmap    = _bmp;
                        objDWG.MessageProcess = "Saving file: " + objDWG.Name;
                        db.SaveAs(objDWG.FilePath, DwgVersion.Current);
                    }
                }
                catch (System.Exception ex)
                {
                    objDWG.MessageProcess = string.Format("Problem processing file: {0} - \"{1}\"", objDWG.Name, ex.Message);
                }
            }
        }
 public void Run(Database db, Transaction tr, DWGFileModel objDWG)
 {
     _evRun.Invoke(db, tr, objDWG);
 }