private PropertyDefinition ConvertShorthandColumnIndex(ITomlRoot root, TomlInt tomlInt) { var columnIndex = tomlInt.Value; if (columnIndex <= 0 || columnIndex > int.MaxValue) { throw new ParseException($"{columnIndex} is an invalid {nameof(ColumnDefinition.ColumnIndex)} value. Must be > 0."); } return(new PropertyDefinition { ColumnIndex = (int)columnIndex }); }
private void WriteInt(TomlInt i) { switch (i.IntType) { case TomlInt.IntTypes.Binary: WriteIntWithBase("0b", i.Value, 2); break; case TomlInt.IntTypes.Octal: WriteIntWithBase("0o", i.Value, 8); break; case TomlInt.IntTypes.Hex: WriteIntWithBase("0x", i.Value, 16); break; default: this.writer.Write(i.Value); break; } void WriteIntWithBase(string prefix, long value, int b) { this.writer.Write(prefix); this.writer.Write(Convert.ToString(value, b).ToUpperInvariant()); } }
public void Visit(TomlInt i) => data[currentPath] = i.Value.ToString(CultureInfo.InvariantCulture);
void ITomlObjectVisitor.Visit(TomlInt i) => sb.Append("{").Append("\"type\":\"integer\", \"value\":\"").Append(i.Value).Append("\"}");
void ITomlObjectVisitor.Visit(TomlInt i) => this.table[this.currentKey] = i.Value;
public void Visit(TomlInt i) => this.Item = i.Value;
/// <summary> /// Saves the current configuration out to the config file. /// </summary> public void Save() { // Physical Paramters TomlTable physicalParameters = Toml.Create(); // Passes TomlInt passes = physicalParameters.Add("Passes", Passes).Added; passes.AddComment(" The number of times to run the complete etching path", CommentLocation.Append); // PixelSize TomlFloat pixelSize = physicalParameters.Add("PixelSize", PixelSize).Added; pixelSize.AddComment(" The size of each pixel (mm per pixel)", CommentLocation.Append); // OriginX TomlFloat originX = physicalParameters.Add("OriginX", OriginX).Added; originX.AddComment(" The X coordinate of the top-left corner, in mm", CommentLocation.Append); // OriginY TomlFloat originY = physicalParameters.Add("OriginY", OriginY).Added; originY.AddComment(" The Y coordinate of the top-left corner, in mm", CommentLocation.Append); // ZHeight TomlFloat zHeight = physicalParameters.Add("ZHeight", ZHeight).Added; zHeight.AddComment(" The Z height to set the laser cutter during etching, in mm", CommentLocation.Append); // TravelSpeed TomlFloat travelSpeed = physicalParameters.Add("TravelSpeed", TravelSpeed).Added; travelSpeed.AddComment(" The speed to move the head between etching operations (when the laser is off), in mm per minute", CommentLocation.Append); // EtchSpeed TomlFloat etchSpeed = physicalParameters.Add("EtchSpeed", EtchSpeed).Added; etchSpeed.AddComment(" The speed to move the head during etching operations (when the laser is on), in mm per minute", CommentLocation.Append); // G-code Commands TomlTable gCodeCommands = Toml.Create(); // LaserOffCommand TomlString laserOffCommand = gCodeCommands.Add("LaserOffCommand", LaserOffCommand).Added; laserOffCommand.AddComment(" The G-code command to turn the laser off", CommentLocation.Append); // LaserLowCommand TomlString laserLowCommand = gCodeCommands.Add("LaserLowCommand", LaserLowCommand).Added; laserLowCommand.AddComment(" The G-code command to turn the laser on, but at a low power level (used for the pre-etch trace preview)", CommentLocation.Append); // LaserHighCommand TomlString laserHighCommand = gCodeCommands.Add("LaserHighCommand", LaserHighCommand).Added; laserHighCommand.AddComment(" The G-code command to turn the laser on full power during etching", CommentLocation.Append); // MoveCommand TomlString moveCommand = gCodeCommands.Add("MoveCommand", MoveCommand).Added; moveCommand.AddComment(" The G-code command to use during moves", CommentLocation.Append); // CommentMode TomlString commentMode = gCodeCommands.Add("CommentMode", CommentMode.ToString()).Added; commentMode.AddComment(" The G-code comment format to use (Semicolon or Parentheses)", CommentLocation.Append); // HomeXY TomlBool homeXY = gCodeCommands.Add("HomeXY", HomeXY).Added; homeXY.AddComment(" True to home the X and Y axes at the start, false to leave them where they were and assume that they are already homed", CommentLocation.Append); // Pre-Etch Trace Preview TomlTable preEtchTracePreview = Toml.Create(); // IsBoundaryPreviewEnabled TomlBool isBoundaryPreviewEnabled = preEtchTracePreview.Add("IsBoundaryPreviewEnabled", IsBoundaryPreviewEnabled).Added; isBoundaryPreviewEnabled.AddComment(" True to perform the pre-etch boundary trace preview, false to disable it and get right to etching", CommentLocation.Append); // PreviewDelay TomlInt previewDelay = preEtchTracePreview.Add("PreviewDelay", PreviewDelay).Added; previewDelay.AddComment(" The delay, in milliseconds, to wait at the start and end of the pre-etch trace preview", CommentLocation.Append); TomlTable settingsTable = Toml.Create(); settingsTable.Add("Physical-Parameters", physicalParameters); settingsTable.Add("G-Code-Commands", gCodeCommands); settingsTable.Add("Pre-Etch-Trace-Preview", preEtchTracePreview); Toml.WriteFile(settingsTable, ConfigFileName); }