Example #1
0
        public static TerminalTabControlItem CreateTerminalTabPageByFavoriteName(FavoriteConfigurationElement favorite)
        {
            String terminalTabTitle = favorite.Name;

            if (Settings.ShowUserNameInTitle)
            {
                Credential.GetCredentials(favorite).AppendTabPageTitleWithUserName(ref terminalTabTitle);
            }

            return(new TerminalTabControlItem(terminalTabTitle, favorite.Name));
        }
Example #2
0
        /// <summary>
        /// Extension method that returns the tool tip text.
        /// </summary>
        /// <param name="favorite"></param>
        /// <returns></returns>
        public static String GetToolTipText(this FavoriteConfigurationElement favorite)
        {
            string captionComputer = "Computer: ";
            string captionURL      = "Url: ";

            bool isUrl = false;

            string serverName = favorite.GetServersAndIPs(ref isUrl);

            if (isUrl)
            {
                serverName = captionURL + serverName;
            }
            else
            {
                serverName = captionComputer + serverName;
            }

            if (!string.IsNullOrEmpty(serverName) && serverName.Length > 100)
            {
                serverName = serverName.Remove(90, serverName.Length - 90) + " ...";
            }

            String toolTip = string.IsNullOrEmpty(serverName) || string.IsNullOrEmpty(serverName.Replace(captionComputer, string.Empty).Replace(captionURL, string.Empty)) ? string.Empty : serverName + Environment.NewLine;

            if (favorite.Port > 0)
            {
                toolTip += "Port: " + favorite.Port + Environment.NewLine;
            }

            if (Credential.GetCredentials(favorite).IsSetUserNameAndDomainName)
            {
                toolTip += "User: "******"-" : favorite.Notes;

                if (!string.IsNullOrEmpty(notes) && notes != "-")
                {
                    bool appendWithDots = false;

                    string[] notesArray = notes.Split('\n');

                    if (notesArray.Length == 1 && notes.Length > 300)
                    {
                        notes          = notes.Remove(300, notes.Length - 300);
                        appendWithDots = true;
                    }

                    if (notesArray.Length > 5)
                    {
                        notes = notesArray[0] +
                                notesArray[1] +
                                notesArray[2] +
                                notesArray[3] +
                                notesArray[4].TrimEnd();

                        appendWithDots = true;
                    }

                    if (appendWithDots)
                    {
                        notes += " ...";
                    }
                }

                toolTip += String.Format("Tag: {1}{0}Connect to Console: {2}{0}Notes: {3}", Environment.NewLine, string.IsNullOrEmpty(favorite.Tags) ? "-" : favorite.Tags, favorite.ConnectToConsole, notes);
            }

            return(toolTip);
        }