private void CreateDevicePin(CircuitButton button) { DevicePin pin = this.CircuitProject.DevicePinSet.Create(button, PinType.Output, 1); pin.PinSide = button.PinSide; pin.Inverted = button.Inverted; }
public DialogButton(CircuitButton button) { this.button = button; this.DataContext = this; this.InitializeComponent(); this.name.Text = this.button.Notation; this.isToggle.IsChecked = this.button.IsToggle; this.side.SelectedItem = PinDescriptor.PinSideDescriptor(this.button.PinSide); this.note.Text = this.button.Note; }
private CircuitButton Register(RowId rowId) { CircuitData data = new CircuitData() { CircuitId = this.Table.GetField(rowId, CircuitButtonData.CircuitButtonIdField.Field) }; CircuitButton button = this.Create(rowId, this.CircuitProject.CircuitTable.Insert(ref data)); this.CreateDevicePin(button); return(button); }
public CircuitButton Create(string notation, bool isToggle, PinSide pinSide) { CircuitButton button = this.CreateItem(Guid.NewGuid(), notation, isToggle, pinSide, CircuitButtonData.WidthField.Field.DefaultValue, CircuitButtonData.HeightField.Field.DefaultValue, CircuitButtonData.NoteField.Field.DefaultValue ); this.CreateDevicePin(button); return(button); }
public CircuitButton Copy(CircuitButton other) { CircuitButtonData data; other.CircuitProject.CircuitButtonSet.Table.GetData(other.CircuitButtonRowId, out data); if (this.FindByCircuitButtonId(data.CircuitButtonId) != null) { data.CircuitButtonId = Guid.NewGuid(); } data.CircuitButton = null; return(this.Register(this.Table.Insert(ref data))); }
public DialogButton(CircuitButton button) { this.button = button; this.DataContext = this; this.InitializeComponent(); this.name.Text = this.button.Notation; this.isToggle.IsChecked = this.button.IsToggle; this.side.SelectedItem = PinDescriptor.PinSideDescriptor(this.button.PinSide); this.inverted.IsChecked = this.button.Inverted; this.keyGesture.Key = button.Key; this.keyGesture.ModifierKeys = button.ModifierKeys; this.keyGesture.Refresh(); this.note.Text = this.button.Note; }
public override void Refresh() { CircuitButton button = (CircuitButton)this.CircuitSymbol.Circuit; Rect rect = new Rect( Symbol.ScreenPoint(this.CircuitSymbol.X), Symbol.ScreenPoint(this.CircuitSymbol.Y), Symbol.ScreenPoint(button.Width), Symbol.ScreenPoint(button.Height) ); if (this.CircuitSymbol.Rotation != Rotation.Up) { rect = Symbol.Transform(rect, Symbol.RotationTransform(this.CircuitSymbol.Rotation, this.CircuitSymbol.X, this.CircuitSymbol.Y, button.Width, button.Height)); } this.symbolRect = rect; this.PositionGlyph(rect); }
public void UpdateButtonGlyph(Panel panel) { Tracer.Assert(panel != null); CircuitButton button = this.Circuit as CircuitButton; Tracer.Assert(button != null); if (button.IsToggle) { if (panel.Children.Count < 3) { panel.Children.Add(CircuitGlyph.Skin <Border>(SymbolShape.ToggleLed)); } } else { if (2 < panel.Children.Count) { UIElement rect = panel.Children[2]; Tracer.Assert(rect is Border); panel.Children.Remove(rect); } } }
protected override void Edit(Symbol symbol) { CircuitSymbol circuitSymbol = symbol as CircuitSymbol; if (circuitSymbol != null) { if (this.InEditMode) { LogicalCircuit lc = circuitSymbol.Circuit as LogicalCircuit; if (lc != null) { this.OpenLogicalCircuit(lc); return; } CircuitProbe cp = circuitSymbol.Circuit as CircuitProbe; if (cp != null) { this.Edit(cp); return; } CircuitButton cb = circuitSymbol.Circuit as CircuitButton; if (cb != null) { this.Edit(cb); return; } Constant ct = circuitSymbol.Circuit as Constant; if (ct != null) { this.Edit(ct); return; } Sensor sr = circuitSymbol.Circuit as Sensor; if (sr != null) { this.Edit(sr); return; } Memory m = circuitSymbol.Circuit as Memory; if (m != null) { this.Edit(m); return; } Pin pin = circuitSymbol.Circuit as Pin; if (pin != null) { this.Edit(pin); return; } LedMatrix ledMatrix = circuitSymbol.Circuit as LedMatrix; if (ledMatrix != null) { this.Edit(ledMatrix); return; } Sound sound = circuitSymbol.Circuit as Sound; if (sound != null) { this.Edit(sound); return; } GraphicsArray graphicsArray = circuitSymbol.Circuit as GraphicsArray; if (graphicsArray != null) { this.Edit(graphicsArray); return; } } else if (this.CircuitRunner != null && this.CircuitRunner.VisibleMap != null) { CircuitMap map = this.CircuitRunner.VisibleMap.Child(circuitSymbol); if (map != null) { this.OpenLogicalCircuit(map); return; } if (circuitSymbol.Circuit is CircuitProbe) { FunctionProbe functionProbe = this.CircuitRunner.VisibleMap.FunctionProbe(circuitSymbol); if (functionProbe != null) { this.Mainframe.ShowDialog(new DialogProbeHistory(functionProbe)); } return; } if ((circuitSymbol.Circuit is Memory) || (circuitSymbol.Circuit is GraphicsArray)) { IFunctionMemory functionMemory = this.CircuitRunner.VisibleMap.FunctionMemory(circuitSymbol); if (functionMemory != null) { this.Mainframe.ShowDialog(new DialogMemory(functionMemory)); } return; } if (circuitSymbol.Circuit is Constant) { if (this.CircuitRunner.Root.First() == this.CircuitRunner.VisibleMap) { FunctionConstant functionConstant = this.CircuitRunner.VisibleMap.FunctionConstant(circuitSymbol); if (functionConstant != null) { this.CircuitProject.InOmitTransaction(() => functionConstant.Value++); } } else { this.Mainframe.Status = Properties.Resources.MessageNotRootConstant(this.CircuitRunner.Root.First().Circuit.Name); } } } } else if (this.InEditMode) { TextNote textNote = symbol as TextNote; if (textNote != null) { this.Edit(textNote); } } }
private void Edit(CircuitButton button) { this.Mainframe.ShowDialog(new DialogButton(button)); }