private void SetState(MultiState mState, int stateIndex, int color, bool blink = false) { MSState mst; mst = mState.GetState(stateIndex); mst.LowerValue = stateIndex - 1; //mst.UpperValue = 0.95; mst.Color = color; //mst.DefineState(0, 0, pbRed); mst.Blink = blink; }
private int ProcessReplaceTagPart(Symbol sym, string sour, string targ) { int result = 0; try { if (sym.Type == (int)PBObjLib.pbSYMBOLTYPE.pbSymbolComposite) { Composite comp = (Composite)sym; for (int i = 1; i <= comp.GroupedSymbols.Count; i++) { Symbol subsym = comp.GroupedSymbols.Item(i); result += ProcessReplaceTagPart(subsym, sour, targ); } } else { if (sym.IsMultiState) { MultiState obj = sym.GetMultiState(); string tagName = obj.GetPtTagName(); string newName = ReplacePart(tagName, sour, targ); if (tagName != newName) { obj.SetPtTagName(newName); result++; } } if (sym.Type == (int)PBObjLib.pbSYMBOLTYPE.pbSymbolValue) { Value obj = (Value)sym; string tagName = obj.GetTagName(1); string newName = ReplacePart(tagName, sour, targ); if (tagName != newName) { obj.SetTagName(newName); result++; } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } return(result); }
private void CreateMultistate(Symbol sym, string tagName, pbTrendCOLOR[] colors) { MultiState mState = sym.CreateMultiState(tagName); mState.StateCount = colors.Length; for (int idx = 0; idx < colors.Length; idx++) { int colorVal = (int)colors[idx]; SetState(mState, idx + 1, colorVal, false); } //mState.DefineState(1, 0, 0); //mState.DefineState(2, 1, 2); }
private void button2_Click(object sender, EventArgs e) { Display ThisDisplay = m_App.ActiveDisplay; for (int i = 1; i <= ThisDisplay.SelectedSymbols.Count; i++) { Symbol s = ThisDisplay.SelectedSymbols.Item(i); if (s.IsMultiState) { MultiState ms = s.GetMultiState(); ms.GetState(1).Color = 32768; ms.ColorBadData = 65535; } } }
private void button1_Click(object sender, EventArgs e) { Display ThisDisplay = m_App.ActiveDisplay; int replaceCount = 0; for (int i = 1; i <= ThisDisplay.Symbols.Count; i++) { try { Symbol s = ThisDisplay.Symbols.Item(i); if (s.IsMultiState) { MultiState obj = s.GetMultiState(); if (obj.GetPtTagName() != obj.GetPtTagName().Replace(textBox1.Text, textBox2.Text)) { replaceCount++; } obj.SetPtTagName(obj.GetPtTagName().Replace(textBox1.Text, textBox2.Text)); } if (s.Type == 7 & textBox1.Text != "" & textBox2.Text != "") { Value obj = (Value)ThisDisplay.Symbols.Item(i); //string tgNm = obj.GetTagName(1); if (obj.GetTagName(1) != obj.GetTagName(1).Replace(textBox1.Text, textBox2.Text)) { replaceCount++; } obj.SetTagName(obj.GetTagName(1).Replace(textBox1.Text, textBox2.Text)); ThisDisplay.Refresh(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } } MessageBox.Show(string.Format("Replace {0} item(s)", replaceCount)); this.Close(); }