public SmartControl() { InitializeComponent(); if (Environment.OSVersion.Platform.ToString().StartsWith("Win")) { this.Size = new Size(320, 260); } statisticsWidget.Dock = DockStyle.Fill; statisticsWidget.CloseButtonClicked += (sender, args) => { this.Controls.Remove(currentWidget); this.Controls.Add(groupList); widgetCycle.Start(); }; groupList = new GroupList(); groupList.Dock = DockStyle.Fill; groupList.GroupSelected += groupList_GroupSelected; widgetCycle.Interval = 5000; widgetCycle.Tick += widgetCycle_Tick; widgetCycle.Enabled = true; widgetCycle.Start(); currentWidget = loadingWidget; currentWidget.Dock = DockStyle.Fill; this.Controls.Add(currentWidget); Program.HomeGenie.LoadDataCompleted = () => { foreach (Group g in Program.HomeGenie.Groups) { GroupView widget = new GroupView(); widget.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None; widget.ItemClicked = (sender, tile) => { ShowModuleScreen(tile.Module); }; widget.SetGroup(g); widget.GroupsButtonClicked += (sender, args) => { this.Controls.Add(groupList); this.Controls.SetChildIndex(groupList, 0); groupList.Invalidate(); }; groupWidgets.Add(widget); } groupList.SetGroups(Program.HomeGenie.Groups); System.Threading.Thread t = new System.Threading.Thread(() => { System.Threading.Thread.Sleep(5000); UiHelper.SafeInvoke(this, () => { if (currentWidget != null) { this.Controls.Remove(currentWidget); } this.Controls.Add(groupList); }); }); t.Start(); }; Program.HomeGenie.Connect(); }