Beispiel #1
0
        /// <summary>
        /// Updates the dictionaries based on the new names of the inputs/outputs
        /// </summary>
        /// <param name="newNameDict">Dictionary of old name keys to new name values</param>
        private void truthTableWindow_RelabelStrokes(Dictionary <string, string> newNameDict)
        {
            foreach (string s in newNameDict.Keys)
            {
                // Change the shape names that were affected
                foreach (Shape shape in sketch.Shapes)
                {
                    if (shape.Name == s)
                    {
                        shape.Name = newNameDict[s];
                    }
                }

                // Update all the dictionaries
                if (inputMapping.ContainsKey(s))
                {
                    ListSet <string> values = inputMapping[s];
                    LabelShape(values, newNameDict[s]);
                    inputMapping.Remove(s);
                    inputMapping.Add(newNameDict[s], values);
                }
                else if (outputMapping.ContainsKey(s))
                {
                    ListSet <string> values = outputMapping[s];
                    LabelShape(values, newNameDict[s]);
                    outputMapping.Remove(s);
                    outputMapping.Add(newNameDict[s], values);
                }
                if (wireToInputGateMapping.ContainsKey(s))
                {
                    Dictionary <int, ListSet <string> > values = wireToInputGateMapping[s];
                    wireToInputGateMapping.Remove(s);
                    wireToInputGateMapping.Add(newNameDict[s], values);
                }
            }

            // Create our new Circuit
            if (!circuitParser.SuccessfullyParse(sketchPanel.Sketch))
            {
                return;
            }
            sketchPanel.Circuit = new Circuit(circuitParser.CircuitStructure,
                                              circuitParser.CircuitOutputs,
                                              circuitParser.CircuitInputs);

            // Update popup names
            circuitValuePopups.UpdatePopupNames(newNameDict);
            cleanCircuit.UpdateLabel(newNameDict);
            ShowToggles();
        }