/// <summary> /// Populates this <see cref="ConnectionDialog">ConnectionDialog</see> with specific connection. /// </summary> /// <param name="uilink"></param> /// <param name="startingLinkID"></param> public void PopulateDialog(UIConnection uilink, int startingLinkID) { _uilink = uilink; _startingLinkID = startingLinkID; _propertyManagerCache = new Hashtable(); _shouldBeSaved = false; ElementTypeFilterCheckBox.Checked = false; DimensionFilterCheckBox.Checked = false; int count; ILinkableComponent component; component = uilink.ProvidingModel.LinkableComponent; IExchangeItem[] outputExchangeItems = new IExchangeItem[component.OutputExchangeItemCount]; count = component.OutputExchangeItemCount; for (int i = 0; i < count; i++) { outputExchangeItems[i] = component.GetOutputExchangeItem(i); } providerExchangeItemSelector.PopulateExchangeItemTree(outputExchangeItems, true); component = uilink.AcceptingModel.LinkableComponent; IExchangeItem[] inputExchangeItems = new IExchangeItem[component.InputExchangeItemCount]; count = component.InputExchangeItemCount; for (int i = 0; i < count; i++) { inputExchangeItems[i] = component.GetInputExchangeItem(i); } acceptorExchangeItemSelector.PopulateExchangeItemTree(inputExchangeItems, true); UpdateListLinks(); labelInfo.Text = "Connection " + uilink.ProvidingModel.ModelID + " => " + uilink.AcceptingModel.ModelID; }
/// <summary> /// Selects one model to be shown in dialog. /// </summary> /// <param name="modelID">ID of model to be selected.</param> public void SelectModel(string modelID) { if (modelID == null) { outputExchangeItemSelector.PopulateExchangeItemTree(new OutputExchangeItem[0], false); inputExchangeItemSelector.PopulateExchangeItemTree(new InputExchangeItem[0], false); _loadedModelID = null; } else { // find model by ID int modelIndex = -1; for (int i = 0; i < comboBoxModel.Items.Count; i++) { if ((string)comboBoxModel.Items[i] == modelID) { modelIndex = i; break; } } if (modelIndex < 0 || modelIndex >= _uiModels.Count) { // model with modelID wasn't found Debug.Assert(false); SelectModel(null); return; } UIModel selectedModel = (UIModel)_uiModels[modelIndex]; Debug.Assert(selectedModel.ModelID == modelID); // load exchange items (if they aren't already loaded) if (modelID != _loadedModelID) { IExchangeItem[] outputExchangeItems = new IExchangeItem[selectedModel.LinkableComponent.OutputExchangeItemCount]; for (int i = 0; i < selectedModel.LinkableComponent.OutputExchangeItemCount; i++) { outputExchangeItems[i] = selectedModel.LinkableComponent.GetOutputExchangeItem(i); } outputExchangeItemSelector.PopulateExchangeItemTree(outputExchangeItems, false); IExchangeItem[] inputExchangeItems = new IExchangeItem[selectedModel.LinkableComponent.InputExchangeItemCount]; for (int i = 0; i < selectedModel.LinkableComponent.InputExchangeItemCount; i++) { inputExchangeItems[i] = selectedModel.LinkableComponent.GetInputExchangeItem(i); } inputExchangeItemSelector.PopulateExchangeItemTree(inputExchangeItems, false); _loadedModelID = selectedModel.ModelID; } // select model also in comboBox // this can cause this method is reentered comboBoxModel.SelectedIndex = modelIndex; //labelInfo.Text = "Model " + selectedModel.ModelID; // show properties of this model PropertyGridSelectObject(selectedModel.LinkableComponent); } }