Exemplo n.º 1
0
        protected void SetReactions(CompoundListReaction curReaction, CompoundListReaction newReaction)
        {
            ChangeGeneric(true);
            Font BoldFont = new Font(txtCurReactants.Font, FontStyle.Bold);

            txtCurGeneric.Text = curReaction.ToString();
            txtNewGeneric.Text = newReaction.ToString();

            //Bold changes:
            //Only reasonable approach here is using the all powerful Regex...
            Match m = CompoundListReaction.s_SourceSinkRegex.Match(txtCurGeneric.Text);
            Match curMatch = Compound.s_CompoundSeperator.Match(
                m.Groups["Value"].Value);
            Match newMatch = Compound.s_CompoundSeperator.Match(
                CompoundListReaction.s_SourceSinkRegex.Match(txtNewGeneric.Text).Groups["Value"].Value);
            int offset = m.Groups["Value"].Index;
            foreach (Capture curComp in curMatch.Groups["Comp"].Captures)
            {
                bool contained = false;
                string s = curComp.Value.Trim();
                foreach (Capture newComp in newMatch.Groups["Comp"].Captures)
                    if (newComp.Value.Trim() == s)
                    {
                        contained = true;
                        break;
                    }
                if (!contained)
                {
                    txtCurGeneric.Select(curComp.Index + offset, curComp.Length);
                    HighlightText(txtCurGeneric);
                }
            }

            foreach (Capture newComp in newMatch.Groups["Comp"].Captures)
            {
                bool contained = false;
                string s = newComp.Value.Trim();
                foreach (Capture curComp in curMatch.Groups["Comp"].Captures)
                    if (curComp.Value.Trim() == s)
                    {
                        contained = true;
                        break;
                    }
                if (!contained)
                {
                    txtNewGeneric.Select(newComp.Index + offset, newComp.Length);
                    HighlightText(txtNewGeneric);
                }
            }
        }