c# create a string list<string,string> and sort to a combo box avoiding duplicates ?

  • Thread starter Thread starter elfenliedtopfan2
  • Start date Start date
E

elfenliedtopfan2

Guest
ok i have a json file witch i parsed into width hight

and i want to store this in a list and add to combo box avoiding duplicates witch height entry's

this is part of the json code sorry its huge so only did little sniplet

"/i/models/1dbac27e101440bdbd109a793b7bba82/textures?optimized=1": {
"results": [
{
"updatedAt": "2018-03-12T18:23:49.016712",
"images": [
{
"updatedAt": "2018-03-12T18:23:48.97236",
"createdAt": "2018-03-12T18:23:48.972321",
"size": 1779,
"options": {},
"uid": "82e6f3dbb1b84317b34ff9f819cb4294",
"url": "https://media.sketchfab.com/urls/1d...8be05717/82e6f3dbb1b84317b34ff9f819cb4294.png",
"width": 32,
"height": 32
},
{
"updatedAt": "2018-03-12T18:23:47.687583",
"createdAt": "2018-03-12T18:23:47.687562",
"size": 2120744,
"options": {},
"uid": "dc70a1d7a3444bc0b2d6aae81a421b0a",
"url": "https://media.sketchfab.com/urls/1d...8be05717/dc70a1d7a3444bc0b2d6aae81a421b0a.png",
"width": 2048,
"height": 2048
},
{
"updatedAt": "2018-03-21T19:39:07.335926",
"createdAt": "2018-03-21T19:39:07.335891",
"size": 114516,
"options": {
"quality": 92,
"format": "RGB"
},
"uid": "89012757f3c540ff85b583f94ecc53e7",
"url": "https://media.sketchfab.com/urls/1d...be05717/89012757f3c540ff85b583f94ecc53e7.jpeg",
"width": 1024,
"height": 1024
},
{
"updatedAt": "2018-03-21T19:39:08.121997",
"createdAt": "2018-03-21T19:39:08.121976",
"size": 51684,
"options": {
"quality": 95,
"format": "RGB"
},
"uid": "5daed444d5e04c96ac8c84ce064fb32b",
"url": "https://media.sketchfab.com/urls/1d...be05717/5daed444d5e04c96ac8c84ce064fb32b.jpeg",
"width": 512,
"height": 512
},
{
"updatedAt": "2018-03-21T19:39:08.190984",
"createdAt": "2018-03-21T19:39:08.190962",
"size": 17008,
"options": {
"quality": 95,
"format": "RGB"
},
"uid": "499f5b9dd0e94095a7249713ff597d2e",
"url": "https://media.sketchfab.com/urls/1d...be05717/499f5b9dd0e94095a7249713ff597d2e.jpeg",
"width": 256,
"height": 256
},
{
"updatedAt": "2018-03-21T19:39:08.264038",
"createdAt": "2018-03-21T19:39:08.264017",
"size": 5871,
"options": {
"quality": 95,
"format": "RGB"
},
"uid": "bfc4fa4d25014df9b9fae1450d48f93a",
"url": "https://media.sketchfab.com/urls/1d...be05717/bfc4fa4d25014df9b9fae1450d48f93a.jpeg",
"width": 128,
"height": 128
},
{
"updatedAt": "2018-03-21T19:39:08.30114",
"createdAt": "2018-03-21T19:39:08.301119",
"size": 2057,
"options": {
"quality": 95,
"format": "RGB"
},
"uid": "8c42dc051a004073b3b0f449cf237eb3",
"url": "https://media.sketchfab.com/urls/1d...be05717/8c42dc051a004073b3b0f449cf237eb3.jpeg",
"width": 64,
"height": 64
},
{
"updatedAt": "2018-03-21T19:39:08.33484",
"createdAt": "2018-03-21T19:39:08.334818",
"size": 267563,
"options": {
"quality": 88,
"format": "RGB"
},
"uid": "948f9fb9389c42c7986bee4ce3cd3c2f",
"url": "https://media.sketchfab.com/urls/1d...be05717/948f9fb9389c42c7986bee4ce3cd3c2f.jpeg",
"width": 2048,
"height": 2048
}
],
"createdAt": "2018-03-12T18:23:47.679882",
"colorSpace": "unknown",
"uid": "02ca517770ae4ad3b8005fc28be05717",
"name": "SCOPE_03_Base_Color.png"
},
{
"updatedAt": "2018-03-11T18:03:33.108193",
"images": [
{
"updatedAt": "2018-03-11T18:03:31.038732",
"createdAt": "2018-03-11T18:03:31.038718",
"size": 23479,
"options": {},
"uid": "bfb40239c507478c80142c8b85147082",
"url": "https://media.sketchfab.com/urls/1d...591464a5/bfb40239c507478c80142c8b85147082.png",
"width": 256,
"height": 256
},
{
"updatedAt": "2018-03-11T18:03:33.042656",
"createdAt": "2018-03-11T18:03:33.04262",
"size": 480,
"options": {},
"uid": "a42964e1fd424c7b9c87455ab8a11cde",
"url": "https://media.sketchfab.com/urls/1d...591464a5/a42964e1fd424c7b9c87455ab8a11cde.png",
"width": 32,
"height": 32
},
{
"updatedAt": "2018-03-21T19:38:47.640418",
"createdAt": "2018-03-21T19:38:47.640381",
"size": 118,
"options": {
"quality": 100,
"format": "A"
},
"uid": "0f9a1bf59b804ba6b19ae1dbf4a10342",
"url": "https://media.sketchfab.com/urls/1d...591464a5/0f9a1bf59b804ba6b19ae1dbf4a10342.png",
"width": 128,
"height": 128
},
{
"updatedAt": "2018-03-21T19:38:47.679613",
"createdAt": "2018-03-21T19:38:47.679593",
"size": 108,
"options": {
"quality": 100,
"format": "A"
},
"uid": "e827e6a9931544138686c72f6491ea56",
"url": "https://media.sketchfab.com/urls/1d...591464a5/e827e6a9931544138686c72f6491ea56.png",
"width": 64,
"height": 64
},
{
"updatedAt": "2018-03-21T19:38:47.71363",
"createdAt": "2018-03-21T19:38:47.713606",
"size": 124,
"options": {
"quality": 95,
"format": "A"
},
"uid": "9b40026f390d4c009cbff32a3f393477",
"url": "https://media.sketchfab.com/urls/1d...591464a5/9b40026f390d4c009cbff32a3f393477.png",
"width": 256,
"height": 256
}
],
"createdAt": "2018-03-11T18:03:31.032536",
"colorSpace": "unknown",
"uid": "031f7aa6fd9641a1a708eb90591464a5",
"name": "DIODE_Opacity.png"
},
{
"updatedAt": "2018-03-21T19:32:38.83781",
"images": [
{
"updatedAt": "2018-03-21T19:32:36.505361",
"createdAt": "2018-03-21T19:32:36.505347",
"size": 7765255,
"options": {},
"uid": "a5019128261c4b74bf01fa6301bc4816",
"url": "https://media.sketchfab.com/urls/1d...db891c71/a5019128261c4b74bf01fa6301bc4816.png",
"width": 4096,
"height": 4096
},
{
"updatedAt": "2018-03-21T19:32:38.767988",
"createdAt": "2018-03-21T19:32:38.767952",
"size": 1284,
"options": {},
"uid": "a25b8e90036b4ef48b904508a5ed9a3f",
"url": "https://media.sketchfab.com/urls/1d...db891c71/a25b8e90036b4ef48b904508a5ed9a3f.png",
"width": 32,
"height": 32
},
{
"updatedAt": "2018-03-21T19:39:58.097489",
"createdAt": "2018-03-21T19:39:58.097461",
"size": 279308,
"options": {
"quality": 88,
"format": "RGB"
},
"uid": "a63668e0364c429d939cb524e55b6168",
"url": "https://media.sketchfab.com/urls/1d...b891c71/a63668e0364c429d939cb524e55b6168.jpeg",
"width": 2048,
"height": 2048
},
{
"updatedAt": "2018-03-21T19:39:59.067947",
"createdAt": "2018-03-21T19:39:59.067929",
"size": 122382,
"options": {
"quality": 92,
"format": "RGB"
},
"uid": "beabf154bbb349ab935d805cc2d04dfa",
"url": "https://media.sketchfab.com/urls/1d...b891c71/beabf154bbb349ab935d805cc2d04dfa.jpeg",
"width": 1024,
"height": 1024
},
{
"updatedAt": "2018-03-21T19:39:59.209492",
"createdAt": "2018-03-21T19:39:59.209475",
"size": 53597,
"options": {
"quality": 95,
"format": "RGB"
},
"uid": "d9c80ba150554cb085fa009f54436cae",
"url": "https://media.sketchfab.com/urls/1d...b891c71/d9c80ba150554cb085fa009f54436cae.jpeg",
"width": 512,
"height": 512
},
{
"updatedAt": "2018-03-21T19:39:59.242606",
"createdAt": "2018-03-21T19:39:59.242588",
"size": 17203,
"options": {
"quality": 95,
"format": "RGB"
},
"uid": "edb61e90373a40a290dd04b39e527e40",
"url": "https://media.sketchfab.com/urls/1d...b891c71/edb61e90373a40a290dd04b39e527e40.jpeg",
"width": 256,
"height": 256
},
{
"updatedAt": "2018-03-21T19:39:59.271927",
"createdAt": "2018-03-21T19:39:59.271911",
"size": 5576,
"options": {
"quality": 95,
"format": "RGB"
},
"uid": "ca1103af5dba41ba86cd276b79b4c85a",
"url": "https://media.sketchfab.com/urls/1d...b891c71/ca1103af5dba41ba86cd276b79b4c85a.jpeg",
"width": 128,
"height": 128
},
{
"updatedAt": "2018-03-21T19:39:59.303287",
"createdAt": "2018-03-21T19:39:59.303273",
"size": 1806,
"options": {
"quality": 95,
"format": "RGB"
},
"uid": "9943edd2e121422ea74d8dd5f1354ece",
"url": "https://media.sketchfab.com/urls/1d...b891c71/9943edd2e121422ea74d8dd5f1354ece.jpeg",
"width": 64,
"height": 64
},
{
"updatedAt": "2018-03-21T19:39:59.334431",
"createdAt": "2018-03-21T19:39:59.334416",
"size": 905360,
"options": {
"quality": 88,
"format": "RGB"
},
"uid": "0e5bc02f83924827ace1ddfbbd56187d",
"url": "https://media.sketchfab.com/urls/1d...b891c71/0e5bc02f83924827ace1ddfbbd56187d.jpeg",
"width": 4096,
"height": 4096
}
],
"createdAt": "2018-03-21T19:32:36.49973",
"colorSpace": "unknown",
"uid": "036651068d404bd2b31b12afdb891c71",
"name": "RECEIVER_Base_Color.png"
},

so once its found say 4096 x 4096 it only add the value in once as it does have a lot of textures and there are multiple concordances of the same sizes on different textures


and this is the code i am using to get the with and height but i not sure how to add it all into a list then put hight and width to a combo box form the list as this list will be static list


to have a working program currently i just made it so if its == 2048 x 2048 but i want the user to be able to choose



// start to grab textures
var jsonContent = File.ReadAllText(elfenliedprogsettings.Read("DOWNLOADPATH") + "\\textures.json");
var data = (JObject)JsonConvert.DeserializeObject(jsonContent);

var texturesNodeKey = "/i/models/" + texturemodel + "/textures?optimized=1";
var images = new Dictionary<string, string>();
foreach (var resultNode in data[texturesNodeKey]["results"])
{
var name = resultNode["name"].ToObject<string>();
Name = name;
foreach (var imageNode in resultNode["images"])
{
var height = imageNode["height"].ToObject<long>();
var width = imageNode["width"].ToObject<long>();
var url = imageNode["url"].ToObject<string>();
Url = url;
if (height == 2048 && width == 2048)
{
need to do something here to store all height and width the json has but not sure

how to accomplish this.
}
}
}


thanks in advance elfenliedtopfan5

Continue reading...
 
Back
Top