예제 #1
0
        public void RegisterPosKeyAndEvent(int keyValue, int keyCode, string content, Thickness margin, int row, int col, int accessKey, string eventClass)
        {
            PosButton btn = new PosButton();

            btn.Style    = (Style)FindResource("GlassyButtonStyle1");
            btn.Height   = 75;
            btn.KeyValue = keyValue;
            btn.KeyCode  = keyCode;
            btn.Content  = content;
            //   btn.FontSize = 12;
            btn.Margin         = margin;
            btn.AccessKeyValue = accessKey;
            btn.KeyClass       = eventClass;
            btn.Focusable      = false;
            Grid.SetRow(btn, row);
            Grid.SetColumn(btn, col);
            this.MyGrid.Children.Add(btn);

            btn.Click += new RoutedEventHandler(btn_Click);

            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                PosEvent posEvent = assembly.CreateInstance(eventClass) as PosEvent;
                PosContext.Instance.KeysById.Add(keyCode.ToString(), posEvent);
            }
            catch (System.NullReferenceException exNull)
            {
                Logger.Error(this.GetType().ToString(), "Invalid class name " + eventClass, exNull);
            }
            catch (Exception ex)
            {
                Logger.Error(this.GetType().ToString(), ex.ToString(), ex);
            }
        }
예제 #2
0
        void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;

            //MessageBox.Show(posButton.KeyCode.ToString());

            string keyCode = posButton.KeyCode.ToString();

            Hashtable table     = PosContext.Instance.KeysById;
            PosEvent  posEvent1 = (PosEvent)table[keyCode];

            if (posEvent1 != null)
            {
                // posEvent1.Engage(posButton.KeyValue);

                if (posEvent1.isDialog)
                {
                    PosContext.Instance.PosKeyValue = posButton.KeyValue;
                    PosDialogEvent posDialog = posEvent1 as PosDialogEvent;
                    posDialog.PushState(posDialog.StartState);
                    PosEventStack.Instance.PushEvent(posEvent1);
                    PosEventStack.Instance.NextEvent();
                }
                else
                {
                    posEvent1.Engage(posButton.KeyValue);
                }
            }
        }
        void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;

            PosContext.Instance.InputLine = posButton.Sku;
            new EnterKey().Engage(0);
        }
예제 #4
0
        void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;
            // object keyValue = posButton.Tag;
            // MessageBox.Show(posButton.KeyCode.ToString());
            string keyCode = posButton.KeyCode.ToString();

            Hashtable table     = PosContext.Instance.KeysById;
            PosEvent  posEvent1 = (PosEvent)table[keyCode];

            if (posEvent1 != null)
            {
                //posEvent1.Engage(posButton.KeyValue);
                if (posEvent1.isDialog)
                {
                    PosContext.Instance.PosKeyValue = posButton.KeyValue;
                    PosDialogEvent posDialog = posEvent1 as PosDialogEvent;
                    posDialog.PushState(posDialog.StartState); //Assume "0" as the default state
                    PosEventStack.Instance.PushEvent(posEvent1);
                    PosEventStack.Instance.NextEvent();
                }
                else
                {
                    posEvent1.Engage(posButton.KeyValue);
                }
            }

            //PnlInput input = PosContext.Instance.PosPrompt as PnlInput;
            //input.InputControl.Focus();
            //_contrainer.get
        }
예제 #5
0
        //     1             2             3                   4           5       6       7                   8               9

        public void RegisterPosKeyAndEvent(int keyValue, int keyCode, string content, Thickness margin, int row, int col, int accessKey, string eventClass, string buttonStyle, int span)
        {
            PosButton btn = new PosButton();

            //btn.Style = (Style)FindResource("GlassyButtonStyle");
            btn.Style          = (Style)FindResource(buttonStyle);
            btn.KeyValue       = keyValue;
            btn.KeyCode        = keyCode;
            btn.Content        = content;
            btn.FontSize       = 14;
            btn.Margin         = new Thickness(1, 1, 1, 1); //margin;
            btn.AccessKeyValue = accessKey;
            btn.KeyClass       = eventClass;
            btn.Focusable      = false;
            // btn.Width = ;
            btn.Height = 77;

            Grid.SetColumnSpan(btn, span);
            Grid.SetRow(btn, row);
            Grid.SetColumn(btn, col);
            this.KeyPadGrid.Children.Add(btn);

            btn.Click += new RoutedEventHandler(btn_Click);

            this.RegisterEvent(keyCode, eventClass);
        }
예제 #6
0
        public void LoadControls()
        {
            // PosContext.Instance.KeysByControl.Clear();

            int count = VisualTreeHelper.GetChildrenCount(this.MyGrid);

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    UIElement child = (UIElement)VisualTreeHelper.GetChild(this.MyGrid, i);
                    if (child is PosButton)
                    {
                        PosButton posBtn = child as PosButton;
                        try
                        {
                            PosContext.Instance.KeysByControl.Add(posBtn.AccessKeyValue, posBtn);
                        }
                        catch
                        {
                            MessageBox.Show("Unable to add poskey " + posBtn.KeyClass.ToString());
                        }
                    }
                }
            }
        }
예제 #7
0
        public void RegisterControlEvent(int keyValue, int keyCode, string eventClass)
        {
            PosButton posBtn = new PosButton();

            posBtn.KeyValue = keyValue;
            posBtn.KeyCode  = keyCode;
            posBtn.KeyClass = eventClass;
            alphaPosConrols.Add(posBtn);
        }
        /// <summary>
        /// </summary>
        public void AddPosKeys(int subMenuID, string menuName)
        {
            this.txtBlockMenuName.Text = menuName;


            // PosKey posKey = new PosKey();
            //  posKey.Panel_id = subMenuID;
            //  posKey.Config_no = PosSettings.Default.Configuration; //PosContext.Instance.Config.ConfigNo;

            // try
            // {
            EclipsePos.Data.Item item = new EclipsePos.Data.Item();
            item.Organization_no = PosSettings.Default.Organization;
            item.Item_group      = this.ItemGroup;

            DataSet   data   = item.LoadByItemGroup(this.ItemGroup);
            DataTable dt     = data.Tables[0];
            int       rowNum = 0;
            int       colNum = 0;

            foreach (DataRow dr in dt.Rows)
            {
                ++rowNum;
                PosButton btn = new PosButton();
                btn.Style    = (Style)FindResource("GlassyButtonStyle");
                btn.Content  = dr["short_Desc"].ToString();
                btn.FontSize = 12;
                // btn.AccessKeyValue = int.Parse(dr["plu"].ToString());
                btn.Sku       = dr["sku"].ToString();
                btn.Margin    = new Thickness(3, 0, 3, 5);
                btn.Focusable = false;
                btn.Height    = 60;
                // btn.Width = 100;

                // btn.KeyText = dr["param"].ToString();
                Grid.SetRow(btn, rowNum);


                Grid.SetColumn(btn, colNum);

                if (rowNum == 8)
                {
                    ++colNum;
                    rowNum = 0;
                }



                this.MyGrid.Children.Add(btn);


                btn.Click += new RoutedEventHandler(btn_Click);
            }
        }
예제 #9
0
        void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;

            PosContext.Instance.InputLine = posButton.ItemGroup;
            EjSalesPerson ej = new EjSalesPerson();

            ej.States().PushState(EjSalesPerson.GET_SALES_PERSON);
            PosEventStack.Instance.PushEvent(ej);
            PosEventStack.Instance.NextEvent();
            //new EnterKey().Engage(0);
        }
예제 #10
0
        void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;
            // ItemGroupDetailsView itemGroupDetails = new ItemGroupDetailsView();
            //  LeftMenuView leftMenu = _container.Resolve<LeftMenuView>();
            ItemGroupDetailsView itemGroupDetails = _container.Resolve <ItemGroupDetailsView>();

            itemGroupDetails.ItemGroup = posButton.ItemGroup;
            itemGroupDetails.AddPosKeys(999, "Items");
            PosContext.Instance.CurrentPosDisplay.LoadItemGroupDetailPanel(itemGroupDetails);
            _container.Teardown(itemGroupDetails);
        }
예제 #11
0
        public void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;
            string    keyCode   = posButton.KeyCode.ToString();

            Hashtable table     = PosContext.Instance.KeysById;
            PosEvent  posEvent1 = (PosEvent)table[keyCode];

            if (posEvent1 != null)
            {
                posEvent1.Engage(posButton.KeyValue);
            }
        }
예제 #12
0
        public void AddPosKeysTemp()
        {
            PosButton btn = new PosButton();

            //   btn.Style = (Style)FindResource("GlassyButtonStyle");
            btn.FontSize = 12;
            btn.Name     = "F1";
            btn.Content  = "Banquet";
            // btn.HorizontalAlignment = HorizontalAlignment.Stretch;
            btn.Margin = new Thickness(2, 2, 2, 2);
            btn.Height = 75;
            Grid.SetColumn(btn, 0);
            Grid.SetRow(btn, 0);
            this.TableGroupGrid.Children.Add(btn);
        }
예제 #13
0
        public void RegisterPosKeyAndEvent(int keyValue, string content, Thickness margin, int row, int col)
        {
            PosButton btn = new PosButton();

            btn.Style     = (Style)FindResource("GlassyButtonStyle");
            btn.KeyValue  = keyValue;
            btn.Content   = content;
            btn.Height    = 75;
            btn.Margin    = margin;
            btn.Focusable = false;
            Grid.SetRow(btn, row);
            Grid.SetColumn(btn, col);
            this.MyGrid.Children.Add(btn);

            btn.Click += new RoutedEventHandler(btn_Click);
        }
예제 #14
0
        public void LoadControls()
        {
            // PosContext.Instance.KeysByControl.Clear();

            int count = VisualTreeHelper.GetChildrenCount(this.TableGroupGrid);

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    UIElement child = (UIElement)VisualTreeHelper.GetChild(this.TableGroupGrid, i);
                    if (child is PosButton)
                    {
                        PosButton posBtn = child as PosButton;
                        PosContext.Instance.KeysByControl.Add(posBtn.AccessKeyValue, posBtn);
                    }
                }
            }
        }
예제 #15
0
        void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;

            //MessageBox.Show(posButton.KeyCode.ToString());

            string keyCode = posButton.KeyCode.ToString();

            Hashtable table     = PosContext.Instance.KeysById;
            PosEvent  posEvent1 = (PosEvent)table[keyCode];

            if (posEvent1 != null)
            {
                posEvent1.Engage(posButton.KeyValue);
            }

            //PnlInput input = PosContext.Instance.PosPrompt as PnlInput;
            //input.InputControl.Focus();
        }
예제 #16
0
        public void AddClearPosKey()
        {
            PosButton btn = new PosButton();

            btn.Style          = (Style)FindResource("ClearKeyButtonStyle");
            btn.KeyValue       = 0;
            btn.KeyCode        = 32;
            btn.Content        = " ";
            btn.FontSize       = 14;
            btn.Margin         = new Thickness(10, 0, 12, 12);
            btn.AccessKeyValue = 46;
            btn.KeyClass       = "EclipsePos.Apps.PosEvents.ClearKey";
            btn.Height         = 47;
            btn.Width          = 80;
            btn.Content        = "Clear";

            Grid.SetRow(btn, 0);
            Grid.SetColumn(btn, 0);

            this.TableGroupGrid.Children.Add(btn);



            btn.Click += new RoutedEventHandler(btn_Click);

            try
            {
                Assembly assembly = Assembly.GetExecutingAssembly();
                PosEvent posEvent = assembly.CreateInstance("EclipsePos.Apps.PosEvents.ClearKey") as PosEvent;
                PosContext.Instance.KeysById.Add(btn.KeyCode, posEvent);
            }
            catch (System.NullReferenceException exNull)
            {
                //Logger.Error("FrmMain.cs", "Invalid class name " + eventClass);
            }
            catch (Exception ex)
            {
                //Logger.Error("FrmMain.cs", ex.ToString());
            }
        }
예제 #17
0
        public void LoadControls()
        {
            // PosContext.Instance.KeysByControl.Clear();

            int count = VisualTreeHelper.GetChildrenCount(this.RightGrid);

            if (count > 0)
            {
                for (int i = 0; i < count; i++)
                {
                    UIElement child = (UIElement)VisualTreeHelper.GetChild(this.RightGrid, i);
                    if (child is PosButton)
                    {
                        PosButton posBtn = child as PosButton;
                        try
                        {
                            PosContext.Instance.KeysByControl.Add(posBtn.KeyCode, posBtn);
                        }
                        catch (Exception e)
                        {
                            //  MessageBox.Show(e.ToString());
                        }
                    }
                }
            }

            foreach (Object obj in alphaPosConrols)
            {
                PosButton btn = obj as PosButton;
                try
                {
                    PosContext.Instance.KeysByControl.Add(btn.KeyCode, btn);
                }
                catch
                {
                }
            }
        }
예제 #18
0
//        public string SelectedItem()
//        {
//            DataRowView data = this.logListView.SelectedItem as DataRowView;
//            return data["sku"].ToString();
//        }


        void btn_Click(object sender, RoutedEventArgs e)
        {
            PosButton posButton = sender as PosButton;

            this.LogViewFunctions(posButton.KeyValue);



            //MessageBox.Show(posButton.KeyCode.ToString());

            /*
             * string keyCode = posButton.KeyCode.ToString();
             *
             * Hashtable table = PosContext.Instance.KeysById;
             * PosEvent posEvent1 = (PosEvent)table[keyCode];
             * if (posEvent1 != null)
             * {
             *  posEvent1.Engage(posButton.KeyValue);
             * }
             *
             * //PnlInput input = PosContext.Instance.PosPrompt as PnlInput;
             * //input.InputControl.Focus();
             * */
        }
예제 #19
0
        /*
         *      public void KeyPressed(int key)
         *      {
         * //  MessageBox.Show("Key Down" );
         *              //.KeyDown(key);
         *              //if (EventTypes == KeyboardEventType.DownUp)
         *              //	KeyUp(key);
         *      //	System.Windows.Forms.Keys keys = (Keys)key;
         *              //if (key == 131072 ) return;
         *
         *              int keyCode = key; //posKeyboard.PosKeyData;
         *              //MessageBox.Show("ON data event" + key.ToString());
         *              if (key == 162 || key == 163 )
         *              {
         *                      modifier = 131072;
         *                      return;
         *              }
         *              else
         *              {
         *                      key += modifier;
         *                      modifier = 0;
         *              }
         *
         *
         *              try
         *              {
         *                      Hashtable table = PosContext.Instance.KeysByControl;
         *
         *                      if (table.ContainsKey(keyCode) )
         *                      {
         *                              object obj  = table[keyCode];
         *                              if (obj is PosButton )
         *                              {
         *                                      PosButton btn = obj as PosButton;
         *
         *                                      //btn.Invoke(new MenuLoadEvent(this.MenuLoadHandler), new object[]{btn} );
         *              if (btn.IsEnabled)
         *              {
         *                  if (btn.KeyClass.Trim().Length > 0 )
         *                  {
         *                      Assembly assembly = Assembly.GetExecutingAssembly();
         *                      PosEvent posEvent = assembly.CreateInstance(btn.KeyClass) as PosEvent;
         *                      //posEvent.Engage(btn.KeyValue);
         *                      posEvent.PromptText = btn.KeyText;
         *                      if (posEvent != null)
         *                      {
         *
         *                          if (posEvent.isDialog)
         *                          {
         *                              PosContext.Instance.PosKeyValue = btn.KeyValue;
         *                              PosDialogEvent posDialog = posEvent as PosDialogEvent;
         *                              posDialog.PushState(posDialog.StartState); //Assume "0" as the default state
         *                              PosEventStack.Instance.PushEvent(posEvent);
         *                              PosEventStack.Instance.NextEvent();
         *                          }
         *                          else
         *                          {
         *                              posEvent.Engage(btn.KeyValue);
         *                          }
         *
         *                      }
         *                  }
         *              }
         *              else
         *              {
         *                  PosContext.Beep(500, 500);
         *              }
         *          }
         *                      }
         *                      else
         *                      {
         *                              PosContext.Beep(500, 500);
         *                      }
         *              }
         *              catch(Exception e2)
         *              {
         *                      MessageBox.Show(e2.ToString());
         *              }
         *
         *      }
         */



        //Event handler for platform invoke
        public void MenuLoadHandler(PosButton btn)
        {
            //	btn.PerformClick();
        }
예제 #20
0
        /// <summary>
        /// </summary>
        public void AddPosKeys(int subMenuID, string menuName)
        {
            this.txtBlockMenuName.Text = menuName;


            PosKey posKey = new PosKey();

            posKey.Panel_id  = subMenuID;
            posKey.Config_no = PosSettings.Default.Configuration; //PosContext.Instance.Config.ConfigNo;
            DataSet   data   = posKey.LoadBySubMenu();
            DataTable dt     = data.Tables[0];
            int       rowNum = 0;
            int       colNum = 0;

            foreach (DataRow dr in dt.Rows)
            {
                ++rowNum;
                PosButton btn = new PosButton();
                btn.Style = (Style)FindResource("GlassyButtonStyle");
                //  btn.Height = 60;
                //  btn.Width = 100;
                btn.KeyValue       = int.Parse(dr["key_val"].ToString());
                btn.KeyCode        = int.Parse(dr["key_code"].ToString());
                btn.KeyClass       = dr["key_class"].ToString();
                btn.Content        = dr["param"].ToString(); //dr["image"].ToString();
                btn.AccessKeyValue = int.Parse(dr["attr"].ToString());
                // btn.FontSize = 12;
                btn.Margin    = new Thickness(5, 0, 5, 10);
                btn.Focusable = false;
                btn.KeyText   = dr["param"].ToString();
                btn.Tag       = "..\\..\\Images\\" + dr["image"].ToString().Trim();
                Grid.SetRow(btn, rowNum);

                Grid.SetColumn(btn, colNum);

                if (rowNum == 8)
                {
                    ++colNum;
                    rowNum = 0;
                }

                // Grid.SetColumn(btn, 3);
                // Grid.SetColumn(btn, 0);

                /*
                 * if (dr["flags"].ToString().Trim().Length > 0)
                 * {
                 *  try
                 *  {
                 *      Image img = new Image();
                 *      BitmapImage src = new BitmapImage();
                 *      src.BeginInit();
                 *      src.UriSource = new Uri(Environment.CurrentDirectory +"\\Images\\"+dr["flags"].ToString().Trim(), UriKind.RelativeOrAbsolute);
                 *      src.EndInit();
                 *      img.VerticalAlignment = VerticalAlignment.Center;
                 *      img.HorizontalAlignment = HorizontalAlignment.Center;
                 *      img.Source = src;
                 *      img.Width = 25;
                 *      img.Height = 25;
                 *      Grid.SetRow(img, rowNum);
                 *      Grid.SetColumn(img, 1);
                 *      this.MyGrid.Children.Add(img);
                 *  }
                 *  catch
                 *  {
                 *  }
                 * }
                 *
                 */

                TextBlock txtBlock = new TextBlock();
                txtBlock.Text = dr["param"].ToString();
                // txtBlock.FontSize = 16;
                txtBlock.Margin        = new Thickness(5, 5, 0, 0);
                txtBlock.TextAlignment = TextAlignment.Justify;
                txtBlock.Foreground    = Brushes.White;

                Grid.SetColumn(txtBlock, 0);
                Grid.SetRow(txtBlock, rowNum);

                this.MyGrid.Children.Add(btn);
                //this.MyGrid.Children.Add(txtBlock);

                btn.Click += new RoutedEventHandler(btn_Click);

                string eventClass = dr["key_class"].ToString();

                try
                {
                    Assembly assembly = Assembly.GetExecutingAssembly();
                    PosEvent posEvent = assembly.CreateInstance(eventClass) as PosEvent;
                    posEvent.PromptText = txtBlock.Text;
                    PosContext.Instance.KeysById.Add(dr["key_code"].ToString(), posEvent);
                    // PosContext.Instance.KeysByControl.Add(btn, posEvent);
                }
                catch (System.NullReferenceException exNull)
                {
                    Logger.Error(this.GetType().ToString(), "Invalid class name " + exNull.ToString() + exNull);
                }
                catch (Exception ex)
                {
                    Logger.Error(this.GetType().ToString(), ex.ToString(), ex);
                }
            }


            this.KeyDisable();
        }
예제 #21
0
        /// <summary>
        /// </summary>
        public void AddPosKeys(int subMenuID, string menuName)
        {
            this.txtBlockMenuName.Text = menuName;


            // PosKey posKey = new PosKey();
            //  posKey.Panel_id = subMenuID;
            //  posKey.Config_no = PosSettings.Default.Configuration; //PosContext.Instance.Config.ConfigNo;

            // try
            // {
            EclipsePos.Data.ItemGroup itemGroup = new EclipsePos.Data.ItemGroup();
            itemGroup.Organization_no = PosSettings.Default.Organization;
            DataSet   data   = itemGroup.LoadByOrganization();
            DataTable dt     = data.Tables[0];
            int       rowNum = 0;
            int       colNum = 0;

            foreach (DataRow dr in dt.Rows)
            {
                ++rowNum;
                PosButton btn = new PosButton();
                btn.Height = 60;
                // btn.Width = 95;
                btn.Style     = (Style)FindResource("GlassyButtonStyle");
                btn.Content   = dr["group_name"].ToString();
                btn.ItemGroup = dr["group_id"].ToString();
                btn.FontSize  = 12;

                //  btn.AccessKeyValue = int.Parse(dr["attr"].ToString());
                btn.Margin    = new Thickness(3, 0, 3, 5);
                btn.Focusable = false;
                // btn.KeyText = dr["param"].ToString();
                Grid.SetRow(btn, rowNum);

                Grid.SetColumn(btn, colNum);

                if (rowNum == 8)
                {
                    ++colNum;
                    rowNum = 0;
                }



                this.MyGrid.Children.Add(btn);


                btn.Click += new RoutedEventHandler(btn_Click);

                /*
                 * string eventClass = dr["key_class"].ToString();
                 *
                 * try
                 * {
                 *   Assembly assembly = Assembly.GetExecutingAssembly();
                 *   PosEvent posEvent = assembly.CreateInstance(eventClass) as PosEvent;
                 *   PosContext.Instance.KeysById.Add(dr["key_code"].ToString(), posEvent);
                 *
                 * }
                 * catch (System.NullReferenceException exNull)
                 * {
                 *   Logger.Error(this.GetType().ToString(), "Invalid class name " + exNull.ToString() + exNull);
                 * }
                 * catch (Exception ex)
                 * {
                 *   Logger.Error(this.GetType().ToString(), ex.ToString(), ex);
                 * }
                 *
                 */
            }


            // this.KeyDisable();
            //  }
            //  catch
            //  {
            //  }
        }
예제 #22
0
        /// <summary>
        /// </summary>
        public void AddPosKeys(int subMenuID, string menuName)
        {
            //this.txtBlockMenuName.Text = menuName;


            PosKey posKey = new PosKey();

            posKey.Panel_id  = subMenuID;
            posKey.Config_no = PosSettings.Default.Configuration; //PosContext.Instance.Config.ConfigNo;
            DataSet   data   = posKey.LoadBySubMenu();
            DataTable dt     = data.Tables[0];
            int       colNum = 0;
            int       rowNum = 0;

            foreach (DataRow dr in dt.Rows)
            {
                PosButton btn = new PosButton();
                btn.Style = (Style)FindResource("GlassyButtonStyle1");

                btn.Height         = 75;
                btn.KeyValue       = int.Parse(dr["key_val"].ToString());
                btn.KeyCode        = int.Parse(dr["key_code"].ToString());
                btn.AccessKeyValue = int.Parse(dr["attr"].ToString());
                btn.Content        = dr["key_text"].ToString();
                btn.KeyClass       = dr["key_class"].ToString();
                btn.Tag            = "..\\..\\Images\\" + dr["image"].ToString().Trim();
                btn.Margin         = new Thickness(2, 2, 2, 2);
                btn.Focusable      = false;
                Grid.SetRow(btn, rowNum);
                Grid.SetColumn(btn, colNum++);

                this.MyGrid.Children.Add(btn);

                if (colNum > 5)
                {
                    colNum = 0;
                    ++rowNum;
                }


                btn.Click += new RoutedEventHandler(btn_Click);

                //Register key in PosContext;
                //Create events
                string eventClass = dr["key_class"].ToString();
                try
                {
                    Assembly assembly = Assembly.GetExecutingAssembly();
                    PosEvent posEvent = assembly.CreateInstance(eventClass) as PosEvent;
                    if (!PosContext.Instance.KeysById.ContainsKey(dr["key_code"].ToString()))
                    {
                        PosContext.Instance.KeysById.Add(dr["key_code"].ToString(), posEvent);
                    }
                }
                catch (System.NullReferenceException exNull)
                {
                    Logger.Error(this.GetType().ToString(), "Invalid class name " + eventClass);
                }
                catch (Exception ex)
                {
                    Logger.Error(this.GetType().ToString(), ex.ToString());
                }
            }

            this.KeyDisable();
        }