private void button_render_Click(object sender, RoutedEventArgs e) { //string blueprintstr = blueprint.ToString(); //string child = ((dynamic)filter_output.SelectedItem).child.ToString(); Loadwindow w = new Loadwindow(); try { w.Show(); dynamic child = Newtonsoft.Json.JsonConvert.DeserializeObject <dynamic>(Edit_child.Text); int i = 0; int index = ((dynamic)filter_output.SelectedItem).index; for (int j = 0; j < blueprint.bodies.Count; j++) { for (int k = 0; k < blueprint.bodies[j].childs.Count; k++) { if (index == i) { blueprint.bodies[j].childs[k] = child; BP.setblueprint(blueprint); BP.Description.description = BP.Description.description + "\n++Applied RAW changes"; mainwindow.RenderBlueprint(); //Update(); w.Close(); MessageBox.Show("edit successful"); filterupdate(); return; } i++; } } for (int j = 0; j < blueprint.joints.Count; j++) { if (index == i) { blueprint.joints[j] = child; BP.setblueprint(blueprint); BP.Description.description = BP.Description.description + "\n++Applied RAW changes"; mainwindow.RenderBlueprint(); //Update(); w.Close(); MessageBox.Show("edit successful"); filterupdate(); return; } i++; } w.Close(); MessageBox.Show("edit UNsuccessfull :("); } catch (Exception exc) { w.Close(); MessageBox.Show(exc.Message); } }
public AreaProperties(MainWindow mainwindow) { this.mainwindow = mainwindow; InitializeComponent(); Loadwindow w = new Loadwindow(); w.Show(); Update(); w.Close(); }
private void filterupdate() { // if (filter != null && filter.IsAlive) filter.Abort(); // filter = new Thread(new ThreadStart(filter_output_update)); // filter.SetApartmentState(ApartmentState.STA); // filter.Start(); Loadwindow l = new Loadwindow(); l.Show(); filter_output_update(); l.Close(); }
public void Load() { Loadwindow l = new Loadwindow(); string bppath = ""; try { bppath = ((Blueprint)listBox_blueprints.SelectedItem).blueprintpath.ToString(); l.Show(); new BP(bppath); mainwindow.RenderBlueprint(); if (mainwindow.advancedconnections != null && mainwindow.advancedconnections.IsLoaded) { mainwindow.advancedconnections.Update(); } if (mainwindow.advancedcolorwindow != null && mainwindow.advancedcolorwindow.IsLoaded) { mainwindow.advancedcolorwindow.Update(); } if (mainwindow.swapblockswindow != null && mainwindow.swapblockswindow.IsLoaded) { mainwindow.swapblockswindow.Update(); } if (mainwindow.blockProperties != null && mainwindow.blockProperties.IsLoaded) { mainwindow.blockProperties.Update(); } if (mainwindow.areaProperties != null && mainwindow.areaProperties.IsLoaded) { mainwindow.areaProperties.Update(); } if (mainwindow.blockPropertiesRAW != null && mainwindow.blockPropertiesRAW.IsLoaded) { mainwindow.blockPropertiesRAW.Update(); } l.Close(); } catch (Exception e) { MessageBox.Show(e.Message); l.Close(); } }
private void button_render_Click(object sender, RoutedEventArgs e) { //apply changes if (Convert.ToInt32(filter_x1.Text) > Convert.ToInt32(filter_x2.Text)) { string h = filter_x1.Text; filter_x1.Text = filter_x2.Text; filter_x2.Text = h; } if (Convert.ToInt32(filter_y1.Text) > Convert.ToInt32(filter_y2.Text)) { string h = filter_y1.Text; filter_y1.Text = filter_y2.Text; filter_y2.Text = h; } if (Convert.ToInt32(filter_z1.Text) > Convert.ToInt32(filter_z2.Text)) { string h = filter_z1.Text; filter_z1.Text = filter_z2.Text; filter_z2.Text = h; } int x1 = Convert.ToInt32(filter_x1.Text); int y1 = Convert.ToInt32(filter_y1.Text); int z1 = Convert.ToInt32(filter_z1.Text); int x2 = Convert.ToInt32(filter_x2.Text); int y2 = Convert.ToInt32(filter_y2.Text); int z2 = Convert.ToInt32(filter_z2.Text); string targetuuid = null; if (filter_type.SelectedIndex < 0) { filter_type.SelectedIndex = 0; } if (filter_type.SelectedIndex > 0) { targetuuid = ((Item)filter_type.SelectedItem).UUID; } dynamic blueprint = BP.Blueprint; if (filtercolor != null && filtercolor.StartsWith("#")) { filtercolor = filtercolor.Substring(1, 6).ToLower(); } foreach (dynamic body in blueprint.bodies) { foreach (dynamic child in body.childs) { if (child.color.ToString().StartsWith("#")) { child.color = child.color.ToString().Substring(1, 6).ToLower(); } dynamic realpos = BP.getposandbounds(child); if ((filtercolor == null || filtercolor == child.color.ToString()) && (targetuuid == null || targetuuid == child.shapeId.ToString()) && (x1 <= (int)realpos.pos.x && (int)realpos.pos.x + (int)realpos.bounds.x <= x2) && (y1 <= (int)realpos.pos.y && (int)realpos.pos.y + (int)realpos.bounds.y <= y2) && (z1 <= (int)realpos.pos.z && (int)realpos.pos.z + (int)realpos.bounds.z <= z2)) { child.pos.x = child.pos.x + Convert.ToInt32(new_x.Text); child.pos.y = child.pos.y + Convert.ToInt32(new_y.Text); child.pos.z = child.pos.z + Convert.ToInt32(new_z.Text); if (new_color.Text != "") { child.color = new_color.Text.ToString().Substring(1, 6); } if (Edit_gate.IsVisible && new_gatemode.SelectedIndex > 0) { child.controller.mode = new_gatemode.SelectedIndex - 1; } if (Edit_lamp.IsVisible) { if (new_luminance.Text != "") { child.controller.luminance = Convert.ToInt32(new_luminance.Text); } if (new_coneangle.Text != "") { child.controller.coneAngle = Convert.ToInt32(new_coneangle.Text); } if (new_lampcolor.Text != "") { child.controller.color = new_lampcolor.Text; } } if (Edit_sensor.IsVisible && (new_sensorrange.Text != "" || new_sensorcolormode.IsChecked == true)) { if (new_sensorrange.Text != "") { child.controller.range = Convert.ToInt32(new_sensorrange.Text); } child.controller.colorMode = new_sensorcolormode.IsChecked == true?true:false; child.controller.color = new_sensorcolor.Text; } if (Edit_Timer.IsVisible && new_timerseconds.Text != null) { child.controller.seconds = Convert.ToInt32(new_timerseconds); child.controller.ticks = Convert.ToInt32(new_timerticks); } } } } if (blueprint.joints != null) { foreach (dynamic child in blueprint.joints) { if (child.color.ToString().StartsWith("#")) { child.color = child.color.ToString().Substring(1, 6); } dynamic c = child; c.pos = child.posA; c.xaxis = child.xaxisA; c.zaxis = child.zaxisA; dynamic realpos = BP.getposandbounds(c); realpos.pos = child.posA; if (!(Convert.ToInt32(child.zaxis.ToString()) > 0 || !(realpos.bounds.x != 1 || realpos.bounds.y != 1 || realpos.bounds.z != 1))) { int zaxis = Convert.ToInt32(child.zaxis.ToString()); if (zaxis == -1) { realpos.pos.x -= realpos.bounds.x - 1; } if (zaxis == -2) { realpos.pos.y -= realpos.bounds.y - 1; } if (zaxis == -3) { realpos.pos.z -= realpos.bounds.z - 1; } } if ((filtercolor == null || filtercolor == child.color.ToString()) && (targetuuid == null || targetuuid == child.shapeId.ToString()) && (x1 <= (int)realpos.pos.x && (int)realpos.pos.x + (int)realpos.bounds.x <= x2) && (y1 <= (int)realpos.pos.y && (int)realpos.pos.y + (int)realpos.bounds.y <= y2) && (z1 <= (int)realpos.pos.z && (int)realpos.pos.z + (int)realpos.bounds.z <= z2)) { child.posA.x = child.posA.x + Convert.ToInt32(new_x.Text); child.posA.y = child.posA.y + Convert.ToInt32(new_y.Text); child.posA.z = child.posA.z + Convert.ToInt32(new_z.Text); if (new_color.Text != "") { child.color = new_color.Text.ToString().Substring(1, 6); } } } } Loadwindow w = new Loadwindow(); w.Show(); BP.Description.description = BP.Description.description += "++ Applied some area property changes "; BP.setblueprint(BP.Blueprint); this.mainwindow.RenderBlueprint(); //Update(); filterupdate(); w.Close(); }
private void filterupdate() { var l = new Loadwindow(); l.Show(); disableAll(); filter_output.Items.Clear(); if (Convert.ToInt32(filter_x1.Text) > Convert.ToInt32(filter_x2.Text)) { string h = filter_x1.Text; filter_x1.Text = filter_x2.Text; filter_x2.Text = h; } if (Convert.ToInt32(filter_y1.Text) > Convert.ToInt32(filter_y2.Text)) { string h = filter_y1.Text; filter_y1.Text = filter_y2.Text; filter_y2.Text = h; } if (Convert.ToInt32(filter_z1.Text) > Convert.ToInt32(filter_z2.Text)) { string h = filter_z1.Text; filter_z1.Text = filter_z2.Text; filter_z2.Text = h; } int x1 = Convert.ToInt32(filter_x1.Text); int y1 = Convert.ToInt32(filter_y1.Text); int z1 = Convert.ToInt32(filter_z1.Text); int x2 = Convert.ToInt32(filter_x2.Text); int y2 = Convert.ToInt32(filter_y2.Text); int z2 = Convert.ToInt32(filter_z2.Text); this.mainwindow.setMarker2((x1 + x2 + 0.0f) / 2, (y1 + y2 + 0.0f) / 2, (z1 + z2 + 0.0f) / 2, (x2 - x1), (y2 - y1), (z2 - z1)); string targetuuid = null; if (filter_type.SelectedIndex < 0) { filter_type.SelectedIndex = 0; } if (filter_type.SelectedIndex > 0) { targetuuid = ((Item)filter_type.SelectedItem).UUID; } //thread: if (filter != null && filter.IsAlive) { filter.Abort(); } filter = new Thread(() => { //filter correct blocks: int i = 0; foreach (dynamic body in blueprint.bodies) { foreach (dynamic child in body.childs) { if (child.color.ToString().StartsWith("#")) { child.color = child.color.ToString().Substring(1, 6).ToLower(); } dynamic realpos = BP.getposandbounds(child); if ((filtercolor == null || filtercolor == child.color.ToString()) && (targetuuid == null || targetuuid == child.shapeId.ToString()) && (x1 <= (int)realpos.pos.x && (int)realpos.pos.x + (int)realpos.bounds.x <= x2) && (y1 <= (int)realpos.pos.y && (int)realpos.pos.y + (int)realpos.bounds.y <= y2) && (z1 <= (int)realpos.pos.z && (int)realpos.pos.z + (int)realpos.bounds.z <= z2)) { dynamic listitem = new JObject(); listitem.pos = new JObject(); listitem.pos.x = (int)realpos.pos.x; listitem.pos.y = (int)realpos.pos.y; listitem.pos.z = (int)realpos.pos.z; listitem.bounds = new JObject(); listitem.bounds.x = (int)realpos.bounds.x; listitem.bounds.y = (int)realpos.bounds.y; listitem.bounds.z = (int)realpos.bounds.z; listitem.blockname = "unnamed shape" + child.shapeId.ToString(); listitem.index = i; if (Database.blocks.ContainsKey(child.shapeId.ToString())) { listitem.blockname = Database.blocks[child.shapeId.ToString()].Name; } listitem.color = child.color.ToString(); listitem.child = child.ToString(); this.Dispatcher.Invoke((Action)(() => { filter_output.Items.Add(listitem); })); } i++; } } if (blueprint.joints != null) { foreach (dynamic child in blueprint.joints) { if (child.color.ToString().StartsWith("#")) { child.color = child.color.ToString().Substring(1, 6).ToLower(); } dynamic c = child; c.pos = child.posA; c.xaxis = child.xaxisA; c.zaxis = child.zaxisA; dynamic realpos = BP.getposandbounds(c); realpos.pos = child.posA; if (!(Convert.ToInt32(child.zaxis.ToString()) > 0 || !(realpos.bounds.x != 1 || realpos.bounds.y != 1 || realpos.bounds.z != 1))) { int zaxis = Convert.ToInt32(child.zaxis.ToString()); if (zaxis == -1) { realpos.pos.x -= realpos.bounds.x - 1; } if (zaxis == -2) { realpos.pos.y -= realpos.bounds.y - 1; } if (zaxis == -3) { realpos.pos.z -= realpos.bounds.z - 1; } } if ((filtercolor == null || filtercolor == child.color.ToString()) && (targetuuid == null || targetuuid == child.shapeId.ToString()) && (x1 <= (int)realpos.pos.x && (int)realpos.pos.x + (int)realpos.bounds.x <= x2) && (y1 <= (int)realpos.pos.y && (int)realpos.pos.y + (int)realpos.bounds.y <= y2) && (z1 <= (int)realpos.pos.z && (int)realpos.pos.z + (int)realpos.bounds.z <= z2)) { dynamic listitem = new JObject(); listitem.pos = new JObject(); listitem.pos.x = (int)realpos.pos.x; listitem.pos.y = (int)realpos.pos.y; listitem.pos.z = (int)realpos.pos.z; listitem.bounds = new JObject(); listitem.bounds.x = (int)realpos.bounds.x; listitem.bounds.y = (int)realpos.bounds.y; listitem.bounds.z = (int)realpos.bounds.z; listitem.blockname = "unnamed shape" + child.shapeId.ToString(); if (Database.blocks.ContainsKey(child.shapeId.ToString())) { listitem.blockname = Database.blocks[child.shapeId.ToString()].Name; } listitem.color = child.color.ToString(); listitem.child = child.ToString(); listitem.index = i; this.Dispatcher.Invoke((Action)(() => { filter_output.Items.Add(listitem); })); } i++; } } }); filter.IsBackground = true; filter.Start(); l.Close(); }
private void button_render_Click(object sender, RoutedEventArgs e) { //blueprintIndex foreach (dynamic body in BP.Blueprint.bodies) { foreach (dynamic child in body.childs) { if (Convert.ToInt32(child.blueprintIndex) == selectedchildindex) { if (Edit_controller.IsVisible) { child.controller.joints.Clear(); foreach (dynamic item in (dynamic)new_controllercontrolls.Items) { item.startAngle = Convert.ToInt32(item.startAngle); item.frames[0].targetAngle = Convert.ToInt32(item.controller0); item.frames[1].targetAngle = Convert.ToInt32(item.controller1); item.frames[2].targetAngle = Convert.ToInt32(item.controller2); item.frames[3].targetAngle = Convert.ToInt32(item.controller3); item.frames[4].targetAngle = Convert.ToInt32(item.controller4); item.frames[5].targetAngle = Convert.ToInt32(item.controller5); item.frames[6].targetAngle = Convert.ToInt32(item.controller6); item.frames[7].targetAngle = Convert.ToInt32(item.controller7); item.frames[8].targetAngle = Convert.ToInt32(item.controller8); item.frames[9].targetAngle = Convert.ToInt32(item.controller9); child.controller.joints.Add(item); } } if (Edit_gate.IsVisible) { child.controller.mode = new_gatemode.SelectedIndex; } if (Edit_general.IsVisible) { child.pos.x = Convert.ToInt32(new_x.Text); child.pos.y = Convert.ToInt32(new_y.Text); child.pos.z = Convert.ToInt32(new_z.Text); child.color = new_color.Text; child.xaxis = Convert.ToInt32(new_xaxis.Text); child.zaxis = Convert.ToInt32(new_zaxis.Text); dynamic selectedblock = ((dynamic)filter_output.SelectedItem); selectedblock.pos.x = child.pos.x; selectedblock.pos.y = child.pos.y; selectedblock.pos.z = child.pos.z; selectedblock.xaxis = child.xaxis; selectedblock.zaxis = child.zaxis; } if (Edit_sensor.IsVisible) { child.controller.colorMode = new_sensorcolormode.IsChecked; child.controller.range = Convert.ToInt32(new_sensorrange.Text); child.controller.color = new_sensorcolor.Text; } if (Edit_lamp.IsVisible) { child.controller.coneAngle = Convert.ToInt32(new_coneangle.Text); child.controller.luminance = Convert.ToInt32(new_luminance.Text); } if (Edit_Timer.IsVisible) { child.controller.seconds = Convert.ToInt32(new_timerseconds.Text); child.controller.ticks = Convert.ToInt32(new_timerticks.Text); } } } } Loadwindow w = new Loadwindow(); w.Show(); BP.Description.description = BP.Description.description += "++ Applied some block property changes "; BP.setblueprint(BP.Blueprint); this.mainwindow.RenderBlueprint(); //Update(); dynamic bounds = BP.GetBounds(); int x1 = bounds.minx, y1 = bounds.maxx, z1 = bounds.miny, x2 = bounds.maxy, y2 = bounds.minz, z2 = bounds.maxz; this.Dispatcher.Invoke((Action)(() => {//this refer to form in WPF application if (filter_x1.Text != "") { x1 = Convert.ToInt32(filter_x1.Text); } if (filter_y1.Text != "") { y1 = Convert.ToInt32(filter_y1.Text); } if (filter_z1.Text != "") { z1 = Convert.ToInt32(filter_z1.Text); } if (filter_x2.Text != "") { x2 = Convert.ToInt32(filter_x2.Text); } if (filter_y2.Text != "") { y2 = Convert.ToInt32(filter_y2.Text); } if (filter_z2.Text != "") { z2 = Convert.ToInt32(filter_z2.Text); //0.1! = any } this.mainwindow.setMarker2((x1 + x2 + 0.0f) / 2, (y1 + y2 + 0.0f) / 2, (z1 + z2 + 0.0f) / 2, (x2 - x1), (y2 - y1), (z2 - z1)); })); w.Close(); }