Example #1
0
        private void SetVariantCombinations(SymbolMacro symbolMacro)
        {
            _previewControl.VariantsCombinations = new ObservableCollection <VariantCombination>();
            _previewControl.PreviewType          = PreviewType.WindowMacro;

            foreach (var representationType in symbolMacro.RepresentationTypes)
            {
                VariantCombination variantCombination = new VariantCombination(PreviewType.SymbolMacro);
                variantCombination.PreviewObject      = symbolMacro;
                variantCombination.RepresentationType = representationType;
                foreach (int variantIndex in symbolMacro.GetVariants(representationType))
                {
                    symbolMacro.ChangeCurrentVariant(representationType, variantIndex);

                    Variant variant = new Variant(variantCombination);
                    variant.Index       = variantIndex;
                    variant.Description = symbolMacro.Description
                                          .GetStringToDisplay(MultiLanguage.GuiLanguage);
                    variant.Description = Regex.Replace(variant.Description, @"\r\n?|\n", " ");

                    variantCombination.Variants.Add(variant);
                }

                _previewControl.VariantsCombinations.Add(variantCombination);
            }

            _previewControl.SelectedVariantCombination = _previewControl.VariantsCombinations.FirstOrDefault();
            _previewControl.CheckControls();
        }
Example #2
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);
            }
        }
        private void Draw()
        {
            if (SelectedVariant != null)
            {
                switch (PreviewType)
                {
                case PreviewType.WindowMacro:
                    WindowMacro windowMacro = (WindowMacro)SelectedVariantCombination.PreviewObject;
                    windowMacro.ChangeCurrentVariant(SelectedVariantCombination.RepresentationType, SelectedVariant.Index);
                    Preview.DrawingService.CreateDisplayList(windowMacro);
                    Preview.DrawEplan();
                    break;

                case PreviewType.SymbolMacro:
                    SymbolMacro symbolMacro = (SymbolMacro)SelectedVariantCombination.PreviewObject;
                    symbolMacro.ChangeCurrentVariant(SelectedVariantCombination.RepresentationType, SelectedVariant.Index);
                    Preview.DrawingService.CreateDisplayList(symbolMacro);
                    Preview.DrawEplan();
                    symbolMacro.Dispose();
                    break;

                case PreviewType.PageMacro:
                    PageMacro pageMacro = (PageMacro)SelectedVariantCombination.PreviewObject;
                    Preview.DrawingService.CreateDisplayList(pageMacro.Pages[SelectedVariant.Index]);
                    Preview.DrawEplan();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
            }
        }
Example #4
0
        /// <summary>
        /// Init Preview object for WPF
        /// </summary>
        /// <param name="border">Border which should inhert the UserControl</param>
        /// <param name="projectFile">EPLAN project file to preview (*.elk)</param>
        public Preview(Border border, string projectFile)
        {
            // Clean
            WindowMacro = null;
            SymbolMacro = null;
            PageMacro   = null;

            if (!File.Exists(projectFile))
            {
                throw new FileNotFoundException(projectFile);
            }

            // Check if project is open
            var projectManager = new ProjectManager();

            projectManager.LockProjectByDefault = false;
            //EplanProject = ProjectUtility.OpenProject(projectFile);
            foreach (var openProject in projectManager.OpenProjects)
            {
                if (openProject.ProjectLinkFilePath.Equals(projectFile))
                {
                    EplanProject = openProject;
                    break;
                }
            }
            if (EplanProject == null)
            {
                EplanProject = projectManager.OpenProject(projectFile, ProjectManager.OpenMode.Exclusive);
            }

            DrawingService = new DrawingService();
            DrawingService.DrawConnections = true;

            border.Child            = _previewControl;
            _previewControl.Preview = this;
        }
Example #5
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
        }
Example #6
0
 /// <summary>
 /// Displays the given SymbolMacro
 /// </summary>
 /// <param name="symbolMacro">EPLAN SymbolMacro</param>
 public void Display(SymbolMacro symbolMacro)
 {
     SymbolMacro = symbolMacro;
     SetVariantCombinations(SymbolMacro);
 }