//Creates a new wire object from the set of parameters generated by SaveParameters() public static Wire CreateFromParameters(Circuit parent, Dictionary <string, string> parameters) { Point origin = new Point(double.Parse(parameters["startX"], System.Globalization.CultureInfo.InvariantCulture), double.Parse(parameters["startY"], System.Globalization.CultureInfo.InvariantCulture)); Orientation orientation = (parameters["orientation"] == "horiz") ? Orientation.Horizontal : Orientation.Vertical; int length = int.Parse(parameters["length"]); Color colour = (Color)ColorConverter.ConvertFromString(parameters["colour"]); Wire newWire = new Wire(parent, orientation, length, colour, origin); newWire.Render(); return(newWire); }
private void Breadboard_MouseMove(object sender, MouseEventArgs e) { if ((e.LeftButton == MouseButtonState.Pressed) && (ParentCircuit.ParentWindow.SelectedTool == "SELECT")) { ParentCircuit.HandleComponentDrag(sender, e); } if (StartedWire) { Point actualCoord = GetAbsolutePosition(GetHoleCoord(e.GetPosition(this))); Orientation o = Util.getBestOrientation(WirePointA, actualCoord); int length = 0; if (o == Orientation.Horizontal) { length = (int)((actualCoord.X - WirePointA.X) / Constants.ScaleFactor); } else { length = (int)((actualCoord.Y - WirePointA.Y) / Constants.ScaleFactor); } NewWire.Length = length; NewWire.WireOrientation = o; NewWire.Render(); } else if (StartedLeadedComponent) { Point actualCoord = GetAbsolutePosition(GetHoleCoord(e.GetPosition(this))); Orientation o = Util.getBestOrientation(ComponentPointA, actualCoord); int length = 0; if (o == Orientation.Horizontal) { length = (int)((actualCoord.X - ComponentPointA.X) / Constants.ScaleFactor); } else { length = (int)((actualCoord.Y - ComponentPointA.Y) / Constants.ScaleFactor); } NewLeadedComponent.Length = length; NewLeadedComponent.orientation = o; NewLeadedComponent.Render(); } }