예제 #1
0
        public ApiExtSampleForm()
        {
            InitializeComponent();

            this._logger = LoggerFactory.GetLogger(this.GetType());
            this._locale = ApiExtHelpers.GetEplanGUILanguage();
        }
예제 #2
0
        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);
            }
        }
예제 #3
0
 /// <summary>
 /// Return the HashCode of this object.
 /// </summary>
 /// <returns>The HashCode of this object.</returns>
 public override Int32 GetHashCode()
 {
     unchecked
     {
         return(ISOCode.GetHashCode() * 5 ^
                Numeric.GetHashCode() * 3 ^
                Name.GetHashCode());
     }
 }
예제 #4
0
 /// <summary>
 /// Compares the current Currency with another Currency.
 /// </summary>
 /// <param name="other">A Currency to compare with this
 /// Currency.</param>
 /// <returns>A 32-bit signed integer that indicates the relative order
 /// of the objects being compared. The return value has the following
 /// meanings: Less than zero - This object is less than the other
 /// parameter. Zero - This object is equal to other. Greater than
 /// zero - This object is greater than other.</returns>
 public int CompareTo(Currency other)
 {
     if (other == null)
     {
         return(1);
     }
     else
     {
         return(ISOCode.CompareTo(other.ISOCode));
     }
 }
예제 #5
0
        public static string GetISOStringValue(MultiLangString multiLangString)
        {
            string sLang = "ko_KR";

            ISOCode isoCode = new ISOCode(sLang);

            ISOCode.Language language = isoCode.GetNumber();
            string           value    = multiLangString.GetString(language);


            return(value.Trim());
        }
예제 #6
0
        public static string ToLocaleText(this PropertyValue propertyValue, ISOCode locale = null, Language secondLanguage = Language.L_en_US)
        {
            if (propertyValue == null || propertyValue.IsEmpty)
            {
                return(string.Empty);
            }

            switch (propertyValue.Definition.Type)
            {
            case PropertyDefinition.PropertyType.MultilangString:
                return(GetMultilangStringText(propertyValue, locale, secondLanguage));

            default:
                return(propertyValue.ToString());
            }
        }
예제 #7
0
        /// <summary>
        /// Compares two instances of this object.
        /// </summary>
        /// <param name="Currency">An object to compare with.</param>
        public Int32 CompareTo(Currency Currency)
        {
            if (Currency is null)
            {
                throw new ArgumentNullException("The given Currency must not be null!");
            }

            var c = ISOCode.CompareTo(Currency.ISOCode);

            if (c == 0)
            {
                c = Numeric.CompareTo(Currency.Numeric);
            }

            if (c == 0)
            {
                c = Name.CompareTo(Currency.Name);
            }

            return(c);
        }
예제 #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);
        }
예제 #9
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);
            }
        }
예제 #10
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);
            }
        }
예제 #11
0
        /// <summary>Language detected based on iso639-1</summary>
        public async Task <ILanguage> GetLanguage()
        {
            var iso6391Code = ISOCode.Substring(0, 2).ToLowerInvariant(); // ISO639-1 are two letters code, but for Chinese Google returns 2 different codes (zh-CN for simplified and zh-TW for traditional)

            return(await Database.FirstOrDefault <ILanguage>(l => l.IsoCode.ToLowerInvariant() == iso6391Code));
        }