Esempio n. 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
                    PicLoaderDxf picLoader = new PicLoaderDxf(factory);
                    picLoader.Load(filePath);
                    picLoader.FillFactory();
                }
                // fit view to loaded entities
                _factoryViewer.FitView();
            }
            catch (Exception /*ex*/)
            {
            }
            return(true);
        }
Esempio n. 2
0
        public static void GenerateImage(Size size, string filePath, string thumbnailFilePath)
        {
            // load file
            PicFactory factory = new PicFactory();
            string     fileExt = System.IO.Path.GetExtension(filePath);

            if (string.Equals(".des", fileExt, StringComparison.CurrentCultureIgnoreCase))
            {
                PicLoaderDes picLoaderDes = new PicLoaderDes(factory);
                using (DES_FileReader fileReader = new DES_FileReader())
                    fileReader.ReadFile(filePath, picLoaderDes);
            }
            else if (string.Equals(".dxf", fileExt, StringComparison.CurrentCultureIgnoreCase))
            {
                using (PicLoaderDxf picLoaderDxf = new PicLoaderDxf(factory))
                {
                    picLoaderDxf.Load(filePath);
                    picLoaderDxf.FillFactory();
                }
            }
            // draw image
            Image bmp;

            ThumbnailGenerator.GenerateImage(size, factory, false, out bmp);
            bmp.Save(thumbnailFilePath);
        }
Esempio n. 3
0
        private void LoadDrawing(string filePath, string fileExt)
        {
            factoryViewCtrl.Visible = true;

            PicFactory factory = factoryViewCtrl.Factory;

            if (string.Equals("des", fileExt, StringComparison.CurrentCultureIgnoreCase))
            {
                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);
            }
            else if (string.Equals("dxf", fileExt, StringComparison.CurrentCultureIgnoreCase))
            {
                using (PicLoaderDxf picLoaderDxf = new PicLoaderDxf(factory))
                {
                    picLoaderDxf.Load(filePath);
                    picLoaderDxf.FillFactory();
                }
            }
            // update factoryViewCtrl
            factoryViewCtrl.FitView();
        }
Esempio n. 4
0
 private void onShowForm(object sender, EventArgs e)
 {
     try
     {
         PicFactory   factory      = new PicFactory();
         PicLoaderDes picLoaderDes = new PicLoaderDes(factory);
         using (DES_FileReader fileReader = new DES_FileReader())
             fileReader.ReadFile(FilePath, picLoaderDes);
         Generator.ShowProcessor(factory, "test");
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Esempio n. 5
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
                    PicLoaderDxf picLoader = new PicLoaderDxf(factory);
                    picLoader.Load(filePath);
                    picLoader.FillFactory();
                }
                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 = System.IO.Path.GetFileNameWithoutExtension(filePath);
                }
                if (textBoxDescription.Text.Length == 0)
                {
                    textBoxDescription.Text = System.IO.Path.GetFileNameWithoutExtension(filePath);
                }
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
            return(true);
        }
Esempio n. 6
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();
        }
        public static DESQuerier LoadFile(string filePath)
        {
            if (!File.Exists(filePath))
            {
                throw new DESQuerierFileNotFoundException(filePath);
            }
            // instantiate factory
            PicFactory factory = new PicFactory();
            // instantiate loader
            PicLoaderDes picLoader = new PicLoaderDes(factory);

            // load file
            DesLib4NET.DES_FileReader reader = new DES_FileReader();
            reader.ReadFile(filePath, picLoader);
            // test for valid entities

            // return DESQuerier
            return(new DESQuerier(factory));
        }
        private void onOK(object sender, EventArgs e)
        {
            // build factory entities
            try
            {
                // load file
                Pic.Factory2D.PicFactory factory      = new PicFactory();
                PicLoaderDes             picLoaderDes = new PicLoaderDes(factory);
                using (DES_FileReader fileReader = new DES_FileReader())
                {
                    fileReader.ReadFile(_drawingName, picLoaderDes);
                }

                // build imposition solutions
                if (Mode == 0)
                {
                    _impositionTool = new ImpositionToolCardboardFormat(factory, CurrentCardboardFormat);
                }
                else
                {
                    _impositionTool = new ImpositionToolXY(factory, NumberDirX, NumberDirY);
                }
                // -> margins
                _impositionTool.HorizontalAlignment = HorizontalAlignment;
                _impositionTool.VerticalAlignment   = VerticalAlignment;
                _impositionTool.SpaceBetween        = new Vector2D(ImpSpaceX, ImpSpaceY);
                _impositionTool.Margin    = new Vector2D(ImpMarginLeftRight, ImpMarginBottomTop);
                _impositionTool.MinMargin = new Vector2D(ImpRemainingMarginLeftRight, ImpRemainingMarginBottomTop);
                // -> allowed patterns
                _impositionTool.AllowRotationInColumnDirection = AllowColumnRotation;
                _impositionTool.AllowRotationInRowDirection    = AllowRowRotation;
                // -> offsets
                _impositionTool.ImpositionOffset = Offset;
                _solutions = new List <ImpositionSolution>();

                // instantiate ProgressWindow and launch process
                ProgressWindow progress = new ProgressWindow();
                System.Threading.ThreadPool.QueueUserWorkItem(new System.Threading.WaitCallback(GenerateImpositionSolutions), progress);
                progress.ShowDialog();

                if (null != _solutions && _solutions.Count > 0)
                {
                    FormLayoutViewer form = new FormLayoutViewer();
                    // set solutions
                    form.Solutions   = _solutions;
                    form.Format      = CurrentCardboardFormat;
                    form.DrawingName = Path.GetFileNameWithoutExtension(_drawingName);
                    // show imposition dlg
                    if (DialogResult.OK == form.ShowDialog(this))
                    {
                        _outputFilePath = form.OutputFilePath;
                        _result         = form.Result;
                    }
                    else
                    {
                        _result = 0;
                        return;
                    }
                }
            }
            catch (PicToolTooLongException /*ex*/)
            {
                MessageBox.Show(
                    string.Format(Properties.Resources.ID_ABANDONPROCESSING
                                  , Pic.Factory2D.Properties.Settings.Default.AreaMaxNoSegments)
                    , Application.ProductName
                    , MessageBoxButtons.OK
                    , MessageBoxIcon.Stop);
            }
            catch (Exception ex)
            {
                _log.Error(ex.ToString());
            }
            if (null != LayoutValidated)
            {
                LayoutValidated(sender, new LayoutCtrlEventArgs(_result, GetOutputFile()));
            }
        }