public void UpdatePointers() { GeneralComponent ParraComponentList = MainCircuit.Main; SumResistance = ParraComponentList.GetResistance(); VoltagePerComponent = ParraComponentList.GetCopyOfSubList()[0].GetVoltage(); SumCurrent = ParraComponentList.GetCurrent(); UpdateLabels(); }
public void UpdatePointers() { GeneralComponent ParraComponentList = MainCircuit.Main.GetCopyOfSubList()[0]; if (ParraComponentList.GetType() != 'b') { SumResistance = ParraComponentList.GetResistance(); CurrentPerBranch = ParraComponentList.GetCopyOfSubList()[0].GetCurrent(); SumCurrent = ParraComponentList.GetCurrent(); UpdateLabels(); } else { SingleResistorLabelValues(); } }
public void DrawCircuit() { double EMFValue = MainCircuit.GetEmfValue(); MainCircuit.Main.CalculateResistance(); // Recalcuates so all drawn values are correct UpdateDimensions(); //Resizes the table based on the current size of the circuit ResetPanel(); DrawSection(MainCircuit.Main, 1, numRows - 1); //Draws the circuit recursively if (MainCircuit.Main.FindComponentFromName("IntRes") == null) { DrawEMFSource(EMFValue); } else { DrawEMFSource(EMFValue); GeneralComponent InternalResistance = MainCircuit.Main.FindComponentFromName("IntRes"); //Finds the internal resistance from the circuit ModifyPicture(Resources.ResistorIntRes, MiddleCollumn + 1, 0, PrefixDouble(InternalResistance.GetResistance(), 'Ω')).AssosiatedComponent = InternalResistance; //Updates the diagram to include internal resistance } }
public void DrawSection(GeneralComponent component, int StartingX, int StartingY) { if (component.GetType() == 'b') { PictureBoxWithReference PictureBoxImage = ModifyPicture(Resources.Resistor, StartingX, StartingY, PrefixDouble(component.GetResistance(), 'Ω')); // This is the bit that draws the resistors based on positions worked out by the parrallel and series bits PictureBoxImage.AssosiatedComponent = component; } else if (component.GetType() == 'p') { List <GeneralComponent> ListForDrawing = component.GetCopyOfSubList();// Gets a copy of the current circuit from the PhysicsEngine Module // Starts From Current position and starts to draw a parrallel component // Draws the bottom line first as if it dosn't, It ovverides TOPRIGHTLEFT DrawBottomLine(StartingX + 1, StartingY, StartingX + component.xsize - 1);// If this wasn't there there would be gaps ModifyPicture(Resources.TopRightLeft, StartingX, StartingY).AssosiatedComponent = component; ModifyPicture(Resources.TopRightLeft, StartingX + component.xsize - 1, StartingY).AssosiatedComponent = component; DrawSection(ListForDrawing[0], StartingX + 1, StartingY); //Starts going through the vertical list of components to be drawn in parrallel for (int i = 1; i < ListForDrawing.Count; i++) { //If the y Size of The Component that Has to be drawn previously is larger than 1, extra extentions are drawn for (int x = 1; x < ListForDrawing[i - 1].ysize; x++) { StartingY--; //Moves the Y value up ModifyPicture(Resources.Down, StartingX, StartingY).AssosiatedComponent = component; //Draws a vertical Straight Line ModifyPicture(Resources.Down, StartingX + (component.xsize - 1), StartingY).AssosiatedComponent = component; //Draws the corresponding line on the other side } StartingY--; //Itterates the Y one more if (i == ListForDrawing.Count - 1) // If this is the last component in the List, Draw a different joining wire { ModifyPicture(Resources.RightBottom, StartingX, StartingY).AssosiatedComponent = component; ModifyPicture(Resources.LeftBottom, StartingX + (component.xsize - 1), StartingY).AssosiatedComponent = component; } else { ModifyPicture(Resources.TopRightBottom, StartingX, StartingY).AssosiatedComponent = component;//If not then Just branch for the next component ModifyPicture(Resources.TopLeftBottom, StartingX + (component.xsize - 1), StartingY).AssosiatedComponent = component; } DrawBottomLine(StartingX + 1, StartingY, StartingX + component.xsize - 1); DrawSection(ListForDrawing[i], StartingX + 1, StartingY);// Goes up the parrallel component and draws the next section } } else if (component.GetType() == 's') { List <GeneralComponent> ListForDrawing = component.GetCopyOfSubList(); // Gets a copy of the current circuit from the PhysicsEngine Module foreach (GeneralComponent subComponent in ListForDrawing) // Goes through each series component { if (subComponent.GetName() != "IntRes") { DrawSection(subComponent, StartingX, StartingY); //Draws each one StartingX += subComponent.xsize; // Increments The starting X so it is in the correct position for next component. } } } }