예제 #1
0
        //このメソッドの実行後には必ずinternal_errorをチェックすること
        private string gen_json()
        {
            internal_error = "";
            //内部エラーをリセット
            internal_error = "";
            if (target_data.Count < 1)
            {
                internal_error = "差分範囲1つも入力されていません。";
                return("");
            }

            CDataObj obj = new CDataObj()
            {
                target = target_data.ToArray <CTarget>(),
                parts  = parts_data.ToArray <CPart>()
            };

            int base_x;

            //参照: http://dobon.net/vb/dotnet/vb2cs/isnumeric.html
            if (!int.TryParse(tb_base_x.Text, out base_x))
            {
                MessageBox.Show("基準範囲には数値を入力してください。");
                internal_error = "Not inputed error!";
                return("");
            }

            //基準範囲をプラスしておく
            for (int i = 0, len = obj.target.Count <CTarget>(); i < len; i++)
            {
                obj.target[i].x += base_x;
            }

            return(JsonConvert.SerializeObject(obj));
        }
예제 #2
0
        private void set_from_json(string json)
        {
            CDataObj obj = JsonConvert.DeserializeObject <CDataObj>(json);

            target_data = new ObservableCollection <CTarget>(obj.target);
            parts_data  = new ObservableCollection <CPart>(obj.parts);
            this.grid_target.ItemsSource = target_data;
            this.grid_parts.ItemsSource  = parts_data;
        }
예제 #3
0
        private void add_from_json(string json)
        {
            CDataObj obj = JsonConvert.DeserializeObject <CDataObj>(json);

            var getNameWin = new Window1();

            getNameWin.ShowDialog();
            var name = getNameWin.name;

            foreach (var item in obj.parts)
            {
                if (name != "")
                {
                    item.id = "[" + name + "]" + item.id;
                }
                parts_data.Add(item);
            }

            this.grid_parts.ItemsSource = parts_data;
        }