private void UpdatePhrasePresentation(PhraseDescriptor phraseDescriptor)
 {
     if (phraseDescriptor != null)
     {
         this.UpdateConditionItem(phraseDescriptor);
         ConditionsEditorControl.PhrasePresentationControl phrasePresentationControl = this.GetPhrasePresentationControlByPhraseDescriptor(phraseDescriptor);
         if (phraseDescriptor.Used && phrasePresentationControl == null)
         {
             this.sentencePanel.SuspendLayout();
             phrasePresentationControl = new ConditionsEditorControl.PhrasePresentationControl(phraseDescriptor);
             this.sentencePanel.Controls.Add(phrasePresentationControl);
             this.sentencePanel.Controls.SetChildIndex(phrasePresentationControl, this.GetIndexOfPhrasePresentationControl(phrasePresentationControl));
             this.UpdatePhrasePresentationControlPrefix();
             this.sentencePanel.ResumeLayout(true);
             this.sentencePanel.ScrollControlIntoView(phrasePresentationControl);
             return;
         }
         if (!phraseDescriptor.Used && phrasePresentationControl != null)
         {
             this.sentencePanel.SuspendLayout();
             this.sentencePanel.Controls.Remove(phrasePresentationControl);
             this.UpdatePhrasePresentationControlPrefix();
             this.sentencePanel.ResumeLayout(true);
             phrasePresentationControl.Dispose();
         }
     }
 }
        private int GetIndexOfPhrasePresentationControl(ConditionsEditorControl.PhrasePresentationControl phraseControl)
        {
            int i;

            for (i = 0; i < this.sentencePanel.Controls.Count - 1; i++)
            {
                ConditionsEditorControl.PhrasePresentationControl phrasePresentationControl = this.sentencePanel.Controls[i] as ConditionsEditorControl.PhrasePresentationControl;
                if (phrasePresentationControl == null || phraseControl.PhraseDescriptor.Index >= phrasePresentationControl.PhraseDescriptor.Index)
                {
                    break;
                }
            }
            return(i);
        }
        private void UpdatePhrasePresentationControlPrefix()
        {
            int previousGroupID = int.MinValue;

            for (int i = this.sentencePanel.Controls.Count - 1; i >= 0; i--)
            {
                ConditionsEditorControl.PhrasePresentationControl phrasePresentationControl = this.sentencePanel.Controls[i] as ConditionsEditorControl.PhrasePresentationControl;
                if (phrasePresentationControl != null && phrasePresentationControl.PhraseDescriptor != null)
                {
                    phrasePresentationControl.UpdateText(previousGroupID);
                    previousGroupID = phrasePresentationControl.PhraseDescriptor.GroupID;
                }
            }
        }
 private ConditionsEditorControl.PhrasePresentationControl GetPhrasePresentationControlByPhraseDescriptor(PhraseDescriptor phrase)
 {
     ConditionsEditorControl.PhrasePresentationControl result = null;
     foreach (object obj in this.sentencePanel.Controls)
     {
         Control control = (Control)obj;
         ConditionsEditorControl.PhrasePresentationControl phrasePresentationControl = control as ConditionsEditorControl.PhrasePresentationControl;
         if (phrasePresentationControl != null && phrasePresentationControl.PhraseDescriptor == phrase)
         {
             result = phrasePresentationControl;
             break;
         }
     }
     return(result);
 }