public FrameworkElement CreateShapedGlyph(string skin) { Gate gate = this.Circuit as Gate; Tracer.Assert(gate != null); Canvas canvas = this.CreateGlyphCanvas(this); CircuitGlyph.AddJam(canvas, this.Jams(), null); FrameworkElement shape = CircuitGlyph.Skin(canvas, skin); int top = Math.Max(0, gate.InputCount - 3) / 2; int bottom = Math.Max(0, gate.InputCount - 3 - top); Rectangle topLine = shape.FindName("topLine") as Rectangle; if (topLine != null) { topLine.Height = Symbol.ScreenPoint(top); } Rectangle bottomLine = shape.FindName("bottomLine") as Rectangle; if (bottomLine != null) { bottomLine.Height = Symbol.ScreenPoint(bottom); } return(canvas); }
public FrameworkElement CreateSimpleGlyph(string skin, CircuitGlyph mainSymbol) { Canvas canvas = this.CreateGlyphCanvas(mainSymbol); if (this == mainSymbol) { CircuitGlyph.AddJam(canvas, this.Jams(), null); } FrameworkElement shape = CircuitGlyph.Skin(canvas, skin); FrameworkElement probeView = shape.FindName("ProbeView") as FrameworkElement; if (probeView != null) { if (this == mainSymbol) { this.ProbeView = probeView; } TextBlock textBlock = probeView as TextBlock; if (textBlock != null) { textBlock.Text = this.Circuit.Notation; } } return(canvas); }
public FrameworkElement CreateLedMatrixGlyph(CircuitGlyph mainSymbol) { Canvas canvas = this.CreateGlyphCanvas(mainSymbol); if (this == mainSymbol) { CircuitGlyph.AddJam(canvas, this.Jams(), null); } FrameworkElement shape = CircuitGlyph.Skin(canvas, SymbolShape.LedMatrix); UniformGrid grid = shape.FindName("ProbeView") as UniformGrid; Tracer.Assert(grid != null); if (this == mainSymbol) { this.ProbeView = grid; } LedMatrix matrix = (LedMatrix)this.Circuit; grid.Columns = matrix.Columns; grid.Rows = matrix.Rows; string skin = (matrix.CellShape == LedMatrixCellShape.Round) ? SymbolShape.LedMatrixRoundCell : SymbolShape.LedMatrixRectCell; int cellCount = matrix.Rows * matrix.Columns; for (int i = 0; i < cellCount; i++) { grid.Children.Add(Symbol.Skin(skin)); } return(canvas); }
public FrameworkElement CreateSensorGlyph(string skin) { Canvas canvas = this.CreateGlyphCanvas(this); CircuitGlyph.AddJam(canvas, this.Jams(), null); FrameworkElement shape = CircuitGlyph.Skin(canvas, skin); FrameworkElement probeView = shape.FindName("ProbeView") as FrameworkElement; Tracer.Assert(probeView != null); this.ProbeView = probeView; TextBlock textBlock = probeView as TextBlock; if (textBlock != null) { textBlock.Text = Sensor.UnknownValue; } else { TextBox textBox = (TextBox)probeView; textBox.Text = Sensor.UnknownValue; } TextBlock notation = shape.FindName("Notation") as TextBlock; Tracer.Assert(notation != null); notation.Text = this.Circuit.Notation; return(canvas); }
public FrameworkElement CreateSimpleGlyph(string skin, CircuitGlyph mainSymbol) { Canvas canvas = this.CreateGlyphCanvas(mainSymbol); if (this == mainSymbol) { CircuitGlyph.AddJam(canvas, this.Jams(), null); } FrameworkElement shape = CircuitGlyph.Skin(canvas, skin); if (shape.FindName("ProbeView") is FrameworkElement probeView) { if (this == mainSymbol) { this.ProbeView = probeView; } if (probeView is TextBlock textBlock) { textBlock.Text = this.Circuit.Notation; } else if (probeView is Image) { RenderOptions.SetBitmapScalingMode(probeView, BitmapScalingMode.NearestNeighbor); } } return(canvas); }
public FrameworkElement CreateRectangularGlyph() { Canvas canvas = this.CreateGlyphCanvas(this); canvas.Background = Symbol.CircuitFill; bool ln = CircuitGlyph.AddJam(canvas, this.Left, (j, t) => { Canvas.SetLeft(t, Symbol.PinRadius); Canvas.SetTop(t, Symbol.ScreenPoint(j.Y) - 2 * Symbol.PinRadius); }); bool tn = CircuitGlyph.AddJam(canvas, this.Top, (j, t) => { Canvas.SetLeft(t, Symbol.ScreenPoint(j.X) - Symbol.PinRadius); Canvas.SetTop(t, Symbol.PinRadius); }); bool rn = CircuitGlyph.AddJam(canvas, this.Right, (j, t) => { Canvas.SetRight(t, Symbol.PinRadius); Canvas.SetTop(t, Symbol.ScreenPoint(j.Y) - 2 * Symbol.PinRadius); }); bool bn = CircuitGlyph.AddJam(canvas, this.Bottom, (j, t) => { Canvas.SetLeft(t, Symbol.ScreenPoint(j.X) - Symbol.PinRadius); Canvas.SetBottom(t, Symbol.PinRadius); }); FrameworkElement shape = CircuitGlyph.Skin(canvas, SymbolShape.Rectangular); if (shape.FindName("Notation") is TextBlock text) { text.Margin = new Thickness(ln ? 10 : 5, tn ? 10 : 5, rn ? 10 : 5, bn ? 10 : 5); text.Text = this.Circuit.Notation; } return(canvas); }
public FrameworkElement CreateButtonGlyph(CircuitGlyph mainSymbol) { Tracer.Assert(this.Circuit is CircuitButton); Canvas canvas = this.CreateGlyphCanvas(mainSymbol); if (this == mainSymbol) { CircuitGlyph.AddJam(canvas, this.Jams(), null); } ButtonControl buttonControl = (ButtonControl)CircuitGlyph.Skin(canvas, SymbolShape.Button); Panel.SetZIndex(buttonControl, 0); buttonControl.Content = this.Circuit.Notation; buttonControl.Width = canvas.Width; buttonControl.Height = canvas.Height; if (this == mainSymbol) { this.ProbeView = buttonControl; } this.UpdateButtonGlyph(canvas); return(canvas); }
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); } } }