public void refreshJsonFile()
        {
            // 삭제
            listView_json.Items.Clear();
            cur_jsonfile.Clear();

            // 추가
            //string[] files = Directory.GetFiles(@"D:\git\config_manager\ConfigManager_sln\ConfigEditor_proj\bin\Debug", "*.json");
            // 현재 application이 실행되는 경로의 json 파일을 찾아라
            string[] files = Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.json");

            for (int i = 0; i < files.Length; i++)
            {
                Label    lb = new Label();
                string[] filename_splited = files[i].Split('\\');
                lb.Content = filename_splited[filename_splited.Length - 1];
                listView_json.Items.Add(lb);
            }
            cur_jsonfile.path     = files[0];
            cur_jsonfile.filename = (listView_json.Items.GetItemAt(0) as Label).Content as string;

            string json = FileContoller.read(cur_jsonfile.path);

            refreshJsonItem(json, cur_jsonfile.filename);

            listView_json.SelectionChanged += ListView_json_SelectionChanged;
        }
Exemple #2
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);
                }
            }
            if (ServerMenuButton.group.Count > 0)
            {
                ServerMenuButton.group[0].IsChecked = true;
            }
        }
Exemple #3
0
        private void OnClickButtonOpenJsonFile(object sender, RoutedEventArgs e)
        {
            if (JsonInfo.current == null)
            {
                return;
            }

            JsonInfo.current.Clear();
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.InitialDirectory = root_path;

            if (JsonInfo.current.Path != null)
            {
                string        dir_path = JsonInfo.current.Path.Substring(0, JsonInfo.current.Path.LastIndexOf('\\') + 1);
                DirectoryInfo d        = new DirectoryInfo(dir_path);
                if (d.Exists)
                {
                    ofd.InitialDirectory = dir_path;
                }
            }

            // 파일 열기
            ofd.Filter = "JSon Files (.json)|*.json";
            if (ofd.ShowDialog(this) == true)
            {
                Console.WriteLine(ofd.FileName);

                string json = FileContoller.read(ofd.FileName);
                refreshJsonTree(JsonController.parseJson(json));

                JsonInfo.current.Path = ofd.FileName;
            }
        }
Exemple #4
0
        void initServerTab()
        {
            // UI 초기화
            ServerGrid servergrid = new ServerGrid();

            grid_server.Children.Add(servergrid);
            ServerMenuButton[] smbtn = new ServerMenuButton[ServerInfo.CATEGORIES.Length];
            for (int i = 0; i < ServerInfo.CATEGORIES.Length; i++)
            {
                ServerInfo.jobj_root.Add(new JProperty(ServerInfo.CATEGORIES[i], new JObject()));
                smbtn[i] = new ServerMenuButton(ServerInfo.CATEGORIES[i]);
                servergrid.Children.Add(smbtn[i]);
                ServerGrid.current.submenu.Children.Add(smbtn[i].child);
            }
            smbtn[0].IsChecked = true;

            CommandView commandView;

            commandView = new CommandView();
            grid_second.Children.Add(commandView);


            // serverinfo.json 파일 로드
            FileInfo fi = new FileInfo(ServerInfo.PATH);

            if (fi.Exists)
            {
                string json = FileContoller.read(ServerInfo.PATH);
                try
                {
                    ServerInfo.jobj_root = JObject.Parse(json);
                    List <ServerInfo>[] serverinfos = ServerInfo.ConvertFromJson(ServerInfo.jobj_root);
                    for (int i = 0; i < ServerInfo.CATEGORIES.Length; i++)
                    {
                        for (int j = 0; j < serverinfos[i].Count; j++)
                        {
                            smbtn[i].child.Items.Add(new ServerInfoTextBlock(serverinfos[i][j]));
                        }
                    }
                    //for(int i = 0; i < ServerInfo.CATEGORIES.Length; i++)
                    //{
                    //	JObject jobj = ServerInfo.jobj_root[ServerInfo.CATEGORIES[i]] as JObject;
                    //	ServerInfo si;
                    //	foreach(var v in jobj.Properties())
                    //	{
                    //		si = ServerInfo.ConvertFromJson(v);
                    //		smbtn[i].child.Items.Add(new ServerInfoTextBlock(si));
                    //	}
                    //}
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
        private void ListView_json_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            Label selected = listView_json.SelectedItem as Label;

            if (selected != null)
            {
                cur_jsonfile.filename = selected.Content as string;
                string json = FileContoller.read(cur_jsonfile.filename);
                refreshJsonItem(json, cur_jsonfile.filename);
            }
        }
Exemple #6
0
        private void OnClickButtonCancelJsonFile(object sender, RoutedEventArgs e)
        {
            if (JsonInfo.current == null || JsonInfo.current.Path == null)
            {
                return;
            }

            string        dir_path = JsonInfo.current.Path.Substring(0, JsonInfo.current.Path.LastIndexOf('\\') + 1);
            DirectoryInfo d        = new DirectoryInfo(dir_path);

            if (!d.Exists)
            {
                return;
            }

            string json = FileContoller.read(JsonInfo.current.path);

            refreshJsonTree(JsonController.parseJson(json));
        }