public CircuitElementDrawingVisual(ICircuitElement circuitElement)
        {
            CircuitElement = circuitElement;

            this.Offset = circuitElement.Location;

            circuitElement.Updated += (o, e) =>
                {
                    this.Offset = circuitElement.Location;
                };
        }
Example #2
0
 private Wire CreateWire(string operation, ICircuitElement input1, ICircuitElement input2, string output)
 {
     Wire wire = null;
     switch (operation)
     {
         case "NOT":
             if (input2 != null)
             {
                 wire = new Wire(output, new NotGate(input2));
             }
             break;
         case "AND":
             if (input1 != null && input2 != null)
             {
                 wire = new Wire(output, new AndGate(input1, input2));
             }
             break;
         case "OR":
             if (input1 != null && input2 != null)
             {
                 wire = new Wire(output, new OrGate(input1, input2));
             }
             break;
         case "LSHIFT":
             if (input1 != null && input2 != null)
             {
                 wire = new Wire(output, new LeftShiftGate(input1, input2));
             }
             break;
         case "RSHIFT":
             if (input1 != null && input2 != null)
             {
                 wire = new Wire(output, new RightShiftGate(input1, input2));
             }
             break;
         case "":
             if (input1 != null || input2 != null)
             {
                 wire = new Wire(output, input1 ?? input2);
             }
             break;
         default:
             throw new ApplicationException("Unsupported operation " + operation);
     }
     return wire;
 }
Example #3
0
 public Wire(string identifier, ICircuitElement input)
 {
     Identifier = identifier;
     _input = input;
 }
Example #4
0
 protected ShiftGate(ICircuitElement input, ICircuitElement shift)
 {
     Input = input;
     Shift = shift;
 }
Example #5
0
 public NotGate(ICircuitElement input)
 {
     _input = input;
 }
Example #6
0
 public OrGate(ICircuitElement input1, ICircuitElement input2)
     : base(input1, input2)
 {
 }
Example #7
0
 public LeftShiftGate(ICircuitElement input, ICircuitElement shift)
     : base(input, shift)
 {
 }
Example #8
0
 protected BinaryGate(ICircuitElement input1, ICircuitElement input2)
 {
     Input1 = input1;
     Input2 = input2;
 }