Ejemplo n.º 1
0
        private void ConnectToLog(string readerName, string initialisationString)
        {
            string         displayString;
            IMessageReader reader;

            try
            {
                if (initialisationString == null)
                {
                    initialisationString = _modules.GetInitialisationString(readerName);
                }
                displayString = initialisationString ?? readerName;

                // Create the message reader and set its initialisation string, prompting the user if necessary.

                reader = _modules.CreateMessageReader(readerName, initialisationString);
            }
            catch (Exception ex)
            {
                throw new ApplicationException(string.Format("Failed to initialise a '{0}' message reader"
                                                             + " using configuration string '{1}'.", readerName, initialisationString), ex);
            }

            // Not found - create and show a new log form for the message reader.

            var form = new LogForm {
                MdiParent = this
            };

#if DEBUG
            form.Closed += logForm_Closed;
#endif
            string displayText = displayString + " (" + _modules.GetDisplayName(readerName) + ")";

            string fullConfigurationString = readerName + "|" + displayString + "|" + initialisationString;
            form.ConfigurationString = fullConfigurationString;

            form.Initialise(reader, displayText);
            form.Show();

            _recentlyUsed.ItemUsed(fullConfigurationString, displayText);

            using (new LongRunningMonitor(this))
            {
                form.AutoStart();                 // Now that the form is visible populate it with messages.
            }
        }