Example #1
0
        private void OpenFile(LineEvaluator mustIncludeLineInOutput)
        {
            FileStream   fs = null;
            StreamReader sr = null;

            try
            {
                StringBuilder output   = new StringBuilder();
                string        fileName = GetSelectedFile();
                try
                {
                    fs = new FileStream(fileName, FileMode.Open,
                                        FileAccess.Read, FileShare.ReadWrite);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                    return;
                }
                int lineNumber = 0;

                sr = new StreamReader(fs);
                while (!sr.EndOfStream)
                {
                    lineNumber++;
                    string line = sr.ReadLine();
                    if (mustIncludeLineInOutput(line, lineNumber))
                    {
                        output.AppendLine("Line " + lineNumber.ToString() + "    " + line);
                    }
                }
                string contents = output.ToString();
                if (string.IsNullOrEmpty(contents))
                {
                    contents = "File " + fileName + " opened but no contents matched filter";
                }

                LogViewerDisplay.Text = contents;
                string lastChar = contents.Substring(contents.Length - 2, 1);
                LogViewerDisplay.Select(contents.Length - 3, contents.Length - 2);
                LogViewerDisplay.ScrollToCaret();
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                    sr.Dispose();
                }
                if (fs != null)
                {
                    fs.Close();
                    fs.Dispose();
                }
            }
        }
Example #2
0
        public void TestMethod1()
        {
            List <string> contentL = new List <string>();

            contentL.Add("04:26:12: [Verföhnt] hat sich eingeloggt.");
            contentL.Add("08:13:15: [Filysha] hat sich eingeloggt.");
            contentL.Add("04:26:12: [16. Level 65][Shaslol@Zaviel]: tentakelrapeforlife");
            contentL.Add("04:26:12: [Gilde][Shaslol@Zaviel]: tentakelrapeforlife");
            contentL.Add("07:20:34: [10. Level 50-59@Typhiria][@Typhiria]: Das Zonenereignis [Instabil: Glutinsel] in [Glutinsel] hat auf Typhiria begonnen!");
            contentL.Add("04:26:12: [16. Level 65][Sheide@Zaviel]: we all have our secrets :D");
            contentL.Add("04:26:16: [16. Level 65][Wedancegj@Gelidra]: w8t one sec zaviel are u he or she :D");
            contentL.Add("04:26:19: [Artoine@Typhiria] flüstert: ich hab programmieren als haupt- und nebenfach in" +
                         "der schule aber da macht man nicht so schnell progress :D auf ner uni gehts schon tausendmal schneller vorwärts");
            contentL.Add("04:26:20: [4. Stufe 1-29][Raphaely]: Also ein paar k platin ansammeln und auktionshaus preiskontrolle veranstalten...");
            contentL.Add("15:39:07: [Bobito] hat beim Bedarfs-Wurf 44 gewürfelt für: [Dicker Goldgürtel]");
            contentL.Add("15:39:07: [Bobito] hat mit einem Bedarfs-Wurf von 44 Folgendes gewonnen: [Dicker Goldgürtel]");
            contentL.Add("15:39:07: [Bobito] hat Folgendes erbeutet: [Dicker Goldgürtel]");
            contentL.Add("15:39:15: [Bobito] hat beim Bedarfs-Wurf 3 gewürfelt für: [Güldener Zermalmer]");
            contentL.Add("15:39:15: [Bobito] hat mit einem Bedarfs-Wurf von 3 Folgendes gewonnen: [Güldener Zermalmer]");

            MacroManager.Initialize();
            LineEvaluator   lEval = new LineEvaluator();
            ContentControls dw    = new ContentControls("chattest");

            dw.add("global", new DataGrid());

            lEval.registerCustomMask("lfm", Brushes.Orange);

            foreach (var item in contentL)
            {
                Line line = lEval.createLine(item);
                dw.write(line);
            }
        }
Example #3
0
        private Point3D EvaluateSpreadPosition(double x1, double y1, Point3D point, double spreadT)
        {
            double x2 = point.X;
            double y2 = point.Y;

            LineEvaluator line = new LineEvaluator();

            line.Point1 = MapToMesh(x1, y1);
            line.Point2 = MapToMesh(x2, y2);
            return(line.Evaluate(spreadT));
        }
Example #4
0
        private string GetFilteredFileContents(LineEvaluator mustIncludeLineInOutput, string fileName)
        {
            FileStream   fs = null;
            StreamReader sr = null;

            try
            {
                StringBuilder output = new StringBuilder();
                try
                {
                    fs = new FileStream(fileName, FileMode.Open,
                                        FileAccess.Read, FileShare.ReadWrite);
                }
                catch (Exception exc)
                {
                    MessageBox.Show(exc.Message);
                    return(string.Empty);
                }
                int lineNumber = 0;
                sr = new StreamReader(fs);
                while (!sr.EndOfStream)
                {
                    lineNumber++;
                    string line = sr.ReadLine();
                    if (mustIncludeLineInOutput(line, lineNumber))
                    {
                        output.AppendLine("Line " + lineNumber.ToString() + "    " + line);
                    }
                }
                return(output.ToString());
            }
            catch (Exception exc)
            {
                MessageBox.Show(exc.Message);
                return(string.Empty);
            }
            finally
            {
                if (sr != null)
                {
                    sr.Close();
                    sr.Dispose();
                }
                if (fs != null)
                {
                    fs.Close();
                    fs.Dispose();
                }
            }
        }