private void clickButton(object sender, EventArgs e, MocrButton button) { bool lit = button.lit; // Reset all screenButtons[0].setLitState(false); screenButtons[1].setLitState(false); screenButtons[2].setLitState(false); if (!lit) { button.setLitState(true); form.dataStorage.setData(positionCode + "S", button.buttonColor.ToString()); } else { form.dataStorage.setData(positionCode + "S", MocrButton.color.BLANK.ToString()); } }
static public MocrButton CreateButton(double x, double y, double w, double h, String t, bool pixels, MocrButton.style type) { int top, left, width, height; if (pixels) { top = (int)y; left = (int)x; width = (int)w; height = (int)h; } else { top = (int)(y * form.pxPrLine) + form.padding_top; left = (int)((x * form.pxPrChar) + form.padding_left); width = (int)Math.Ceiling((w * form.pxPrChar)); height = (int)Math.Ceiling(h * form.pxPrLine); } MocrButton button = new MocrButton(); button.Location = new Point(left, top); button.Size = new Size(width, height); //button.BackColor = Color.FromArgb(255, 32, 32, 32); button.Cursor = Cursors.Hand; //button.FlatAppearance.BorderColor = Color.FromArgb(255, 96, 96, 96); //button.FlatAppearance.BorderSize = 1; //button.FlatAppearance.MouseOverBackColor = Color.FromArgb(255, 64, 64, 64); //button.FlatAppearance.MouseDownBackColor = Color.FromArgb(255, 16, 16, 16); button.Font = form.smallFontB; button.Text = t; button.Padding = new Padding(0); button.buttonStyle = type; form.Controls.Add(button); return(button); }
private void clickButton(object sender, EventArgs e, MocrButton button) { }
private void fillForm() { // LOGO PictureBox emblem = new PictureBox(); emblem.Image = logo; emblem.Location = new Point(padding_left, padding_top); emblem.Size = getSize(21, 9); emblem.SizeMode = PictureBoxSizeMode.CenterImage; this.Controls.Add(emblem); // ADDRESS AND NAME FIELDS CustomLabel ipAddrLbl = new CustomLabel(); ipAddrLbl.setCharWidth(pxPrChar); ipAddrLbl.setlineHeight(pxPrLine); ipAddrLbl.setcharOffset(charOffset); ipAddrLbl.setlineOffset(lineOffset); ipAddrLbl.Font = font; ipAddrLbl.AutoSize = false; ipAddrLbl.Location = getPoint(22, 1); ipAddrLbl.Size = getSize(20, 1); ipAddrLbl.Text = "Server IP:"; ipAddrLbl.Padding = new Padding(0); ipAddrLbl.Margin = new Padding(0); ipAddrLbl.ForeColor = foreColor; this.Controls.Add(ipAddrLbl); CustomLabel nameLbl = new CustomLabel(); nameLbl.setCharWidth(pxPrChar); nameLbl.setlineHeight(pxPrLine); nameLbl.setcharOffset(charOffset); nameLbl.setlineOffset(lineOffset); nameLbl.Font = font; nameLbl.AutoSize = false; nameLbl.Location = getPoint(22, 4); nameLbl.Size = getSize(20, 1); nameLbl.Text = "Your ID:"; nameLbl.Padding = new Padding(0); nameLbl.Margin = new Padding(0); nameLbl.ForeColor = foreColor; this.Controls.Add(nameLbl); ipAddr = new TextBox(); ipAddr.Location = getPoint(22, 2); ipAddr.Size = getSize(20, 1); ipAddr.Font = font; ipAddr.ForeColor = foreColor; ipAddr.BorderStyle = BorderStyle.None; ipAddr.BackColor = Color.FromArgb(255, 32, 32, 32); ipAddr.AutoSize = false; ipAddr.Text = "127.0.0.1"; ipAddr.KeyDown += checkForEnter; this.Controls.Add(ipAddr); name = new TextBox(); name.Location = getPoint(22, 5); name.Size = getSize(20, 1); name.Font = font; name.ForeColor = foreColor; name.BorderStyle = BorderStyle.None; name.BackColor = Color.FromArgb(255, 32, 32, 32); name.AutoSize = false; name.Text = "Flight Director"; name.KeyDown += checkForEnter; this.Controls.Add(name); // CONNECT BUTTON MocrButton button = new MocrButton(); button.Location = getPoint(22, 7); button.Size = getSize(20, 1); button.Cursor = Cursors.Hand; button.Font = font; button.Text = "Connect"; button.Padding = new Padding(0); button.Click += ConnectToServer; this.Controls.Add(button); // CONNECTION STATUS kRPCStatus = new CustomLabel(); kRPCStatus.setCharWidth(pxPrChar); kRPCStatus.setlineHeight(pxPrLine); kRPCStatus.setcharOffset(charOffset); kRPCStatus.setlineOffset(lineOffset); kRPCStatus.Font = font; kRPCStatus.AutoSize = false; kRPCStatus.Location = getPoint(1, 9); kRPCStatus.Size = getSize(42, 1); kRPCStatus.Text = " kRPC: NOT CONNECTED"; kRPCStatus.Padding = new Padding(0); kRPCStatus.Margin = new Padding(0); kRPCStatus.ForeColor = foreColor; this.Controls.Add(kRPCStatus); pySSSMQStatus = new CustomLabel(); pySSSMQStatus.setCharWidth(pxPrChar); pySSSMQStatus.setlineHeight(pxPrLine); pySSSMQStatus.setcharOffset(charOffset); pySSSMQStatus.setlineOffset(lineOffset); pySSSMQStatus.Font = font; pySSSMQStatus.AutoSize = false; pySSSMQStatus.Location = getPoint(1, 10); pySSSMQStatus.Size = getSize(42, 1); pySSSMQStatus.Text = "PySSSMQ: NOT CONNECTED"; pySSSMQStatus.Padding = new Padding(0); pySSSMQStatus.Margin = new Padding(0); pySSSMQStatus.ForeColor = foreColor; this.Controls.Add(pySSSMQStatus); // GAME SCENE gameScene = new CustomLabel(); gameScene.setCharWidth(pxPrChar); gameScene.setlineHeight(pxPrLine); gameScene.setcharOffset(charOffset); gameScene.setlineOffset(lineOffset); gameScene.Font = font; gameScene.AutoSize = false; gameScene.Location = getPoint(1, 12); gameScene.Size = getSize(42, 1); gameScene.Text = "GAME SCENE: "; gameScene.Padding = new Padding(0); gameScene.Margin = new Padding(0); gameScene.ForeColor = foreColor; this.Controls.Add(gameScene); // PySSSMQ BUTTON /* * MocrButton pybutton = new MocrButton(); * pybutton.Location = getPoint(1, 17); * pybutton.Size = getSize(24, 1); * pybutton.Cursor = Cursors.Hand; * pybutton.Font = font; * pybutton.Text = "Start PySSSMQ-Server"; * pybutton.Padding = new Padding(0); * pybutton.Click += StartPyServer; * this.Controls.Add(pybutton); * * MocrButton pybuttonS = new MocrButton(); * pybuttonS.Location = getPoint(1, 18); * pybuttonS.Size = getSize(24, 1); * pybuttonS.Cursor = Cursors.Hand; * pybuttonS.Font = font; * pybuttonS.Text = "Stop PySSSMQ-Server"; * pybuttonS.Padding = new Padding(0); * pybuttonS.Click += StopPyServer; * this.Controls.Add(pybuttonS); * * // PySSSMQ-server status * pySSSMQStatus2 = new CustomLabel(); * pySSSMQStatus2.setCharWidth(pxPrChar); * pySSSMQStatus2.setlineHeight(pxPrLine); * pySSSMQStatus2.setcharOffset(charOffset); * pySSSMQStatus2.setlineOffset(lineOffset); * pySSSMQStatus2.Font = font; * pySSSMQStatus2.AutoSize = false; * pySSSMQStatus2.Location = getPoint(1, 16); * pySSSMQStatus2.Size = getSize(42, 5); * pySSSMQStatus2.Text = "PySSSMQ-Server: NOT RUNNING"; * pySSSMQStatus2.Padding = new Padding(0); * pySSSMQStatus2.Margin = new Padding(0); * pySSSMQStatus2.ForeColor = foreColor; * this.Controls.Add(pySSSMQStatus2); */ // AGC STATUS AND CONTROL AGCStatus = new CustomLabel(); AGCStatus.setCharWidth(pxPrChar); AGCStatus.setlineHeight(pxPrLine); AGCStatus.setcharOffset(charOffset); AGCStatus.setlineOffset(lineOffset); AGCStatus.Font = font; AGCStatus.AutoSize = false; AGCStatus.Location = getPoint(1, 21); AGCStatus.Size = getSize(42, 1); AGCStatus.Text = "AGC: NOT RUNNING"; AGCStatus.Padding = new Padding(0); AGCStatus.Margin = new Padding(0); AGCStatus.ForeColor = foreColor; this.Controls.Add(AGCStatus); AGCButton = new MocrButton(); AGCButton.Location = getPoint(1, 22); AGCButton.Size = getSize(24, 1); AGCButton.Cursor = Cursors.Hand; AGCButton.Font = font; AGCButton.Text = "Start AGC"; AGCButton.Padding = new Padding(0); AGCButton.Click += toggleAGC; this.Controls.Add(AGCButton); }
private void iterateDistances(Object sender, EventArgs e, int timestep) { Console.WriteLine("ITERATING " + timestep); MocrButton button = (MocrButton)sender; button.setLightColor(MocrButton.color.RED); button.setLitState(true); //Thread.Sleep(100); // CALCULATE DISTANCES FOR THE BURN ORBIT distances = new Dictionary <double, double?>(); distancesB = new Dictionary <double, double?>(); distancesC = new Dictionary <double, double?>(); minDistB = -1; minDistMETB = 0; Tuple <double, double, double> positionB = positionVector; Tuple <double, double, double> speedB = velocityVector; posB.Clear(); posC.Clear(); zedB.Clear(); zedC.Clear(); if (screenDropdowns[0].SelectedItem != null) { CelestialBody sat = (CelestialBody)screenDropdowns[0].SelectedItem; double satRadius = sat.EquatorialRadius; double satSpereOfInfluence = sat.SphereOfInfluence; double satMy = sat.GravitationalParameter; Orbit satOrbit = sat.Orbit; double satSMA = satOrbit.SemiMajorAxis; double satEcc = satOrbit.Eccentricity; bool insideSatSphere = false; double deltaX; double deltaY; double deltaZ; double dist; int i = 0; int t = timestep; int c = 30000; if (screenInputs[6].Text != null) { try { c = int.Parse(screenInputs[6].Text); } catch (Exception) { } } for (int ut = (int)Math.Round(UT); ut < (int)Math.Ceiling(UT + c); ut += t) { double satTAAUT = satOrbit.TrueAnomalyAtUT(ut); Tuple <double, double, double> satPositionVectorInPlane = getPositionVector(satSMA, satTAAUT, satEcc); Tuple <double, double, double> satPositionVector = transform(satPositionVectorInPlane, referencePlane); /* * double TAAUT = form.connection.SpaceCenter().ActiveVessel.Orbit.TrueAnomalyAtUT(ut); * Tuple<double, double, double> positionVectorInPlane = getPositionVector(sMa, TAAUT, eccentricity); * Tuple<double, double, double> positionVector = transform(positionVectorInPlane, referencePlane); * * double deltaX = positionVector.Item1 - satPositionVector.Item1; * double deltaY = positionVector.Item2 - satPositionVector.Item2; * double deltaZ = positionVector.Item3 - satPositionVector.Item3; * * double dist = Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2) + Math.Pow(deltaZ, 2)); * distances.Add(i, dist); * * if (dist < minDist || minDist == -1) * { * minDist = dist - satRadius; * minDistMET = (ut - (UT - MET)); * } */ double currentRadius; double currentGravity; if (insideSatSphere) { currentRadius = OrbitFunctions.vectorMagnitude(positionB); currentGravity = satMy / Math.Pow(currentRadius, 2); } else { currentRadius = OrbitFunctions.vectorMagnitude(positionB); currentGravity = my / Math.Pow(currentRadius, 2); } double gravX = currentGravity * (-positionB.Item1 / currentRadius); double gravY = currentGravity * (-positionB.Item2 / currentRadius); double gravZ = currentGravity * (-positionB.Item3 / currentRadius); double speedX = speedB.Item1 + (gravX * t); double speedY = speedB.Item2 + (gravY * t); double speedZ = speedB.Item3 + (gravZ * t); double posX = positionB.Item1 + (speedB.Item1 * t); double posY = positionB.Item2 + (speedB.Item2 * t); double posZ = positionB.Item3 + (speedB.Item3 * t); positionB = new Tuple <double, double, double>(posX, posY, posZ); speedB = new Tuple <double, double, double>(speedX, speedY, speedZ); if (insideSatSphere) { deltaX = positionB.Item1; deltaY = positionB.Item2; deltaZ = positionB.Item3; dist = Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2) + Math.Pow(deltaZ, 2)); distancesC.Add(i, dist - satRadius); posC.Add(new Tuple <double?, double?>(posX + satPositionVector.Item1, -posY + -satPositionVector.Item2)); zedC.Add(i, deltaZ); } else { deltaX = positionB.Item1 - satPositionVector.Item1; deltaY = positionB.Item2 - satPositionVector.Item2; deltaZ = positionB.Item3 - satPositionVector.Item3; dist = Math.Sqrt(Math.Pow(deltaX, 2) + Math.Pow(deltaY, 2) + Math.Pow(deltaZ, 2)); distancesB.Add(i, dist - satRadius); posB.Add(new Tuple <double?, double?>(posX, -posY)); zedB.Add(i, deltaZ); } if (dist < minDistB || minDistB == -1) { minDistB = dist - satRadius; minDistMETB = (ut - (UT - MET)); if (insideSatSphere) { minDistVesselPos = new Tuple <double, double>(posX + satPositionVector.Item1, -posY + -satPositionVector.Item2); } else { minDistVesselPos = new Tuple <double, double>(posX, -posY); } minDistSatPos = new Tuple <double, double>(satPositionVector.Item1, -satPositionVector.Item2); } if (!insideSatSphere && dist < satSpereOfInfluence) { positionB = OrbitFunctions.vectorSubtrackt(positionB, satPositionVector); insideSatSphere = true; } else if (insideSatSphere && dist > satSpereOfInfluence) { positionB = OrbitFunctions.vectorAdd(positionB, satPositionVector); insideSatSphere = false; } i += t; } } screenOrbit.point1 = minDistVesselPos; screenOrbit.point2 = minDistSatPos; button.setLightColor(MocrButton.color.BLANK); button.setLitState(false); }