bool filteringResultForRow(DataGridViewRow row)
        {
            bool matches = false;

            foreach (DataGridViewCell cell in row.Cells)
            {
                if (textBoxFilter.Text != filterDefault && textBoxFilter.Text != string.Empty)
                {
                    if (cell.Value != null && cell.Value.ToString().ToLower().Contains(textBoxFilter.Text.ToLower()))
                    {
                        matches = true;
                        break;
                    }
                }
                else
                {
                    matches = true;
                }
            }

            bool matchesManual = false;

            if (checkFilterMan.Checked)
            {
                parseResult pr = row.Tag as parseResult;
                matchesManual = pr != null && pr.match_filename == pr.full_filename;
            }
            else
            {
                matchesManual = true;
            }

            return(matches && matchesManual);
        }
        parseResult merge(parseResult orig, DataGridViewRow changes)
        {
            foreach (DataGridViewCell cell in changes.Cells)
            {
                var colname = dataGridViewReview.Columns[cell.ColumnIndex].Name;
                if (colname == "Status")
                {
                    orig.success = (bool)cell.Value;
                }
                if (colname != "Filename" &&
                    colname != "Status")
                {
                    if (orig.parser.Matches.ContainsKey(colname))
                    {
                        orig.parser.Matches[colname] = cell.Value as string;
                    }
                    else if (!string.IsNullOrEmpty(cell.Value as string))
                    {
                        orig.parser.Matches.Add(colname, cell.Value as string);
                    }
                }
            }

            return(orig);
        }
        private void contextMenuStripChangeCell_Opening(object sender, CancelEventArgs e)
        {
            DataGridViewCell cell = null;

            if (dataGridViewReview.SelectedCells.Count == 1)
            {
                cell = dataGridViewReview.SelectedCells[0];
            }
            if (cell == null)
            {
                return;
            }

            contextMenuStripChangeCell.Items.Clear();
            parseResult origpr = dataGridViewReview.Rows[cell.RowIndex].Tag as parseResult;

            contextMenuStripChangeCell.Items.Add("File: " + origpr.full_filename);
            contextMenuStripChangeCell.Items.Add(string.Format("Matched using expression [{0}]:", origpr.parser.RegexpMatchedIndex));
            contextMenuStripChangeCell.Items.Add(origpr.parser.RegexpMatched);

            // for enabled column simply offer to change to all
            if (cell is DataGridViewCheckBoxCell && cell.ColumnIndex == 0)
            {
                bool isChecked = (bool)cell.Value;
                contextMenuStripChangeCell.Items.Add(string.Format("{0} all currently displayed", isChecked ? "Disable" : "Enable"));
                contextMenuStripChangeCell.Items[2].Tag = new object[] { cell, isChecked, !isChecked };
                return;
            }

            var orig = cell.Tag as string;

            if (orig == null)
            {
                return;
            }


            //// lets see if the cell was changed
            string cellValue = cell.Value as string;

            // if no change dont offer to do anything

            if (string.IsNullOrEmpty(orig) && string.IsNullOrEmpty(cellValue))
            {
                return;
            }
            if (orig == cellValue)
            {
                return;
            }
            // else offer to do this change automatically for them all

            contextMenuStripChangeCell.Items.Add(string.Format("Change all \"{0}\" to \"{1}\" in Column \"{2}\"", orig, cellValue, dataGridViewReview.Columns[cell.ColumnIndex].HeaderText));
            contextMenuStripChangeCell.Items[2].Tag = new object[] { cell, orig, cellValue };
        }
Esempio n. 4
0
        // test implementation
        public void parseBufferFast
            (List <byte> dataIn, ConcurrentBag <canMessage2> dataOut, int maxMsgs = -1)
        {
            bool finish  = false;
            int  counter = 0;
            int  dataIdx = 0;

            while (dataIn.Count > dataIdx && false == finish)
            {
                byte b = dataIn[dataIdx];
                while (dataIn.Count > dataIdx && b != 't' && b != 'T' && b != 'F' && b != 'E' && b != 'G' && b != '\r' && b != '\b')
                {
                    b = dataIn[dataIdx++];
                }

                /*// skip all the bytes untill the marker is received
                 * while (dataIn.Count > dataIdx && dataIn[dataIdx] != 't' && dataIn[dataIdx] != 'T' &&
                 *  dataIn[dataIdx] != 'F' && dataIn[dataIdx] != 'E' && dataIn[dataIdx] != 'G' && dataIdx[dat)
                 *  dataIdx++;
                 */
                if (dataIdx >= dataIn.Count)
                {
                    break;
                }

                if (b == '\r')
                {
                    //Debug.WriteLine("Sent");
                    sent = true;
                    dataIdx++;
                    continue;
                }

                if (b == '\b')
                {
                    Debug.WriteLine("NOT Sent");
                    dataIdx++;
                    continue;
                }

                if (dataIn[dataIdx] == 'F')
                {
                    int err = parse2ByteVal('F', ref dataIn, ref dataIdx);
                    if (-1 == err)
                    {
                        break;
                    }

                    if (err > 0)
                    {
                        Debug.WriteLine("F = " + err.ToString("X2"));
                        updateErrorCounters(err);
                        // err = err;
                        //Debug.WriteLine("F = " + err.ToString("X2"));
                    }
                    continue;
                }

                if (dataIn[dataIdx] == 'E')
                {
                    int err = parse2ByteVal('E', ref dataIn, ref dataIdx);
                    if (-1 == err)
                    {
                        break;
                    }
                    //Debug.WriteLine("E = " + err.ToString("X2"));
                    if (err > 0)
                    {
                        //err = err;
                    }
                    continue;
                }

                if (dataIn[dataIdx] == 'G')
                {
                    int err = parse2ByteVal('G', ref dataIn, ref dataIdx);
                    if (-1 == err)
                    {
                        break;
                    }
                    // handle
                    RawRegDataHandle(err);

                    if (err > 0)
                    {
                        //Debug.WriteLine("G = " + err.ToString());
                    }

                    continue;
                }

                // message
                canMessage2 msg = null;
                parseResult res = parseCanMessage(ref dataIn, ref dataIdx, out msg);

                if (res == parseResult.parseOk)
                {
                    dataOut.Add(msg);
                    TimestampError = false;
                    if (maxMsgs > 0)
                    {
                        if (++counter >= maxMsgs)
                        {
                            finish = true;
                        }
                    }
                }
                else if (res == parseResult.parseNoTimeStamp)
                {
                    TimestampError = true;
                }
                else if (res == parseResult.parseFiltered)
                {
                    // do nothing
                }
                else if (res == parseResult.parseBuffTooLow)
                {
                    finish = true;
                }
                else
                {
                    dataIdx++;  // dataIn.RemoveAt(0);
                }
            }

            // extract the data we'd parsed
            dataIn.RemoveRange(0, dataIdx);
        }
Esempio n. 5
0
        /// <summary>
        /// Updates the File, Folder and Path property using the LocalMedia data
        /// </summary>
        private void updatePropertiesFromLocalMedia()
        {
            if (LocalMedia != null)
            {
                string filenameToParse;
                string parserFilename;

                DirectoryInfo baseFolder = Utility.GetMusicVideoBaseDirectory(LocalMedia[0].File.Directory);
                folder = baseFolder.Name;
                file   = LocalMedia[0].File.Name;
                path   = baseFolder.FullName;

                if (file == "VIDEO_TS.IFO")
                {
                    parserFilename = folder + ".dvd";
                }
                else
                {
                    parserFilename = LocalMedia[0].File.FullName;
                }

                //filenameToParse = LocalMedia[0].File.FullName;
                filenameToParse = parserFilename;
                FilenameParser parser = new FilenameParser(filenameToParse, baseFolder);

                parseResult CurrentParseResult = new parseResult();
                parser.Matches.Add(MusicVideoImporter.cFilename, file);
                parser.Matches.Add(MusicVideoImporter.cExt, LocalMedia[0].File.Extension);
                parser.Matches.Add(MusicVideoImporter.cPath, LocalMedia[0].TrimmedFullPath);
                parser.Matches.Add(MusicVideoImporter.cVolumeLabel, LocalMedia[0].MediaLabel);

                if (!parser.Matches.ContainsKey(MusicVideoImporter.cArtist))
                {
                    CurrentParseResult.failedArtist = true;
                    CurrentParseResult.success      = false;
                    CurrentParseResult.exception    = "Artist is not valid";
                }

                if (!parser.Matches.ContainsKey(MusicVideoImporter.cTrack))
                {
                    CurrentParseResult.failedTrack = true;
                    CurrentParseResult.success     = false;
                    CurrentParseResult.exception   = "Track is not valid";
                }

                if (!parser.Matches.ContainsKey(MusicVideoImporter.cAlbum))
                {
                    CurrentParseResult.failedAlbum = true;
                    CurrentParseResult.success     = true;
                    CurrentParseResult.exception   = "Album is not valid";
                }

                CurrentParseResult.match_filename = LocalMedia[0].TrimmedFullPath;
                CurrentParseResult.full_filename  = LocalMedia[0].File.Name;
                CurrentParseResult.parser         = parser;

                if (!CurrentParseResult.failedArtist)
                {
                    artist = CurrentParseResult.Artist;
                    artist = Regex.Replace(artist, @"\s{2,}", " ").Trim();
                }

                if (!CurrentParseResult.failedAlbum)
                {
                    album = CurrentParseResult.Album;
                    album = Regex.Replace(album, @"\s{2,}", " ").Trim();
                }

                if (!CurrentParseResult.failedTrack)
                {
                    track = CurrentParseResult.Track;
                    track = Regex.Replace(track, @"\s{2,}", " ").Trim();
                }


                logger.Debug(string.Format("Result of Parsing : Artist: {0}    Album: {1}    Track: {2}", artist, album, track));
            }
        }
Esempio n. 6
0
        parseResult merge(parseResult orig, DataGridViewRow changes)
        {
            foreach (DataGridViewCell cell in changes.Cells)
            {
                var colname = dataGridViewReview.Columns[cell.ColumnIndex].Name;
                if (colname == "Status")
                    orig.success = (bool)cell.Value;
                if (colname != "Filename" &&
                    colname != "Status")
                {
                    if (orig.parser.Matches.ContainsKey(colname))
                        orig.parser.Matches[colname] = cell.Value as string;
                    else if(!string.IsNullOrEmpty(cell.Value as string)) 
                        orig.parser.Matches.Add(colname, cell.Value as string);
                }
            }

            return orig;
        }