private static TerminalID[] CreateTIDs(Gates.IOGates.AbstractNumeric gate) { // note that only ONE of these can be true // but we do an add so that it works for whichever // one is selected TerminalID[] tids = new TerminalID[gate.NumberOfInputs + gate.Output.Length]; int tidx = 0; // for the top line we invert the ordering // this matches standard IC numbering // AND provides for matching up of LSB for (int i = 0; i < gate.NumberOfInputs; i++) { tids[tidx++] = new TerminalID(true, gate.NumberOfInputs - i - 1, Position.TOP); } // for the bottom, we will purposefully // violate standard IC numbering // BECAUSE we want the visual appearance of // a binary # to line up with the illuminated ports for (int i = 0; i < gate.Output.Length; i++) { tids[tidx++] = new TerminalID(false, gate.Output.Length - i - 1, Position.BOTTOM); } return(tids); }
private static TerminalID[] CreateTerminals(int inputs) { TerminalID[] tids = new TerminalID[inputs + 1]; for (int i = 0; i < inputs; i++) tids[i] = new TerminalID(true, i, Position.LEFT); tids[inputs] = new TerminalID(false, 0, Position.RIGHT); return tids; }
private static TerminalID[] CreateTerminals(int inputs) { TerminalID[] tids = new TerminalID[inputs + 1]; for (int i = 0; i < inputs; i++) { tids[i] = new TerminalID(true, i, Position.LEFT); } tids[inputs] = new TerminalID(false, 0, Position.RIGHT); return(tids); }
private TerminalID[] CloneTerminals() { // duplicate the term ids because they have individual // refernece to actual terminal TerminalID[] ntid = new TerminalID[_termsid.Length]; for (int i = 0; i < ntid.Length; i++) { ntid[i] = new TerminalID(_termsid[i].isInput, _termsid[i].ID, _termsid[i].pos); } return(ntid); }
public IC(Gates.IC gate, TerminalID[] termsid) : base(gate, termsid) { locationHints = new Dictionary<Gates.AbstractGate, GateLocation>(); // may need to length the gate symbol // to accomodate the label // load the terminal tooltips foreach (TerminalID tid in _termsid) { Gates.AbstractGate ab; if (tid.isInput) ab = gate.Inputs[tid.ID]; else ab = gate.Outputs[tid.ID]; tid.t.ToolTip = ab.Name; } r = new Rectangle(); r.Margin = new System.Windows.Thickness(12, 17, 12, 17); r.Width = this.Width - 24; r.Height = this.Height - 34; r.Stroke = Brushes.Black; r.StrokeThickness = 2; r.Fill = Brushes.White; myCanvas.Children.Add(r); nm = new TextBox(); nm.Text = gate.Name; nm.HorizontalAlignment = System.Windows.HorizontalAlignment.Center; nm.VerticalAlignment = System.Windows.VerticalAlignment.Center; nm.TextAlignment = TextAlignment.Center; nm.Margin = new System.Windows.Thickness(20, this.Height / 2 - 12, 20, this.Height / 2 - 12); nm.Width = this.Width - 40; nm.Height = 24; nm.BorderThickness = new Thickness(0); IsReadOnly = true; myCanvas.Children.Add(nm); nm.LostFocus += new RoutedEventHandler(nm_LostFocus); nm.KeyDown += new System.Windows.Input.KeyEventHandler(nm_KeyDown); ResizeDueToName(); }
public UserIO(Gates.IOGates.UserIO gate, TerminalID[] termids) : base(gate, termids) { _uio = gate; _gate.PropertyChanged += EventDispatcher.CreateBatchDispatchedHandler(_gate, _ui_PropertyChanged); txtName = new TextBox(); txtName.Margin = new System.Windows.Thickness(5, 22, 5, 22); txtName.Visibility = System.Windows.Visibility.Hidden; txtName.Width = 54; txtName.Height = 20; txtName.LostFocus += new System.Windows.RoutedEventHandler(txtName_LostFocus); txtName.KeyDown += new System.Windows.Input.KeyEventHandler(txtName_KeyDown); //ContextMenu = new System.Windows.Controls.ContextMenu(); //MenuItem rename = new MenuItem(); //rename.Header = "Rename..."; //rename.Click += new System.Windows.RoutedEventHandler(rename_Click); //ContextMenu.Items.Add(rename); }
private static TerminalID[] CreateTIDs(Gates.IOGates.AbstractNumeric gate) { // note that only ONE of these can be true // but we do an add so that it works for whichever // one is selected TerminalID[] tids = new TerminalID[gate.NumberOfInputs + gate.Output.Length]; int tidx = 0; // for the top line we invert the ordering // this matches standard IC numbering // AND provides for matching up of LSB for (int i = 0; i < gate.NumberOfInputs; i++) tids[tidx++] = new TerminalID(true, gate.NumberOfInputs - i - 1, Position.TOP); // for the bottom, we will purposefully // violate standard IC numbering // BECAUSE we want the visual appearance of // a binary # to line up with the illuminated ports for (int i = 0; i < gate.Output.Length; i++) tids[tidx++] = new TerminalID(false, gate.Output.Length - i - 1, Position.BOTTOM); return tids; }
private TerminalID[] CloneTerminals() { // duplicate the term ids because they have individual // refernece to actual terminal TerminalID[] ntid = new TerminalID[_termsid.Length]; for (int i = 0; i < ntid.Length; i++) ntid[i] = new TerminalID(_termsid[i].isInput, _termsid[i].ID, _termsid[i].pos); return ntid; }