예제 #1
0
        private bool LoadDrawing(string filePath)
        {
            try
            {
                // show factory viewer control
                _factoryViewer.Visible = true;
                // get factory reference
                PicFactory factory = _factoryViewer.Factory;
                // clear factory
                factory.Clear();

                string fileExt = System.IO.Path.GetExtension(filePath).ToLower();
                if (string.Equals(".des", fileExt, StringComparison.CurrentCultureIgnoreCase))
                {
                    // load des file
                    DES_FileReader fileReader = new DES_FileReader();
                    PicLoaderDes   picLoader  = new PicLoaderDes(factory);
                    fileReader.ReadFile(filePath, picLoader);
                }
                else if (string.Equals(".dxf", fileExt, StringComparison.CurrentCultureIgnoreCase))
                {
                    // load dxf file
                    using (PicLoaderDXF picLoader = new PicLoaderDXF(factory))
                        picLoader.Load(filePath);
                }
                // fit view to loaded entities
                _factoryViewer.FitView();
            }
            catch (Exception /*ex*/)
            {
            }
            return(true);
        }
예제 #2
0
        private bool LoadDrawing(string filePath)
        {
            try
            {
                // show factory viewer control
                factoryViewer.Visible = true;
                // get factory reference
                PicFactory factory = factoryViewer.Factory;
                // clear factory
                factory.Clear();

                string fileExt = Path.GetExtension(filePath).ToLower();
                if (string.Equals(".des", fileExt, StringComparison.CurrentCultureIgnoreCase))
                {
                    // load des file
                    DES_FileReader fileReader = new DES_FileReader();
                    PicLoaderDes   picLoader  = new PicLoaderDes(factory);
                    fileReader.ReadFile(filePath, picLoader);
                }
                else if (string.Equals(".dxf", fileExt, StringComparison.CurrentCultureIgnoreCase))
                {
                    // load dxf file
                    PicLoaderDXF picLoader = new PicLoaderDXF(factory);
                    picLoader.Load(filePath);
                }
                else if (string.Equals(".ai", fileExt, StringComparison.CurrentCultureIgnoreCase))
                {
                    // load ai file
                }
                // fit view to loaded entities
                factoryViewer.FitView();

                if (textBoxName.Text.Length == 0)
                {
                    textBoxName.Text = Path.GetFileNameWithoutExtension(filePath);
                }
                if (textBoxDescription.Text.Length == 0)
                {
                    textBoxDescription.Text = Path.GetFileNameWithoutExtension(filePath);
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
            return(true);
        }
예제 #3
0
        private void LoadDrawing(string filePath, string fileExt)
        {
            _log.Info($"Loading file {filePath}...");
            if (!System.IO.File.Exists(filePath))
            {
                _log.Error($"File ({filePath}) does not exist.");
                return;
            }
            factoryViewCtrl.Visible = true;
            PicFactory factory = factoryViewCtrl.Factory;

            switch (fileExt.ToLower())
            {
            case "des":
            {
                PicLoaderDes picLoaderDes = new PicLoaderDes(factory);
                using (DES_FileReader fileReader = new DES_FileReader())
                    fileReader.ReadFile(filePath, picLoaderDes);
                // remove existing quotations
                factory.Remove((new PicFilterCode(PicEntity.ECode.PE_COTATIONDISTANCE))
                               | (new PicFilterCode(PicEntity.ECode.PE_COTATIONHORIZONTAL))
                               | (new PicFilterCode(PicEntity.ECode.PE_COTATIONVERTICAL)));
                // build autoquotation
                PicAutoQuotation.BuildQuotation(factory);
            }
            break;

            case "dxf":
            {
                using (PicLoaderDXF picLoaderDxf = new PicLoaderDXF(factory))
                {
                    if (!picLoaderDxf.Load(filePath))
                    {
                        return;
                    }
                }
            }
            break;

            default:
                break;
            }
            // update factoryViewCtrl
            factoryViewCtrl.FitView();
        }