/// <summary> /// Uses the AFEventFrameFindControl, but overrides the EventFrameBrowser to FindEventFrames (AFOperations). /// Opens dialog to select eventframes to be shown in the AFViewControl /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void afEventFrameFindCtrl_DialogButtonPressing(object sender, CancelEventArgs e) { e.Cancel = true; AFNamedCollectionList <AFEventFrame> frames = null; bool b = true; // afEventFrameFindCtrl.FindEventFrame(afDatabasePicker1.AFDatabase, true, ref b); // afEventFrameFindCtrl // AFEventFrame frame = afEventFrameFindCtrl.FindEventFrame(afDatabasePicker1.AFDatabase, false, ref b); AFOperations.FindEventFrames(this, afDatabasePicker1.AFDatabase, out frames, true, true, "PersistID"); if (frames.Count > 0) { avcEventFrames.AFSetObject(frames, afDatabasePicker1.AFDatabase, null, null); avcEventFrames.AFSelection = frames[0]; object selected = avcEventFrames.AFSelection; avcEventFrames_ItemSelected(this, null); } }
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(); }
public PBToolkitBar() { InitializeComponent(); PISystems systems = new PISystems(); m_System = systems.DefaultPISystem; if (m_Database == null) { DialogResult dialogResult; m_Database = AFOperations.ConnectToDatabase(this, m_System.Name, "", true, out dialogResult); } m_FoundElement = null; btnConnect_Click(null, null); }
private void PITagSearch_Click(object sender, EventArgs e) { List <PIPoint> ptlist = AFOperations.FindPIPoints(this, myPIServer.Name, "", true, false); if (ptlist != null) { foreach (PIPoint pt in ptlist) { string[] displayvalues = new string[4]; displayvalues[0] = pt.Name; displayvalues[1] = pt.GetAttribute("Descriptor").ToString(); displayvalues[2] = pt.CurrentValue().Timestamp.ToString(); displayvalues[3] = pt.CurrentValue().Value.ToString(); ListViewItem lvi = new ListViewItem(displayvalues); TagList.Items.Add(lvi); } } }
/// <summary> /// Handles the afTreeView Menu Item calls, brings up the FindElements Dialog and EventFrame Dialog /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void afTreeViewElements_MenuItemClicked(object sender, MenuItemClickedEventArgs e) { try { e.Handled = true; bool persistUserData = true; bool multiSelect = true; string myPersistID = "MyPersistID"; if ((AFMenu.MenuCommand)e.ClickedItem.MergeIndex == AFMenu.MenuCommand.FindChildren) { AFNamedCollectionList <AFElement> elements = null; DialogResult dr = AFOperations.FindElements(this, afDatabasePicker1.AFDatabase, out elements, multiSelect, persistUserData, myPersistID); //Clear Search and Load new search if (dr == DialogResult.OK) { currentSearchResults = elements; currentTreeSearchTimes = 0; currentTreeSearch = ""; tbElementSearchName.Text = ""; if (currentSearchResults.Count > 0) { findTreeNode(afTreeViewElements.Nodes[0], currentSearchResults[currentTreeSearchTimes]); } } } else if ((AFMenu.MenuCommand)e.ClickedItem.MergeIndex == AFMenu.MenuCommand.FindEventFrames) { AFNamedCollectionList <AFEventFrame> frames = null; AFOperations.FindEventFrames(this, afDatabasePicker1.AFDatabase, out frames, true, true, "PersistID"); if (frames.Count > 0) { avcEventFrames.AFSetObject(frames, afDatabasePicker1.AFDatabase, null, null); avcEventFrames.AFSelection = frames[0]; object selected = avcEventFrames.AFSelection; avcEventFrames_ItemSelected(this, null); } } } catch { } }
private void PITagSearch_Click(object sender, EventArgs e) { try { myPIServer = (PIServer)piServerPicker1.AFSelection; List <PIPoint> ptlist = AFOperations.FindPIPoints(this, myPIServer.Name, "", true, false); if (ptlist != null) { foreach (PIPoint pt in ptlist) { string[] displayvalues = new string[2]; displayvalues[0] = pt.Name; displayvalues[1] = pt.GetAttribute("Descriptor").ToString(); ListViewItem lvi = new ListViewItem(displayvalues); TagList.Items.Add(lvi); } } } catch (Exception ex) { MessageBox.Show(ex.Message + " : Have not connected PI Data Archive"); } }
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(); }