public ServerPanel() { current = this; this.Background = null; SubPanel = new ServerInfoPanel(); this.Children.Add(SubPanel); }
void InitServerTab() { // serverinfo.json 파일 로드 FileInfo fi = new FileInfo(ServerInfo.PATH); if (fi.Exists) { string json = FileContoller.Read(ServerInfo.PATH); try { ServerInfo.jobj_root = JObject.Parse(json); panel_server = ServerInfo.ConvertFromJson(ServerInfo.jobj_root); grid_server.Children.Add(panel_server); } catch (Exception e) { Log.PrintError(e.Message, "UserControls.ServerMenu.InitServertab"); } } else { try { ServerInfo.jobj_root = new JObject(new JProperty("Server", new JObject())); ServerPanel panel_server = ServerInfo.ConvertFromJson(ServerInfo.jobj_root); grid_server.Children.Add(panel_server); } catch (Exception e) { Log.PrintError(e.Message, "UserControls.ServerMenu.InitServertab"); } } if (ServerMenuButton.group.Count > 0) { ServerMenuButton.group[0].IsChecked = true; } }
public static ServerPanel ConvertFromJson(JObject jobj_root) { if (jobj_root == null) { return(null); } ServerPanel servergrid = new ServerPanel(); try { foreach (var v in jobj_root.Properties()) { JObject jobj_server_menu = v.Value as JObject; if (jobj_server_menu == null) { continue; } ServerMenuButton smbtn = new ServerMenuButton(v.Name); servergrid.Children.Add(smbtn); ServerPanel.SubPanel.Children.Add(smbtn.child); foreach (var jprop_server_info in jobj_server_menu.Properties()) { ServerInfo serverinfo = ServerInfo.ConvertFromJson(jprop_server_info); smbtn.child.Items.Add(new ServerInfoPanel(serverinfo)); } } return(servergrid); } catch (Exception e) { Log.PrintError(e.Message, "UserControls.ServerInfo.ConvertFromJson"); } return(null); }