Het hier getoonde voorbeeld laat zien hoe je de afbeelding en tekst van de knoppen kunt beheren die worden gebruikt in de demoversie van de touchkassa.
De code moet geplaatst worden in een Billing customizer die aangemaakt werd op basis van de overeenkomstige sequentie. Deze implementeert de interface MercatorUi.ICustomizers.IBillingEngineCreated.
De code is als volgt:
using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Windows.Forms;
using MercatorApi;
using MercatorUi;
// <ReferenceInclude>"WidgetPosTouch.dll"</ReferenceInclude>
namespace Billing
{
public class Customizer : MercatorUi.ICustomizers.IBillingEngineCreated
{
public void BillingEngineCreated(MercatorUi.Engine.Gescom.BillingEngine billingEngine)
{
billingEngine.BillingFormLoaded += BillingEngine_BillingFormLoaded;
}
void BillingEngine_BillingFormLoaded(object sender, EventArgs e)
{
MercatorUi.Engine.Gescom.BillingEngine billingEngine = (MercatorUi.Engine.Gescom.BillingEngine)sender;
billingEngine.BillingFormLoaded -= BillingEngine_BillingFormLoaded;
foreach (Control c in billingEngine.BillingForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Billing.BillingObjects.TouchSelector)))
{
MercatorUi.Forms.Billing.BillingObjects.TouchSelector touchSelector = (MercatorUi.Forms.Billing.BillingObjects.TouchSelector)c;
touchSelector.AddingButtons += TouchSelector_AddingButtons;
touchSelector.ButtonTouchAdded += TouchSelectorOrList_ButtonTouchAdded;
}
foreach (Control c in billingEngine.BillingForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Billing.BillingObjects.TouchList)))
{
MercatorUi.Forms.Billing.BillingObjects.TouchList touchList = (MercatorUi.Forms.Billing.BillingObjects.TouchList)c;
touchList.ButtonTouchAdded += TouchSelectorOrList_ButtonTouchAdded;
touchList.AfterItemButtonClick += TouchList_AfterItemButtonClick;
}
billingEngine.BillingForm.FormClosed += BillingForm_FormClosed;
foreach (MercatorUi.Widgets.WidgetBaseControl widget in MercatorUi.Globals.ListWidgets)
{
if (widget is WidgetPosTouch.UserControlPosTouch)
{
((WidgetPosTouch.UserControlPosTouch)widget).RegisterBilling(billingEngine.BillingForm);
break;
}
}
}
void BillingForm_FormClosed(object sender, FormClosedEventArgs e)
{
MercatorUi.Forms.Billing.BillingForm billingForm = (MercatorUi.Forms.Billing.BillingForm)sender;
foreach (Control c in billingForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Billing.BillingObjects.TouchSelector)))
{
MercatorUi.Forms.Billing.BillingObjects.TouchSelector touchSelector = (MercatorUi.Forms.Billing.BillingObjects.TouchSelector)c;
touchSelector.AddingButtons -= TouchSelector_AddingButtons;
touchSelector.ButtonTouchAdded -= TouchSelectorOrList_ButtonTouchAdded;
}
foreach (Control c in billingForm.FindMovableControlsByType(typeof(MercatorUi.Forms.Billing.BillingObjects.TouchList)))
{
MercatorUi.Forms.Billing.BillingObjects.TouchList touchList = (MercatorUi.Forms.Billing.BillingObjects.TouchList)c;
touchList.ButtonTouchAdded -= TouchSelectorOrList_ButtonTouchAdded;
touchList.AfterItemButtonClick -= TouchList_AfterItemButtonClick;
}
billingForm.FormClosed -= BillingForm_FormClosed;
}
void TouchSelector_AddingButtons(object sender, MercatorUi.Forms.Billing.BillingObjects.TouchSelector.AddingButtonsEventArgs e)
{
//Dialogs.Stop(e.ReqSql.ToString());
e.ReqSql = e.ReqSql.Replace("s_id as id,", "s_id as id,s_prix_ti,s_cle4,s_cle1,s_qv_3,s_qdispo,")
.Replace("order by dbo.XDESIGN_F(s_id)", "order by s_cle1");
}
void TouchSelectorOrList_ButtonTouchAdded(object sender, MercatorUi.Forms.Billing.BillingObjects.TouchSelector.ButtonTouchAddedEventArgs e)
{
if (e.ButtonTouch.Niveau == MercatorUi.Forms.Billing.BillingObjects.TouchSelector.TouchSelectorNiveau.ART)
{
DataSet ds = Api.Zselect(MercatorUi.Globals.RepData, string.Format("select dbo.XDESIGN_{0}(s_id) as design,s_prix_ti from STOCK (NOLOCK) where s_id=@s_id", MercatorUi.Globals.Langue), new MercatorSqlParam("@s_id", e.ButtonTouch.Name, SqlDbType.Char, 10));
if ((ds != null) && (ds.Tables[0].Rows.Count > 0))
{
Label labelDesign = new Label();
labelDesign.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
labelDesign.Text = ds.Tables[0].Rows[0]["design"].ToString().TrimEnd();
labelDesign.AutoSize = true;
labelDesign.BackColor = System.Drawing.Color.Transparent;
labelDesign.Location = new System.Drawing.Point(5, 3);
e.ButtonTouch.Controls.Add(labelDesign);
Label labelPrix = new Label();
labelPrix.Font = new System.Drawing.Font("Microsoft Sans Serif", 6.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
labelPrix.Text = Api.Transform(Convert.ToDouble(ds.Tables[0].Rows[0]["s_prix_ti"]), "### ##0.00") + " €";
labelPrix.AutoSize = false;
labelPrix.Size = new System.Drawing.Size(100, 14);
labelPrix.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
labelPrix.BackColor = System.Drawing.Color.Transparent;
labelPrix.Location = new System.Drawing.Point(5, 95);
e.ButtonTouch.Controls.Add(labelPrix);
}
}
else if (e.ButtonTouch.Text != "") // op Rayons / Families -> controleer of de afbeelding bestaat in de SQL Bestanden / Anderen
{
Label labelNom = null;
byte[] bytes = Api.SqlFileToBytes("<Other\\" + e.ButtonTouch.Text + ".png");
if ((bytes != null) && (bytes.Length > 0))
{
e.ButtonTouch.Image = Api.BytesToImage(bytes);
labelNom = new Label();
labelNom.Font = new System.Drawing.Font("Microsoft Sans Serif", 7.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
labelNom.Text = e.ButtonTouch.Text;
labelNom.AutoSize = true;
labelNom.BackColor = System.Drawing.Color.Transparent;
labelNom.Location = new System.Drawing.Point(5, 2);
e.ButtonTouch.Controls.Add(labelNom);
e.ButtonTouch.Text = "";
}
if (e.ButtonTouch.Niveau == MercatorUi.Forms.Billing.BillingObjects.TouchSelector.TouchSelectorNiveau.FAMILLE)
{
e.ButtonTouch.BackColor = System.Drawing.Color.IndianRed;
e.ButtonTouch.ColorTable = DevComponents.DotNetBar.eButtonColor.Flat;
if (labelNom != null)
labelNom.ForeColor = System.Drawing.Color.White;
}
else if (e.ButtonTouch.Niveau == MercatorUi.Forms.Billing.BillingObjects.TouchSelector.TouchSelectorNiveau.SSFAMILLE)
{
e.ButtonTouch.BackColor = System.Drawing.Color.DarkOrange;
e.ButtonTouch.ColorTable = DevComponents.DotNetBar.eButtonColor.Flat;
if (labelNom != null)
labelNom.ForeColor = System.Drawing.Color.White;
}
}
}
void touchList_AfterItemButtonClick(object sender, MercatorUi.Forms.Billing.BillingObjects.TouchList.AfterItemButtonClickEventArgs e)
{
// er werd net een artikel toegevoegd in het tabblad dat het object voor betaalwijzen bevat -> dit updaten
MercatorUi.Forms.Billing.BillingObjects.TouchList touchList = (MercatorUi.Forms.Billing.BillingObjects.TouchList)sender;
MercatorUi.Forms.Billing.BillingForm billingForm = (MercatorUi.Forms.Billing.BillingForm)touchList.Form;
billingForm.UpdatePayments();
}
}
}