/// <summary> /// /// </summary> /// <param name="element"></param> /// <param name="ecInstance"></param> /// <returns></returns> internal bool UpdateInstance(Element element, ref IECInstance ecInstance) { var elementRefP = (IntPtr)element.MdlElementRef(); var modelRefP = (IntPtr)element.ModelReference.MdlModelRefP(); return(UpdateInstance(elementRefP, modelRefP, ref ecInstance)); }
/// <summary> /// /// </summary> /// <param name="elementRefP"></param> /// <param name="modelRefPtr"></param> /// <param name="ecInstance"></param> /// <returns></returns> internal string CreateInstance(IntPtr elementRefP, IntPtr modelRefPtr, ref IECInstance ecInstance) { var instanceId = XmlInstanceCreate.CreateInstance(elementRefP, modelRefPtr, ecInstance); ecInstance.InstanceId = instanceId; return(instanceId); }
//WS: set instance property values internal bool SetInstancePropertyValue(ref IECInstance pInstance, string propertyAccessString, string propertyValue) { try { pInstance.SetAsString(propertyAccessString, propertyValue); return(true); } catch (Exception ex) { Debug.Print("{0} in {1}\n\t{2}", ex, ex.TargetSite, ex.Message); return(false); } }
private void CreateImportItem(List <ImportItem> importItems) { BMECInstanceManager instanceManager = BMECApi.Instance.InstanceManager; foreach (ImportItem importItem in importItems) { if (string.IsNullOrEmpty(importItem.Key) || !importItem.Valid) { //log-- this means there are blank records continue; } System.Windows.Forms.Application.DoEvents(); ArrayList associations = new ArrayList(); ArrayList propertyValues = new ArrayList(); //use the instance to set the properties foreach (IECPropertyValue propertyValue in importItem.Instance) { if (propertyValue.IsNull) { continue; } if (propertyValue.StringValue == null) { continue; } string pval = string.Format("{0}={1}", propertyValue.AccessString, propertyValue.StringValue); propertyValues.Add(pval); } foreach (string rItem in importItem.RelationClassValueCache.Keys) { string relatedVal = string.Format("{0}={1}", rItem, importItem.RelationClassValueCache[rItem]); associations.Add(relatedVal); } string clsName = importItem.Instance.ClassDefinition.Name; if (associations.Count > 0) { WorkspaceUtilities.SaveSettings("Associations." + clsName, associations); } IECInstance ecInstance = instanceManager.CreateECInstance(clsName); BMECApi.Instance.SpecProcessor.FillCurrentPreferences(ecInstance, true); ECInstanceDialog ecDlg = new ECInstanceDialog(importItem.Instance); ecDlg.InitializeWithCustomProperties(associations, propertyValues, true); ecDlg.SaveData(false); } }
public void UpdateWBSParts(IECInstance selectedECInstance) { try { if (selectedECInstance == null) { return; } ArrayList assocItems = SchemaUtilities.GetAssociatedItemInformation(selectedECInstance.ClassDefinition); UpdateWBSParts(assocItems, selectedECInstance); } catch (Exception ex) { WorkspaceUtilities.DisplayErrorMessage(ex.Message, string.Empty); } }
private IECInstance GetAssociatedItemFromInstance ( IECInstance ecInstance, IECRelationshipClass ecRelClass, IECClass ecParentClass ) { DgnUtilities dgnUtil = DgnUtilities.GetInstance(); if (ecInstance.InstanceId == "mechanical") { return(null); } ECInstanceList ecList = dgnUtil.GetParentInstances(ecInstance, ecRelClass, ecParentClass, dgnUtil.GetDGNConnection()); return((ecList.Count > 0) ? ecList[0] : null); }
private IECInstance EditECInstance(IECInstance ecInst) { ECInstanceDialog ecDlg = new ECInstanceDialog(ecInst); ecDlg.DialogTitle = string.Format(LocalizableStrings.EditingInstanceTitle, ecInst.ClassDefinition.DisplayLabel, SchemaUtilities.GetDisplayNameForECInstance(ecInst, false)); ecDlg.ShowDialog(); //User didn't save the new instance if (!ecDlg.SavePressed) { return(null); } //We were not able to save the new instance if (!ecDlg.SaveData()) { return(null); } return(ecDlg.GetECInstance()); }
private static string getXmlFormECInstance(IECInstance ecInst) { string nameSpace = ecInst.ClassDefinition.Schema.NamespacePrefix; XElement el = new XElement(XName.Get(ecInst.ClassDefinition.Name, nameSpace)); foreach (var prop in ecInst.ClassDefinition) { var propValue = ecInst.FindPropertyValue(prop.Name, false, false, false, true); if (propValue != null && !propValue.IsNull) { XElement subEl = new XElement(XName.Get(propValue?.AccessString, nameSpace)); try { subEl.Value = propValue.XmlStringValue; } catch (NullReferenceException ex) {} catch (Exception ex) {} el.Add(subEl); } } return(el.ToString()); }
public void UpdateWBSParts(ArrayList assocItems, IECInstance selectedECInstance) { if (assocItems == null || assocItems.Count == 0 || selectedECInstance == null) { return; } //set cache of WBS items (classname, relationship name) IDictionary <string, string> aitems = new Dictionary <string, string> (); foreach (string item in assocItems) { string[] part = item.Split(new char[] { '|' }); if (part.Length < 1) { continue; } string className = part[0]; string relClassName = part[1]; if (!aitems.ContainsKey(className)) { aitems.Add(className, relClassName); } } DgnUtilities dgnUtil = DgnUtilities.GetInstance(); IECRelationshipInstanceCollection ecList = selectedECInstance.GetRelationshipInstances(); if (ecList == null || ecList.Count == 0) { return; } bool needWBS = false; string msg = string.Empty; //iterate thru relationship instances IEnumerator en = ecList.GetEnumerator(); while (en.MoveNext()) { IECRelationshipInstance rel = en.Current as IECRelationshipInstance; if (rel == null) { continue; } string wbsRelationshipName = rel.ClassDefinition.Name; IECInstance wbsSource = rel.Source; if (wbsSource == null) { continue; } string wbsSourceClassName = wbsSource.ClassDefinition.Name; //match wbs type and pass to UpdateWBSComboxValue() if (!aitems.ContainsKey(wbsSourceClassName)) { continue; } if (UpdateWBSComboxValue(wbsSource, wbsRelationshipName) == WBSUpdateType.NeedToCreate) { IECPropertyValue sourceVal = wbsSource.FindPropertyValue(s_WBSName, false, false, false); string val = string.Empty; if (sourceVal != null && !sourceVal.IsNull) { val = sourceVal.StringValue; } msg = msg + "\n" + string.Format(LocalizableStrings.MissingWbs, wbsSourceClassName, val); needWBS = true; } } if (needWBS && !string.IsNullOrEmpty(msg)) { string val = WorkspaceUtilities.GetMSConfigVariable("AllowPlacementOnMissingWBSItems"); if (string.IsNullOrEmpty(val) || val != "1") { dgnUtil.RunKeyin("BMECH DEFERDEFAULTCMD"); } //this value is used in consistency manager placement. //setting to false allows CM to display instances correctly dgnUtil.ConsistencyPlacementValidState = false; string message = string.Format(LocalizableStrings.AlertMissingWbs, msg); dgnUtil.ConsistencyPlacementErrorMessage = message; MessageBox.Show(message, LocalizableStrings.WBSAlert, MessageBoxButtons.OK, MessageBoxIcon.Warning); WorkspaceUtilities.DisplayWarningMessage(LocalizableStrings.WBSAlert, message); } }
public bool FillAssociatedItems(bool isModifyTool) { ArrayList classRelationshipStrs = SchemaUtilities.GetAssociatedItems(_ClassDef); if (classRelationshipStrs.Count == 0) { return(false); } if (_bMultiInst) {//when editing associations of multiple instances, edit and delete options should not be available. this.optionDelete.Visible = false; this.optionEdit.Visible = false; //refresh/redraw the grid this.OnResize(new EventArgs()); } for (int i = 0; i < classRelationshipStrs.Count; i++) { string strData = classRelationshipStrs[i] as string; string[] strArr = strData.Split(new char[] { '|' }); IECClass ecAssociatedClass = SchemaUtilities.PlantSchema.GetClass(strArr[0]); int rowIndex = this.Rows.Add(); DataGridViewTextBoxCell itemTypeCell = this[s_WBSClassKey, rowIndex] as DataGridViewTextBoxCell; itemTypeCell.Value = ecAssociatedClass.DisplayLabel; //itemTypeCell.Tag = ecAssociatedClass; DataGridViewComboBoxCell itemInstanceCell = this[s_WBSInstanceKey, rowIndex] as DataGridViewComboBoxCell; //ArrayList arr = DgnUtilities.GetInstance().GetECInstanceDisplayLabelsFromDgn (strArr[0]); ECInstanceList arr = DgnUtilities.GetInstance().GetAllInstancesFromDgn(strArr[0]); IECRelationshipClass ecAssociatedRel = SchemaUtilities.PlantSchema.GetClass(strArr[1]) as IECRelationshipClass; // move class to 1st column tag, to start with, later changed itemInstanceCell.Tag = ecAssociatedClass; itemTypeCell.Tag = ecAssociatedRel; if (_bMultiInst) { itemInstanceCell.Items.Add(_cstr_Varies); } itemInstanceCell.Items.Add(LocalizableStrings.None); Dictionary <string, IECInstance> dropDownCache = new Dictionary <string, IECInstance> (); foreach (IECInstance returnedInstance in arr) //for (int j = 0; j < arr.Count; j++) { // insert only if this is not from a referenced file if (DgnUtilities.GetInstance().IsECInstanceFromReferenceFile(returnedInstance)) { continue; } string key = SchemaUtilities.GetDisplayNameForECInstance(returnedInstance, true); if (dropDownCache.ContainsKey(key)) { dropDownCache[key] = returnedInstance; } else { // insert dropDownCache.Add(key, returnedInstance); itemInstanceCell.Items.Add(key); } } if (dropDownCache.Count > 0) { itemInstanceCell.Tag = dropDownCache; } if (isModifyTool) { string strLastInstID = null; string key = ""; for (int j = 0; j < _instList.Count; j++) { IECInstance parentInstance = GetAssociatedItemFromInstance(_instList[j], ecAssociatedRel, ecAssociatedRel.Source.GetClasses()[0].Class); string strCurrInstID = ""; // If we have a parent instance, then we must be using an existing instance. We need to make sure we select the existing values. if (null != parentInstance) { key = SchemaUtilities.GetDisplayNameForECInstance(parentInstance, true); strCurrInstID = parentInstance.InstanceId; } else { key = LocalizableStrings.None; strCurrInstID = LocalizableStrings.None; } if (String.IsNullOrEmpty(strLastInstID)) { strLastInstID = strCurrInstID; } else { if (strCurrInstID != strLastInstID) { key = _cstr_Varies; break; } } } // end for loop itemInstanceCell.Value = key; } itemInstanceCell.Sorted = true; DataGridViewImageCell tempImageCell = this["optionAdd", rowIndex] as DataGridViewImageCell; tempImageCell.Tag = ecAssociatedClass; } if (!isModifyTool) { ArrayList AssociatonList = WorkspaceUtilities.GetSettings("Associations." + _ClassDef.Name); LoadSettings(AssociatonList, false); } return(true); }
private void OnCellMouseClick ( object sender, DataGridViewCellMouseEventArgs e ) { if (e.RowIndex == -1) { return; } if (e.ColumnIndex == 1) { this.BeginEdit(true); ComboBox comboBox = (ComboBox)this.EditingControl; if (null != comboBox) { comboBox.DroppedDown = true; } } if (e.ColumnIndex < AddButtonColumn) { return; } DgnUtilities dgnUtil = DgnUtilities.GetInstance(); IECClass ecClass = getECClassInformationForCurrentSelection(e.RowIndex); //this[ClassColumn, e.RowIndex].Tag as IECClass; IECRelationshipClass ecRelClass = getECRelationshipClassInformationForCurrentSelection(e.RowIndex); //this[ComboBoxColumn, e.RowIndex].Tag as IECRelationshipClass; DataGridViewComboBoxCell itemInstanceCell = this[s_WBSInstanceKey, e.RowIndex] as DataGridViewComboBoxCell; string strVal = this[s_WBSInstanceKey, e.RowIndex].Value as string; if (strVal == LocalizableStrings.None && (e.ColumnIndex != AddButtonColumn && e.ColumnIndex != BrowseButtonColumn)) { this[e.ColumnIndex, e.RowIndex].Selected = false; return; } //ADD/////////////////////////////////////////////////////////////////////////////////////////////////////////// if (e.ColumnIndex == AddButtonColumn) { // If we are connected to iModelHub we should acquire a a new tag for WBS ECInstanceDialog ecDlg = new ECInstanceDialog(ecClass.Name); ecDlg.ShowDialog(); //User didn't save the new instance if (!ecDlg.SavePressed) { return; } //We were not able to save the new instance if (!ecDlg.SaveData()) { return; } RefillItems(e.RowIndex, ecClass.Name); if (itemInstanceCell.Items.Count > 0) { itemInstanceCell.Value = SchemaUtilities.GetDisplayNameForECInstance(ecDlg.GetECInstance(), false); } } //EDIT////////////////////////////////////////////////////////////////////////////////////////////////////////// else if (e.ColumnIndex == EditButtonColumn) { IECInstance ecInst = this[e.ColumnIndex, e.RowIndex].Tag as IECInstance; if (ecInst == null) { MessageBox.Show(LocalizableStrings.NoEditDesc, LocalizableStrings.NoEditTitle, MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { IECInstance ecInstance = EditECInstance(ecInst); if (ecInstance == null) { return; } RefillItems(e.RowIndex, ecClass.Name); if (itemInstanceCell.Items.Count > 0) { itemInstanceCell.Value = SchemaUtilities.GetDisplayNameForECInstance(ecInstance, false); } _bInstanceModified = true; } } //DELETE//////////////////////////////////////////////////////////////////////////////////////////////////////// else if (e.ColumnIndex == DeleteButtonColumn) { IECInstance ecInst = this[e.ColumnIndex, e.RowIndex].Tag as IECInstance; if (ecInst == null) { MessageBox.Show(LocalizableStrings.NoDeleteDescRefOut, LocalizableStrings.NoDeleteTitle, MessageBoxButtons.OK, MessageBoxIcon.Stop); } else { //.GetRelationshipInstances (ecClass.Name, _instance.ClassDefinition.Name, ecRelClass.Name, dgnUtil.GetDGNConnection()); ECInstanceList ecList = dgnUtil.GetRelatedInstances(ecInst, ecRelClass, _ClassDef, dgnUtil.GetDGNConnection()); if (ecList.Count > 0) { MessageBox.Show(string.Format(LocalizableStrings.NoDeleteDescAssocCompFound, itemInstanceCell.Value), LocalizableStrings.NoDeleteTitle, MessageBoxButtons.OK, MessageBoxIcon.Stop); return; } if (MessageBox.Show(String.Format(LocalizableStrings.AreYouSureDelete, SchemaUtilities.GetDisplayNameForECInstance(ecInst, true)), String.Format(LocalizableStrings.DeleteInstanceTitle, ecInst.ClassDefinition.DisplayLabel), MessageBoxButtons.YesNo, MessageBoxIcon.Stop) == DialogResult.No) { return; } dgnUtil.DeleteECInstanceFromDgn(ecInst, dgnUtil.GetDGNConnection()); RefillItems(e.RowIndex, ecClass.Name); if (itemInstanceCell.Items.Count > 0) { itemInstanceCell.Value = itemInstanceCell.Items[0]; } else { itemInstanceCell.Value = null; } } _bInstanceModified = true; } //BROWSE//////////////////////////////////////////////////////////////////////////////////////////////////////// else if (e.ColumnIndex == BrowseButtonColumn) { IECInstance newEcinstance = ecClass.CreateInstance() as IECInstance; if (newEcinstance == null) { return; } object instance = dgnUtil.TagBrowser(newEcinstance, dgnUtil.AssoicatedItemsTagBrowserOverrides); if (instance == null || !(instance is IECInstance)) { return; } IECInstance selectedECInstance = instance as IECInstance; //CommonTools.BIMAdapter.BIMAdapter.ReleaseTag (newEcinstance); dgnUtil.CopyProperties(selectedECInstance, newEcinstance, false); //BusinessKeyUtility.Release (newEcinstance); BusinessKeyUtility.SetIsReserved(newEcinstance, true); dgnUtil.UpdateFunctionalGuidProperty(selectedECInstance, newEcinstance); dgnUtil.WriteECInstanceToDgn(newEcinstance, dgnUtil.GetDGNConnection()); //CommonTools.BIMAdapter //IECInstance inst = EditECInstance (ecInstance); //if(inst == null) // return; // inst = ecInstance; RefillItems(e.RowIndex, ecClass.Name); if (itemInstanceCell.Items.Count > 0) { itemInstanceCell.Value = SchemaUtilities.GetDisplayNameForECInstance(newEcinstance, false); } _bInstanceModified = true; } this[e.ColumnIndex, e.RowIndex].Selected = false; }
//update the WBS specific item based on the wbs ecinstance and relationship name private WBSUpdateType UpdateWBSComboxValue(IECInstance sourceWBS, string WBSRrelationshipName) { //set source WBS values //these values will be matched against values in existing datagrid combo box string sourceName = sourceWBS.ClassDefinition.Name; IECPropertyValue sourceVal = sourceWBS.FindPropertyValue(s_WBSName, false, false, false); if (sourceVal == null || sourceVal.IsNull) { return(WBSUpdateType.Error); } string sourceWbsValue = sourceVal.StringValue; DataGridViewCell dataGridClassCell = null; DataGridViewCell dataGridInstanceCell = null; //iterate items and try match passed in value against associated datagrid combox items for (int i = 0; i < this.Rows.Count; i++) { ECClass ecClass = this[s_WBSClassKey, i].Tag as ECClass; if (!ecClass.Name.Equals(WBSRrelationshipName)) { continue; } string currentValue = this[s_WBSInstanceKey, i].Value as string; //values are the same no need to update if (currentValue.Equals(sourceWbsValue)) { return(WBSUpdateType.ExistingFoundInDgn); } //list of existing WBS items are stored in tag Dictionary <string, IECInstance> cachedInstances = this[s_WBSInstanceKey, i].Tag as Dictionary <string, IECInstance>; if (cachedInstances == null || cachedInstances.Count == 0) { continue; } foreach (IECInstance wbsInst in cachedInstances.Values) { IECPropertyValue wbsPropval = wbsInst.FindPropertyValue(s_WBSName, false, false, false); if (wbsPropval == null || wbsPropval.IsNull) { return(WBSUpdateType.Error); } //if match is found set datagrid values if (wbsPropval.StringValue.Equals(sourceWbsValue)) { dataGridClassCell = this[s_WBSClassKey, i]; dataGridInstanceCell = this[s_WBSInstanceKey, i]; break; } } if (dataGridInstanceCell != null && dataGridClassCell != null) { break; } } //if all those values are found, set datagrid values if (dataGridInstanceCell != null && dataGridClassCell != null) { dataGridClassCell.Selected = true; dataGridInstanceCell.Selected = true; dataGridInstanceCell.Value = sourceWbsValue; return(WBSUpdateType.ExistingFoundInDgn); } return(WBSUpdateType.NeedToCreate); }
//WS: added: internal Dictionary <string, string> GetElementInstancePropertyValues(Element oEle, IECInstance ecInstance) { Dictionary <string, string> oDicPropertyValues = new Dictionary <string, string>(); IEnumerator <IECProperty> oPropertyEnu = ecInstance.ClassDefinition.GetEnumerator(true); IEnumerator <IECPropertyValue> oValEnu = ecInstance.GetEnumerator(true); while (oPropertyEnu.MoveNext()) { oValEnu.MoveNext(); oDicPropertyValues.Add(oPropertyEnu.Current.Name, oValEnu.Current.XmlStringValue); } return(oDicPropertyValues); }
/// <summary> /// /// </summary> /// <param name="elementRefP"></param> /// <param name="modelRefPtr"></param> /// <param name="ecInstance"></param> /// <returns></returns> internal bool UpdateInstance(IntPtr elementRefP, IntPtr modelRefPtr, ref IECInstance ecInstance) { return(HasECInstance(elementRefP, modelRefPtr, ecInstance.InstanceId) && XmlInstanceUpdate.UpdateInstance(ecInstance, modelRefPtr, false)); }
/*------------------------------------------------------------------------------------**/ /// <summary> /// Import /// </summary> /// <param name="unparsed"></param> /*--------------+---------------+---------------+---------------+---------------+------*/ public static void Import ( string unparsed ) { if (string.IsNullOrEmpty(unparsed)) { WorkspaceUtilities.DisplayErrorMessage(LocalizableStrings.BadImportCommand, LocalizableStrings.ImportCommandFormat); return; } BMECApi.Instance.ClearActivePlacementTool(); // exit current placement tool IECClass ecClass = SchemaUtilities.PlantSchema.GetClass(unparsed.Trim()); if (ecClass == null) { WorkspaceUtilities.DisplayErrorMessage(string.Format(LocalizableStrings.BadClassName, unparsed.Trim()), ""); return; } BMECInstanceManager instanceManager = BMECApi.Instance.InstanceManager; OpenFileDialog openFileDlg = new OpenFileDialog(); openFileDlg.Multiselect = false; openFileDlg.Filter = "Import data file|*.txt"; openFileDlg.ShowDialog(); if (string.IsNullOrEmpty(openFileDlg.FileName)) { return; } if (!IsImportFileValidFormat(openFileDlg.FileName, ecClass)) { return; } System.IO.StreamReader sr = System.IO.File.OpenText(openFileDlg.FileName); ArrayList associations = new ArrayList(); ArrayList propertyValues = new ArrayList(); WaitDialog wtDlg = new WaitDialog(); wtDlg.SetTitleString(LocalizableStrings.ImportingInstances); wtDlg.SetInformationSting(LocalizableStrings.ImportingInstancesInfo); wtDlg.Show(); string lineRead = sr.ReadLine().Trim(); while (!sr.EndOfStream) { Application.DoEvents(); if (string.IsNullOrEmpty(lineRead)) { lineRead = sr.ReadLine().Trim(); continue; } if (lineRead == "[Associations]") { associations.Clear(); while (!sr.EndOfStream) { lineRead = sr.ReadLine().Trim(); if (string.IsNullOrEmpty(lineRead)) { continue; } if (lineRead == "[InstanceData]") { break; } associations.Add(lineRead); } } if (lineRead == "[InstanceData]") { propertyValues.Clear(); while (!sr.EndOfStream) { lineRead = sr.ReadLine().Trim(); if (lineRead == "[InstanceData]") { break; } if (lineRead == "[Associations]") { break; } if (string.IsNullOrEmpty(lineRead)) { continue; } propertyValues.Add(lineRead); } IECInstance ecInstance = instanceManager.CreateECInstance(ecClass.Name); BMECApi.Instance.SpecProcessor.FillCurrentPreferences(ecInstance, true); ecInstance.InstanceId = "mechanical"; ECInstanceDialog ecDlg = new ECInstanceDialog(ecInstance); ecDlg.InitializeWithCustomProperties(associations, propertyValues, true); ecDlg.SaveData(); } } wtDlg.Close(); sr.Close(); }
/*------------------------------------------------------------------------------------**/ /// <summary> /// ReplaceComponents /// </summary> /// <param name="unparsed"></param> /*--------------+---------------+---------------+---------------+---------------+------*/ public static void ReplaceComponents ( string unparsed ) { if (PipelineUtilities.IsReplaceDialogRunning) { return; } BMECApi MechnanicalAPI = BMECApi.Instance; // Don't proceed for readonly files if (MechnanicalAPI.IsActiveModelReadOnly()) { MechnanicalAPI.SendToMessageCenterD(Bentley.DgnPlatformNET.OutputMessagePriority.Information, LocalizableStrings.DgnReadonly); return; } ECInstanceList ecList = MechnanicalAPI.GetSelectedInstances(); int count = 0; for (int i = 0; i < ecList.Count; i++) { IECInstance ecInstanceTemp = ecList[i] as IECInstance; if (ecInstanceTemp == null) { continue; } // Skip anything other than piping components or valve operators if (!(SchemaUtilities.IsPipingComponent(ecInstanceTemp) || SchemaUtilities.IsComponentOfType(ecInstanceTemp, ClassNames.VALVE_OPERATING_DEVICE))) { continue; } //You can't replace fasteners if (SchemaUtilities.IsComponentOfType(ecInstanceTemp, ClassNames.FASTENER)) { continue; } //You can't replace seals if (SchemaUtilities.IsComponentOfType(ecInstanceTemp, ClassNames.SEAL)) { continue; } count++; } ECInstanceList nozzleList = new ECInstanceList(); bool bHasFreeformNozzle = false; if (count == 0) { for (int i = 0; i < ecList.Count; i++) { IECInstance ecInstanceTemp = ecList[i] as IECInstance; if (ecInstanceTemp.ClassDefinition.Name == "NOZZLE") { IECPropertyValue propVal = ecInstanceTemp["TYPE_FOR_DATUM"]; if (propVal != null && propVal.StringValue == "Freeform") { bHasFreeformNozzle = true; nozzleList.Add(ecInstanceTemp); } } } } if (count == 0 && !bHasFreeformNozzle) { MechnanicalAPI.SendToMessageCenterD(DgnPlatformNET.OutputMessagePriority.Information, LocalizableStrings.NoComponentsSelectedinDgn); return; } for (int i = 0; i < ecList.Count; i++) { DgnUtilities dgnUtil = DgnUtilities.GetInstance(); IECInstance ecInst = ecList[i]; if (dgnUtil.IsECInstanceFromReferenceFile(ecInst) || dgnUtil.IsECInstanceReferencedOut(ecInst)) { MechnanicalAPI.SendToMessageCenterD(DgnPlatformNET.OutputMessagePriority.Information, LocalizableStrings.ReadonlyComps); return; } } if (s_ReplaceCompDialog == null) { if (nozzleList.Count <= 0) { s_ReplaceCompDialog = new DlgReplaceComponent(ecList, ReplaceDialogMode.SimpleReplace, true); s_ReplaceCompDialog.FormClosed += new FormClosedEventHandler(ReplaceCompDialog_FormClosed); } else { s_ReplaceCompDialog = new DlgReplaceComponent(nozzleList, ReplaceDialogMode.ChangeSpecSize, false); s_ReplaceCompDialog.FormClosed += new FormClosedEventHandler(ReplaceCompDialog_FormClosed); } } s_ReplaceCompDialog.Show(); }
private void OnCellValueChanged ( object sender, DataGridViewCellEventArgs e ) { if (e.ColumnIndex != 1) { return; } if (e.RowIndex < 0 || e.ColumnIndex < 0) { return; } IECClass ecClass = getECClassInformationForCurrentSelection(e.RowIndex); //this[ClassColumn, e.RowIndex].Tag as IECClass; IECRelationshipClass ecRelClass = getECRelationshipClassInformationForCurrentSelection(e.RowIndex); //this[ClassColumn, e.RowIndex].Tag as IECRelationshipClass; string strVal = LocalizableStrings.None; if (null != this[ComboBoxColumn, e.RowIndex].Value) { strVal = this[ComboBoxColumn, e.RowIndex].Value.ToString(); } if (strVal == _cstr_Varies) { return; } DgnUtilities dgnUtil = DgnUtilities.GetInstance(); IECInstance newECIsnt = getInstanceForCurrentSelection(e.RowIndex, strVal); // get from Tag //dgnUtil.GetSourceInstance (ecClass, strVal); foreach (IECInstance ecInstance in _instList) { IECRelationshipInstanceCollection ecRelCol = ecInstance.GetRelationshipInstances(); IEnumerator <IECRelationshipInstance> ecRelInstEnum = ecRelCol.GetEnumerator(); bool newSourceSet = false; while (ecRelInstEnum.MoveNext()) { IECRelationshipInstance ecRelInst = ecRelInstEnum.Current; if (!ecRelInst.ClassDefinition.Is(ecRelClass)) { continue; } if (strVal == LocalizableStrings.None || string.IsNullOrEmpty(strVal)) { ecRelCol.Remove(ecRelInst); } else { ecRelInst.Source = newECIsnt; } newSourceSet = true; break; } if (!newSourceSet && newECIsnt != null) { IECRelationshipInstance temporaryRelInst = ecRelClass.CreateInstance() as IECRelationshipInstance; temporaryRelInst.Source = newECIsnt; temporaryRelInst.Target = ecInstance; ecInstance.GetRelationshipInstances().Add(temporaryRelInst); } IECInstance ecInst = newECIsnt; if (ecInst != null) { if ((dgnUtil.IsECInstanceFromReferenceFile(ecInst) || dgnUtil.IsECInstanceReferencedOut(ecInst) || ecInst.IsReadOnly)) { ecInst = null; } } DataGridViewImageCell tempImageCell = this["optionEdit", e.RowIndex] as DataGridViewImageCell; tempImageCell.Tag = ecInst; tempImageCell = this["optionDelete", e.RowIndex] as DataGridViewImageCell; tempImageCell.Tag = ecInst; //Mark the property (having business key CA/or NAME property if no Business key is defined) as changed and set the event which will reset the property pane. //This is required to update UNIT and SERVICE property listed in property pane on the fly whenever user changes the UNIT or SERVICE in ASSOCIATIONS pane. IECPropertyValue propVal = BusinessKeyUtility.GetPropertyValue(ecInstance); if (propVal != null) { ecInstance.OnECPropertyValueChanged(propVal); } } SaveSettings(); }