/// <summary> /// Fills the slot with a prexisting <see cref="WheelSetupPanel"/>. TODO: Use this for soft value saving when someone unchecks something. /// </summary> /// <param name="setupPanel"></param> public void FillSlot(WheelSetupPanel setupPanel) { wheelSetupPanel = setupPanel; wheelSetupPanel.Dock = DockStyle.Fill; this.Controls.Add(wheelSetupPanel); IsFilled = true; }
/// <summary> /// Fills the slot with a new <see cref="WheelSetupPanel"/> and sets its <see cref="WizardData.WizardWheelType"/> properly to <paramref name="wheelType"/> /// </summary> /// <param name="node"></param> /// <param name="wheelType"></param> public void FillSlot(RigidNode_Base node, WizardData.WizardWheelType wheelType = WizardData.WizardWheelType.NORMAL) { wheelSetupPanel = new WheelSetupPanel(node, wheelType); wheelSetupPanel.Dock = DockStyle.Fill; this.SuspendLayout(); while (Controls.Count > 0) { Controls[0].Dispose(); } this.Controls.Add(wheelSetupPanel); wheelSetupPanel.Visible = true; this.ResumeLayout(); wheelSetupPanel._WheelTypeChangedInternal += delegate() { OnWheelTypeChanged(); }; IsFilled = true; }
/// <summary> /// Adds as many <see cref="WheelSlotPanel"/>s as there are wheels /// </summary> public void Initialize() { // Clear existing panels while (LeftWheelsPanel.Controls.Count > 0) { LeftWheelsPanel.Controls[0].Dispose(); } while (RightWheelsPanel.Controls.Count > 0) { RightWheelsPanel.Controls[0].Dispose(); } while (MiddleWheelsPanel.Controls.Count > 0) { MiddleWheelsPanel.Controls[0].Dispose(); } while (RightBackWheelsPanel.Controls.Count > 0) { RightBackWheelsPanel.Controls[0].Dispose(); } while (LeftBackWheelsPanel.Controls.Count > 0) { LeftBackWheelsPanel.Controls[0].Dispose(); } Dictionary <string, RigidNode_Base> availableNodes = new Dictionary <string, RigidNode_Base>(); // TODO: Rename this to availableNodes after a different merge setupPanels = new Dictionary <string, WheelSetupPanel>(); leftOrder = new List <string>(); rightOrder = new List <string>(); middleOrder = new List <string>(); leftBackOrder = new List <string>(); rightBackOrder = new List <string>(); // Find all nodes that can be wheels Dictionary <string, int> duplicatePartNames = new Dictionary <string, int>(); numberOfJoints = 0; foreach (RigidNode_Base node in Utilities.GUI.SkeletonBase.ListAllNodes()) { if ((node.GetSkeletalJoint() != null)) { numberOfJoints++; } } foreach (RigidNode_Base node in Utilities.GUI.SkeletonBase.ListAllNodes()) { if (node.GetSkeletalJoint() != null && node.GetSkeletalJoint().GetJointType() == SkeletalJointType.ROTATIONAL) { string readableName = node.ModelFileName.Replace('_', ' ').Replace(".bxda", ""); readableName = readableName.Substring(0, 1).ToUpperInvariant() + readableName.Substring(1); // Capitalize first character if (availableNodes.ContainsKey(readableName)) { // Add the part name to the list of duplicate parts if (!duplicatePartNames.ContainsKey(node.ModelFileName)) { duplicatePartNames.Add(node.ModelFileName, 2); } // Find the next available name int identNum = duplicatePartNames[node.ModelFileName]; while (availableNodes.ContainsKey(readableName + ' ' + identNum) && identNum <= 100) { identNum++; } // Add the joint to the list with the new unique name readableName += ' ' + identNum.ToString(); // Update the next available ID duplicatePartNames[node.ModelFileName] = identNum; } availableNodes.Add(readableName, node); } } // Generate panels foreach (KeyValuePair <string, RigidNode_Base> node in availableNodes) { // Get default wheel type based on drive train WizardData.WizardWheelType type; if (SynthesisGUI.Instance.SkeletonBase.driveTrainType == RigidNode_Base.DriveTrainType.H_DRIVE) { type = WizardData.WizardWheelType.OMNI; } else { type = WizardData.WizardWheelType.NORMAL; } // Create panel WheelSetupPanel panel = new WheelSetupPanel(node.Value, node.Key, type); panel.removeHandler += RemoveNodeFromPanel; panel.mouseDownHandler += SetupPanel_StartDrag; setupPanels.Add(node.Key, panel); } _initialized = true; UpdateUI(); OnInvalidatePage(); // Reset the next page in the wizard }