Exemplo n.º 1
0
        private bool doRead()
        {
            if (!File.Exists(PathRead))
            {
                MessageBox.Show("File does not exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (StlFile.IsBinaryFile(PathRead))
            {
                reader = new BinaryStlReader <Triangle, Vertex, Normal>(new DataCreator());
                writer = null;
            }
            else
            {
                reader = new AsciiStlReader <Triangle, Vertex, Normal>(new DataCreator());
                writer = null;
            }

            ByteReadHelper readHelper = readStenography();
            string         msg        = "";

            if (readHelper.ReadEverything())
            {
                try {
                    textBox3.Text = MyEncoding.GetString(readHelper.Data.ToArray());
                    return(true);
                } catch (Exception e) {
                    msg = "\n" + e.Message;
                }
            }
            MessageBox.Show("Could not decode data!" + msg, "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            return(false);
        }
Exemplo n.º 2
0
        private bool doWrite()
        {
            if (!File.Exists(PathRead))
            {
                MessageBox.Show("Read file does not exist", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return(false);
            }
            if (File.Exists(PathWrite))
            {
                DialogResult result = MessageBox.Show("Write file already exists, overwrite?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
                if (result == DialogResult.No)
                {
                    return(false);
                }
            }
            if (StlFile.IsBinaryFile(PathRead))
            {
                reader = new BinaryStlReader <Triangle, Vertex, Normal>(new DataCreator());
                writer = new BinaryStlWriter <Triangle, Vertex, Normal>(new DataExtractor());
            }
            else
            {
                reader = new AsciiStlReader <Triangle, Vertex, Normal>(new DataCreator());
                writer = new AsciiStlWriter <Triangle, Vertex, Normal>(new DataExtractor());
            }

            return(performStenography(MyEncoding.GetBytes(textBox3.Text)));
        }
Exemplo n.º 3
0
 public bool IsBinaryFile_ReturnsExpected(string filename)
 {
     return(StlFile.IsBinaryFile(filename));
 }