public override void WriteCommands(Stream stream, Encoding encoding, Project project) { int realX = this.CalculatePrintingX(this.Width, project); int realY = this.CalculatePrintingY(this.Height, project); UsbUtil.WriteCommand(stream, encoding, "X" + realX + ";" + realY + ";" + (realX + this.Width) + ";" + (realY + this.Height) + ";" + this.Thickness); }
public virtual void WriteCommands(Stream stream, Encoding encoding, Project project) { UsbUtil.WriteCommand(stream, encoding, "G" + (project.XOffset + this.Position.X) + ";" + GetAlignmentChar(this.HorizontalAlignment)); UsbUtil.WriteCommand(stream, encoding, "I" + (project.YOffset + this.Position.Y) + ";" + GetAlignmentChar(this.VerticalAlignment)); UsbUtil.WriteCommand(stream, encoding, "R" + GetRotationDegrees(this.Rotation)); if (this.SupportsHorizontalScaling()) { UsbUtil.WriteCommand(stream, encoding, "D" + this.HorizontalScaling); } }
public override void WriteCommands(Stream stream, Encoding encoding, Project project) { int width = this.LineDirection == Direction.Horizontal ? this.Length : 1; int height = this.LineDirection == Direction.Vertical ? this.Length : 1; int realX = this.CalculatePrintingX(width, project); int realY = this.CalculatePrintingY(height, project); Console.WriteLine(this.Thickness + ";" + this.LineDirection.ToString()); UsbUtil.WriteCommand(stream, encoding, "X" + realX + ";" + realY + ";" + (realX + width) + ";" + (realY + height) + ";" + this.Thickness); }
private void btnPrintTicket_Click(object sender, EventArgs e) { if (!this.isConnected) { new PrinterNotConnectedDialog().ShowDialog(); return; } PrintTicketsDialog dialog = new PrintTicketsDialog(Project, SelectedTicket); if (dialog.ShowDialog() != DialogResult.OK) { return; } Ticket ticket = dialog.SelectedTicket; int amount = dialog.Amount; // Configuration UsbUtil.WriteCommand(this.connection.BaseStream, Encoding.Default, "k1;0"); // Layout for (int i = 0; i < amount; i++) { using (MemoryStream stream = new MemoryStream()) { stream.WriteByte(UsbUtil.BeginLayout); foreach (TicketItem item in ticket.Items) { item.WriteCommands(stream, Encoding.Default, Project); } stream.WriteByte(UsbUtil.EndLayout); byte[] buffer = stream.GetBuffer(); this.connection.Write(buffer, 0, buffer.Length); Console.WriteLine(ManualControlWindow.formatOutput(Encoding.Default.GetString(buffer))); //stream.WriteTo(this.connection.BaseStream); } UsbUtil.WriteCommand(this.connection.BaseStream, Encoding.Default, "#1"); this.Project.NextTicketNumber++; } isChanged = true; UpdateSaveButton(); nudNewTicketNumber.Value = Project.NextTicketNumber; pnlTicketItems.Refresh(); }
public override void WriteCommands(System.IO.Stream stream, Encoding encoding, Project project) { UsbUtil.WriteCommand(stream, encoding, "G0" + project.XOffset); UsbUtil.WriteCommand(stream, encoding, "I0" + project.YOffset); UsbUtil.WriteCommand(stream, encoding, this.Text); }
private void btnChooseMagazine_Click(object sender, EventArgs e) { UsbUtil.WriteCommand(this.connection.BaseStream, this.connection.Encoding, "y9;30;2;" + (int)(nudMagazine.Value - 1)); }
private void btnReinitialise_Click(object sender, EventArgs e) { UsbUtil.WriteCommand(this.connection.BaseStream, Encoding.Default, "y9;30;0"); }
public override void WriteCommands(System.IO.Stream stream, Encoding encoding, Project project) { /*string varName = this.GetVariableName(); * if (varName != null) * { * base.WriteCommands(stream, encoding, project); * Util.WriteCommand(stream, encoding, "F" + this.TextSpacing); * Util.WriteCommand(stream, encoding, "V" + varName); * Util.WriteCommand(stream, encoding, "T" + GetCommandFontName(this.FontType, this.FontSize) + ";" + this.GetText(project)); * } * else*/ Point oldPos = this.Position; Font f = GetFont(); string[] lines = GetText(project).Split(new string[] { "\r\n" }, StringSplitOptions.None); int cumulativeHeight = 0; foreach (string line in lines) { cumulativeHeight += (int)TextRenderer.MeasureText(line, f).Height; } cumulativeHeight += (int)(FontSize / 2 * (lines.Length - 1)); // Fix starting position of 'inverse' printing directions if (Rotation == ItemRotation.R180) { if (HorizontalAlignment == Alignment.Begin) { this.Position += new Size(0, cumulativeHeight); } else if (HorizontalAlignment == Alignment.Center) { this.Position += new Size(0, cumulativeHeight / 2); } } else if (Rotation == ItemRotation.R90) { if (HorizontalAlignment == Alignment.Begin) { this.Position += new Size(cumulativeHeight, 0); } else if (HorizontalAlignment == Alignment.Center) { this.Position += new Size(cumulativeHeight / 2, 0); } } foreach (string line in lines) { if (line.Trim() != "") { base.WriteCommands(stream, encoding, project); UsbUtil.WriteCommand(stream, encoding, "F" + this.TextSpacing); UsbUtil.WriteCommand(stream, encoding, "T" + GetCommandFontName(this.FontType, this.FontSize) + ";" + line); } switch (Rotation) { case ItemRotation.R0: this.Position += new Size(0, (int)TextRenderer.MeasureText(line, f).Height + this.FontSize); break; case ItemRotation.R180: this.Position -= new Size(0, (int)TextRenderer.MeasureText(line, f).Height + this.FontSize); break; case ItemRotation.R90: this.Position -= new Size((int)TextRenderer.MeasureText(line, f).Height + this.FontSize, 0); break; case ItemRotation.R270: this.Position += new Size((int)TextRenderer.MeasureText(line, f).Height + this.FontSize, 0); break; } } this.Position = oldPos; }