private void comboBoxPartList_SelectedIndexChanged(object sender, EventArgs e) { //selected entry was changed //check if the selection didn't actually change if (comboBoxPartList.SelectedIndex == m_intLastSelected && m_dicCurrentIndices.ContainsKey(CurrentPart.Id) && CurrentPart.DocumentElement.OwnerDocument == CurrentPartCollection[m_dicCurrentIndices[CurrentPart.Id] + 1].DocumentElement.OwnerDocument) { return; } Debug.WriteLine("Switched selection in stream list."); //clear the tooltip toolTipNamespace.Active = false; toolTipNamespace.RemoveAll(); //reset property page controlMain.RefreshProperties(null); //check if we selected the last item in the list if (comboBoxPartList.SelectedIndex == comboBoxPartList.Items.Count - 1) { //then we selected add using (Forms.FormAddPart fap = new Forms.FormAddPart()) { //add a new stream from the XML retrieved from the Add New dialog //otherwise, select the last selected item and populate with its xml if (fap.ShowDialog() == DialogResult.OK) { try { //add the stream object objMissing = Type.Missing; CurrentPartCollection.Add(fap.XmlString, objMissing); Debug.WriteLine("Dropdown refresh for manual stream addition"); RefreshPartList(false, false, true, string.Empty, string.Empty, null); } catch (COMException ex) { ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, Properties.Resources.ErrorOnPartAdd, ex.Message)); if (comboBoxPartList.SelectedIndex != m_intLastSelected) { comboBoxPartList.SelectedIndex = m_intLastSelected; } } } else { //user cancel if (comboBoxPartList.SelectedIndex != m_intLastSelected) { comboBoxPartList.SelectedIndex = m_intLastSelected; } } } } else { Debug.WriteLine("Tree refresh for SelectedIndexChanged from " + m_intLastSelected.ToString(CultureInfo.InvariantCulture) + " to " + comboBoxPartList.SelectedIndex.ToString(CultureInfo.InvariantCulture)); //set the new selection m_intLastSelected = comboBoxPartList.SelectedIndex; //fire back at the event class to switch up the event handlers Debug.Assert(EventHandler != null, "null event handler"); // Find the correct part (skipping ones we don't list) int index = -1; foreach (Office.CustomXMLPart currentPart in CurrentPartCollection) { if (OpenDoPEModel.Model.isOpenDoPEPart(currentPart)) { // Not listed, therefore don't count continue; } else { index++; } if (m_intLastSelected == index) { EventHandler.ChangeCurrentPart(currentPart); break; } } //EventHandler.ChangeCurrentPart(CurrentPartCollection[m_intLastSelected + 1]); //refresh the tree Debug.WriteLine("now, RefreshTreeControl"); controlMain.RefreshTreeControl(m_mxnToSelect); } }
private void comboBoxPartList_SelectedIndexChanged(object sender, EventArgs e) { //selected entry was changed //check if the selection didn't actually change if (comboBoxPartList.SelectedIndex == m_intLastSelected && m_dicCurrentIndices.ContainsKey(CurrentPart.Id) && CurrentPart.DocumentElement.OwnerDocument == CurrentPartCollection[m_dicCurrentIndices[CurrentPart.Id] + 1].DocumentElement.OwnerDocument) { return; } Debug.WriteLine("Switched selection in stream list."); //clear the tooltip toolTipNamespace.Active = false; toolTipNamespace.RemoveAll(); //reset property page ((ControlMain)Parent).RefreshProperties(null); //check if we selected the last item in the list if (comboBoxPartList.SelectedIndex == comboBoxPartList.Items.Count - 1) { //then we selected add using (Forms.FormAddPart fap = new Forms.FormAddPart()) { //add a new stream from the XML retrieved from the Add New dialog //otherwise, select the last selected item and populate with its xml if (fap.ShowDialog() == DialogResult.OK) { try { //add the stream object objMissing = Type.Missing; CurrentPartCollection.Add(fap.XmlString, objMissing); Debug.WriteLine("Dropdown refresh for manual stream addition"); RefreshPartList(false, false, true, string.Empty, string.Empty, null); } catch (COMException ex) { ShowErrorMessage(string.Format(CultureInfo.CurrentCulture, Properties.Resources.ErrorOnPartAdd, ex.Message)); if (comboBoxPartList.SelectedIndex != m_intLastSelected) { comboBoxPartList.SelectedIndex = m_intLastSelected; } } } else { //user cancel if (comboBoxPartList.SelectedIndex != m_intLastSelected) { comboBoxPartList.SelectedIndex = m_intLastSelected; } } } } else { Debug.WriteLine("Tree refresh for SelectedIndexChanged from " + m_intLastSelected.ToString(CultureInfo.InvariantCulture) + " to " + comboBoxPartList.SelectedIndex.ToString(CultureInfo.InvariantCulture)); //set the new selection m_intLastSelected = comboBoxPartList.SelectedIndex; //fire back at the event class to switch up the event handlers Debug.Assert(EventHandler != null, "null event handler"); EventHandler.ChangeCurrentPart(CurrentPartCollection[m_intLastSelected + 1]); //refresh the tree ((ControlMain)Parent).RefreshTreeControl(m_mxnToSelect); } }