/// <summary>
        /// Users the interface toggle message agent.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="MessageAgentEventArgs"/> instance containing the event data.</param>
        private void UserInterfaceToggleMessageAgent(object sender, MessageAgentEventArgs e)
        {
            var hoursMinutes = DateTime.Now;

            // ReSharper disable LocalizableElement
            var newEventlog = new ImsOpcBridgeEventLog(e.Message, Resources.EventLogStatusOK, hoursMinutes.ToString("g", CultureInfo.CurrentCulture));

            // ReSharper restore LocalizableElement
            this.EventLogs.Insert(0, newEventlog); // add as first item

            this.UpdateNumberOfItems();
        }
Beispiel #2
0
        /// <summary>
        /// Users the interface on toggle message agent.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="messageAgentEventArgs">The <see cref="MessageAgentEventArgs"/> instance containing the event data.</param>
        /// <exception cref="System.ArgumentNullException">@ messageAgentEventArgs</exception>
        /// <exception cref="System.ArgumentOutOfRangeException">@ messageAgentEventArgs</exception>
        public void UserInterfaceOnToggleMessageAgent(object sender, MessageAgentEventArgs messageAgentEventArgs)
        {
            if (messageAgentEventArgs == null)
            {
                throw new ArgumentNullException(@"messageAgentEventArgs");
            }

            this.timerMessage.Stop();

            var    messageLines = messageAgentEventArgs.Message.Split(new[] { Environment.NewLine }, 0);
            string message;

            if (messageLines.Length > 1)
            {
                // ReSharper disable LocalizableElement
                message = messageLines[0] + @"...";

                // ReSharper restore LocalizableElement
            }
            else
            {
                message = messageAgentEventArgs.Message;
            }

            this.CurrentMessageText = Resources.MESSAGE + message;
            this.Messages.Insert(0, DateTime.Now + " - " + message);

            switch (messageAgentEventArgs.MessageType)
            {
            case MessageType.MessageExclamation:
                this.BackgroundColor = @"#007CAA";
                this.ForegroundColor = @"#ffffff";

                ////this.BackgroundColor = @"#e94c0a";
                ////this.ForegroundColor = @"#ffffff";
                break;

            case MessageType.MessageInformation:
                this.BackgroundColor = @"#007CAA";
                this.ForegroundColor = @"#ffffff";

                ////this.BackgroundColor = @"#0099ff";
                ////this.ForegroundColor = @"#ffffff";
                break;

            case MessageType.MessageQuestion:
                this.BackgroundColor = @"#007CAA";
                this.ForegroundColor = @"#ffffff";

                ////this.BackgroundColor = @"#0099ff";
                ////this.ForegroundColor = @"#ffffff";
                break;

            case MessageType.MessageStop:
                this.BackgroundColor = @"#007CAA";
                this.ForegroundColor = @"#ffffff";
                break;

            case MessageType.MessageAsterix:
                this.BackgroundColor = @"#007CAA";
                this.ForegroundColor = @"#ffffff";

                ////this.BackgroundColor = @"#0099ff";
                ////this.ForegroundColor = @"#ffffff";
                break;

            case MessageType.MessageError:
                this.BackgroundColor = @"#007CAA";
                this.ForegroundColor = @"#ffffff";

                ////this.BackgroundColor = @"#e94c0a";
                ////this.ForegroundColor = @"#ffffff";
                break;

            case MessageType.MessageHand:
                this.BackgroundColor = @"#007CAA";
                this.ForegroundColor = @"#ffffff";

                ////this.BackgroundColor = @"#0099ff";
                ////this.ForegroundColor = @"#ffffff";
                break;

            case MessageType.MessageNone:
                this.BackgroundColor = @"#007CAA";
                this.ForegroundColor = @"#ffffff";

                ////this.BackgroundColor = @"#506771";
                ////this.ForegroundColor = @"#ffffff";
                break;

            case MessageType.MessageWarning:
                this.BackgroundColor = @"#007CAA";
                this.ForegroundColor = @"#ffffff";

                ////this.BackgroundColor = @"#ffe596";
                ////this.ForegroundColor = @"#ffffff";
                break;

            default:
                throw new ArgumentOutOfRangeException(@"messageAgentEventArgs");
            }

            if (this.AgentMode != AgentMode.List)
            {
                this.AgentMode = AgentMode.Single;

                this.timerMessage.Start();
            }
        }