Exemplo n.º 1
0
        private async void search_Click(object sender, EventArgs e)
        {
            if (thereIsValidInformation() == false)
            {
                return;
            }

            listBox1.Items.Clear();
            cancelButton.Enabled = true;
            results.Visible      = false;

            try
            {
                var res = await FileSearch.Find(folder, ext, query, cts.Token, progress);

                // This code will run within the UI context
                var resText = String.Format("Total files: {0}, .{1} files: {2}. Files matched the search: {3}",
                                            res.totalFiles, ext, res.totalFilesWithExtension, res.files.Count);
                results.Text    = resText;
                results.Visible = true;
            }
            catch (OperationCanceledException ex)
            {
                // benign exception
            }
            catch (Exception ex)
            {
                MessageBox.Show("Error: " + ex.Message); // Ooopss..
            }

            progressBar1.Value   = 0;
            cancelButton.Enabled = false;
            maximumSet           = false;
            cts = new CancellationTokenSource(); // reset the token
        }
Exemplo n.º 2
0
        public bool LoadFile(string filePath)
        {
            if (string.IsNullOrEmpty(filePath))
            {
                return(false);
            }

            FileFullPath = filePath;

            StartingEntries = FileSearch.Find(FileFullPath, "starting,");
            StoppingEntries = FileSearch.Find(FileFullPath, "stopping,");

            if (!LoadStartingData())
            {
                return(false);
            }
            if (!LoadStoppingData())
            {
                return(false);
            }

            foreach (string s in Devices)
            {
                IEnumerable <FileSearchResults> res = Enumerable.Empty <FileSearchResults>();
                res = FileSearch.Find(FileFullPath, $",{s},");
                LaserEntries.Add(res);
            }

            if (!LoadLaserData())
            {
                return(false);
            }

            EncoderTransformEntries = FileSearch.Find(FileFullPath, ",encoderTransform,");

            LoadStatusData();

            return(true);
        }