public ApiExtSampleForm()
        {
            InitializeComponent();

            this._logger = LoggerFactory.GetLogger(this.GetType());
            this._locale = ApiExtHelpers.GetEplanGUILanguage();
        }
        private void btnBOMDeletePart_Click(object sender, EventArgs e)
        {
            if (cBoxBOMParts.SelectedIndex == -1)
            {
                return;
            }

            EplanArticleReferenceViewModel articleReference = this.cBoxBOMParts.SelectedItem as EplanArticleReferenceViewModel;

            if (articleReference == null)
            {
                return;
            }

            Function targetFunction = ((EplanFunctionViewModel)this.cBoxBOMFunctions.SelectedItem).Function;

            if (targetFunction == null)
            {
                return;
            }

            targetFunction.RemoveArticleReference(articleReference.ArticleReference);

            int functionIndex = cBoxBOMFunctions.SelectedIndex;

            cBoxBOMFunctions.SelectedIndex = -1;
            cBoxBOMFunctions.SelectedIndex = functionIndex;

            // Refresh Part Reference List
            RefreshPartReferenceList(this.cBoxBOMFunctions);

            // Refresh Drawing
            ApiExtHelpers.RefreshDrawing();
        }
        private void btnProjectReadProperties_Click(object sender, EventArgs e)
        {
            if (!ValidateProjectSelected(this.txtProject))
            {
                return;
            }

            try
            {
                ISOCode       guiLang       = ApiExtHelpers.GetEplanGUILanguage();
                Project       targetProject = ProjectHelper.GetProject(this.txtProject.Text);
                StringBuilder propertyText  = new StringBuilder();
                propertyText.AppendFormat("Project [{1}] Properties{0}{0}", Environment.NewLine, targetProject.ProjectName);

                propertyText.AppendFormat("Job Number = [{1}]{0}", Environment.NewLine, targetProject.Properties[10013]);
                propertyText.AppendFormat("EPLAN.Project.UserSupplementaryField1 = [{1}]{0}{0}", Environment.NewLine, targetProject.Properties["EPLAN.Project.UserSupplementaryField1"]);

                propertyText.AppendFormat("SupplementaryField[11]{0}", Environment.NewLine);
                propertyText.AppendFormat(" ToString() = [{1}]{0}", Environment.NewLine, targetProject.Properties[10901, 11]);
                propertyText.AppendFormat(" ToString(Lang) = [{1}]{0}", Environment.NewLine, targetProject.Properties[10901, 11].ToString(guiLang.GetNumber()));
                propertyText.AppendFormat(" ToMultiLangString().GetStringToDisplay(Lang) = [{1}]{0}{0}", Environment.NewLine, targetProject.Properties[10901, 11].ToMultiLangString().GetStringToDisplay(guiLang.GetNumber()));

                propertyText.AppendFormat("Project Description = [{1}]{0}", Environment.NewLine, targetProject.Properties[10011]);

                MessageDisplayHelper.Show(propertyText.ToString(), "::: Read Project Properties");
            }
            catch (Exception ex)
            {
                MessageDisplayHelper.Show(string.Format("Read Properties Failed!{0}{1}", Environment.NewLine, ex.Message), "::: Read Project Properties", EnumDecisionIcon.eEXCLAMATION);
            }
        }
        private void btnBOMReplacePart_Click(object sender, EventArgs e)
        {
            // 01. Get Current Selected Part Reference
            if (cBoxBOMParts.SelectedIndex == -1)
            {
                return;
            }

            EplanArticleReferenceViewModel articleReference = this.cBoxBOMParts.SelectedItem as EplanArticleReferenceViewModel;

            if (articleReference == null)
            {
                return;
            }

            // 02. Get Current Function to replce against
            Function targetFunction = ((EplanFunctionViewModel)this.cBoxBOMFunctions.SelectedItem).Function;

            if (targetFunction == null)
            {
                return;
            }

            // 03. Get New Part
            string selectedPartNumber  = string.Empty;
            string selectedPartVariant = string.Empty;

            new EplApplication().ShowPartSelectionDialog(ref selectedPartNumber, ref selectedPartVariant);

            if (this._logger.IsDebugEnabled)
            {
                this._logger.DebugFormat("btnBOMReplacePart_Click(), selectedPartNumber=[{0}], selectedPartVariant=[{1}]", selectedPartNumber, selectedPartVariant);
            }

            if (string.IsNullOrEmpty(selectedPartNumber))
            {
                return;
            }

            // 04. Info from Current Part Reference
            int articleReferenceIndex = articleReference.ArticleReference.ReferencePos;

            if (this._logger.IsDebugEnabled)
            {
                this._logger.DebugFormat("btnBOMReplacePart_Click(), articleReference.PartNr=[{0}], articleReference.Index=[{1}]",
                                         articleReference.ArticleReference.PartNr, articleReferenceIndex);
            }

            // 05. Replace the Part Number with New One
            articleReference.ArticleReference.PartNr = selectedPartNumber;
            articleReference.ArticleReference.StoreToObject();

            // 06. Refresh Part Reference List
            RefreshPartReferenceList(this.cBoxBOMFunctions);

            // 07. Refresh Drawing
            ApiExtHelpers.RefreshDrawing();
        }
        private void btnGoToGraphics_Click(object sender, EventArgs e)
        {
            if (cBoxPlaced3DObjects.SelectedIndex == -1)
            {
                return;
            }

            EplanBarBaseViewModel selectedItem = this.cBoxPlaced3DObjects.SelectedItem as EplanBarBaseViewModel;

            if (selectedItem == null)
            {
                return;
            }

            ApiExtHelpers.OpenInstallationSpaceWithPlacement3D(selectedItem.BarBase);
        }
        /// <summary>
        /// 지정된 Functiuon에 대하여, 이미지를 생성
        /// - 이미 생성된 이미지가 있는 경우, 기존 이미지를 삭제하고 신규로 생성하는 방식 사용
        /// - 이미지 너비(Width)만 지정하고, 높이(Height)는 이미지 비율에 따라 자동으로 지정됨
        /// </summary>
        /// <param name="function">대상 Function</param>
        /// <param name="imageWidth">이미지 너비</param>
        /// <param name="gapFromSymbol">심볼에서 이미지 배치 상대 위치, (-): 왼쪽 배치, (+): 오른쪽 배치</param>
        public static void DoImage(this Function function, double imageWidth = 30.0, double gapFromSymbol = -10)
        {
            if (function == null)
            {
                throw new ArgumentNullException("function");
            }

            Image functionImage = null;

            try
            {
                using (SafetyPoint safetyPoint = SafetyPoint.Create())
                {
                    functionImage = FindFunctionImage(function);
                    Article part = function.Articles.FirstOrDefault();

                    if (functionImage != null)
                    {
                        functionImage.Remove();
                        functionImage = null;
                    }

                    if (part != null)
                    {
                        CreateNewImage(function, part, imageWidth, gapFromSymbol);
                    }

                    safetyPoint.Commit();
                }
            }
            catch (Exception ex)
            {
                MessageDisplayHelper.Show(string.Format("이미지 박스 추가 실패{1}ex.Message=[{0}]", ex.Message, Environment.NewLine), "DoImage", EnumDecisionIcon.eEXCLAMATION);
            }
            finally
            {
                ApiExtHelpers.RefreshDrawing();

                if (functionImage != null)
                {
                    functionImage.Dispose();
                    functionImage = null;
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Execution of the Action.
        /// </summary>
        /// <returns>True:  Execution of the Action was successful</returns>
        public bool Execute(ActionCallingContext ctx)
        {
            try
            {
                SelectionSet selection = new SelectionSet();

                foreach (var function in selection.Selection.OfType <Function>())
                {
                    function.SymbolVariant = SymbolVariantHelper.GetNext(function.SymbolVariant);
                }

                ApiExtHelpers.RefreshDrawing();
            }
            catch (Exception ex)
            {
                MessageDisplayHelper.Show(string.Format("Symbol Change Error{1}error=[{0}]", ex.Message, Environment.NewLine), "ActionNextSymbolVariant", EnumDecisionIcon.eEXCLAMATION);
            }

            return(true);
        }
Beispiel #8
0
        private static string GetMultilangStringText(PropertyValue propertyValue, ISOCode locale, Language secondLanguage = Language.L_en_US)
        {
            ISOCode workingLocale = null;
            string  toReturn      = string.Empty;

            if (propertyValue == null || propertyValue.IsEmpty)
            {
                return(toReturn);
            }

            try
            {
                workingLocale = locale ?? ApiExtHelpers.GetEplanGUILanguage();
                Language workingLanguage = workingLocale.GetNumber();

                toReturn = propertyValue.ToString(workingLanguage);

                // 현재 Locale로 값이 없는 경우, 기본 값(@??_??)으로 구한다
                if (string.IsNullOrWhiteSpace(toReturn))
                {
                    toReturn = propertyValue.ToString(Language.L___);
                }

                // 값이 없는 경우, 두번째 Language로 구한다
                if (string.IsNullOrWhiteSpace(toReturn) && secondLanguage != Language.L___ && secondLanguage != workingLanguage)
                {
                    toReturn = propertyValue.ToString(secondLanguage);
                }
            }
            finally
            {
                // 내부에서 생성한 ISOCode Instance Dispose
                if (locale == null && workingLocale != null)
                {
                    workingLocale.Dispose();
                }
            }

            return(toReturn);
        }
        private void btnBOMAddNewPart_Click(object sender, EventArgs e)
        {
            Function targetFunction = ((EplanFunctionViewModel)this.cBoxBOMFunctions.SelectedItem).Function;

            if (targetFunction == null)
            {
                return;
            }

            string selectedPartNumber  = string.Empty;
            string selectedPartVariant = string.Empty;

            new EplApplication().ShowPartSelectionDialog(ref selectedPartNumber, ref selectedPartVariant);

            if (this._logger.IsDebugEnabled)
            {
                this._logger.DebugFormat("btnBOMAddNewPart_Click(), selectedPartNumber=[{0}], selectedPartVariant=[{1}]", selectedPartNumber, selectedPartVariant);
            }

            if (string.IsNullOrEmpty(selectedPartNumber))
            {
                return;
            }

            if (string.IsNullOrEmpty(selectedPartVariant))
            {
                targetFunction.AddArticleReference(selectedPartNumber);
            }
            else
            {
                targetFunction.AddArticleReference(selectedPartNumber, selectedPartVariant, 1, true);
            }

            // Refresh Part Reference List
            RefreshPartReferenceList(this.cBoxBOMFunctions);

            // Refresh Drawing
            ApiExtHelpers.RefreshDrawing();
        }
Beispiel #10
0
        private void btnPartShowUsageInPage_Click(object sender, EventArgs e)
        {
            if (!ValidatePageSelected(this.cBoxPartPages))
            {
                return;
            }

            try
            {
                ISOCode guiLang    = ApiExtHelpers.GetEplanGUILanguage();
                Page    targetPage = ((EplanPageViewModel)this.cBoxPartPages.SelectedItem).Page;

                foreach (var function in targetPage.Functions)
                {
                    foreach (var partReference in function.ArticleReferences)
                    {
                        Article part = partReference.Article;

                        StringBuilder propertyText = new StringBuilder();
                        propertyText.AppendFormat("partReference.PartNr [{1}]{0}{0}", Environment.NewLine, partReference.PartNr);

                        if (part != null)
                        {
                            propertyText.AppendFormat("part.Properties.ARTICLE_DESCR1 = [{1}]{0}{0}", Environment.NewLine, part.Properties.ARTICLE_DESCR1.IsEmpty ? string.Empty : part.Properties.ARTICLE_DESCR1.ToString());
                            propertyText.AppendFormat("part.Properties.ARTICLE_DESCR2 = [{1}]{0}{0}", Environment.NewLine, part.Properties.ARTICLE_DESCR2.IsEmpty ? string.Empty : part.Properties.ARTICLE_DESCR2.ToString());
                            propertyText.AppendFormat("part.Properties.ARTICLE_DESCR3 = [{1}]{0}{0}", Environment.NewLine, part.Properties.ARTICLE_DESCR2.IsEmpty ? string.Empty : part.Properties.ARTICLE_DESCR2.ToString());

                            propertyText.AppendFormat("part.Properties.ARTICLE_NOTE = [{1}]{0}{0}", Environment.NewLine, part.Properties.ARTICLE_NOTE.IsEmpty ? string.Empty : part.Properties.ARTICLE_NOTE.ToString());
                        }

                        MessageDisplayHelper.Show(propertyText.ToString(), string.Format("[{0}] 속성", partReference.PartNr));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageDisplayHelper.Show(string.Format("Page Part Liist Failed!{0}{1}", Environment.NewLine, ex.Message), "::: Part Page List", EnumDecisionIcon.eEXCLAMATION);
            }
        }
Beispiel #11
0
        private void btnPageReadProperties_Click(object sender, EventArgs e)
        {
            if (!ValidatePageSelected(this.cBoxPagePages))
            {
                return;
            }

            try
            {
                ISOCode guiLang    = ApiExtHelpers.GetEplanGUILanguage();
                Page    targetPage = ((EplanPageViewModel)this.cBoxPagePages.SelectedItem).Page;

                StringBuilder propertyText = new StringBuilder();
                propertyText.AppendFormat("Page [{1}] Properties{0}{0}", Environment.NewLine, targetPage.Name);

                propertyText.AppendFormat("PageType = [{1}]{0}", Environment.NewLine, targetPage.PageType);
                propertyText.AppendFormat("PageTypeName = [{1}]{0}{0}", Environment.NewLine, targetPage.PageTypeName);

                propertyText.AppendFormat("EPLAN.Page.UserSupplementaryField11 = [{1}]{0}{0}", Environment.NewLine, targetPage.Properties["EPLAN.Page.UserSupplementaryField11"]);

                propertyText.AppendFormat("SupplementaryField[21]{0}", Environment.NewLine);
                propertyText.AppendFormat(" ToString() = [{1}]{0}", Environment.NewLine, targetPage.Properties[11901, 21]);
                propertyText.AppendFormat(" ToString(Lang) = [{1}]{0}", Environment.NewLine, targetPage.Properties[11901, 21].ToString(guiLang.GetNumber()));
                propertyText.AppendFormat(" ToMultiLangString().GetStringToDisplay(Lang) = [{1}]{0}{0}", Environment.NewLine, targetPage.Properties[11901, 21].ToMultiLangString().GetStringToDisplay(guiLang.GetNumber()));

                propertyText.AppendFormat("Page Description{0}", Environment.NewLine);
                propertyText.AppendFormat(" ToString() = [{1}]{0}", Environment.NewLine, targetPage.Properties.PAGE_NOMINATIOMN);
                propertyText.AppendFormat(" ToString(Lang) = [{1}]{0}", Environment.NewLine, targetPage.Properties.PAGE_NOMINATIOMN.ToString(guiLang.GetNumber()));
                propertyText.AppendFormat(" ToMultiLangString().GetStringToDisplay(Lang) = [{1}]{0}", Environment.NewLine, targetPage.Properties.PAGE_NOMINATIOMN.ToMultiLangString().GetStringToDisplay(guiLang.GetNumber()));


                MessageDisplayHelper.Show(propertyText.ToString(), "::: Read Project Properties");
            }
            catch (Exception ex)
            {
                MessageDisplayHelper.Show(string.Format("Read Properties Failed!{0}{1}", Environment.NewLine, ex.Message), "::: Read Project Properties", EnumDecisionIcon.eEXCLAMATION);
            }
        }