Пример #1
0
        /// <summary>
        ///     Removes useless prefixes from the string provided
        /// </summary>
        /// <param name="fullName"></param>
        /// <param name="model"></param>
        /// <returns></returns>
        protected string StripUseless(string fullName, IModelElement model)
        {
            string retVal = fullName;

            if (model != null)
            {
                string[] words   = fullName.Split('.');
                string[] context = model.FullName.Split('.');

                int i = 0;
                while (i < words.Length && i < context.Length)
                {
                    if (words[i] != context[i])
                    {
                        break;
                    }

                    i++;
                }

                // i is the first different word.
                retVal = "";
                while (i < words.Length)
                {
                    if (!String.IsNullOrEmpty(retVal))
                    {
                        retVal += ".";
                    }
                    retVal = retVal + words[i];
                    i++;
                }

                if (Util.isEmpty(retVal))
                {
                    retVal = model.Name;
                }
            }

            if (retVal.StartsWith(DefaultPrefix))
            {
                retVal = retVal.Substring(DefaultPrefix.Length);
            }

            return(retVal);
        }
Пример #2
0
        /// <summary>
        ///     Updates the node color according to the associated messages
        /// </summary>
        /// <returns>true if the node color has been changed</returns>
        public bool UpdateColor()
        {
            bool  retVal = false;
            Color color  = NothingColor;

            if (Model != null)
            {
                MessageInfoEnum info;

                BaseTreeNode parent = Parent as BaseTreeNode;
                if (parent != null && parent.Model != Model)
                {
                    info = Model.MessagePathInfo;
                }
                else
                {
                    // The color of this node is computed according to the color of its sub nodes
                    if (!SubNodesBuilt)
                    {
                        BuildOrRefreshSubNodes(null);
                    }

                    info = MessageInfoEnum.NoMessage;
                    foreach (BaseTreeNode subNode in Nodes)
                    {
                        info = info | subNode.Model.MessagePathInfo;
                    }
                    info = Util.CreatePathTo(info);
                }

                color = ColorBasedOnInfo(info);
            }

            // ReSharper disable once RedundantCheckBeforeAssignment
            if (color != ForeColor)
            {
                retVal    = true;
                ForeColor = color;
            }

            return(retVal);
        }
Пример #3
0
        /// <summary>
        ///     Updates the node name text according to the modelized item
        /// </summary>
        public virtual void UpdateText()
        {
            string name = "";

            if (DefaultName != null)
            {
                name = DefaultName;
            }
            else
            {
                if (Model != null)
                {
                    name = Model.Name;
                }
            }
            if (Text != name && !Util.isEmpty(name))
            {
                Text = name;
            }
        }