Пример #1
0
        public FrmMain()
        {
            InitializeComponent();

            // Inicializando a dll
            var ret = ACBrPosPrinter.POS_Inicializar("ACBrLib.ini".ToUTF8(), "".ToUTF8());

            ACBrPosPrinter.CheckResult(ret);
        }
Пример #2
0
 private void ToogleActivate()
 {
     if (btnAtivar.Text == @"Ativar")
     {
         SaveConfig();
         var ret = ACBrPosPrinter.POS_Ativar();
         ACBrPosPrinter.CheckResult(ret);
         btnAtivar.Text = @"Desativar";
     }
     else
     {
         var ret = ACBrPosPrinter.POS_Desativar();
         ACBrPosPrinter.CheckResult(ret);
         btnAtivar.Text = @"Ativar";
     }
 }
Пример #3
0
        private void SaveConfig()
        {
            var modelo = (int)cbbModelo.GetSelectedValue <ACBrPosPrinterModelo>();
            var ret    = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "Modelo".ToUTF8(), modelo.ToString().ToUTF8());

            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "Porta".ToUTF8(), cbbPortas.SelectedItem.ToString().ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "ColunasFonteNormal".ToUTF8(), ((int)nudColunas.Value).ToString().ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "EspacoEntreLinhas".ToUTF8(), ((int)nudEspacos.Value).ToString().ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "LinhasBuffer".ToUTF8(), ((int)nudBuffer.Value).ToString().ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "LinhasEntreCupons".ToUTF8(), ((int)nudLinhasPular.Value).ToString().ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "ControlePorta".ToUTF8(), Convert.ToInt32(cbxControlePorta.Checked).ToString().ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "CortaPapel".ToUTF8(), Convert.ToInt32(cbxCortarPapel.Checked).ToString().ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "TraduzirTags".ToUTF8(), Convert.ToInt32(cbxTraduzirTags.Checked).ToString().ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "IgnorarTags".ToUTF8(), Convert.ToInt32(cbxIgnorarTags.Checked).ToString().ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "ArqLog".ToUTF8(), txtArqLog.Text.ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            var paginaCodigo = (int)cbbPaginaCodigo.GetSelectedValue <PosPaginaCodigo>();

            ret = ACBrPosPrinter.POS_ConfigGravarValor("PosPrinter".ToUTF8(), "PaginaDeCodigo".ToUTF8(), paginaCodigo.ToString().ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravar("ACBrLib.ini".ToUTF8());
            ACBrPosPrinter.CheckResult(ret);
        }
Пример #4
0
        private void FrmMain_Shown(object sender, EventArgs e)
        {
            cbbModelo.EnumDataSource <ACBrPosPrinterModelo>();
            cbbPaginaCodigo.EnumDataSource <PosPaginaCodigo>();
            cbbPortas.Items.AddRange(SerialPort.GetPortNames());

            cbbPortas.Items.Add("LPT1");
            cbbPortas.Items.Add("LPT2");
            cbbPortas.Items.Add(@"\\localhost\Epson");
            cbbPortas.Items.Add(@"c:\temp\ecf.txt");

            cbbPortas.SelectedIndex = cbbPortas.Items.Count - 1;

            cbbPortas.Items.Add("TCP:192.168.0.31:9100");

            foreach (string printer in PrinterSettings.InstalledPrinters)
            {
                cbbPortas.Items.Add($"RAW:{printer}");
            }

            // Altera as config de log
            var ret = ACBrPosPrinter.POS_ConfigGravarValor("Principal".ToUTF8(), "LogNivel".ToUTF8(), "4".ToUTF8());

            ACBrPosPrinter.CheckResult(ret);

            var logPath = Path.Combine(Application.StartupPath, "Docs");

            if (!Directory.Exists(logPath))
            {
                Directory.CreateDirectory(logPath);
            }

            ret = ACBrPosPrinter.POS_ConfigGravarValor("Principal".ToUTF8(), "LogPath".ToUTF8(), logPath.ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            ret = ACBrPosPrinter.POS_ConfigGravar("ACBrLib.ini".ToUTF8());
            ACBrPosPrinter.CheckResult(ret);

            LoadConfig();
        }
Пример #5
0
        private void LoadConfig()
        {
            ACBrPosPrinter.POS_ConfigLer("ACBrLib.ini");

            var bufferLen = 256;
            var pValue    = new StringBuilder(bufferLen);

            var ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "Modelo".ToUTF8(), pValue, ref bufferLen);

            ACBrPosPrinter.CheckResult(ret);

            cbbModelo.SetSelectedValue((ACBrPosPrinterModelo)Convert.ToInt32(pValue.FromUTF8()));

            bufferLen = 256;
            pValue.Clear();
            ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "Porta".ToUTF8(), pValue, ref bufferLen);
            ACBrPosPrinter.CheckResult(ret);

            cbbPortas.SelectedItem = pValue.FromUTF8();

            bufferLen = 256;
            pValue.Clear();
            ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "ColunasFonteNormal".ToUTF8(), pValue, ref bufferLen);
            ACBrPosPrinter.CheckResult(ret);

            nudColunas.Value = Convert.ToInt32(pValue.FromUTF8());

            bufferLen = 256;
            pValue.Clear();
            ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "EspacoEntreLinhas".ToUTF8(), pValue, ref bufferLen);
            ACBrPosPrinter.CheckResult(ret);

            nudEspacos.Value = Convert.ToInt32(pValue.FromUTF8());

            pValue.Clear();
            ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "LinhasBuffer".ToUTF8(), pValue, ref bufferLen);
            ACBrPosPrinter.CheckResult(ret);

            nudBuffer.Value = Convert.ToInt32(pValue.FromUTF8());

            bufferLen = 256;
            pValue.Clear();
            ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "LinhasEntreCupons".ToUTF8(), pValue, ref bufferLen);
            ACBrPosPrinter.CheckResult(ret);

            nudLinhasPular.Value = Convert.ToInt32(pValue.FromUTF8());

            bufferLen = 256;
            pValue.Clear();
            ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "ControlePorta".ToUTF8(), pValue, ref bufferLen);
            ACBrPosPrinter.CheckResult(ret);

            cbxControlePorta.Checked = Convert.ToBoolean(Convert.ToInt32(pValue.FromUTF8()));

            bufferLen = 256;
            pValue.Clear();
            ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "CortaPapel".ToUTF8(), pValue, ref bufferLen);
            ACBrPosPrinter.CheckResult(ret);

            cbxCortarPapel.Checked = Convert.ToBoolean(Convert.ToInt32(pValue.FromUTF8()));

            bufferLen = 256;
            pValue.Clear();
            ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "TraduzirTags".ToUTF8(), pValue, ref bufferLen);
            ACBrPosPrinter.CheckResult(ret);

            cbxTraduzirTags.Checked = Convert.ToBoolean(Convert.ToInt32(pValue.FromUTF8()));

            bufferLen = 256;
            pValue.Clear();
            ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "IgnorarTags".ToUTF8(), pValue, ref bufferLen);
            ACBrPosPrinter.CheckResult(ret);

            cbxIgnorarTags.Checked = Convert.ToBoolean(Convert.ToInt32(pValue.FromUTF8()));

            bufferLen = 256;
            pValue.Clear();
            ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "ArqLog".ToUTF8(), pValue, ref bufferLen);
            ACBrPosPrinter.CheckResult(ret);

            txtArqLog.Text = pValue.FromUTF8();

            bufferLen = 256;
            pValue.Clear();
            ret = ACBrPosPrinter.POS_ConfigLerValor("PosPrinter".ToUTF8(), "PaginaDeCodigo".ToUTF8(), pValue, ref bufferLen);
            ACBrPosPrinter.CheckResult(ret);

            cbbPaginaCodigo.SetSelectedValue((PosPaginaCodigo)Convert.ToInt32(pValue.FromUTF8()));
        }
Пример #6
0
        private void btnImprimir_Click(object sender, EventArgs e)
        {
            var ret = ACBrPosPrinter.POS_Imprimir(txtImpressao.Text.ToUTF8(), false, true, true, 1);

            ACBrPosPrinter.CheckResult(ret);
        }