Esempio n. 1
0
        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);
                    ServerPanel panel_server = ServerInfo.ConvertFromJson(ServerInfo.jobj_root);

                    grid_server.Children.Add(panel_server);
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
            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)
                {
                    Console.WriteLine(e.Message);
                }
            }

            if (ServerMenuButton.group.Count > 0)
            {
                ServerMenuButton.group[0].IsChecked = true;
            }
        }
Esempio n. 2
0
        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 ServerInfoTextBlock(serverinfo));
                    }
                }
                return(servergrid);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            return(null);
        }