private void BtnSetMSClick(object sender, EventArgs e) { btnConnect_Click(null, null); bool res = AFOperations.BrowseElement(this, m_Database, null, ref m_FoundElement); if (!res) { return; } if (m_FoundElement == null) { MessageBox.Show("Element not selected", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string afelemName = "AF2." + m_FoundElement.GetPath() + "|Result"; pbTrendCOLOR[] colorsTemplate; switch (cmbColors.SelectedIndex) { case 0: colorsTemplate = ColorTemplate0; break; case 1: colorsTemplate = ColorTemplate1; break; case 2: colorsTemplate = ColorTemplate2; break; case 3: colorsTemplate = ColorTemplate3; break; default: colorsTemplate = ColorTemplate1; break; } Display disp = m_App.ActiveDisplay; var selectedSyms = disp.SelectedSymbols; for (int i = 1; i <= selectedSyms.Count; i++) { try { Symbol sym = selectedSyms.Item(i); CreateMultistate(sym, afelemName, colorsTemplate); } catch (Exception ex) { MessageBox.Show(ex.Message); } } disp.Refresh(); }
private void btnReplace_Click(object sender, EventArgs e) { btnConnect_Click(null, null); bool res = AFOperations.BrowseElement(this, m_Database, null, ref m_FoundElement); if (!res) { return; } if (m_FoundElement == null) { MessageBox.Show("Element not selected", "", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } string afelemName = "AF2." + m_FoundElement.GetPath(); Display disp = m_App.ActiveDisplay; var selectedSyms = disp.SelectedSymbols; int replaceCount = 0; for (int i = 1; i <= selectedSyms.Count; i++) { try { Symbol sym = selectedSyms.Item(i); replaceCount += ProcessReplaceElement(sym, afelemName); } catch (Exception ex) { MessageBox.Show(ex.Message); } } MessageBox.Show(string.Format("Replace {0} item(s)", replaceCount)); disp.Refresh(); }