Exemple #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();
        }
        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();
                }
            }
        }