/// <summary> ///获取服务器最新音乐数据,并显示列表及音乐文件 /// </summary> private void LoadUI(bool EnableOffLine = false) { var categoryClient = new Lin.BGA.APIClient.CategoryClient(); listCategory = categoryClient.GetList(); if (!DataHelper.Ping(null)) { if (!EnableOffLine) { return; } } else { InitDataAsync(); } while (panelMusic.Controls.Count > 0) { panelMusic.Controls.RemoveAt(0); } int Flag = 0; foreach (var itemCategory in listCategory) { Control groupBox = panelMusic.Controls.Find("GroupBox" + itemCategory.ID, false).FirstOrDefault(); ListBox listbox; if (null == groupBox) { groupBox = new GroupBox(); panelMusic.Controls.Add(groupBox); groupBox.Name = "GroupBox" + itemCategory.ID; groupBox.Left = (250 + 30) * Flag; groupBox.Width = 250; groupBox.Height = 400; groupBox.Text = itemCategory.Name; listbox = new ListBox(); listbox.Name = "ListBox" + itemCategory.ID; groupBox.Controls.Add(listbox); listbox.Top = 20; listbox.Left = 10; listbox.Width = 230; listbox.Height = 360; listbox.Font = new Font("宋体", 12); listbox.MouseDoubleClick += Listbox_MouseDoubleClick; } else { listbox = (ListBox)groupBox.Controls.Find("ListBox" + itemCategory.ID, false).First(); } foreach (var itemMusic in itemCategory.MusicInfo) { listbox.Items.Add(itemMusic.Name); } Flag++; } }
static void Main(string[] args) { var result = new CategoryClient().GetList(); // Console.WriteLine(result); // Console.ReadLine(); }