/// <summary> /// Provides the explanation associated to the ITextualExplain /// </summary> /// <param name="textualExplain"></param> /// <param name="explainSubElements"></param> /// <returns></returns> public static string GetText(ITextualExplain textualExplain, bool explainSubElements) { TextualExplanation text = new TextualExplanation(); textualExplain.GetExplain(text, explainSubElements); return(text.Text); }
/// <summary> /// Explains a list of namables and shows the associated textbox /// </summary> /// <param name="namable">The namable to explain</param> /// <param name="location"> /// The location where the explain box should be displayed. If empty is displayed, the location is /// computed based on the combo box location /// </param> /// <param name="sensibleToMouseMove">Indicates that the explain box should be closed when the mouse moves</param> private void ExplainAndShow(INamable namable, Point location, bool sensibleToMouseMove) { explainRichTextBox.Text = ""; if (namable != null) { TextualExplanation explanation = new TextualExplanation(); ITextualExplain textualExplain = namable as ITextualExplain; if (textualExplain != null) { textualExplain.GetExplain(explanation, false); } explainRichTextBox.Text = explanation.Text; explainRichTextBox.ProcessAllLines(); if (location == Point.Empty) { if (SelectionComboBox.DroppedDown) { explainRichTextBox.Location = new Point( SelectionComboBox.Location.X + SelectionComboBox.Size.Width, SelectionComboBox.Location.Y + SelectionComboBox.Size.Height ); } else { explainRichTextBox.Location = new Point( SelectionComboBox.Location.X, SelectionComboBox.Location.Y + SelectionComboBox.Size.Height ); } } else { explainRichTextBox.Location = new Point( Math.Min(location.X, EditionTextBox.Size.Width - explainRichTextBox.Size.Width), Math.Min(location.Y, EditionTextBox.Size.Height - explainRichTextBox.Size.Height)); } ConsiderMouseMoveToCloseExplanation = sensibleToMouseMove; explainRichTextBox.Size = new Size(400, 200); if (explainRichTextBox.Size.Width >= Size.Width * 0.8) { explainRichTextBox.Size = new Size((int)(Size.Width * 0.8), explainRichTextBox.Size.Height); } if (explainRichTextBox.Size.Height >= Size.Height * 0.8) { explainRichTextBox.Size = new Size(explainRichTextBox.Size.Width, (int)(Size.Height * 0.8)); } explainRichTextBox.Show(); EditionTextBox.SendToBack(); } }
/// <summary> /// Provides an explanation of explainable, if it is not null /// </summary> /// <param name="explainable"></param> /// <param name="explainSubElements"></param> public void Write(ITextualExplain explainable, bool explainSubElements = true) { if (explainable != null) { explainable.GetExplain(this, explainSubElements); } else { Data.Append("<Unknown>"); } }