Ejemplo n.º 1
0
        static public void Plan2LayTrans()
        {
            try
            {
#if BRX_APP
                return;
#else
                _AcAp.Document doc = _AcAp.Application.DocumentManager.MdiActiveDocument;
                using (_AcAp.DocumentLock m_doclock = doc.LockDocument())
                {
                    _AcEd.Editor ed = _AcAp.Application.DocumentManager.MdiActiveDocument.Editor;
                    // First let's use the editor method, GetFileNameForOpen()
                    _AcEd.PromptOpenFileOptions opts = new _AcEd.PromptOpenFileOptions("Excel-Datei für Layer-Infos");
                    opts.Filter = "Excel (*.xlsx)|*.xlsx|Excel alt (*.xls)|*.xls";
                    _AcEd.PromptFileNameResult pr = ed.GetFileNameForOpen(opts);
                    if (pr.Status != _AcEd.PromptStatus.OK)
                    {
                        return;
                    }

                    //_AcWnd.OpenFileDialog ofd = new _AcWnd.OpenFileDialog("Excel-Datei", "", "xlsx", "LayTrans", _AcWnd.OpenFileDialog.OpenFileDialogFlags.AllowAnyExtension);
                    //System.Windows.Forms.DialogResult dr = ofd.ShowDialog();
                    //if (dr != System.Windows.Forms.DialogResult.OK)  return;

                    string fileName = pr.StringResult;

                    Engine engine = new Engine();
                    var    ok     = engine.LayTrans(fileName);
                    if (!ok)
                    {
                        _AcAp.Application.ShowAlertDialog(string.Format(CultureInfo.CurrentCulture, "Fehler in LayTrans!"));
                    }
                    else
                    {
                        string msg = string.Format(CultureInfo.CurrentCulture, "LayTrans wurde erfolgreich beendet.");
                        _AcAp.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage(msg);
                        log.Info(msg);
                    }
                }
#endif
            }
            catch (System.Exception ex)
            {
                log.Error(ex.Message, ex);
                _AcAp.Application.ShowAlertDialog(string.Format(CultureInfo.CurrentCulture, "Fehler in Plan2LayTrans aufgetreten! {0}", ex.Message));
            }
        }