/// <summary>
        /// Method for calling process command
        /// </summary>
        /// <param name="dlg">Dialog to design and process command</param>
        private void DesignAndProcessCommand(Epi.Windows.Analysis.Dialogs.CommandDesignDialog dlg)
        {
            #region Input Validation
            if (dlg == null)
            {
                throw new System.ArgumentNullException("dlg");
            }
            #endregion  Input Validation

            try
            {
                DialogResult result = dlg.ShowDialog();
                if (result == DialogResult.OK)
                {
                    //Some dialogs may not generate a command. No need to process command if command text is empty.
                    if (!string.IsNullOrEmpty(dlg.CommandText))
                    {
                        if (CommandGenerated != null)
                        {
                            Epi.Windows.Analysis.Forms.CommandProcessingMode Mode = (Epi.Windows.Analysis.Forms.CommandProcessingMode)dlg.ProcessingMode;
                            CommandGenerated(dlg.CommandText, Mode);
                        }
                    }
                    dlg.Close();
                }
            } //try
            finally
            {
                //fix defect 279
                if (this.tvCommands.SelectedNode.Parent != null)
                {
                    tvCommands.SelectedNode = this.tvCommands.SelectedNode.Parent;
                }
                else
                {
                    throw new System.ArgumentNullException("Parent node is null");
                }

                // dcs0 TODO - I don't think this should be here
                //programEditor.SavePGM(Files.LastPgm);
            }//finally
        }
        /// <summary>
        /// Method for calling process command
        /// </summary>
        /// <param name="dlg">Dialog to design and process command</param>
        private void DesignAndProcessCommand(Epi.Windows.Analysis.Dialogs.CommandDesignDialog dlg)
        {
            #region Input Validation
            if (dlg == null)
            {
                throw new System.ArgumentNullException("dlg");
            }
            #endregion  Input Validation

            try
            {
                DialogResult result = dlg.ShowDialog();
                if (result == DialogResult.OK)
                {
                    //Some dialogs may not generate a command. No need to process command if command text is empty.
                    if (!string.IsNullOrEmpty(dlg.CommandText))
                    {
                        String csvFilePath = GetFilePathGivenCommand(dlg.CommandText);

                        if (System.IO.File.Exists(csvFilePath))
                        {
                            byte[] buffer             = new byte[5];
                            System.IO.FileStream file = new System.IO.FileStream(csvFilePath, System.IO.FileMode.Open);
                            file.Read(buffer, 0, 5);
                            file.Close();

                            System.IO.StreamReader reader = new System.IO.StreamReader(csvFilePath);
                            string line = reader.ReadLine();
                            reader.Close();

                            if (line.ToUpper().Contains("SEP="))
                            {
                                String message = String.Format(resources.GetString("DELIMITER_HEADER_WARNING"), line);
                                MessageBox.Show(message);
                            }

                            string command = dlg.CommandText;

                            if (buffer[0] == 255 && buffer[1] == 254)
                            {
                                command = command.Insert(command.IndexOf("HDR="), "CharacterSet=UNICODE;");
                            }

                            dlg.CommandText = command;
                        }

                        if (CommandGenerated != null)
                        {
                            Epi.Windows.Analysis.Forms.CommandProcessingMode Mode = (Epi.Windows.Analysis.Forms.CommandProcessingMode)dlg.ProcessingMode;
                            CommandGenerated(dlg.CommandText, Mode);
                        }
                    }
                    dlg.Close();
                }
            } //try
            finally
            {
                //fix defect 279
                if (this.tvCommands.SelectedNode.Parent != null)
                {
                    tvCommands.SelectedNode = this.tvCommands.SelectedNode.Parent;
                }
                else
                {
                    throw new System.ArgumentNullException("Parent node is null");
                }

                // dcs0 TODO - I don't think this should be here
                //programEditor.SavePGM(Files.LastPgm);
            }//finally
        }