public void MakeComposite(string name, List <Gate> toGroup) { Delete(); RegisterPartModel target = new RegisterPartModel() { Register = null, Offset = 0, Width = toGroup.Select <Gate, int>(x => x.End).Max() + 1 }; CompositeGate cg = new CompositeGate(name, target); foreach (StepModel step in _steps) { for (int j = 0; j < step.Gates.Count; j++) { Gate oldGate = step.Gates[j]; CustomGate custom = oldGate as CustomGate; if (custom != null && custom.FunctionName.Equals(name)) { for (int k = oldGate.Begin; k <= oldGate.End; k++) { RegisterRefModel gateRef = GetRefFromOffset(k); Gate newGate = new EmptyGate(gateRef); step.SetGate(newGate); } Gate replacement = PasteGate(cg, oldGate.Begin); if (step.HasPlace(replacement.Begin, replacement.End)) { step.SetGate(replacement); } } j = oldGate.End; } } _compositeGates[name] = toGroup; //CompositeGate cg = new CompositeGate(name, toGroup, target); Gate toPaste = PasteGate(cg, _selectedItems.Value.BeginRow); bool notPasted = true; int i = _selectedItems.Value.BeginColumn; while (notPasted && i <= _selectedItems.Value.EndColumn) { if (_steps[i].HasPlace(toPaste.Begin, toPaste.End)) { _steps[i].SetGate(toPaste); notPasted = false; } i++; } if (notPasted) { InsertStepLeft(_selectedItems.Value.BeginColumn); _steps[_selectedItems.Value.BeginColumn].SetGate(toPaste); } }
private void RefreshCompositePane(CustomGate gate) { _selectedType = SelectedType.CompositeGate; _name = gate.FunctionName; if (gate.Name == GateName.Parametric) { ParametricGate cg = gate as ParametricGate; PopulateCandidates(); OnPropertyChanged("Candidates"); int methodIndex = _candidates.IndexOf(cg.Method); _paramsValues[methodIndex] = cg.Parameters; MethodIndex = methodIndex; } else // Composite { CompositeGate cg = gate as CompositeGate; PopulateCandidates(); OnPropertyChanged("Candidates"); _paramsValues[0] = new object[] { null, cg.TargetRegister }; MethodIndex = 0; } }