Пример #1
0
        /// <summary>
        ///     Refreshes the data
        /// </summary>
        public virtual void RefreshData()
        {
            SuspendLayout();

            ITextualExplain explainable = Instance as ITextualExplain;

            if (explainable != null)
            {
                string text = TextualExplanationUtils.GetText(explainable, true);

                if (text != null)
                {
                    if (text != _lastExplanation)
                    {
                        _lastExplanation = text;
                        Text             = text;
                    }
                }
                else
                {
                    _lastExplanation = "";
                    Text             = "";
                }
            }
            else
            {
                _lastExplanation = "";
                Text             = "";
            }

            ResumeLayout();
        }
Пример #2
0
        /// <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);
        }
Пример #3
0
        /// <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();
            }
        }
Пример #4
0
 /// <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>");
     }
 }
Пример #5
0
 /// <summary>
 ///     Sets the more information according to the displayed model
 /// </summary>
 private void SetMoreInfo()
 {
     ModelElement.DontRaiseError(() =>
     {
         moreInfoRichTextBox.Text       = "";
         ITextualExplain textualExplain = DisplayedModel as ITextualExplain;
         if (textualExplain != null)
         {
             moreInfoRichTextBox.Instance = DisplayedModel;
             moreInfoRichTextBox.Text     = TextualExplanationUtils.GetText(textualExplain, true);
         }
         Refresh();
     });
 }