Exemplo n.º 1
0
        /// <summary>
        /// Display a file
        /// </summary>
        /// <param name="path">Full filename</param>
        /// <param name="previewType">Type of file</param>
        public void Display(string path, PreviewType previewType)
        {
            if (path == null)
            {
                return;
            }
            if (!File.Exists(path))
            {
                throw new FileNotFoundException(path);
            }

            switch (previewType)
            {
            case PreviewType.WindowMacro:
                WindowMacro = new WindowMacro();
                WindowMacro.Open(path, EplanProject);
                SetVariantCombinations(WindowMacro);
                break;

            case PreviewType.SymbolMacro:
                SymbolMacro = new SymbolMacro();
                SymbolMacro.Open(path, EplanProject);
                SetVariantCombinations(SymbolMacro);
                break;

            case PreviewType.PageMacro:
                PageMacro = new PageMacro();
                PageMacro.Open(path, EplanProject);
                SetVariantCombinations(PageMacro);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(previewType), previewType, null);
            }
        }
Exemplo n.º 2
0
        private PointD InsertMacro(string windowMacroPath, Project project, Page page, PointD?point)
        {
            SymbolMacro symbolMacro = new SymbolMacro();

            symbolMacro.Open(windowMacroPath, project);

            WindowMacro.Enums.RepresentationType representationType = symbolMacro.RepresentationTypes.First();
            int variant = 0;

            var offsetX = 40;
            var offsetY = 200;

            if (point == null)
            {
                point = new PointD(offsetX, offsetY);
            }
            else
            {
                point = new PointD(point.Value.X + offsetX, point.Value.Y);
            }

            var insert = new Insert();

            insert.SymbolMacro(symbolMacro,
                               representationType,
                               variant,
                               page,
                               point.Value,
                               Insert.MoveKind.Absolute,
                               WindowMacro.Enums.NumerationMode.Number);
            return(page.GetBoundingBox().Last());

            // todo: Check variant
            // todo: Check RepresentationType
            // todo: Locking
        }