Sample of code for adding a Touchscreen Control on a POS Custom Screen:
using System;
using System.Collections.Generic;
using CXSRetailPOS;
using DevExpress.XtraVerticalGrid.Rows;
using CXS.Platform.UI.TouchScreen;
namespace POSTouchScreenSample
{
public partial class POSCustomScreen : BasePOSCustomView
{
List<DumyCustomer> m_CustomerList = null;
#region Event functions
public enum EventType
{
Ok,
Cancel
}
public class EventArgs : System.EventArgs
{
public EventType EventType;
public EventArgs(EventType eventType)
{
EventType = eventType;
}
}
public delegate void EventHandler(object sender, EventArgs args);
public event EventHandler OnEvent;
#endregion // Event functions
public POSCustomScreen()
{
InitializeComponent();
Title = "Custom Customer Search";
m_Button11.Visible = true;
m_Button11.Text = "Ok";
m_Button11.Click += new System.EventHandler(OkButtonClickHandler);
m_Button12.Visible = true;
m_Button12.Text = "Cancel";
m_Button12.Click += new System.EventHandler(CancelButtonClickHandler);
if (m_CustomerList == null) m_CustomerList = new List<DumyCustomer>();
m_CustomerList.Add(new DumyCustomer("test Customer", 15, DateTime.Today));
m_vGridControl.DataSource = m_CustomerList;
}
protected override void TextEntryViewEventHandler(object sender, CXSTextEntryView.EventArgs args)
{
if (args.EventType == CXSTextEntryView.EventType.Ok)
{
m_RowCustomerName.Properties.Value = m_TextEntryView.Value;
}
}
protected override void NumberEntryViewEventHandler(object sender, CXSNumberEntryView.EventArgs args)
{
if (args.EventType ==CXSNumberEntryView.EventType.Ok)
{
m_rowCustomerAge.Properties.Value = m_NumberEntryView.Value;
}
}
protected override void DateEntryViewEventHandler(object sender, CXSDateEntryView.EventArgs args)
{
if (args.EventType == CXSDateEntryView.EventType.Ok)
{
m_rowCustomerBirthDate.Properties.Value = m_DateEntryView.Value;
}
}
private void OkButtonClickHandler(object sender, System.EventArgs e)
{
FireDoneEvent(new EventArgs(EventType.Ok));
}
private void CancelButtonClickHandler(object sender, System.EventArgs e)
{
FireDoneEvent(new EventArgs(EventType.Cancel));
}
protected virtual void FireDoneEvent(EventArgs args)
{
StopBlocking(args);
if (OnEvent != null)
OnEvent(this, args);
}
private void m_vGridControl_FocusedRowChanged(object sender, DevExpress.XtraVerticalGrid.Events.FocusedRowChangedEventArgs e)
{
if (e.Row == null) return;
HandleFocussedRow(e.Row as EditorRow);
}
private void HandleFocussedRow(EditorRow row)
{
if (row == null) return;
// Setup View for new row
if (row == m_RowCustomerName)
{
ShowTextEntryView(m_RowCustomerName.Properties.Value.ToString(), 100, false);
}
else if (row == m_rowCustomerAge)
{
ShowNumberEntryView(Convert.ToDecimal(m_rowCustomerAge.Properties.Value), CXS.Platform.UI.TouchScreen.NumberPadModes.Int);
}
else if (row == m_rowCustomerBirthDate)
{
ShowDateEntryView(m_rowCustomerBirthDate.Properties.Value.ToString());
}
else
{
ShowXMarkView();
}
}
}
}