Ejemplo n.º 1
0
 public void Initialize()
 {
     Payload = new CSVEncoder();
     Payload.WriteInteger(1);
     Payload.WriteBoolean(true);
     Payload.WriteString("test");
 }
Ejemplo n.º 2
0
        public void WriteDecimal_10Point1()
        {
            var writer = new CSVEncoder();

            writer.WriteDecimal((Decimal)10.1);
            Assert.AreEqual(1, writer.Symbols.Count);
            Assert.AreEqual("10.1", writer.Symbols[0]);
        }
Ejemplo n.º 3
0
        public void WriteInteger_Minus10()
        {
            var writer = new CSVEncoder();

            writer.WriteInteger(-10);
            Assert.AreEqual(1, writer.Symbols.Count);
            Assert.AreEqual("-10", writer.Symbols[0]);
        }
Ejemplo n.º 4
0
        public void WriteString_Newline()
        {
            var writer = new CSVEncoder();

            writer.WriteString("a\nb");
            Assert.AreEqual(1, writer.Symbols.Count);
            Assert.AreEqual("a\nb", writer.Symbols[0]);
        }
Ejemplo n.º 5
0
        public void WriteString_Commas()
        {
            var writer = new CSVEncoder();

            writer.WriteString("a,b,c");
            Assert.AreEqual(1, writer.Symbols.Count);
            Assert.AreEqual("a,b,c", writer.Symbols[0]);
        }
Ejemplo n.º 6
0
        public void WriteString_Basic()
        {
            var writer = new CSVEncoder();

            writer.WriteString("test");
            Assert.AreEqual(1, writer.Symbols.Count);
            Assert.AreEqual("test", writer.Symbols[0]);
        }
Ejemplo n.º 7
0
        public void WriteTime_1()
        {
            var writer = new CSVEncoder();

            writer.WriteTime(new TimeSpan(0, 0, 1));
            Assert.AreEqual(1, writer.Symbols.Count);
            Assert.AreEqual("00:00:01", writer.Symbols[0]);
        }
Ejemplo n.º 8
0
        public void WriteDateTime_1()
        {
            var writer = new CSVEncoder();

            writer.WriteDateTime(new DateTime(2000, 1, 1, 1, 2, 3));
            Assert.AreEqual(1, writer.Symbols.Count);
            Assert.AreEqual("2000-01-01 01:02:03Z", writer.Symbols[0]);
        }
Ejemplo n.º 9
0
        public void WriteBoolean_False()
        {
            var writer = new CSVEncoder();

            writer.WriteBoolean(false);
            Assert.AreEqual(1, writer.Symbols.Count);
            Assert.AreEqual("false", writer.Symbols[0]);
        }
Ejemplo n.º 10
0
        public void WriteBoolean_True()
        {
            var writer = new CSVEncoder();

            writer.WriteBoolean(true);
            Assert.AreEqual(1, writer.Symbols.Count);
            Assert.AreEqual("true", writer.Symbols[0]);
        }
Ejemplo n.º 11
0
        public void WriteInteger_10_10()
        {
            var writer = new CSVEncoder();

            writer.WriteInteger(10);
            writer.WriteInteger(10);
            Assert.AreEqual(2, writer.Symbols.Count);
            Assert.AreEqual("10", writer.Symbols[0]);
            Assert.AreEqual("10", writer.Symbols[1]);
        }
Ejemplo n.º 12
0
        public String EncodeSymbolSet(String[] symbolSet)
        {
            var buffer = CSVEncoder.Encode(new List <String>(symbolSet));

            return(Encoding.UTF8.GetString(buffer.ToArray()));
        }
Ejemplo n.º 13
0
        public void WriteString_Null()
        {
            var writer = new CSVEncoder();

            writer.WriteString(null);
        }
Ejemplo n.º 14
0
        private void SaveCurrentURL()
        {
            var w = urls[selectedUrlIndex];

            if (w.GetChildren() == null)
            {
                MessageBox.Show("There are no images to save yet.", "Nothing", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
            }
            else
            {
                bool notloaded = false;
                foreach (var c in w.GetChildren())
                {
                    if (c.GetFullImage() == null || !c.HasRetrievedMatches())
                    {
                        notloaded = true;
                        break;
                    }
                }
                if (notloaded && MessageBox.Show("Some images have not been scraped yet. Do you want to continue anyways?", "Missing", MessageBoxButtons.YesNo, MessageBoxIcon.Asterisk) == DialogResult.No)
                {
                    return;
                }
            }

            FolderBrowserDialog dlg = new FolderBrowserDialog();

            dlg.Description = "Please select a folder to save the sheet and the images.";
            if (dlg.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    string path = dlg.SelectedPath;
                    string mp   = Path.Combine(path, FOLDER_MARKER);
                    if (File.Exists(mp))
                    {
                        if (MessageBox.Show("The folder is already used by another URL, are sure that you want to overwrite the data?", "Used", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.No)
                        {
                            return;
                        }
                    }
                    else
                    {
                        File.Create(mp).Close();
                    }
                    File.SetAttributes(mp, FileAttributes.Hidden);
                    List <IWMatch> matches = new List <IWMatch>();
                    foreach (var iw in w.GetChildren())
                    {
                        if (iw.HasRetrievedMatches() && iw.GetSelectedMatch().GetFullImage() != null)
                        {
                            var    m        = iw.GetSelectedMatch();
                            string filename = GetFileName(path, matches, iw);
                            matches.Add(new IWMatch(iw, m, filename));
                        }
                    }

                    CSVEncoder.EncodeToFileAsync(matches, Path.Combine(path, "Log.csv"));

                    foreach (var m in matches)
                    {
                        string n = m.FilePrefix;
                        m.Original.GetFullImage().Save(Path.Combine(path, n + "_Original.jpg"));
                        m.Match.GetFullImage().Save(Path.Combine(path, n + "_Free.jpg"));
                    }
                }
                catch (Exception ex)
                {
                    Reporter.Report(ex);
                }
            }
        }