示例#1
0
 public void Search()
 {
     // can't find stuff like this
     if (Url == null || ToFind == null)
     {
         return;
     }
     try {
         HttpWebRequest  request  = (HttpWebRequest)WebRequest.Create(Url);
         HttpWebResponse response = (HttpWebResponse)request.GetResponse();
         using (var stream = new StreamReader(response.GetResponseStream())) {
             string line = stream.ReadLine();
             while (line != null)
             {
                 if (ToFind.IsMatch(line))
                 {
                     // found the expression: store the group,
                     // then we can stop reading data
                     Match match = ToFind.Match(line);
                     Result = match.Groups[0].Value;
                     break;
                 }
                 line = stream.ReadLine();
             }
         }
     } catch {}
 }
示例#2
0
        /// <summary>
        /// Megpróbálja megtalálni a megadott mezõt a keresett képek listájában.
        /// Ha megtalálta, akkor kiszedi és játékmód szerint újat rak be, vagy úgy hagyja.
        /// </summary>
        /// <param name="clickedField">A kattintott mezõ</param>
        /// <returns>true - ha megtalálta a mezõt, false ha nem</returns>
        public bool TryToFindField(Field clickedField)
        {
            Image foundImage = null;

            foreach (Image image in ToFind)
            {
                if (clickedField.ImageProperty.Name.Equals(image.Name))
                {
                    foundImage = image;
                    break;
                }
            }
            if (foundImage != null)
            {
                ToFind.Remove(foundImage);

                if (ToFind.Count == 0)
                {
                    outOfImages();
                }

                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#3
0
        /// <summary>
        /// Hozzáad egy új random képet
        /// </summary>
        public void AddNewImageToFind()
        {
            Random random = new Random();
            //kiválaszt megadott számú random mezõt az elkészített táblából
            Field toFindRandomFieldFromBoard = Board.AllFields.OrderBy(x => random.Next()).Take(1).First();

            //a random mezõkbõl kiszedi a képet - ez azért kell, mert egy kép többször is szerepelhet
            ToFind.Add(toFindRandomFieldFromBoard.ImageProperty);
        }
示例#4
0
        public void Search()
        {
            // can't find stuff like this
            if (Url == null || ToFind == null)
            {
                return;
            }

            try
            {
                WebRequest  request  = WebRequest.Create(Url);
                WebResponse response = request.GetResponse();
                using (var stream = new StreamReader(response.GetResponseStream()))
                {
                    string line = stream.ReadLine();

                    while (line != null)
                    {
                        if (ToFind.IsMatch(line))
                        {
                            // found the expression: store the group,
                            // then we can stop reading data
                            Match match = ToFind.Match(line);
                            Result = match.Groups[0].Value;
                            break;
                        }
                        line = stream.ReadLine();
                    }
                }
                response.Close();
            }
            catch (WebException e)
            {
                Console.Error.WriteLine("Failed to load web page to check for regular expression with the following error: " + e.ToString());
            }
            catch { }
        }
示例#5
0
        public async Task <object> Find_Last_4MB(ParsingMethod method)
        {
            const string ToFind      = "596003.67";
            const int    ColumnIndex = 8;

            int rowNumber = 0;
            int rowCount  = 0;

            switch (method)
            {
            case ParsingMethod.CsvHelper:
            {
                var reader = (CsvReader)Open(method, Resources.FileSize.MB4);

                while (await reader.ReadAsync())
                {
                    rowCount++;

                    if (ToFind == reader.GetField(ColumnIndex))
                    {
                        rowNumber = rowCount;
                    }
                }

                if (rowCount != rowNumber)
                {
                    throw new Exception("Failing benchmark because invalid conclusion was made");
                }

                return(reader);
            }

            default:
            {
                var csv = (ITokenizer)GetTokenizer(method, Resources.FileSize.MB4);

                while (true)
                {
                    var row = await csv.GetNextAsync();

                    if (row == null)
                    {
                        break;
                    }

                    rowCount++;

                    if (ToFind.Equals(row[ColumnIndex].ToString()))
                    {
                        rowNumber = rowCount;
                    }
                }

                if (rowCount != rowNumber)
                {
                    throw new Exception("Failing benchmark because invalid conclusion was made");
                }
                return(csv);
            }
            }
        }
 //TextBox NoteText;
 public Find_and_Change(NotesView parent)
 {
     InitializeComponent();
     this.parent = parent;
     ToFind.Focus();
 }