private void OnRefreshTaskbar(object sender, EventArgs e) { List<Control> ToRemove = new List<Control>(); //remove old controls foreach (Control c in gb_Taskbar.Controls) { if (c.Name.Contains("btn_TouchScreenApplication")) { ToRemove.Add(c); } } foreach (Control c in ToRemove) { gb_Taskbar.Controls.Remove(c); } //add new application controls int index = 0; foreach (ITouchScreenApplication app in applications) { Button b = new Button(); b.Width = b.Height = 64; b.Name = "btn_TouchScreenApplication" + index; b.Text = app.DisplayName; b.Left = (btn_TaskbarLeft.Right + 21) + ((b.Width + 10) * index); b.Top = 21; b.Tag = app; b.Click += new EventHandler(Button_OnApplicationClick); app.ClearEventHandlers(); app.OnMenuChanged += new TouchScreenBasicEvent(Screen_OnMenuChanged); app.OnScreenPushed += new TouchScreenBasicEvent(Screen_OnPush); b.TabIndex = index++; gb_Taskbar.Controls.Add(b); } //load a default application if (applications.Count > 0) { currentApplication = applications[0]; UpdateMenu(); UpdateScreen(); } return; }
private void Button_OnApplicationClick(object sender, EventArgs e) { Button b = sender as Button; if ((b != null) && (b.Tag != null)) { currentApplication = (ITouchScreenApplication)b.Tag; UpdateMenu(); UpdateScreen(); } }