public Segment(Position position, PrimitivesSurface surface) : this() { Position = position; Surface = surface; Identifier = Guid.NewGuid (); }
public Line(Position input, Position output, string inputMarker, string outputMarker) { Input = input; Output = output; InputMarker = inputMarker; OutputMarker = outputMarker; }
public Segment Add(DrawingElement el, Position p) { Remove(p); var seg = Segments.FirstOrDefault (s => s.Position == p); if (seg != null) { seg.AddPrimitives (el.Primitives); } else { seg = new Segment (p, el.Primitives, this) { IsPalette = IsPalette }; Segments.Add (seg); } seg.Type = el.Type; CalculateSize (); //join latch if(el.Primitives.Any(pr => pr is LineElement && ((pr as LineElement).End.Y > 1))) { var pos2 = new Position (seg.Position.X, seg.Position.Y + 1); var seg2 = Segments.FirstOrDefault (s => s.Position == pos2); if (seg2 != null) { seg2.Join.Add (seg); seg.Join.Add (seg2); var conR = el .Primitives .Where (p1 => p1 is Connector) .Cast<Connector> () .Where (c => c.Center.Y > 1); seg2.Connectors.AddRange (conR); if (seg.Selected) { seg2.Selected = true; } } } return seg; }
public Segment(Position position, List<Drawable> primitives, PrimitivesSurface surface) : this(position, surface) { _primitives.AddRange(primitives.Where(p => !(p is Connector))); Connectors.AddRange(primitives.Where(p => p is Connector).Cast<Connector>()); }
public bool Remove(Position p) { if (Segments.Any (s => s.Position == p)) { Segments.First (s => s.Position == p).RemoveElement(); return true; } return false; }
public Segment Add(Position p) { var seg = Segments.FirstOrDefault (s => s.Position == p); if (seg == null) { seg = new Segment (p, this) { IsPalette = IsPalette }; Segments.Add (seg); CalculateSize (); } return seg; }
protected bool Equals(Position other) { return X == other.X && Y == other.Y; }