public MainWindow()
 {
     InitializeComponent();
     DataContext = Model = new MainWindowViewModel();
     Logger      = new AnalyserLogger(Model.Blocks, Dispatcher);
     Progress.ProgressChanged += ReportProgress;
     Reader = new FunctionReader(Logger, Progress);
 }
        private void BtnFunctionScan_Click(object sender, RoutedEventArgs e)
        {
            var           fileContent = string.Empty;
            var           fileName    = string.Empty;
            List <string> functions   = new List <string>();

            OpenFileDialog openFileDialog = new OpenFileDialog();

            openFileDialog.InitialDirectory = "c:\\";
            openFileDialog.Filter           = "javascript files (*.js)|*.js|All files (*.*)|*.*";
            openFileDialog.FilterIndex      = 0;
            openFileDialog.RestoreDirectory = true;
            bool result = (bool)openFileDialog.ShowDialog();

            if (result)
            {
                //Get the path of specified file
                fileName = openFileDialog.SafeFileName;

                //Read the contents of the file into a stream
                var fileStream = openFileDialog.OpenFile();

                using (StreamReader reader = new StreamReader(fileStream))
                {
                    string line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        if (FunctionReader.LineContainsFunction(line))
                        {
                            functions.Add(FunctionReader.GetFunctionName(line));
                        }
                    }
                }

                FunctionList newListBox = new FunctionList(fileName, functions);
                newListBox.ShowDialog();
            }
        }