Beispiel #1
0
        public void bx_OpenTamplate()
        {
            App.Document doc = App.Application.DocumentManager.MdiActiveDocument;
            if (doc == null)
            {
                return;
            }

            string strFileName = CheckLocalRepository.GetRepository();

            App.DocumentCollection acDocMgr = App.Application.DocumentManager;

            if (System.IO.File.Exists(strFileName))
            {
                //Для 2011 автокада
#if acad2011
                acDocMgr.Open(strFileName, false);
#endif
                //Для 2012 и выше
#if !acad2011
                App.DocumentCollectionExtension.Open(acDocMgr, strFileName, false);
#endif
            }
            else
            {
                acDocMgr.MdiActiveDocument.Editor.
                WriteMessage($"Файла репозитория { strFileName} не существует.");
            }
        }
Beispiel #2
0
        private static void AddMLeader(Gem.Point2d pnt, Gem.Vector3d otstup,
                                       double scale, string layer,
                                       string mleaderStyleName, string str)
        {
            SettingsParser settings = SettingsParser.getInstance();

            App.Document acDoc   = App.Application.DocumentManager.MdiActiveDocument;
            Db.Database  acCurDb = acDoc.Database;
            using (Db.Transaction acTrans = acCurDb.TransactionManager.StartOpenCloseTransaction())
            {
                Db.BlockTable acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId,
                                                           Db.OpenMode.ForRead) as Db.BlockTable;
                Db.BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl[Db.BlockTableRecord.ModelSpace],
                                                                    Db.OpenMode.ForWrite) as Db.BlockTableRecord;
                Db.MLeader acML = new Db.MLeader();
                acML.SetDatabaseDefaults();
                acML.Layer        = layer;
                acML.MLeaderStyle = CheckLocalRepository.GetIDbyName <Db.MLeaderStyle>(acCurDb, mleaderStyleName);
                acML.ContentType  = Db.ContentType.MTextContent;
                Db.MText mText = new Db.MText();
                mText.SetDatabaseDefaults();
                mText.Contents           = str;
                mText.TextHeight         = scale;
                mText.BackgroundFill     = settings.MTextMask;
                mText.UseBackgroundColor = settings.MTextMask;


                if (settings.MTextMask)
                {
                    mText.BackgroundScaleFactor = settings.MTextMaskKoefficient;
                }

                mText.Location = (new Gem.Point3d(pnt.X, pnt.Y, 0) + otstup);
                acML.MText     = mText;
                int idx = acML.AddLeaderLine(new Gem.Point3d(pnt.X, pnt.Y, 0));

                acML.Scale = 1;


                acBlkTblRec.AppendEntity(acML);
                acTrans.AddNewlyCreatedDBObject(acML, true);
                acTrans.Commit();
            }
        }
Beispiel #3
0
        public bool Update()
        {
            //Получаю конфигурационный файл
            var config = ConfigurationManager.OpenExeConfiguration(
                Assembly.GetExecutingAssembly().Location);
            var userSection = (ClientSettingsSection)config.
                              GetSection("applicationSettings/TheodoliteStrokeParser.Properties.Settings");


            //Настройки Controller

            allScale = userSection.Settings.Get("С_ScaleListParam").Value.ValueXml.InnerText;
            //На всякий случай страхуюсь от невозможности прочитать
            allScale = (allScale != null & allScale.Length < 3) ? "500;0.5;1.5;1.5|1000;1;3;4|2000;2;6;8|5000;6;15;16" : allScale;

            List <string> strAllScale = (from q in allScale.Split('|') select q).ToList();

            ScaleList.Clear();
            foreach (var i in strAllScale)
            {
                List <string> str = i.Split(';').ToList();

                Scale s = new Scale();
                s.Number = int.Parse(str[0]);
                s.Circle = double.Parse(str[1]);
                s.Coord  = double.Parse(str[2]);
                s.Marker = double.Parse(str[3]);

                ScaleList.Add(s);
            }



            //Настройки Model
            double _coordinateTolerance;
            double _areaTolerance;
            double _allAreaTolerance;
            int    _startNumberPoint;
            int    _startNumberCurve;

            _coordinateTolerance = double.TryParse(userSection.Settings.Get("M_СoordinateTolerance")
                                                   .Value.ValueXml.InnerText, out _coordinateTolerance) ? _coordinateTolerance : 0.0001;

            _areaTolerance = double.TryParse(userSection.Settings.Get("M_AreaTolerance")
                                             .Value.ValueXml.InnerText, out _areaTolerance) ? _areaTolerance : 1;

            _allAreaTolerance = double.TryParse(userSection.Settings.Get("M_AllAreaTolerance")
                                                .Value.ValueXml.InnerText, out _allAreaTolerance) ? _allAreaTolerance : 0.0001;

            //Начальный номер вершины
            _startNumberPoint = int.TryParse(userSection.Settings.Get("M_StartNumberPoint")
                                             .Value.ValueXml.InnerText, out _startNumberPoint) ? _startNumberPoint : 1;

            //Начальный номер выбранной линии
            _startNumberCurve = int.TryParse(userSection.Settings.Get("M_StartNumberCurve")
                                             .Value.ValueXml.InnerText, out _startNumberCurve) ? _startNumberCurve : 1;

            coordinateTolerance = _coordinateTolerance;
            areaTolerance       = _areaTolerance;
            allAreaTolerance    = _allAreaTolerance;
            startNumberPoint    = _startNumberPoint;
            startNumberCurve    = _startNumberCurve;



            //Настройки View


            coordinatFormat = userSection.Settings.Get("V_CoordinatFormat").Value.ValueXml.InnerText;
            coordinatFormat = (coordinatFormat != null & coordinatFormat.Length < 1) ? "#0.0000" : coordinatFormat;

            layerText = userSection.Settings.Get("V_LayerText").Value.ValueXml.InnerText;
            layerText = (layerText != null & layerText.Length < 1) ? "ГИС_ЗУ_текст" : layerText;

            layerPoint = userSection.Settings.Get("V_LayerPoint").Value.ValueXml.InnerText;
            layerPoint = (layerPoint != null & layerPoint.Length < 1) ? "ГИС_ЗУ_точки" : layerPoint;


            layerPointNumber = userSection.Settings.Get("V_LayerPointNumber").Value.ValueXml.InnerText;
            layerPointNumber = (layerPointNumber != null & layerPointNumber.Length < 1) ? "ГИС_ЗУ_точки_номер" : layerPointNumber;

            mleaderCoordStyle = userSection.Settings.Get("V_MleaderCoordStyle").Value.ValueXml.InnerText;
            mleaderCoordStyle = (mleaderCoordStyle != null & mleaderCoordStyle.Length < 1) ? "tspCoord" : mleaderCoordStyle;

            mleaderMarkerStyle = userSection.Settings.Get("V_MleaderMarkerStyle").Value.ValueXml.InnerText;
            mleaderMarkerStyle = (mleaderMarkerStyle != null & mleaderMarkerStyle.Length < 1) ? "tspMarker" : mleaderMarkerStyle;

            double _CoordTransform;

            _CoordTransform = double.TryParse(userSection.Settings.Get("V_CoordTransform").Value.ValueXml.InnerText, out _CoordTransform) ? _CoordTransform : 8;
            CoordTransform  = _CoordTransform;

            double MarkerTransformX = double.TryParse(userSection.Settings.Get("V_MarkerTransformX").Value.ValueXml.InnerText, out MarkerTransformX) ? MarkerTransformX : 0;
            double MarkerTransformY = double.TryParse(userSection.Settings.Get("V_MarkerTransformY").Value.ValueXml.InnerText, out MarkerTransformY) ? MarkerTransformY : 0;

            MarkerTransform = (MarkerTransformX != 0 & MarkerTransformY != 0) ? new Gem.Vector3d(MarkerTransformX, MarkerTransformY, 0) : MarkerTransform;

            //BaseCircleRadius = double.TryParse(userSection.Settings.Get("V_BaseCircleRadius").Value.ValueXml.InnerText, out BaseCircleRadius) ? BaseCircleRadius : 1;

            markerText = userSection.Settings.Get("V_MarkerText").Value.ValueXml.InnerText;
            markerText = (markerText != null & markerText.Length < 1) ? @":ЗУ|n| \P S= |s| кв.м" : markerText;

            bool _startExcel;

            _startExcel = bool.TryParse(userSection.Settings.Get("V_startExcel").Value.ValueXml.InnerText, out _startExcel) ? _startExcel : true;
            startExcel  = _startExcel;

            bool _MTextMask;

            _MTextMask = bool.TryParse(userSection.Settings.Get("V_MTextMask").Value.ValueXml.InnerText, out _MTextMask) ? _MTextMask : true;
            MTextMask  = _MTextMask;

            double _MTextMaskKoefficient;

            _MTextMaskKoefficient = double.TryParse(userSection.Settings.Get("V_MTextMaskKoefficient").Value.ValueXml.InnerText, out _MTextMaskKoefficient) ? _MTextMaskKoefficient : 1.1;
            MTextMaskKoefficient  = _MTextMaskKoefficient;

            //_Scale = scale;

            //тут подготавливаем окружение для работы и загружаем стили мультивыноски
            App.Document acDoc   = App.Application.DocumentManager.MdiActiveDocument;
            Db.Database  acCurDb = acDoc.Database;
            Ed.Editor    acEd    = acDoc.Editor;

            bool returnBool = false;

            //Копируем из репозитория слои
            if (!CheckLocalRepository.CloneFromRepository <Db.LayerTableRecord>(acCurDb, layerText, CheckLocalRepository.GetRepository()))
            {
                acEd.WriteMessage($"\n Error! Can not clone Layer \"{layerText}\" from repository! Layer for Marker = \"0\"");
                layerText = "0";
            }

            if (!CheckLocalRepository.CloneFromRepository <Db.LayerTableRecord>(acCurDb, layerPoint, CheckLocalRepository.GetRepository()))
            {
                acEd.WriteMessage($"\n Error! Can not clone Layer \"{layerPoint}\" from repository! Layer for Circle = \"0\"");
                layerPoint = "0";
            }
            if (!CheckLocalRepository.CloneFromRepository <Db.LayerTableRecord>(acCurDb, layerPointNumber, CheckLocalRepository.GetRepository()))
            {
                acEd.WriteMessage($"\n Error! Can not clone Layer \"{layerPointNumber}\" from repository! Layer for Point Marker = \"0\"");
                layerPointNumber = "0";
            }


            //Копируем из репозитория стили МультиВыноски
            if (!CheckLocalRepository.CloneFromRepository <Db.MLeaderStyle>(acCurDb, mleaderCoordStyle, CheckLocalRepository.GetRepository()))
            {
                returnBool = false;
                acEd.WriteMessage($"\n Error! Can not clone MLeader Style \"{mleaderCoordStyle}\" from repository! ");
            }


            if (!CheckLocalRepository.CloneFromRepository <Db.MLeaderStyle>(acCurDb, mleaderMarkerStyle, CheckLocalRepository.GetRepository()))
            {
                acEd.WriteMessage($"\n Error! Can not clone MLeader Style \"{mleaderMarkerStyle}\" from repository! ");
                returnBool = false;
            }

            return(returnBool);
        }