public void Render(Component component, CircuitDiagram.Render.IRenderContext dc, bool absolute) { if (absolute) dc.DrawEllipse(Point.Add(Centre.Resolve(component), component.Location), RadiusX, RadiusY, Thickness, Fill); else dc.DrawEllipse(Centre.Resolve(component), RadiusX, RadiusY, Thickness, Fill); }
/// <summary> /// Determines whether the specified ICircuitElement is a wire. /// </summary> /// <param name="element">The element to check.</param> /// <returns>True if it is a wire, false otherwise.</returns> public static bool IsWire(CircuitDiagram.Elements.ICircuitElement element) { if (!(element is CircuitDiagram.Elements.IComponentElement)) return false; CircuitDiagram.Elements.IComponentElement componentElement = element as CircuitDiagram.Elements.IComponentElement; return (componentElement.ImplementationCollection == CircuitDiagram.IO.ComponentCollections.Common && componentElement.ImplementationItem == "wire") || (componentElement is Component && (componentElement as Component).Description == WireDescription); }
public void Render(Component component, CircuitDiagram.Render.IRenderContext dc, bool absolute) { Rect drawRect = new System.Windows.Rect(Location.Resolve(component), new Size(Width, Height)); if (component.IsFlipped == true && component.Orientation == Orientation.Horizontal) drawRect = new Rect(drawRect.X - Width, drawRect.Y, Width, Height); else if (component.IsFlipped == true && component.Orientation == Orientation.Vertical) drawRect = new Rect(drawRect.X, drawRect.Y - Height, Width, Height); if (absolute) dc.DrawRectangle(Point.Add(drawRect.TopLeft, component.Location), drawRect.Size, StrokeThickness, Fill); else dc.DrawRectangle(drawRect.TopLeft, drawRect.Size, StrokeThickness, Fill); }
public void Render(CircuitDiagram.Render.IRenderContext dc, bool absolute = true) { foreach (RenderDescription renderDescription in Description.RenderDescriptions) { if (renderDescription.Conditions.IsMet(this)) renderDescription.Render(this, dc, absolute); } }
public void Render(Component component, CircuitDiagram.Render.IRenderContext dc, bool absolute) { IList<IPathCommand> commands = Commands; if (component.IsFlipped == true) { commands = new List<IPathCommand>(Commands.Count); foreach (IPathCommand command in Commands) commands.Add(command.Flip(component.Orientation == Orientation.Horizontal)); } if (absolute) dc.DrawPath(Point.Add(Start.Resolve(component), component.Location), commands, Thickness, Fill); else dc.DrawPath(Start.Resolve(component), commands, Thickness, Fill); }
public void Render(Component component, CircuitDiagram.Render.IRenderContext dc, bool absolute) { Point renderLocation = Location.Resolve(component); TextAlignment tempAlignment = Alignment; if (component.IsFlipped && component.Orientation == Orientation.Horizontal) { switch (Alignment) { case TextAlignment.BottomLeft: tempAlignment = TextAlignment.BottomRight; break; case TextAlignment.BottomRight: tempAlignment = TextAlignment.BottomLeft; break; case TextAlignment.CentreLeft: tempAlignment = TextAlignment.CentreRight; break; case TextAlignment.CentreRight: tempAlignment = TextAlignment.CentreLeft; break; case TextAlignment.TopLeft: tempAlignment = TextAlignment.TopRight; break; case TextAlignment.TopRight: tempAlignment = TextAlignment.TopLeft; break; } } else if (component.IsFlipped && component.Orientation == Orientation.Vertical) { switch (Alignment) { case TextAlignment.BottomCentre: tempAlignment = TextAlignment.TopCentre; break; case TextAlignment.BottomLeft: tempAlignment = TextAlignment.TopLeft; break; case TextAlignment.BottomRight: tempAlignment = TextAlignment.TopRight; break; case TextAlignment.TopCentre: tempAlignment = TextAlignment.BottomCentre; break; case TextAlignment.TopLeft: tempAlignment = TextAlignment.BottomLeft; break; case TextAlignment.TopRight: tempAlignment = TextAlignment.BottomRight; break; } } List<TextRun> renderTextRuns = new List<TextRun>(TextRuns.Count); // Build runs foreach (TextRun run in TextRuns) { // Resolve value string renderValue; if (run.Text.StartsWith("$")) { ComponentProperty property = component.FindProperty(run.Text); renderValue = component.GetFormattedProperty(property); } else renderValue = run.Text; System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(@"\\[uU]([0-9A-F]{4})"); renderValue = regex.Replace(renderValue, match => ((char)Int32.Parse(match.Value.Substring(2), System.Globalization.NumberStyles.HexNumber)).ToString()); renderTextRuns.Add(new TextRun(renderValue, run.Formatting)); } if (absolute) dc.DrawText(Point.Add(renderLocation, component.Location), tempAlignment, renderTextRuns); else dc.DrawText(renderLocation, tempAlignment, renderTextRuns); }
public void Render(Component component, CircuitDiagram.Render.IRenderContext dc, bool absolute) { if (absolute) dc.DrawLine(Point.Add(Start.Resolve(component), component.Location), Point.Add(End.Resolve(component), component.Location), Thickness); else dc.DrawLine(Start.Resolve(component), End.Resolve(component), Thickness); }