示例#1
0
 private void writeString(BinaryWriter file, string code, bool binary)
 {
     GCode gc = new GCode();
     gc.Parse(code);
     if (gc.hostCommand) return;
     if (binary)
     {
         if (gc.hasCode)
         {
             byte[] data = gc.getBinary(1);
             file.Write(data);
         }
     }
     else
     {
         System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
         string cmd = gc.getAscii(false, false);
         if (cmd.Length > 0)
             file.Write(enc.GetBytes(cmd + "\n"));
     }
 }
示例#2
0
 private void writeArray(BinaryWriter file, List<GCodeShort> list, bool binary)
 {
     foreach (GCodeShort code in list)
     {
         GCode gc = new GCode();
         gc.Parse(code.text);
         if (gc.hostCommand) continue;
         if (binary)
         {
             if (gc.hasCode)
             {
                 byte[] data = gc.getBinary(1);
                 file.Write(data);
             }
         }
         else
         {
             System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
             string cmd = gc.getAscii(false, false);
             if (cmd.Length > 0)
                 file.Write(enc.GetBytes(cmd + "\n"));
         }
     }
 }