/// <summary>
        /// Create a log reader based on the selected UI inputs
        /// </summary>
        /// <param name="query"></param>
        /// <param name="output"></param>
        /// <param name="logfile"></param>
        /// <param name="machineName"></param>
        /// <returns></returns>
        public bool ReadLog(string query, Dictionary <string, Query> output, string logfile = "", string machineName = "")
        {
            LogReader lr;

            if (LoadFromOption == LoadFromOptions.Live)
            {
                lr = LogReaderFactory.CreateLiveLogReader(query: query, server: machineName);
            }
            else
            {
                if (File.Exists(logfile))
                {
                    lr = LogReaderFactory.CreateSavedLogReader(logfile, query);
                }
                else
                {
                    MessageBoxResult result = MessageBox.Show("Invalid Log File", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    return(false);
                }
            }

            try {
                lr.ReadLog(output, ct);
            }
            catch (Exception e) {
                MessageBoxResult result = MessageBox.Show(e.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return(false);
            }
            return(true);
        }
        private void StartWatch(object sender, RoutedEventArgs e)
        {
            //read textbox values
            string machineName = MachineName.Text;
            string logFile     = LogFile.Text;

            //create query
            //4 = Information Log Level (required)
            //11,12 - EventIDs of the start/end query processing (required)
            string s = LogQueryBuilder.Build(
                new List <int> {
                4
            },
                new List <int> {
                11, 12
            }
                );

            //Create logreader -> sign up for new logreader events -> Begin watching
            watchingLogReader = LogReaderFactory.CreateLiveLogReader(query: s, server: machineName);
            watchingLogReader.CompleteQueryWrittenEvent += WriteWatchResults;
            bool watchStartSuccessful = watchingLogReader.StartWatch();

            if (watchStartSuccessful)
            {
                //update UI with available options
                StartWatchButton.IsEnabled = false;
                ParseButton.IsEnabled      = false;
                CancelButton.IsEnabled     = true;
                Processing.Content         = "Processing";


                dispatcherTimer.Start();

                //set outputwriter to whatever output option was chosen in the ui
                switch (SaveAsOption)
                {
                default:
                case SaveAsOptions.EventFrame:
                    outputWriter = new AFWriter(db);
                    break;

                case SaveAsOptions.Text:
                    outputWriter = new TextFileWriter(FileOutput.Text);
                    break;

                case SaveAsOptions.Console:
                    outputWriter = new ConsoleWriter();
                    break;
                }
            }
            else
            {
                MessageBoxResult result = MessageBox.Show("Error creating log watcher - this feature is not available with this version", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }