public FrameworkElement CreateDisplayGlyph(CircuitGlyph mainSymbol) { Tracer.Assert(mainSymbol != null); List <CircuitSymbol> list = ((LogicalCircuit)this.Circuit).CircuitSymbols().Where(s => s.Circuit.IsValidDisplay()).ToList(); GridPoint offset = Symbol.GridPoint(list.Select(s => s.Bounds()).Aggregate((r1, r2) => Rect.Union(r1, r2)).TopLeft); DisplayCanvas canvas = this.CreateDisplayCanvas(mainSymbol); if (this == mainSymbol) { Border border = Symbol.Skin <Border>(SymbolShape.DisplayBackground); border.Width = canvas.Width; border.Height = canvas.Height; canvas.Children.Add(border); CircuitGlyph.AddJam(canvas, this.Left, (j, t) => { Canvas.SetLeft(t, Symbol.PinRadius); Canvas.SetTop(t, Symbol.ScreenPoint(j.Y) - 2 * Symbol.PinRadius); }); CircuitGlyph.AddJam(canvas, this.Top, (j, t) => { Canvas.SetLeft(t, Symbol.ScreenPoint(j.X) - Symbol.PinRadius); Canvas.SetTop(t, Symbol.PinRadius); }); CircuitGlyph.AddJam(canvas, this.Right, (j, t) => { Canvas.SetRight(t, Symbol.PinRadius); Canvas.SetTop(t, Symbol.ScreenPoint(j.Y) - 2 * Symbol.PinRadius); }); CircuitGlyph.AddJam(canvas, this.Bottom, (j, t) => { Canvas.SetLeft(t, Symbol.ScreenPoint(j.X) - Symbol.PinRadius); Canvas.SetBottom(t, Symbol.PinRadius); }); border = Symbol.Skin <Border>(SymbolShape.DisplayBorder); border.Width = canvas.Width; border.Height = canvas.Height; Panel.SetZIndex(border, int.MaxValue - 1); canvas.Children.Add(border); } foreach (CircuitSymbol symbol in list) { FrameworkElement display = symbol.Circuit.CreateDisplay(symbol, mainSymbol); Canvas.SetLeft(display, Symbol.ScreenPoint(symbol.X - offset.X)); Canvas.SetTop(display, Symbol.ScreenPoint(symbol.Y - offset.Y)); display.RenderTransformOrigin = Symbol.RotationCenter(symbol.Circuit.SymbolWidth, symbol.Circuit.SymbolHeight); RotateTransform rotation = (RotateTransform)display.RenderTransform; rotation.Angle = Symbol.Angle(symbol.Rotation); canvas.AddDisplay(symbol, display); } return(canvas); }
public void CreateSymbol(EditorDiagram editor, GridPoint point) { CircuitProject project = editor.CircuitProject; project.InTransaction(() => project.CircuitSymbolSet.Create(this.GetCircuitToDrop(project), editor.Project.LogicalCircuit, point.X, point.Y)); }
public bool Contains(GridPoint gridPoint) { return(this.pointMap.ContainsKey(gridPoint)); }
public static Point ScreenPoint(GridPoint point) { return(Symbol.ScreenPoint(point.X, point.Y)); }
public bool TryGetValue(GridPoint point, out Conductor conductor) { return(this.map.TryGetValue(point, out conductor)); }
public Wire Create(LogicalCircuit logicalCircuit, GridPoint point1, GridPoint point2) { return(this.CreateItem(Guid.NewGuid(), logicalCircuit, point1.X, point1.Y, point2.X, point2.Y)); }
public bool Contains(GridPoint gridPoint) { return(this.point.Contains(gridPoint)); }
public TextNote Create(LogicalCircuit logicalCircuit, GridPoint point, string note) { return(this.CreateItem(Guid.NewGuid(), logicalCircuit, point.X, point.Y, TextNoteData.WidthField.Field.DefaultValue, TextNoteData.HeightField.Field.DefaultValue, note, TextNoteData.RotationField.Field.DefaultValue )); }
private HashSet <Wire> Bad(LogicalCircuit current) { Dictionary <GridPoint, List <Jam> > jams = new Dictionary <GridPoint, List <Jam> >(); IEnumerable <Jam> connected(Conductor conductor) { IEnumerable <Jam> at(GridPoint point) { List <Jam> list; if (jams.TryGetValue(point, out list)) { return(list); } return(Enumerable.Empty <Jam>()); } return(conductor.Points.SelectMany(point => at(point))); } foreach (CircuitSymbol symbol in current.CircuitSymbols()) { if (!(symbol.Circuit is CircuitProbe)) { foreach (Jam jam in symbol.Jams()) { if (this.stopPending) { return(null); } GridPoint point = jam.AbsolutePoint; List <Jam> list; if (!jams.TryGetValue(point, out list)) { list = new List <Jam>(1); jams.Add(point, list); } list.Add(jam); } } } HashSet <Wire> bad = new HashSet <Wire>(); foreach (Conductor conductor in current.ConductorMap().Conductors) { int first = 0; foreach (Jam jam in connected(conductor)) { if (this.stopPending) { return(null); } if (first == 0) { first = jam.Pin.BitWidth; } else if (first != jam.Pin.BitWidth) { bad.UnionWith(conductor.Wires); break; } } if (this.stopPending) { return(null); } } return(bad); }