Exemplo n.º 1
0
        /// <summary>
        /// Append a new status message for the stream proxy.
        /// </summary>
        /// <param name="statusMessage">New status message to append to current messages.</param>
        /// <remarks>
        /// This method is usually accessed pre-serialization in the service (via <see cref="StreamProxy"/>).
        /// </remarks>
        public void AppendStatusMessage(string statusMessage)
        {
            if (string.IsNullOrWhiteSpace(statusMessage))
            {
                return;
            }

            lock (m_updateLock)
            {
                if (string.IsNullOrEmpty(m_recentStatusMessages))
                {
                    m_recentStatusMessages = ToolTipEx.WordWrapStatus(statusMessage);
                    return;
                }

                string updatedStatusMessages = m_recentStatusMessages + Environment.NewLine + ToolTipEx.WordWrapStatus(statusMessage);

                // Truncate from the left to maintain maximum status size
                if (updatedStatusMessages.Length > MaximumStatusSize)
                {
                    updatedStatusMessages = updatedStatusMessages.Substring(updatedStatusMessages.Length - MaximumStatusSize);
                }

                m_recentStatusMessages = updatedStatusMessages;
            }
        }
        private void UpdateToolTip(string status)
        {
            if (string.IsNullOrWhiteSpace(status))
            {
                return;
            }

            try
            {
                string currentToolTip = Invoke((Func <string>)(() => toolTipEx.GetToolTip(statusStrip))) as string;

                if (string.IsNullOrWhiteSpace(currentToolTip))
                {
                    Invoke((Action)(() => toolTipEx.SetToolTip(statusStrip, ToolTipEx.WordWrapStatus(status))));
                    return;
                }

                currentToolTip += ToolTipEx.WordWrapStatus(status);

                // Truncate from the left to maintain maximum tool-tip size
                if (currentToolTip.Length > MaximumToolTipSize)
                {
                    currentToolTip = currentToolTip.Substring(currentToolTip.Length - MaximumToolTipSize);
                }

                Invoke((Action)(() => toolTipEx.SetToolTip(statusStrip, currentToolTip)));
            }
            catch (ObjectDisposedException)
            {
                // This can happen on shutdown :-p
            }
        }