/// <summary> /// Called when user clicks on the add-in menu /// </summary> /// <param name="e">The context of the VS tools and metadata</param> public override void OnClick(AddinDesignerEventArgs e) { //Microsoft.Dynamics.AX.Metadata.Core.MetaModel.EntryPointType entryPointType; try { var selectedItem = e.SelectedElement as INamedElement; if (selectedItem != null) { //var metadataType = selectedItem.GetMetadataType(); EdtLabelInfo edtLabelInfo = new EdtLabelInfo(); if (selectedItem is IEdtBase) { var axEdt = Common.CommonUtil.GetModelSaveService().GetExtendedDataType(selectedItem.Name); edtLabelInfo = this.getEdtBaseLabel(axEdt, edtLabelInfo); } else if (selectedItem is BaseField) { var axBaseField = selectedItem as BaseField; edtLabelInfo = this.getTableFieldLabel(axBaseField, edtLabelInfo); } edtLabelInfo.DecypherLabels(); System.Windows.Forms.MessageBox.Show("Label: " + edtLabelInfo.Label + Environment.NewLine + "Help: " + edtLabelInfo.HelpLabel); } } catch (Exception ex) { CoreUtility.HandleExceptionWithErrorMessage(ex); } }
/// <summary> /// Called when user clicks on the add-in menu /// </summary> /// <param name="e">The context of the VS tools and metadata</param> public override void OnClick(AddinDesignerEventArgs e) { //Microsoft.Dynamics.AX.Metadata.Core.MetaModel.EntryPointType entryPointType; try { //var modelSettings = Settings.FetchSettings.FindOrCreateSettings(); var selectedItem = e.SelectedElement as INamedElement; if (selectedItem != null) { //var metadataType = selectedItem.GetMetadataType(); EdtLabelInfo edtLabelInfo = new EdtLabelInfo(); if (selectedItem is IEdtBase) { var axEdt = Common.CommonUtil.GetModelSaveService().GetExtendedDataType(selectedItem.Name); edtLabelInfo = this.getEdtBaseLabel(axEdt, edtLabelInfo); } else if (selectedItem is BaseField) { var axBaseField = selectedItem as BaseField; edtLabelInfo = this.getTableFieldLabel(axBaseField, edtLabelInfo); } else if (selectedItem is IDataEntityViewField) { var axEntityField = selectedItem as IDataEntityViewField; edtLabelInfo = this.getDataEntityFieldLabel(axEntityField, edtLabelInfo); } else if (selectedItem is IDataEntityView) { var dataEntity = selectedItem as IDataEntityView; if (String.IsNullOrEmpty(edtLabelInfo.Label) == true && String.IsNullOrEmpty(dataEntity.Label) == false) { // find the label here edtLabelInfo.Label = dataEntity.Label; } if (String.IsNullOrEmpty(edtLabelInfo.HelpLabel) == true && String.IsNullOrEmpty(dataEntity.DeveloperDocumentation) == false) { // find the help label here edtLabelInfo.HelpLabel = dataEntity.DeveloperDocumentation; } } edtLabelInfo.DecypherLabels(); System.Windows.Forms.MessageBox.Show("Label: " + edtLabelInfo.Label + Environment.NewLine + "Help: " + edtLabelInfo.HelpLabel); } } catch (Exception ex) { CoreUtility.HandleExceptionWithErrorMessage(ex); } }