public void Update()
 {
     if (uuidsbackup != BP.GetUsedUuids())
     {
         connectable_UUIDS.Clear();
         foreach (string uuid in BP.GetUsedUuids())
         {
             if (Database.blocks.ContainsKey(uuid) && Database.blocks[uuid] is Part && (Database.blocks[uuid] as Part).IsConnectable)
             {
                 connectable_UUIDS.Add(new Connectable(uuid.ToString(), ((Part)Database.blocks[uuid]).GetBoundsDynamic(), Database.blocks[uuid].Name));
             }
         }
         this.Dispatcher.Invoke((Action)(() =>
         {//this refer to form in WPF application
             comboBox_items1.Items.Clear();
             comboBox_items2.Items.Clear();
         }));
         foreach (Connectable i in connectable_UUIDS)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {//this refer to form in WPF application
                 comboBox_items1.Items.Add(i);
                 comboBox_items2.Items.Add(i);
             }));
         }
     }
     uuidsbackup = BP.GetUsedUuids();
 }
Example #2
0
 public void Update()//new bp, items replaced, ... whatever
 {
     disableAll();
     if (filter_x1.Text == "" || uuidsbackup != BP.GetUsedUuids())
     {
         dynamic bounds = BP.GetBounds();
         filter_x1.Text = bounds.minx.ToString();
         filter_y1.Text = bounds.miny.ToString();
         filter_z1.Text = bounds.minz.ToString();
         filter_x2.Text = bounds.maxx.ToString();
         filter_y2.Text = bounds.maxy.ToString();
         filter_z2.Text = bounds.maxz.ToString();
     }
     if (uuidsbackup != BP.GetUsedUuids() | true)//fill the combobox once
     {
         filter_type.Items.Clear();
         filter_type.Items.Add(new Item("any", "*"));
         foreach (string uuid in BP.GetUsedUuids())
         {
             if (Database.blocks.ContainsKey(uuid))
             {
                 filter_type.Items.Add(new Item(Database.blocks[uuid].Name.ToString(), uuid));
             }
         }
         uuidsbackup.Clear();
         uuidsbackup.UnionWith(BP.GetUsedUuids());
         filter_type.SelectedIndex = 0;
     }
     filterupdate();
 }
 public void Update()
 {
     if (uuidsbackup != BP.GetUsedUuids())
     {
         blockstoreplace = new JArray();
         replacebyblocks = new JArray();
         foreach (string uuid in BP.GetUsedUuids())
         {
             if (Database.blocks.ContainsKey(uuid))
             {
                 dynamic blok = new JObject();
                 blok.name   = Database.blocks[uuid].Name;
                 blok.bounds = (Database.blocks[uuid] is Part)? ((Part)Database.blocks[uuid]).GetBoundsDynamic() : null;
                 blok.uuid   = uuid;
                 blockstoreplace.Add(blok);
             }
         }
         this.Dispatcher.Invoke((Action)(() =>
         {//this refer to form in WPF application
             comboBox_old.Items.Clear();
             comboBox_new.Items.Clear();
         }));
         foreach (dynamic blok in blockstoreplace)
         {
             this.Dispatcher.Invoke((Action)(() =>
             {//this refer to form in WPF application
                 comboBox_old.Items.Add(blok.name);
             }));
         }
     }
     uuidsbackup = BP.GetUsedUuids();
 }
Example #4
0
        public void Update()
        {
            if (uuidsbackup != BP.GetUsedUuids())
            {
                ItemList = new List <Item>
                {
                    new Item("any", "*")
                };
                foreach (string uuid in BP.GetUsedUuids())
                {
                    if (Database.blocks.ContainsKey(uuid))
                    {
                        ItemList.Add(new Item(Database.blocks[uuid].Name, uuid));
                    }
                }
                dynamic colorlist = new JObject();
                foreach (dynamic body in BP.Blueprint.bodies)
                {
                    foreach (dynamic child in body.childs)
                    {
                        if (child.color.ToString().StartsWith("#"))
                        {
                            child.color = child.color.ToString().Substring(1);
                        }
                        if (colorlist[child.color.ToString().ToLower()] == null)
                        {
                            colorlist[child.color.ToString().ToLower()] = true;
                            string c = child.color.ToString();

                            Button b  = new Button();
                            var    bc = new BrushConverter();
                            b.Background = (Brush)bc.ConvertFrom("#" + c);
                            color_list.Items.Add(b);
                        }
                    }
                }

                this.Dispatcher.Invoke((Action)(() =>
                {//this refer to form in WPF application
                    comboBox_old.Items.Clear();
                }));
                foreach (Item item in ItemList)
                {
                    this.Dispatcher.Invoke((Action)(() =>
                    {//this refer to form in WPF application
                        comboBox_old.Items.Add(item);
                    }));
                }
            }
            uuidsbackup = BP.GetUsedUuids();
        }
        public void Update()
        {
            if (uuidsbackup != BP.GetUsedUuids())
            {
                usedblocks = new List <Item>
                {
                    new Item("any", "*")
                };
                foreach (string uuid in BP.GetUsedUuids())
                {
                    if (Database.blocks.ContainsKey(uuid))
                    {
                        usedblocks.Add(new Item(Database.blocks[uuid].Name.ToString(), uuid)); // fill the combobox!   only runs once!
                    }
                }
                filter_type.Items.Clear();
                foreach (Item useditem in usedblocks)
                {
                    filter_type.Items.Add(useditem);
                }
            }
            uuidsbackup = BP.GetUsedUuids();
            filter_type.SelectedIndex = 0;
            int i = 0;
            {
                backuplist = new JObject(); //fill 'backup'list with all childs!

                foreach (dynamic body in BP.Blueprint.bodies)
                {
                    foreach (dynamic child in body.childs)
                    {
                        if (child.color.ToString().StartsWith("#"))
                        {
                            child.color = child.color.ToString().Substring(1);
                        }
                        child.blueprintIndex = i;
                        child.blockname      = Database.blocks[child.shapeId.ToString()].Name;
                        dynamic realpos = BP.getposandbounds(child);

                        if (backuplist[realpos.pos.x.ToString()] == null)
                        {
                            backuplist[realpos.pos.x.ToString()] = new JObject();
                        }
                        if (backuplist[realpos.pos.x.ToString()][realpos.pos.y.ToString()] == null)
                        {
                            backuplist[realpos.pos.x.ToString()][realpos.pos.y.ToString()] = new JObject();
                        }
                        if (backuplist[realpos.pos.x.ToString()][realpos.pos.y.ToString()][realpos.pos.z.ToString()] == null)
                        {
                            backuplist[realpos.pos.x.ToString()][realpos.pos.y.ToString()][realpos.pos.z.ToString()] = new JObject();
                        }
                        if (backuplist[realpos.pos.x.ToString()][realpos.pos.y.ToString()][realpos.pos.z.ToString()][realpos.color.ToString().ToLower()] == null)
                        {
                            backuplist[realpos.pos.x.ToString()][realpos.pos.y.ToString()][realpos.pos.z.ToString()][realpos.color.ToString().ToLower()] = new JObject();
                        }
                        if (backuplist[realpos.pos.x.ToString()][realpos.pos.y.ToString()][realpos.pos.z.ToString()][realpos.color.ToString().ToLower()][realpos.shapeId.ToString().ToLower()] == null)
                        {
                            backuplist[realpos.pos.x.ToString()][realpos.pos.y.ToString()][realpos.pos.z.ToString()][realpos.color.ToString().ToLower()][realpos.shapeId.ToString().ToLower()] = new JObject();
                        }
                        backuplist[realpos.pos.x.ToString()][realpos.pos.y.ToString()][realpos.pos.z.ToString()][realpos.color.ToString().ToLower()][realpos.shapeId.ToString().ToLower()][i.ToString()] = child;

                        i++;
                    }
                }
            }

            //fill xyz:
            dynamic bounds = BP.GetBounds();

            filter_x1.Text = bounds.minx.ToString();
            filter_y1.Text = bounds.miny.ToString();
            filter_z1.Text = bounds.minz.ToString();
            filter_x2.Text = bounds.maxx.ToString();
            filter_y2.Text = bounds.maxy.ToString();
            filter_z2.Text = bounds.maxz.ToString();

            filterupdate();
        }
Example #6
0
        private void Click_requiredmods(object sender, RoutedEventArgs e)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://scrapmechanic.xesau.eu/uuidservice/get_mods");

            request.Method      = "POST";
            request.ContentType = "application/x-www-form-urlencoded";
            string postData = "";

            foreach (string uuid in BP.GetUsedUuids())
            {
                postData += "&uuid[]=" + uuid;
            }
            postData = postData.Substring(1);

            byte[] bytes = Encoding.UTF8.GetBytes(postData);
            request.ContentLength = bytes.Length;

            Stream requestStream = request.GetRequestStream();

            requestStream.Write(bytes, 0, bytes.Length);

            WebResponse  response = request.GetResponse();
            Stream       stream   = response.GetResponseStream();
            StreamReader reader   = new StreamReader(stream);

            var     result = reader.ReadToEnd();
            dynamic Mods   = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(result);

            foreach (dynamic missingmod in Mods.missing)
            {
                if (Database.blocks.ContainsKey(missingmod.ToString()))
                {
                    string  modid = System.IO.Path.GetFileName(Database.blocks[missingmod.ToString()].id.ToString());
                    dynamic mod   = new JObject();
                    mod.name   = Database.blocks[missingmod.ToString()].Mod;
                    mod.ok     = "✔";
                    mod.author = "Unavailable, service couldn't find it";
                    mod.url    = "http://steamcommunity.com/workshop/filedetails/?id=" + modid;

                    if (!((JArray)Mods.mods).Contains(mod))
                    {
                        Mods.mods.Add(mod);
                    }
                }
                else
                {
                    MessageBox.Show("couldn't find required mod for: " + missingmod.ToString());
                }
            }

            foreach (dynamic mod in Mods.mods)
            {
                string fileId = mod.url.ToString().Substring(51);
                if (Database.usedmods.ContainsKey(fileId))
                {
                    mod.ok = "✔";
                }
                else
                if (mod.ok == null)
                {
                    mod.ok = "X";
                }
            }

            new required_mods(Mods).Show();

            stream.Dispose();
            reader.Dispose();
        }