protected override UIValidationError[] GetValidationErrors()
        {
            List <UIValidationError> list = new List <UIValidationError>();

            if (this.ConditionDescriptors != null)
            {
                StringBuilder stringBuilder = new StringBuilder();
                foreach (ConditionDescriptor conditionDescriptor in this.ConditionDescriptors)
                {
                    PhraseDescriptor phraseByIndex = this.GetPhraseByIndex(conditionDescriptor.Index);
                    if (phraseByIndex != null)
                    {
                        ValidationError[] array = phraseByIndex.Validate();
                        foreach (ValidationError validationError in array)
                        {
                            stringBuilder.AppendLine(validationError.Description);
                        }
                    }
                }
                if (stringBuilder.Length > 0)
                {
                    list.Add(new UIValidationError(new LocalizedString(stringBuilder.ToString()), this.sentencePanel));
                }
            }
            return(list.ToArray());
        }
 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 void conditionListView_UpdateItem(object sender, ItemCheckedEventArgs e)
        {
            PhraseDescriptor phraseByListViewItem = this.GetPhraseByListViewItem(e.Item);

            if (phraseByListViewItem != null)
            {
                e.Item.Checked = phraseByListViewItem.Used;
            }
        }
        private PhraseDescriptor GetPhraseByListViewItem(ListViewItem listViewItem)
        {
            PhraseDescriptor    result = null;
            ConditionDescriptor conditionDescriptor = this.conditionListView.GetRowFromItem(listViewItem) as ConditionDescriptor;

            if (conditionDescriptor != null)
            {
                result = this.GetPhraseByIndex(conditionDescriptor.Index);
            }
            return(result);
        }
 public PhrasePresentationControl(PhraseDescriptor phrase) : this()
 {
     if (phrase == null)
     {
         throw new ArgumentNullException("phrase");
     }
     this.phraseDescriptor = phrase;
     base.TabIndex         = this.PhraseDescriptor.Index;
     base.ListSeparator    = this.DefaultListSeparator;
     base.Text             = this.PhraseDescriptor.MarkupText;
     base.DataSource       = this.PhraseDescriptor.DataSource;
 }
        private void conditionListView_ItemCheck(object sender, ItemCheckEventArgs e)
        {
            ConditionDescriptor conditionDescriptor = this.conditionListView.GetRowFromItem(this.conditionListView.Items[e.Index]) as ConditionDescriptor;

            if (conditionDescriptor != null)
            {
                PhraseDescriptor phraseByIndex = this.GetPhraseByIndex(conditionDescriptor.Index);
                if (phraseByIndex != null)
                {
                    phraseByIndex.Used = (e.NewValue == CheckState.Checked);
                }
            }
            base.UpdateError();
        }
 private void UpdateConditionItem(PhraseDescriptor phraseDescriptor)
 {
     if (this.ConditionDescriptors != null && phraseDescriptor != null)
     {
         ConditionDescriptor conditionByIndex = this.GetConditionByIndex(phraseDescriptor.Index);
         if (conditionByIndex != null)
         {
             ListViewItem itemFromRow = this.conditionListView.GetItemFromRow(conditionByIndex);
             if (itemFromRow != null)
             {
                 itemFromRow.Checked = phraseDescriptor.Used;
             }
         }
     }
 }
        private PhraseDescriptor GetPhraseByIndex(int index)
        {
            PhraseDescriptor result = null;

            if (this.PhraseDescriptors != null)
            {
                foreach (PhraseDescriptor phraseDescriptor in this.PhraseDescriptors)
                {
                    if (phraseDescriptor.Index == index)
                    {
                        result = phraseDescriptor;
                        break;
                    }
                }
            }
            return(result);
        }
 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);
 }