1-) C# RMOS - pos printer
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Printing;
using System.IO;
using System.Windows.Forms;
namespace printer_windows
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
List<string> abuyer = new List<string>();
abuyer.Add(".");
abuyer.Add(" * * * ABUYER FISI * * * ");
abuyer.Add(".");
abuyer.Add("Departman : " + "asd");
abuyer.Add(".");
abuyer.Add("MIKTAR");
abuyer.Add("URUN");
abuyer.Add("URUN22");
abuyer.Add("URUN22");
abuyer.Add("MIKTAR".PadRight(13, ' ') + "URUN".PadRight(15, ' '));
try
{
System.ComponentModel.TypeConverter converter = System.ComponentModel.TypeDescriptor.GetConverter(typeof(Font));
Font fnt = (Font)converter.ConvertFromString("Arial, 48pt");
if (fnt == null)
{
fnt = new Font("Arial", 15);
}
Liste = abuyer;
printFont = fnt;
PrintDocument pd = new PrintDocument();
pd.PrintPage += new PrintPageEventHandler(pd_PrintPage);
pd.PrinterSettings.PrinterName =File.ReadAllText("printName.txt");
pd.Print();
abuyer.Clear();
}
catch(Exception ex)
{
MessageBox.Show("HATA ! "+ex.Message);
}
}
static List<string> Liste = new List<string>();
static Font printFont;
private static void pd_PrintPage(object sender, PrintPageEventArgs ev)
{
float yPos = 0;
int count = 0;
float leftMargin = 1;
float topMargin = 1;
for (int i = 0; i < Liste.Count; i++)
{
Font mFont = printFont;
if (Liste[i].StartsWith("TOPLAM"))
{
mFont = new Font(printFont.FontFamily, printFont.Size + 2, FontStyle.Bold);
}
if (Liste[i].StartsWith(" *"))
{
mFont = new Font(printFont.FontFamily, printFont.Size + 2, FontStyle.Bold);
}
if (Liste[i].StartsWith("#"))
{
Liste[i] = Liste[i].Replace("#", "");
mFont = new Font(printFont.FontFamily, printFont.Size + 2, FontStyle.Bold);
}
yPos = topMargin + (count *
printFont.GetHeight(ev.Graphics));
ev.Graphics.DrawString(Liste[i], mFont, Brushes.Black,
leftMargin, yPos, new StringFormat());
count++;
}
}
}
}