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);
        }
Beispiel #2
0
        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();
        }