public void LineBlock_RotateAntiClockws() { var lineBlock = new LineBlock(); Print(lineBlock.Bricks); int[,] a = { { 1, 1, 1, 1 } }; Assert.Equal(a, lineBlock.Bricks); lineBlock.RotateAntiClockwise(); Print(lineBlock.Bricks); a = new[, ] { { 1 }, { 1 }, { 1 }, { 1 } }; Assert.Equal(a, lineBlock.Bricks); lineBlock.RotateAntiClockwise(); Print(lineBlock.Bricks); a = new[, ] { { 1, 1, 1, 1 } }; Assert.Equal(a, lineBlock.Bricks); lineBlock.RotateAntiClockwise(); Print(lineBlock.Bricks); a = new[, ] { { 1 }, { 1 }, { 1 }, { 1 } }; Assert.Equal(a, lineBlock.Bricks); }
private BlockPort AddMultiConduitPort(LineBlock lineBlock, BlockSideEnum side, List <ConduitClosureTerminalInfo> terminals, string outerConduitColor, double spaceBetweenTerminals = -1, double terminalSize = -1, double portMargin = -1) { BlockPort port = new BlockPort(side, "MultiConduit" + outerConduitColor, null, spaceBetweenTerminals, terminalSize, portMargin); foreach (var terminal in terminals) { if (terminal.LineSegment is ConduitSegmentInfo) { ConduitSegmentInfo conduitSegment = terminal.LineSegment as ConduitSegmentInfo; bool visible = false; if (terminal.ConnectionKind == ConduitClosureInternalConnectionKindEnum.NotConnected) { visible = true; } var blockTerminal = new BlockPortTerminal(visible, "InnerConduit" + conduitSegment.Conduit.Color.ToString()); blockTerminal.SetReference(conduitSegment.Id, "InnerConduitSegment"); port.AddTerminal(blockTerminal); } } lineBlock.AddPort(port); return(port); }
private BlockPort AddMultiConduitPort(LineBlock lineBlock, BlockSideEnum side, int nTerminals, string outerConduitColor, double spaceBetweenTerminals = -1, double terminalSize = -1, double portMargin = -1) { BlockPort port = new BlockPort(side, "MultiConduit" + outerConduitColor, null, spaceBetweenTerminals, terminalSize, portMargin); for (int i = 0; i < nTerminals; i++) { port.AddTerminal(new BlockPortTerminal(true, "InnerConduit" + MockupHelper.GetColorStringFromConduitNumber(i + 1))); } lineBlock.AddPort(port); return(port); }
private BlockPort AddBigConduitPort(LineBlock lineBlock, BlockSideEnum side, int nTerminals, string outerConduitColor = null, double spaceBetweenTerminals = -1, double terminalSize = -1, double portMargin = -1) { BlockPort port = new BlockPort(side, outerConduitColor != null ? "BigConduit" + outerConduitColor : null, null, spaceBetweenTerminals, terminalSize, portMargin); for (int i = 0; i < nTerminals; i++) { port.AddTerminal(new BlockPortTerminal(false)); } lineBlock.AddPort(port); return(port); }
private void AffixConduit(LineBlock nodeContainerBlock, SpanEquipmentViewModel viewModel) { if (viewModel.IsPassThrough) { AffixPassThroughConduit(nodeContainerBlock, viewModel); _nodeContainerViewModel.PortViewModels.Add(new NodeContainerBlockPortViewModel(_nodeContainerViewModel, viewModel, NodeContainerBlockPortViewModelKind.PassThrough)); } else { AffixConduitEnd(nodeContainerBlock, viewModel); _nodeContainerViewModel.PortViewModels.Add(new NodeContainerBlockPortViewModel(_nodeContainerViewModel, viewModel, NodeContainerBlockPortViewModelKind.End)); } }
/// <summary> /// Parses unformatted text. /// </summary> /// <returns> A parsed text span. Or <c>null</c> if no text could be parsed.</returns> internal static TextRunInline?Parse(LineBlock markdown, bool trimStart, bool trimEnd, MarkdownDocument document) { var output = document.ResolveEscapeSequences(markdown, trimStart, trimEnd).ToString(); if (string.IsNullOrEmpty(output)) { return(null); } else { return(new TextRunInline { Text = output }); } }
public double AddMultiConduitPassThroughBlock(DiagramBuilder builder, double minWith, double offsetY, int nTerminals) { ////////////////////////////////////////////////////////// /// label block /// LineBlock conduitBlock = new LineBlock(30, offsetY, LineBlockTypeEnum.Simple); conduitBlock.MinWidth = minWith; // Add vest ports AddMultiConduitPort(conduitBlock, BlockSideEnum.Vest, nTerminals, "Orange", -1, -1, 10); // Add east ports AddMultiConduitPort(conduitBlock, BlockSideEnum.East, nTerminals, "Orange", -1, -1, 10); // Connect ports conduitBlock.AddPortConnection(BlockSideEnum.Vest, 1, BlockSideEnum.East, 1, null, "MultiConduitOrange"); // Connect west and east terminals for (int i = 0; i < nTerminals; i++) { conduitBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, i + 1, BlockSideEnum.East, 1, i + 1, null, "InnerConduit" + MockupHelper.GetColorStringFromConduitNumber(i + 1), LineShapeTypeEnum.Polygon); } conduitBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(conduitBlock); ////////////////////////////////////////////////////////// /// label block LineBlock labelBlock = new LineBlock(0, offsetY, LineBlockTypeEnum.Simple); labelBlock.MinWidth = 30; // Add vest port AddBigConduitPort(labelBlock, BlockSideEnum.Vest, nTerminals, null, -1, -1, 10); // Add east port AddBigConduitPort(labelBlock, BlockSideEnum.East, nTerminals, null, -1, -1, 10); labelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "PF-4200", "LabelMediumText"); labelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(labelBlock); return(conduitBlock.DesiredSize.Height); }
public void LineBlockWithLabeledLinesTest() { Diagram diagram = new Diagram(); var lineBlock = new LineBlock() { MinHeight = 200, MinWidth = 300, Margin = 20, IsVisible = false }; // Vest var vestPort1 = new BlockPort(BlockSideEnum.West) { IsVisible = false }; lineBlock.AddPort(vestPort1); AddTerminalsToPort(vestPort1, 3); // East var eastPort1 = new BlockPort(BlockSideEnum.East) { IsVisible = false }; lineBlock.AddPort(eastPort1); AddTerminalsToPort(eastPort1, 3); lineBlock.AddTerminalConnection(BlockSideEnum.West, 1, 1, BlockSideEnum.East, 1, 1, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); // Act lineBlock.CreateDiagramObjects(diagram, 0, 0); if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(diagram).Export("c:/temp/diagram/test.geojson"); } // Assert diagram.DiagramObjects.Count.Should().Be(1); diagram.DiagramObjects.First().Geometry.IsValid.Should().BeTrue(); diagram.DiagramObjects.First().Geometry.Length.Should().Be(0.03); diagram.DiagramObjects.First().Label.Should().Be("This is a label text"); diagram.DiagramObjects.First().Style.Should().Be("This should be a polyline"); }
/// <summary> /// Parses paragraph text. /// </summary> /// <param name="markdown">The markdown text. </param> /// <param name="document">The parsing Document.</param> /// <returns> A parsed paragraph. Or <c>null</c> if nothing was parsed.</returns> public static ParagraphBlock?Parse(LineBlock markdown, MarkdownDocument document) { var inlines = document.ParseInlineChildren(markdown, true, true); // If we didn't find inline elements we return no Paragraph if (inlines.Count == 0) { return(null); } var result = new ParagraphBlock { Inlines = inlines, }; return(result); }
private void AffixConduitEnd(LineBlock nodeContainerBlock, SpanEquipmentViewModel viewModel) { var routeSpanDiagramInfo = viewModel.RootSpanDiagramInfo("OuterConduit"); var blockSide = viewModel.BlockSideWhereSpanEquipmentShouldBeAffixed(); // Create block port representing the outer conduit var outerConduitPort = CreatePortForOuterConduitEnd(viewModel, blockSide); nodeContainerBlock.AddPort(outerConduitPort); List <SpanDiagramInfo> innerSpanData = viewModel.GetInnerSpanDiagramInfos("InnerConduit"); bool innerSpansFound = false; // Create inner conduit ends as port terminals foreach (var innerSpanDiagramInfo in innerSpanData) { CreateTerminalForInnerConduitEnd(viewModel, outerConduitPort, innerSpanDiagramInfo); innerSpansFound = true; } // We're dealing with a multi conduit without any inner conduits or a single span conduit if (!innerSpansFound) { // We're dealing with a single span conduit if (viewModel.IsSingleSpan) { CreateTerminalForSingleConduitEnd(viewModel, outerConduitPort); } // We're dealing with a multi level conduit with no inner conduits else { // Check if cables are related to the outer conduir if (_nodeContainerViewModel.Data.ConduitSegmentToCableChildRelations.ContainsKey(routeSpanDiagramInfo.SegmentId)) { CreateTerminalsForCablesRelatedToSingleConduitEnd(viewModel, outerConduitPort); } // No cables so we create one terminal that shows where the empty multi conduit is heading else { CreateTerminalForShowingWhereEmptySingleConduitIsHeading(viewModel, outerConduitPort); } } } }
private void AffixConduits(LineBlock nodeContainerBlock) { var affixedSpanEquipmentViewModels = new List <SpanEquipmentViewModel>(); foreach (var spanEquipment in _nodeContainerViewModel.Data.SpanEquipments.Where(s => s.IsAttachedToNodeContainer(_nodeContainerViewModel.Data))) { affixedSpanEquipmentViewModels.Add(new SpanEquipmentViewModel(_logger, _nodeContainerViewModel.Data.RouteNetworkElementId, spanEquipment.Id, _nodeContainerViewModel.Data)); } //var organizer = new NodeContainerSpanEquipmentOrganizer(affixedSpanEquipmentViewModels); foreach (var viewModel in GetOrderedSpanEquipmentViewModels(affixedSpanEquipmentViewModels)) { AffixConduit(nodeContainerBlock, viewModel); } }
protected override BlockParseResult <CardMetadataBlock> ParseInternal(LineBlock markdown, int startLine, bool lineStartsNewParagraph, MarkdownDocument document) { var line = markdown[startLine].Trim(); if (line.Length == 0 || line[0] != '>') { return(null); } line = line.Slice(1).TrimStart(); var list = new List <uint>(); uint currentCost = 0; int? times = null; int? cost = null; int? duration = null; string?cardType = null; while (line.Length != 0) { int end; if (line[0] == '(') { end = line.FindClosingBrace() + 1; if (end == 0) { return(null); } } else { end = line.IndexOfNexWhiteSpace(); if (end == -1) { end = line.Length; } } var current = line.Slice(0, end).Trim(); var type = current[^ 1];
public double AddCablePassThroughBlock(DiagramBuilder builder, double offsetY, double minWith) { ////////////////////////////////////////////////////////// /// label block /// LineBlock cableBlock = new LineBlock(30, offsetY, LineBlockTypeEnum.Simple); cableBlock.MinWidth = minWith; // Add vest ports AddBigConduitPort(cableBlock, BlockSideEnum.Vest, 2, null, 20); // Add east ports AddBigConduitPort(cableBlock, BlockSideEnum.East, 2, null, 20); // Connect west and east terminals cableBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "72", "CableOutsideWell"); cableBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 2, BlockSideEnum.East, 1, 2, "72", "CableOutsideWell"); cableBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(cableBlock); ////////////////////////////////////////////////////////// /// label block LineBlock labelBlock = new LineBlock(0, offsetY, LineBlockTypeEnum.Simple); labelBlock.MinWidth = 30; // Add vest port AddBigConduitPort(labelBlock, BlockSideEnum.Vest, 2); // Add east port AddBigConduitPort(labelBlock, BlockSideEnum.East, 2); labelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "FP-0101", "CableOutsideWell"); labelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "FP-0101", "CableOutsideWell"); labelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(labelBlock); return(cableBlock.DesiredSize.Height); }
public void SouthEastPostDrawingTest_ShouldSucceed() { Diagram diagram = new Diagram(); var lineBlock = new LineBlock() { MinHeight = 200, MinWidth = 300, Margin = 20, IsVisible = false }; // East var eastPort = new BlockPort(BlockSideEnum.East) { IsVisible = false }; lineBlock.AddPort(eastPort); AddTerminalsToPort(eastPort, 4); // South var southPort = new BlockPort(BlockSideEnum.South) { IsVisible = false }; lineBlock.AddPort(southPort); AddTerminalsToPort(southPort, 4); // East South connections lineBlock.AddTerminalConnection(BlockSideEnum.South, 1, 1, BlockSideEnum.East, 1, 1, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Polygon); lineBlock.CreateDiagramObjects(diagram, 0, 0); if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(diagram).Export("c:/temp/diagram/test.geojson"); } }
private LineBlock CreateSpanEquipmentBlock(double extraHeightTop = 0) { var nodeEquipmentBlock = new LineBlock() { MinWidth = _initialMinWidth, ExtraHeightTop = extraHeightTop, IsVisible = true, Style = "NodeContainer", Margin = _nodeContainerBlockMargin, DrawingOrder = 100, VerticalContentAlignment = GetContainerVerticalAlignment() }; nodeEquipmentBlock.SetReference(_nodeContainerViewModel.NodeContainer.Id, "NodeContainer"); AffixConduits(nodeEquipmentBlock); ConnectEnds(nodeEquipmentBlock); nodeEquipmentBlock.SetSideCenterAlignment(BlockSideEnum.North); nodeEquipmentBlock.SetSideCenterAlignment(BlockSideEnum.South); return(nodeEquipmentBlock); }
IEnumerator RunLines(List <Line> lines, int startLineIndex = 0) { ParseIfState parseIfState = ParseIfState.AddLines; //List<string> newLines = new List<string>(); int i = 0; while (i < lines.Count) { lastLineIndex = lines[i].index; string line = lines[i].text; //Debug.Log("line["+i+"]: " + line); if (line.IndexOf("<<if") != -1) { if (EvaluateIf(line)) { List <Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count + 1; i += skipAmount; //Debug.Log("Passed if: ParseIfState.SkipToEndIf, skipped: " + skipAmount + " line now #" + i + ": " + lines[i]); yield return(StartCoroutine(RunLines(block, startLineIndex))); if (i >= lines.Count) { break; } parseIfState = ParseIfState.SkipToEndIf; } else { parseIfState = ParseIfState.SkipToNextElse; List <Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count + 1; i += skipAmount; if (i >= lines.Count) { break; } //Debug.Log("Failed if: ParseIfState.SkipToNextElse, skipped: " + skipAmount + " line now #" + i + ": " + lines[i]); } } else if (line.IndexOf("<<elseif") != -1) { if (parseIfState == ParseIfState.SkipToEndIf) { List <Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count + 1; i += skipAmount; if (i >= lines.Count) { break; } //Debug.LogWarning("Skipped: " + skipAmount + " due to ParseIfState.SkipToEndIf line now #" + i + ": " + lines[i]); } else { if (EvaluateIf(line)) { List <Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count + 1; i += skipAmount; yield return(StartCoroutine(RunLines(block, startLineIndex))); parseIfState = ParseIfState.SkipToEndIf; if (i >= lines.Count) { break; } //Debug.Log("Passed elseif: ParseIfState.SkipToEndIf, skipped: " + skipAmount + " line now #" + i + ": " + lines[i]); } else { //Debug.Log("Failed elseif... ParseIfState.SkipToNextElse"); parseIfState = ParseIfState.SkipToNextElse; List <Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count + 1; i += skipAmount; if (i >= lines.Count) { break; } //Debug.LogWarning("Skipped: " + skipAmount + " due to failed IF check line now #" + i + ": " + lines[i]); } } } else if (line.IndexOf("<<else") != -1) { if (parseIfState == ParseIfState.SkipToEndIf) { List <Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count + 1; i += skipAmount; if (i >= lines.Count) { break; } //Debug.LogWarning("Skipped: " + skipAmount + " due to ParseIfState.SkipToEndIf"); } else { if (parseIfState == ParseIfState.SkipToNextElse) { List <Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); i += block.Count; yield return(StartCoroutine(RunLines(block, startLineIndex))); parseIfState = ParseIfState.SkipToEndIf; } else { parseIfState = ParseIfState.AddLines; List <Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count + 1; i += skipAmount; if (i >= lines.Count) { break; } } } } else if (line.IndexOf("<<endif>>") != -1) { parseIfState = ParseIfState.AddLines; i++; } // parse shortcut options with -> else if (parseShortcutOptions && line.Trim().IndexOf("->") == 0) { List <LineBlock> optionLineBlocks = new List <LineBlock>(); int usingTabs = lines[i].tabs; string optionText = ""; /* * var lineTrimmed = line.Trim(); * var optionText = lineTrimmed.Substring(2, lineTrimmed.Length-2); * optionText = optionText.Trim(); */ options.Clear(); // if null, skip lines LineBlock lineBlock = null; while (i < lines.Count) { var currentLine = lines[i]; Debug.Log("usingTabs: " + usingTabs + " currentLine.tabs: " + currentLine.tabs); // starting a new option and line block if (currentLine.tabs == usingTabs && currentLine.text.IndexOf("->") == usingTabs) { string lineText = currentLine.text; bool conditional = true; if (currentLine.text.IndexOf("<<") != -1) { conditional = EvaluateIf(currentLine.text.Substring(usingTabs, currentLine.text.Length - usingTabs)); int startIndex = lineText.IndexOf("<<"); int endIndex = lineText.IndexOf(">>"); lineText = lineText.Substring(0, startIndex) + lineText.Substring(endIndex + 2, lineText.Length - (endIndex + 2)); currentLine.text = lineText; } // end last one if (lineBlock != null) { optionLineBlocks.Add(lineBlock); } if (conditional) { // start new one optionText = lineText.Substring(usingTabs + 2, lineText.Length - (usingTabs + 2)); optionText = optionText.Trim(); options.Add(new Dialogue.Option(optionText, "")); lineBlock = new LineBlock(); } else { lineBlock = null; } // keep going } else if (currentLine.tabs <= usingTabs) { // end here optionLineBlocks.Add(lineBlock); break; } else { if (lineBlock != null) { Debug.Log("adding line to block: " + currentLine.text); lineBlock.lines.Add(currentLine); } else { Debug.Log("skipping line: " + currentLine.text); } } i++; } optionLineBlocks.Add(lineBlock); yield return(StartCoroutine(implementation.RunOptions(options))); options.Clear(); yield return(StartCoroutine(RunLines(optionLineBlocks[currentOption].lines))); } else { if (parseIfState == ParseIfState.AddLines) { yield return(StartCoroutine(RunLine(lines[i], startLineIndex))); } i++; } } }
public override LineBlock VisitLineBlock(LineBlock lineBlock) { lineBlock = lineBlockDelegate?.Invoke(lineBlock) ?? lineBlock; return(base.VisitLineBlock(lineBlock)); }
IEnumerator RunLines(List<Line> lines, int startLineIndex = 0) { ParseIfState parseIfState = ParseIfState.AddLines; //List<string> newLines = new List<string>(); int i = 0; while (i < lines.Count) { lastLineIndex = lines[i].index; string line = lines[i].text; //Debug.Log("line["+i+"]: " + line); if (line.IndexOf("<<if") != -1) { if (EvaluateIf(line)) { List<Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count+1; i += skipAmount; //Debug.Log("Passed if: ParseIfState.SkipToEndIf, skipped: " + skipAmount + " line now #" + i + ": " + lines[i]); yield return StartCoroutine(RunLines(block, startLineIndex)); if (i >= lines.Count) break; parseIfState = ParseIfState.SkipToEndIf; } else { parseIfState = ParseIfState.SkipToNextElse; List<Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count+1; i += skipAmount; if (i >= lines.Count) break; //Debug.Log("Failed if: ParseIfState.SkipToNextElse, skipped: " + skipAmount + " line now #" + i + ": " + lines[i]); } } else if (line.IndexOf("<<elseif") != -1) { if (parseIfState == ParseIfState.SkipToEndIf) { List<Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count+1; i += skipAmount; if (i >= lines.Count) break; //Debug.LogWarning("Skipped: " + skipAmount + " due to ParseIfState.SkipToEndIf line now #" + i + ": " + lines[i]); } else { if (EvaluateIf(line)) { List<Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count+1; i += skipAmount; yield return StartCoroutine(RunLines(block, startLineIndex)); parseIfState = ParseIfState.SkipToEndIf; if (i >= lines.Count) break; //Debug.Log("Passed elseif: ParseIfState.SkipToEndIf, skipped: " + skipAmount + " line now #" + i + ": " + lines[i]); } else { //Debug.Log("Failed elseif... ParseIfState.SkipToNextElse"); parseIfState = ParseIfState.SkipToNextElse; List<Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count+1; i += skipAmount; if (i >= lines.Count) break; //Debug.LogWarning("Skipped: " + skipAmount + " due to failed IF check line now #" + i + ": " + lines[i]); } } } else if (line.IndexOf("<<else") != -1) { if (parseIfState == ParseIfState.SkipToEndIf) { List<Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count+1; i += skipAmount; if (i >= lines.Count) break; //Debug.LogWarning("Skipped: " + skipAmount + " due to ParseIfState.SkipToEndIf"); } else { if (parseIfState == ParseIfState.SkipToNextElse) { List<Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); i += block.Count; yield return StartCoroutine(RunLines(block, startLineIndex)); parseIfState = ParseIfState.SkipToEndIf; } else { parseIfState = ParseIfState.AddLines; List<Line> block = GetIfBlock(lines.GetRange(i, lines.Count - i)); int skipAmount = block.Count+1; i += skipAmount; if (i >= lines.Count) break; } } } else if (line.IndexOf("<<endif>>") != -1) { parseIfState = ParseIfState.AddLines; i++; } // parse shortcut options with -> else if (parseShortcutOptions && line.Trim().IndexOf("->") == 0) { List<LineBlock> optionLineBlocks = new List<LineBlock>(); int usingTabs = lines[i].tabs; string optionText = ""; /* var lineTrimmed = line.Trim(); var optionText = lineTrimmed.Substring(2, lineTrimmed.Length-2); optionText = optionText.Trim(); */ options.Clear(); // if null, skip lines LineBlock lineBlock = null; while (i < lines.Count) { var currentLine = lines[i]; Debug.Log("usingTabs: " + usingTabs + " currentLine.tabs: " + currentLine.tabs); // starting a new option and line block if (currentLine.tabs == usingTabs && currentLine.text.IndexOf("->") == usingTabs) { string lineText = currentLine.text; bool conditional = true; if (currentLine.text.IndexOf("<<") != -1) { conditional = EvaluateIf(currentLine.text.Substring(usingTabs, currentLine.text.Length - usingTabs)); int startIndex = lineText.IndexOf("<<"); int endIndex = lineText.IndexOf(">>"); lineText = lineText.Substring(0, startIndex) + lineText.Substring(endIndex+2, lineText.Length - (endIndex+2)); currentLine.text = lineText; } // end last one if (lineBlock != null) optionLineBlocks.Add(lineBlock); if (conditional) { // start new one optionText = lineText.Substring(usingTabs+2, lineText.Length-(usingTabs+2)); optionText = optionText.Trim(); options.Add(new Dialogue.Option(optionText, "")); lineBlock = new LineBlock(); } else { lineBlock = null; } // keep going } else if (currentLine.tabs <= usingTabs) { // end here optionLineBlocks.Add(lineBlock); break; } else { if (lineBlock != null) { Debug.Log("adding line to block: " + currentLine.text); lineBlock.lines.Add(currentLine); } else { Debug.Log("skipping line: " + currentLine.text); } } i++; } optionLineBlocks.Add(lineBlock); yield return StartCoroutine(implementation.RunOptions(options)); options.Clear(); yield return StartCoroutine(RunLines(optionLineBlocks[currentOption].lines)); } else { if (parseIfState == ParseIfState.AddLines) { yield return StartCoroutine(RunLine(lines[i], startLineIndex)); } i++; } } }
public Diagram Build() { DiagramBuilder builder = new DiagramBuilder(); double offsetY = 0; offsetY += AddCablePassThroughBlock(builder, offsetY, 300); AddMultiConduitPassThroughBlock(builder, 300, offsetY, 10); Diagram diagram = builder.CreateDiagram(); return(diagram); LineBlock junctionBlock = new LineBlock(30, 0); junctionBlock.MinWidth = 300; // Add first vest port with 5 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.Vest, 10, "Orange"); // Add second vest port with 7 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.Vest, 7, "Orange"); // Add fist east port with 10 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.East, 10, "Orange"); // Add second east port with 7 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.East, 7, "Orange"); // Add north big conduit port 1 with 3 terminal AddBigConduitPort(junctionBlock, BlockSideEnum.North, 3, "Red"); // Add north big conduit port 2 with 5 terminal AddBigConduitPort(junctionBlock, BlockSideEnum.North, 5, "Red"); junctionBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, null, "InnerConduitBlue", LineShapeTypeEnum.Polygon); junctionBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 2, BlockSideEnum.North, 1, 1, null, "InnerConduitBlue", LineShapeTypeEnum.Polygon); /* * * // Feeder calbe from central office * junctionBlock.AddConnection(BlockSideEnum.Vest, 2, 5, BlockSideEnum.North, 1, 1, "192", "CableInsideWell"); * * // Transit feeder cable to other flex points * junctionBlock.AddConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.North, 1, 2, "96", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 10, BlockSideEnum.North, 1, 3, "96", "CableInsideWell"); * * // Sp connections * junctionBlock.AddConnection(BlockSideEnum.East, 1, 1, BlockSideEnum.North, 2, 2, "24", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 2, BlockSideEnum.North, 2, 3, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 3, BlockSideEnum.North, 2, 4, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 4, BlockSideEnum.North, 2, 5, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.Vest, 2, 2, BlockSideEnum.North, 2, 1, "48", "CableInsideWell"); * */ builder.ContentObjects.Add(junctionBlock); junctionBlock.Measure(new Layout.Size()); ////////////////////////////////////////////////////////// /// well north label block LineBlock wellNorthLabelBlock = new LineBlock(30, junctionBlock.DesiredSize.Height, LineBlockTypeEnum.Simple); wellNorthLabelBlock.MinHeight = 30; // Add north port with 3 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.North, 3); // Add north port with 5 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.North, 5); // Add south port with 3 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.South, 3); // Add south port with 5 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.South, 5); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 1, BlockSideEnum.South, 1, 1, "GSS 1 (1-16)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 2, BlockSideEnum.South, 1, 2, "GSS 1 (1-8)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 3, BlockSideEnum.South, 1, 3, "GSS 1 (9-16)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 1, BlockSideEnum.South, 2, 1, "GPS 1", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 2, BlockSideEnum.South, 2, 2, "GPS 1", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 3, BlockSideEnum.South, 2, 3, "GPS 2", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 4, BlockSideEnum.South, 2, 4, "GPS 2", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 5, BlockSideEnum.South, 2, 5, "GPS 2 & 3", "CableOutsideWell"); builder.ContentObjects.Add(wellNorthLabelBlock); wellNorthLabelBlock.Measure(new Layout.Size()); ////////////////////////////////////////////////////////// /// well vest label block LineBlock wellVestLabelBlock = new LineBlock(0, 0, LineBlockTypeEnum.Simple); wellVestLabelBlock.MinWidth = 30; // Add vest port with 5 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.Vest, 5); // Add vest port with 7 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.Vest, 7); // Add east port with 5 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.East, 5); // Add east port with 7 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.East, 7); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.East, 1, 4, "PF-4200", "CableOutsideWell"); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 2, 2, BlockSideEnum.East, 2, 2, "SP-5420", "CableOutsideWell"); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 2, 5, BlockSideEnum.East, 2, 5, "CO-1010", "CableOutsideWell"); wellVestLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(wellVestLabelBlock); ////////////////////////////////////////////////////////// /// east label block LineBlock wellEastLabelBlock = new LineBlock(junctionBlock.DesiredSize.Width + 30, 0, LineBlockTypeEnum.Simple); wellEastLabelBlock.MinWidth = 30; wellEastLabelBlock.MinHeight = junctionBlock.DesiredSize.Height; // Add vest port with 10 terminal AddBigConduitPort(wellEastLabelBlock, BlockSideEnum.Vest, 10); // Add east port with 10 terminal AddBigConduitPort(wellEastLabelBlock, BlockSideEnum.East, 10); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "SP-5010", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 2, BlockSideEnum.East, 1, 2, "SP-5011", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 3, BlockSideEnum.East, 1, 3, "SP-5013", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.East, 1, 4, "SP-6002", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 10, BlockSideEnum.East, 1, 10, "FP-4203", "CableOutsideWell"); wellEastLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(wellEastLabelBlock); ////////////////////////////////////////////////////////// /// well north corner 1 LineBlock wellNorthCorner1 = new LineBlock(30, junctionBlock.DesiredSize.Height + wellNorthLabelBlock.DesiredSize.Height, LineBlockTypeEnum.Simple); wellNorthCorner1.MinHeight = 20; // Add south port with 3 terminal AddBigConduitPort(wellNorthCorner1, BlockSideEnum.South, 3); // Add east port with 3 terminal AddBigConduitPort(wellNorthCorner1, BlockSideEnum.East, 3, null, 1, 1); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 1, BlockSideEnum.East, 1, 1, "", "CableOutsideWell"); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 2, BlockSideEnum.East, 1, 2, "", "CableOutsideWell"); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 3, BlockSideEnum.East, 1, 3, "", "CableOutsideWell"); // Set margin on east side to 0 wellNorthCorner1.SetSideMargin(BlockSideEnum.East, 0); //builder.ContentObjects.Add(wellNorthCorner1); Diagram sdiagram = builder.CreateDiagram(); return(diagram); }
public double AddConduitClosureBlock(DiagramBuilder builder, ConduitClosureInfo conduitClosureInfo, double minBlockWidth, double offsetY) { double labelSectionWidth = 40; double sideMargin = 20; LineBlock leftLabelBlock = new LineBlock(0, offsetY, LineBlockTypeEnum.Simple); leftLabelBlock.MinWidth = labelSectionWidth; LineBlock rightLabelBlock = new LineBlock(minBlockWidth + labelSectionWidth, offsetY, LineBlockTypeEnum.Simple); rightLabelBlock.MinWidth = labelSectionWidth; ////////////////////////////////////////////////////////// /// conduit closure block /// LineBlock conduitClosureBlock = new LineBlock(labelSectionWidth, offsetY); conduitClosureBlock.SetReference(conduitClosureInfo.Id, "ConduitClosure"); conduitClosureBlock.MinWidth = minBlockWidth; conduitClosureBlock.MinHeight = 100; conduitClosureBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(conduitClosureBlock); Dictionary <BlockPort, ConduitClosurePortInfo> blockPortToConduitClosurePort = new Dictionary <BlockPort, ConduitClosurePortInfo>(); // Add ports foreach (var side in conduitClosureInfo.Sides) { foreach (var conduitClosurePort in side.Ports) { var nTerminals = conduitClosurePort.Terminals.Count; var blockPort = AddMultiConduitPort(conduitClosureBlock, Convert(side.Position), conduitClosurePort.Terminals, conduitClosurePort.MultiConduitSegment.Conduit.Color.ToString(), -1, -1, 10); blockPort.SetReference(conduitClosurePort.MultiConduitSegment.Id, "MultiConduitSegment"); blockPortToConduitClosurePort.Add(blockPort, conduitClosurePort); // Add left label blocks if (side.Position == ConduitClosureInfoSide.Left) { // Add left west label port AddBigConduitPort(leftLabelBlock, BlockSideEnum.Vest, nTerminals, null, -1, -1, 10); // Add left east label port AddBigConduitPort(leftLabelBlock, BlockSideEnum.East, nTerminals, null, -1, -1, 10); foreach (var terminal in conduitClosurePort.Terminals) { var lineInfo = _traversalHelper.CreateTraversalInfoFromSegment(terminal.LineSegment); leftLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, blockPort.Index, terminal.Position, BlockSideEnum.East, blockPort.Index, terminal.Position, lineInfo.StartRouteNode.Name, "LabelMediumText"); } } // Add right label block if (side.Position == ConduitClosureInfoSide.Right) { // Add right west label port AddBigConduitPort(rightLabelBlock, BlockSideEnum.Vest, nTerminals, null, -1, -1, 10); // Add right east label port AddBigConduitPort(rightLabelBlock, BlockSideEnum.East, nTerminals, null, -1, -1, 10); foreach (var terminal in conduitClosurePort.Terminals) { var lineInfo = _traversalHelper.CreateTraversalInfoFromSegment(terminal.LineSegment); rightLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, blockPort.Index, terminal.Position, BlockSideEnum.East, blockPort.Index, terminal.Position, lineInfo.EndRouteNode.Name, "LabelMediumText"); } } } } conduitClosureBlock.SetSideCenterAllignment(BlockSideEnum.North, true); // Connect ports foreach (var portEntry in blockPortToConduitClosurePort) { var blockPort = portEntry.Key; var conduitClosurePort = portEntry.Value; if ((blockPort.Side == BlockSideEnum.Vest || blockPort.Side == BlockSideEnum.North) && conduitClosurePort.ConnectionKind == ConduitClosureInternalConnectionKindEnum.PassThrough) { var portConnection = conduitClosureBlock.AddPortConnection(blockPort.Side, blockPort.Index, Convert(conduitClosurePort.ConnectedToSide), conduitClosurePort.ConnectedToPort, null, "MultiConduit" + conduitClosurePort.MultiConduitSegment.Conduit.Color.ToString()); portConnection.SetReference(conduitClosurePort.MultiConduitSegment.ConduitId, "Conduit"); } } // Connect terminals HashSet <ConduitClosureTerminalInfo> terminalAlreadyProcessed = new HashSet <ConduitClosureTerminalInfo>(); foreach (var portEntry in blockPortToConduitClosurePort) { var blockPort = portEntry.Key; var conduitClosurePort = portEntry.Value; foreach (var terminal in conduitClosurePort.Terminals) { if (!terminalAlreadyProcessed.Contains(terminal)) { terminalAlreadyProcessed.Add(terminal); if (terminal.ConnectionKind == ConduitClosureInternalConnectionKindEnum.PassThrough || terminal.ConnectionKind == ConduitClosureInternalConnectionKindEnum.Connected) { string color = "Red"; if (terminal.LineSegment is ConduitSegmentInfo) { var conduitSegmentInfo = terminal.LineSegment as ConduitSegmentInfo; color = conduitSegmentInfo.Conduit.Color.ToString(); } var terminalConnection = conduitClosureBlock.AddTerminalConnection(blockPort.Side, blockPort.Index, terminal.Position, Convert(terminal.ConnectedToSide), terminal.ConnectedToPort, terminal.ConnectedToTerminal, null, "InnerConduit" + color, LineShapeTypeEnum.Polygon); terminalConnection.SetReference(terminal.LineId, "InnerConduit"); // make sure we don't connect the other way too var connectedToTerminal = conduitClosureInfo.Sides.Find(s => s.Position == terminal.ConnectedToSide).Ports.Find(p => p.Position == terminal.ConnectedToPort).Terminals.Find(t => t.Position == terminal.ConnectedToTerminal); terminalAlreadyProcessed.Add(connectedToTerminal); } } } } // Add label blocks leftLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(leftLabelBlock); rightLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(rightLabelBlock); return(conduitClosureBlock.DesiredSize.Height); }
private LineBlock CreateConduitPassThroughBlock() { // Create outer conduits var rootSpanInfo = _spanEquipmentViewModel.RootSpanDiagramInfo("OuterConduit"); var spanEquipmentBlock = new LineBlock() { MinWidth = _spanEquipmentAreaWidth, IsVisible = _spanEquipmentViewModel.IsSingleSpan ? false : true, Style = rootSpanInfo.StyleName, Margin = _spanEquipmentViewModel.IsSingleSpan ? 0 : _spanEquipmentBlockMargin, DrawingOrder = 400 }; spanEquipmentBlock.SetReference(rootSpanInfo.IngoingSegmentId, "SpanSegment"); // Create inner conduits var innerSpanData = _spanEquipmentViewModel.GetInnerSpanDiagramInfos("InnerConduit"); var fromPort = _spanEquipmentViewModel.IsSingleSpan ? new BlockPort(BlockSideEnum.West, null, null, 0, -1, 0) { IsVisible = false, DrawingOrder = 420 } : new BlockPort(BlockSideEnum.West) { IsVisible = false, DrawingOrder = 420 }; spanEquipmentBlock.AddPort(fromPort); var toPort = _spanEquipmentViewModel.IsSingleSpan ? new BlockPort(BlockSideEnum.East, null, null, 0, -1, 0) { IsVisible = false, DrawingOrder = 420 } : new BlockPort(BlockSideEnum.East) { IsVisible = false, DrawingOrder = 420 }; spanEquipmentBlock.AddPort(toPort); int terminalNo = 1; var orderedinnerSpanData = innerSpanData.OrderBy(i => (1000 - i.Position)); bool innerSpansFound = false; foreach (var spanInfo in orderedinnerSpanData) { var fromTerminal = new BlockPortTerminal(fromPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "WestTerminalLabel", PointLabel = _spanEquipmentViewModel.GetIngoingRouteNodeName(spanInfo.SegmentId), DrawingOrder = 520 }; fromTerminal.SetReference(spanInfo.IngoingSegmentId, "SpanSegment"); var toTerminal = new BlockPortTerminal(toPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "EastTerminalLabel", PointLabel = _spanEquipmentViewModel.GetOutgoingRouteNodeName(spanInfo.SegmentId), DrawingOrder = 520 }; toTerminal.SetReference(spanInfo.OutgoingSegmentId, "SpanSegment"); var terminalConnection = spanEquipmentBlock.AddTerminalConnection(BlockSideEnum.West, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, null, spanInfo.StyleName, LineShapeTypeEnum.Polygon); terminalConnection.DrawingOrder = 510; terminalConnection.SetReference(spanInfo.IngoingSegmentId, "SpanSegment"); // Add eventually cable running through inner conduit if (_spanEquipmentViewModel.Data.ConduitSegmentToCableChildRelations.ContainsKey(spanInfo.SegmentId)) { var cableId = _spanEquipmentViewModel.Data.ConduitSegmentToCableChildRelations[spanInfo.SegmentId].First(); var fiberCableLineLabel = _spanEquipmentViewModel.Data.GetCableEquipmentLineLabel(cableId); var cableTerminalConnection = spanEquipmentBlock.AddTerminalConnection(BlockSideEnum.West, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, fiberCableLineLabel, "FiberCable", LineShapeTypeEnum.Line); cableTerminalConnection.DrawingOrder = 600; cableTerminalConnection.SetReference(cableId, "SpanSegment"); } terminalNo++; innerSpansFound = true; } if (!innerSpansFound) { var fromTerminal = new BlockPortTerminal(fromPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "WestTerminalLabel", PointLabel = _spanEquipmentViewModel.GetIngoingRouteNodeName(rootSpanInfo.SegmentId), DrawingOrder = 520 }; fromTerminal.SetReference(rootSpanInfo.IngoingSegmentId, "SpanSegment"); var toTerminal = new BlockPortTerminal(toPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "EastTerminalLabel", PointLabel = _spanEquipmentViewModel.GetOutgoingRouteNodeName(rootSpanInfo.SegmentId), DrawingOrder = 520 }; toTerminal.SetReference(rootSpanInfo.OutgoingSegmentId, "SpanSegment"); // If a single conduit if (_spanEquipmentViewModel.IsSingleSpan) { var terminalConnection = spanEquipmentBlock.AddTerminalConnection(BlockSideEnum.West, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, null, rootSpanInfo.StyleName, LineShapeTypeEnum.Polygon); terminalConnection.DrawingOrder = 510; terminalConnection.SetReference(rootSpanInfo.SegmentId, "SpanSegment"); // Add eventually cable running through inner conduit if (_spanEquipmentViewModel.Data.ConduitSegmentToCableChildRelations.ContainsKey(rootSpanInfo.SegmentId)) { var cableId = _spanEquipmentViewModel.Data.ConduitSegmentToCableChildRelations[rootSpanInfo.SegmentId].First(); var fiberCableLineLabel = _spanEquipmentViewModel.Data.GetCableEquipmentLineLabel(cableId); var cableTerminalConnection = spanEquipmentBlock.AddTerminalConnection(BlockSideEnum.West, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, fiberCableLineLabel, "FiberCable", LineShapeTypeEnum.Line); cableTerminalConnection.DrawingOrder = 600; cableTerminalConnection.SetReference(cableId, "SpanSegment"); } } terminalNo++; } return(spanEquipmentBlock); }
public double AddMultiConduitPassThroughBlock(DiagramBuilder builder, ConduitSegmentInfo conduitSegmentInfo, double minBlockWidth, double offsetY) { double labelSectionWidth = 40; double sideMargin = 20; ////////////////////////////////////////////////////////// /// conduit block /// LineBlock conduitBlock = new LineBlock(labelSectionWidth, offsetY, LineBlockTypeEnum.Simple); conduitBlock.MinWidth = minBlockWidth; var nTerminals = conduitSegmentInfo.Children.Count; var color = conduitSegmentInfo.Conduit.Color.ToString(); // Add vest ports AddMultiConduitPort(conduitBlock, BlockSideEnum.Vest, nTerminals, color, -1, -1, 10); // Add east ports AddMultiConduitPort(conduitBlock, BlockSideEnum.East, nTerminals, color, -1, -1, 10); // Connect ports var portConnection = conduitBlock.AddPortConnection(BlockSideEnum.Vest, 1, BlockSideEnum.East, 1, null, "MultiConduit" + color); portConnection.SetReference(conduitSegmentInfo.ConduitId, "Conduit"); // Connect west and east terminals foreach (var child in conduitSegmentInfo.Children.OfType <ConduitSegmentInfo>()) { var terminalConnection = conduitBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, child.Conduit.SequenceNumber, BlockSideEnum.East, 1, child.Conduit.SequenceNumber, null, "InnerConduit" + child.Conduit.Color.ToString(), LineShapeTypeEnum.Polygon); terminalConnection.SetReference(child.Conduit.Id, "SingleConduit"); } conduitBlock.SetSideMargin(sideMargin); conduitBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(conduitBlock); ////////////////////////////////////////////////////////// /// left label block LineBlock leftLabelBlock = new LineBlock(0, offsetY, LineBlockTypeEnum.Simple); leftLabelBlock.MinWidth = labelSectionWidth; // Add vest port AddBigConduitPort(leftLabelBlock, BlockSideEnum.Vest, nTerminals, null, -1, -1, 10); // Add east port AddBigConduitPort(leftLabelBlock, BlockSideEnum.East, nTerminals, null, -1, -1, 10); // Connect west and east terminals foreach (var child in conduitSegmentInfo.Children.OfType <ConduitSegmentInfo>()) { var lineInfo = _traversalHelper.CreateTraversalInfoFromSegment(conduitSegmentInfo); leftLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, child.Conduit.SequenceNumber, BlockSideEnum.East, 1, child.Conduit.SequenceNumber, lineInfo.StartRouteNode.Name, "LabelMediumText"); } leftLabelBlock.SetSideMargin(sideMargin); leftLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(leftLabelBlock); ////////////////////////////////////////////////////////// /// right label block LineBlock rightLabelBlock = new LineBlock(minBlockWidth + labelSectionWidth, offsetY, LineBlockTypeEnum.Simple); rightLabelBlock.MinWidth = labelSectionWidth; // Add vest port AddBigConduitPort(rightLabelBlock, BlockSideEnum.Vest, nTerminals, null, -1, -1, 10); // Add east port AddBigConduitPort(rightLabelBlock, BlockSideEnum.East, nTerminals, null, -1, -1, 10); // Connect west and east terminals foreach (var child in conduitSegmentInfo.Children.OfType <ConduitSegmentInfo>()) { var lineInfo = _traversalHelper.CreateTraversalInfoFromSegment(conduitSegmentInfo); var terminalConnection = rightLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, child.Conduit.SequenceNumber, BlockSideEnum.East, 1, child.Conduit.SequenceNumber, lineInfo.EndRouteNode.Name, "LabelMediumText"); } rightLabelBlock.SetSideMargin(sideMargin); rightLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(rightLabelBlock); return(conduitBlock.DesiredSize.Height); }
private void ParseAllC13Lines(uint c13linesbytes) { C13LinesSeq = new ByteSequence(FlattenedBuffer, ReadOffset, (int)c13linesbytes); int begin = ReadOffset; while (ReadOffset < begin + c13linesbytes) { int chunkbegin = ReadOffset; var chunksig = ExtractUInt32(); var chunksize = ExtractUInt32(); var chunkend = ReadOffset + chunksize.ExtractedValue; if (chunksig.ExtractedValue == 0xf4) { while (ReadOffset < chunkend) { int csbegin = ReadOffset; var checksumfile = ExtractUInt32(); var bytecount = ExtractByte(); var checksumtype = ExtractByte(); var checksum = ExtractBytes(bytecount.ExtractedValue); var seq = new ByteSequence(FlattenedBuffer, csbegin, ReadOffset - csbegin); var csr = new Checksum { FileIndex = checksumfile, ByteCount = bytecount, Type = checksumtype, ChecksumBytes = checksum, OriginalSequence = seq }; Checksums.Add(csr); Extract4ByteAlignment(); } } else if (chunksig.ExtractedValue == 0xf2) { while (ReadOffset < chunkend) { int ldbegin = ReadOffset; var functionoffset = ExtractUInt32(); var segcontrib = ExtractUInt16(); var flags = ExtractUInt16(); var codesize = ExtractUInt32(); var ld = new LineData { FunctionOffset = functionoffset, SegmentOfContribution = segcontrib, Flags = flags, CodeSize = codesize, LineBlocks = new List <LineBlock>() }; while (ReadOffset < chunkend) { var nameindex = ExtractUInt32(); var numlines = ExtractUInt32(); var blocksize = ExtractUInt32(); var lb = new LineBlock { NameIndex = nameindex, NumLines = numlines, BlockSize = blocksize, Pairs = new List <LinePair>() }; for (uint i = 0; i < numlines.ExtractedValue; ++i) { var offset = ExtractUInt32(); var lpflags = ExtractUInt32(); var lp = new LinePair { CodeOffset = offset, Flags = lpflags }; lb.Pairs.Add(lp); } if ((flags.ExtractedValue & 1) != 0) { for (uint i = 0; i < numlines.ExtractedValue; ++i) { ExtractUInt32(); } } ld.LineBlocks.Add(lb); } ld.OriginalSequence = new ByteSequence(FlattenedBuffer, ldbegin, ReadOffset - ldbegin); Lines.Add(ld); } } else { ReadOffset += (int)chunksize.ExtractedValue; } } }
protected override BlockParseResult <WorkerCostBlock> ParseInternal(LineBlock markdown, int startLine, bool lineStartsNewParagraph, MarkdownDocument document) { var line = markdown[startLine].Trim(); if (line.Length == 0 || line[0] != '>') { return(null); } line = line.Slice(1).TrimStart(); var list = new List <uint>(); uint currentCost = 0; while (line.Length != 0) { var end = line.IndexOfNexWhiteSpace(); if (end == -1) { end = line.Length; } var current = line.Slice(0, end).Trim(); var splitter = current.IndexOf(':'); if (splitter == -1) { return(null); } var first = current.Slice(0, splitter); var scccond = current.Slice(splitter + 1); if (!uint.TryParse(first, out var count)) { return(null); } if (!uint.TryParse(scccond, out var cost)) { return(null); } for (var i = 0; i < count; i++) { currentCost += cost; list.Add(currentCost); } line = line.Slice(end).Trim(); } if (list.Count == 0) { return(null); } var result = new WorkerCostBlock() { WorkerCosts = list.AsReadOnly() }; return(BlockParseResult.Create(result, startLine, 1)); }
protected override BlockParseResult <WorkerTextBlock> ParseInternal(LineBlock markdown, int startLine, bool lineStartsNewParagraph, MarkdownDocument document) { var line = markdown[startLine].Trim(); if (line.Length == 0 || line[0] != '>') { return(null); } line = line.Slice(2).TrimStart(); var list = new List <IEnumerable <MarkdownInline> >(); while (line.Length != 0) { var current = line; var splitter = current.IndexOf(":<"); if (splitter == -1) { return(null); } var currentEnd = current.Slice(splitter + 1).FindClosingBrace() + splitter + 1; if (currentEnd < splitter + 1) { return(null); } current = current.Slice(0, currentEnd + 1); var first = current.Slice(0, splitter); var scccond = current.Slice(splitter + 1); // remove the <> scccond = scccond.Slice(1, scccond.Length - 2); if (!uint.TryParse(first, out var count)) { return(null); } for (var i = 0; i < count; i++) { list.Add(document.ParseInlineChildren(scccond, true, true)); } line = line.Slice(current.Length).Trim(); } if (list.Count == 0) { return(null); } var result = new WorkerTextBlock() { WorkerText = list.AsReadOnly() }; return(BlockParseResult.Create(result, startLine, 1)); }
public double AddCablePassThroughBlock(DiagramBuilder builder, List <SegmentWithRouteNodeRelationInfo> cableSegmentRels, double offsetY, double minBlockWidth) { double labelSectionWidth = 40; double sideMargin = 20; double portMargin = 20; int nCables = cableSegmentRels.Count; ////////////////////////////////////////////////////////// /// cable block /// LineBlock cableBlock = new LineBlock(labelSectionWidth, offsetY, LineBlockTypeEnum.Simple); cableBlock.MinWidth = minBlockWidth; // Add vest ports AddBigConduitPort(cableBlock, BlockSideEnum.Vest, nCables, null, portMargin); // Add east ports AddBigConduitPort(cableBlock, BlockSideEnum.East, nCables, null, portMargin); ////////////////////////////////////////////////////////// /// left label block LineBlock leftLabelBlock = new LineBlock(0, offsetY, LineBlockTypeEnum.Simple); leftLabelBlock.MinWidth = labelSectionWidth; // Add vest port AddBigConduitPort(leftLabelBlock, BlockSideEnum.Vest, nCables, null, portMargin); // Add east port AddBigConduitPort(leftLabelBlock, BlockSideEnum.East, nCables, null, portMargin); ////////////////////////////////////////////////////////// /// right label block LineBlock rightLabelBlock = new LineBlock(minBlockWidth + labelSectionWidth, offsetY, LineBlockTypeEnum.Simple); rightLabelBlock.MinWidth = labelSectionWidth; // Add vest port AddBigConduitPort(rightLabelBlock, BlockSideEnum.Vest, nCables, null, portMargin); // Add east port AddBigConduitPort(rightLabelBlock, BlockSideEnum.East, nCables, null, portMargin); int terminalNo = 1; foreach (var cableRel in cableSegmentRels) { var cable = (FiberCableInfo)cableRel.Segment.Line; var lineInfo = _traversalHelper.CreateTraversalInfoFromSegment(cableRel.Segment); // Create cable var termianlCableMid = cableBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, "" + cable.Children.Count, "CableOutsideWell"); termianlCableMid.SetReference(cableRel.Segment.Id, "FiberCableSegment"); // Create left label var terminalCableLeft = leftLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, lineInfo.StartRouteNode.Name, "CableOutsideWell"); terminalCableLeft.SetReference(cableRel.Segment.Id, "FiberCableSegment"); // Create right label var terminalCableRight = rightLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, lineInfo.EndRouteNode.Name, "CableOutsideWell"); terminalCableRight.SetReference(cableRel.Segment.Id, "FiberCableSegment"); terminalNo++; } cableBlock.SetSideMargin(sideMargin); cableBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(cableBlock); leftLabelBlock.SetSideMargin(sideMargin); leftLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(leftLabelBlock); rightLabelBlock.SetSideMargin(sideMargin); rightLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(rightLabelBlock); return(cableBlock.DesiredSize.Height); }
private List <CSToken> ParseTokens(LineArray lines) { List <CSToken> tokens = new List <CSToken>(); StringBuilder builder = new StringBuilder(); int state = Normal; for (int iBlock = 0; iBlock < lines.blocksCount; ++iBlock) { LineBlock block = lines.blocks[iBlock]; for (int iLine = 0; iLine < block.count; ++iLine) { Line line = block.array[iLine]; for (int i = 0; i < line.charsCount;) { char c = line.chars[i].c; if (state == Normal) { if (char.IsWhiteSpace(c)) { ++i; continue; } if (char.IsLetterOrDigit(c) || c == '_') { CSToken token = new CSToken(); builder.Length = 0; builder.Append(c); for (++i; i < line.charsCount; ++i) { c = line.chars[i].c; if (!char.IsLetterOrDigit(c) && c != '_') { break; } builder.Append(c); } token.text = builder.ToString(); token.place = new Place(i, block.offset + iLine); tokens.Add(token); continue; } if (c == '/') { ++i; if (i < line.charsCount) { c = line.chars[i].c; if (c == '/') { i = line.charsCount; } else if (c == '*') { ++i; state = MultilineComment; } else { CSToken token = new CSToken(); token.c = '/'; token.place = new Place(i, block.offset + iLine); tokens.Add(token); } } } else if (c == '"') { builder.Length = 0; builder.Append('"'); for (++i; i < line.charsCount; ++i) { c = line.chars[i].c; if (c == '\\') { ++i; builder.Append('\\'); builder.Append(line.chars[i].c); } else if (c == '"') { ++i; builder.Append('"'); break; } else { builder.Append(c); } } CSToken token = new CSToken(); token.text = builder.ToString(); token.place = new Place(i, block.offset + iLine); tokens.Add(token); } else if (c == '\'') { builder.Length = 0; builder.Append('\''); for (++i; i < line.charsCount; ++i) { c = line.chars[i].c; if (c == '\\') { ++i; builder.Append('\\'); builder.Append(line.chars[i].c); } else if (c == '\'') { ++i; builder.Append('\''); break; } else { builder.Append(c); } } CSToken token = new CSToken(); token.text = builder.ToString(); token.place = new Place(i, block.offset + iLine); tokens.Add(token); } else if (c == '@' && i + 1 < line.charsCount && line.chars[i + 1].c == '"') { i += 2; builder.Length = 0; builder.Append("@\""); state = MultilineString; } else { if (IsPunctuation(c)) { CSToken token = new CSToken(); token.c = c; token.place = new Place(i, block.offset + iLine); tokens.Add(token); } ++i; } } else if (state == MultilineComment) { if (c == '*' && i + 1 < line.charsCount && line.chars[i + 1].c == '/') { ++i; state = Normal; } ++i; } else if (state == MultilineString) { if (c == '"') { ++i; if (i < line.charsCount && line.chars[i].c == '"') { builder.Append("\"\""); ++i; } else { builder.Append('"'); CSToken token = new CSToken(); token.text = builder.ToString(); token.place = new Place(i, block.offset + iLine); tokens.Add(token); state = Normal; } } else { builder.Append(c); ++i; } } } } } return(tokens); }
public void AllDirectionsTerminalLineDrawingTest_ShouldSucceed() { Diagram diagram = new Diagram(); var lineBlock = new LineBlock() { MinHeight = 200, MinWidth = 300, Margin = 20, IsVisible = false }; // Vest var vestPort = new BlockPort(BlockSideEnum.West) { IsVisible = false }; lineBlock.AddPort(vestPort); AddTerminalsToPort(vestPort, 4); // North var northPort = new BlockPort(BlockSideEnum.North) { IsVisible = false }; lineBlock.AddPort(northPort); AddTerminalsToPort(northPort, 4); // East var eastPort = new BlockPort(BlockSideEnum.East) { IsVisible = false }; lineBlock.AddPort(eastPort); AddTerminalsToPort(eastPort, 4); // South var southPort = new BlockPort(BlockSideEnum.South) { IsVisible = false }; lineBlock.AddPort(southPort); AddTerminalsToPort(southPort, 4); // West connections lineBlock.AddTerminalConnection(BlockSideEnum.West, 1, 1, BlockSideEnum.North, 1, 1, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); lineBlock.AddTerminalConnection(BlockSideEnum.West, 1, 2, BlockSideEnum.East, 1, 1, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); lineBlock.AddTerminalConnection(BlockSideEnum.West, 1, 3, BlockSideEnum.South, 1, 1, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); // North connections lineBlock.AddTerminalConnection(BlockSideEnum.North, 1, 2, BlockSideEnum.East, 1, 2, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); lineBlock.AddTerminalConnection(BlockSideEnum.North, 1, 3, BlockSideEnum.South, 1, 2, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); // East connections lineBlock.AddTerminalConnection(BlockSideEnum.East, 1, 3, BlockSideEnum.South, 1, 3, "This is a label text", "This should be a polyline", LineShapeTypeEnum.Line); // Act lineBlock.CreateDiagramObjects(diagram, 0, 0); if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(diagram).Export("c:/temp/diagram/test.geojson"); } // Assert diagram.DiagramObjects.Count(d => d.Style == "This should be a polyline").Should().Be(6); }
public Diagram Build(Guid nodeId, IRouteNetworkState routeNetworkQueryService, IConduitNetworkQueryService conduitNetworkEqueryService, IFiberNetworkQueryService fiberNetworkService, IConduitClosureRepository conduitClosureRepository) { _routeNetworkQueryService = routeNetworkQueryService; _conduitNetworkQueryService = conduitNetworkEqueryService; _traversalHelper = new TraversalHelper(_routeNetworkQueryService); DiagramBuilder builder = new DiagramBuilder(); double minWidth = 300; double offsetY = 0; ConduitClosureInfo conduitClosureInfo = null; if (conduitClosureRepository.CheckIfRouteNodeContainsConduitClosure(nodeId)) { conduitClosureInfo = conduitClosureRepository.GetConduitClosureInfoByRouteNodeId(nodeId); } // Add cables passing through var cableSegmentRels = fiberNetworkService.GetLineSegmentsRelatedToPointOfInterest(nodeId); offsetY += AddCablePassThroughBlock(builder, cableSegmentRels, offsetY, 300); // Add multi conduit passing through var conduitSegmentRels = conduitNetworkEqueryService.GetConduitSegmentsRelatedToPointOfInterest(nodeId); foreach (var conduitSegmentRel in conduitSegmentRels) { // pass by multi conduit if (conduitSegmentRel.RelationType == SegmentRelationTypeEnum.PassThrough && conduitSegmentRel.Segment.Line.LineKind == LineKindEnum.MultiConduit) { // check if outside conduit closure if (conduitClosureInfo != null && conduitClosureInfo.Sides.Exists(s => s.Ports.Exists(p => p.MultiConduitId == conduitSegmentRel.Segment.Line.Id))) { } else { offsetY += AddMultiConduitPassThroughBlock(builder, (ConduitSegmentInfo)conduitSegmentRel.Segment, minWidth, offsetY); } } } // Add conduit closure offsetY += 20; if (conduitClosureInfo != null) { offsetY += AddConduitClosureBlock(builder, conduitClosureInfo, minWidth, offsetY); } Diagram diagram = builder.CreateDiagram(); return(diagram); LineBlock junctionBlock = new LineBlock(30, 0); junctionBlock.MinWidth = 300; // Add first vest port with 5 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.Vest, 10, "Orange"); // Add second vest port with 7 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.Vest, 7, "Orange"); // Add fist east port with 10 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.East, 10, "Orange"); // Add second east port with 7 terminal AddMultiConduitPort(junctionBlock, BlockSideEnum.East, 7, "Orange"); // Add north big conduit port 1 with 3 terminal AddBigConduitPort(junctionBlock, BlockSideEnum.North, 3, "Red"); // Add north big conduit port 2 with 5 terminal AddBigConduitPort(junctionBlock, BlockSideEnum.North, 5, "Red"); junctionBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, null, "InnerConduitBlue", LineShapeTypeEnum.Polygon); junctionBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 2, BlockSideEnum.North, 1, 1, null, "InnerConduitBlue", LineShapeTypeEnum.Polygon); /* * * // Feeder calbe from central office * junctionBlock.AddConnection(BlockSideEnum.Vest, 2, 5, BlockSideEnum.North, 1, 1, "192", "CableInsideWell"); * * // Transit feeder cable to other flex points * junctionBlock.AddConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.North, 1, 2, "96", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 10, BlockSideEnum.North, 1, 3, "96", "CableInsideWell"); * * // Sp connections * junctionBlock.AddConnection(BlockSideEnum.East, 1, 1, BlockSideEnum.North, 2, 2, "24", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 2, BlockSideEnum.North, 2, 3, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 3, BlockSideEnum.North, 2, 4, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.East, 1, 4, BlockSideEnum.North, 2, 5, "48", "CableInsideWell"); * junctionBlock.AddConnection(BlockSideEnum.Vest, 2, 2, BlockSideEnum.North, 2, 1, "48", "CableInsideWell"); * */ builder.ContentObjects.Add(junctionBlock); junctionBlock.Measure(new Layout.Size()); ////////////////////////////////////////////////////////// /// well north label block LineBlock wellNorthLabelBlock = new LineBlock(30, junctionBlock.DesiredSize.Height, LineBlockTypeEnum.Simple); wellNorthLabelBlock.MinHeight = 30; // Add north port with 3 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.North, 3); // Add north port with 5 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.North, 5); // Add south port with 3 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.South, 3); // Add south port with 5 terminal AddBigConduitPort(wellNorthLabelBlock, BlockSideEnum.South, 5); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 1, BlockSideEnum.South, 1, 1, "GSS 1 (1-16)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 2, BlockSideEnum.South, 1, 2, "GSS 1 (1-8)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 1, 3, BlockSideEnum.South, 1, 3, "GSS 1 (9-16)", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 1, BlockSideEnum.South, 2, 1, "GPS 1", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 2, BlockSideEnum.South, 2, 2, "GPS 1", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 3, BlockSideEnum.South, 2, 3, "GPS 2", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 4, BlockSideEnum.South, 2, 4, "GPS 2", "CableOutsideWell"); wellNorthLabelBlock.AddTerminalConnection(BlockSideEnum.North, 2, 5, BlockSideEnum.South, 2, 5, "GPS 2 & 3", "CableOutsideWell"); builder.ContentObjects.Add(wellNorthLabelBlock); wellNorthLabelBlock.Measure(new Layout.Size()); ////////////////////////////////////////////////////////// /// well vest label block LineBlock wellVestLabelBlock = new LineBlock(0, 0, LineBlockTypeEnum.Simple); wellVestLabelBlock.MinWidth = 30; // Add vest port with 5 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.Vest, 5); // Add vest port with 7 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.Vest, 7); // Add east port with 5 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.East, 5); // Add east port with 7 terminal AddBigConduitPort(wellVestLabelBlock, BlockSideEnum.East, 7); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.East, 1, 4, "PF-4200", "CableOutsideWell"); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 2, 2, BlockSideEnum.East, 2, 2, "SP-5420", "CableOutsideWell"); wellVestLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 2, 5, BlockSideEnum.East, 2, 5, "CO-1010", "CableOutsideWell"); wellVestLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(wellVestLabelBlock); ////////////////////////////////////////////////////////// /// east label block LineBlock wellEastLabelBlock = new LineBlock(junctionBlock.DesiredSize.Width + 30, 0, LineBlockTypeEnum.Simple); wellEastLabelBlock.MinWidth = 30; wellEastLabelBlock.MinHeight = junctionBlock.DesiredSize.Height; // Add vest port with 10 terminal AddBigConduitPort(wellEastLabelBlock, BlockSideEnum.Vest, 10); // Add east port with 10 terminal AddBigConduitPort(wellEastLabelBlock, BlockSideEnum.East, 10); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 1, BlockSideEnum.East, 1, 1, "SP-5010", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 2, BlockSideEnum.East, 1, 2, "SP-5011", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 3, BlockSideEnum.East, 1, 3, "SP-5013", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 4, BlockSideEnum.East, 1, 4, "SP-6002", "CableOutsideWell"); wellEastLabelBlock.AddTerminalConnection(BlockSideEnum.Vest, 1, 10, BlockSideEnum.East, 1, 10, "FP-4203", "CableOutsideWell"); wellEastLabelBlock.Measure(new Layout.Size()); builder.ContentObjects.Add(wellEastLabelBlock); ////////////////////////////////////////////////////////// /// well north corner 1 LineBlock wellNorthCorner1 = new LineBlock(30, junctionBlock.DesiredSize.Height + wellNorthLabelBlock.DesiredSize.Height, LineBlockTypeEnum.Simple); wellNorthCorner1.MinHeight = 20; // Add south port with 3 terminal AddBigConduitPort(wellNorthCorner1, BlockSideEnum.South, 3); // Add east port with 3 terminal AddBigConduitPort(wellNorthCorner1, BlockSideEnum.East, 3, null, 1, 1); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 1, BlockSideEnum.East, 1, 1, "", "CableOutsideWell"); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 2, BlockSideEnum.East, 1, 2, "", "CableOutsideWell"); wellNorthCorner1.AddTerminalConnection(BlockSideEnum.South, 1, 3, BlockSideEnum.East, 1, 3, "", "CableOutsideWell"); // Set margin on east side to 0 wellNorthCorner1.SetSideMargin(BlockSideEnum.East, 0); //builder.ContentObjects.Add(wellNorthCorner1); Diagram sdiagram = builder.CreateDiagram(); return(diagram); }
public void LabelTest2() { Diagram diagram = new Diagram(); var lineBlock = new LineBlock() { MinHeight = 200, MinWidth = 300, Margin = 20 }; // Vest var vestPort1 = new BlockPort(BlockSideEnum.West); lineBlock.AddPort(vestPort1); AddTerminalsToPort(vestPort1, 3); var vestPort2 = new BlockPort(BlockSideEnum.West); lineBlock.AddPort(vestPort2); AddTerminalsToPort(vestPort2, 3); // East var eastPort1 = new BlockPort(BlockSideEnum.East); lineBlock.AddPort(eastPort1); AddTerminalsToPort(eastPort1, 3); var eastPort2 = new BlockPort(BlockSideEnum.East); lineBlock.AddPort(eastPort2); AddTerminalsToPort(eastPort2, 3); // North var northPort1 = new BlockPort(BlockSideEnum.North); lineBlock.AddPort(northPort1); AddTerminalsToPort(northPort1, 3); var northPort2 = new BlockPort(BlockSideEnum.North); lineBlock.AddPort(northPort2); AddTerminalsToPort(northPort2, 3); lineBlock.SetSideCenterAlignment(BlockSideEnum.North); // South var southPort1 = new BlockPort(BlockSideEnum.South, "SouthPortStyle1", "SouthPortLabel1"); lineBlock.AddPort(southPort1); AddTerminalsToPort(southPort1, 3); var southPort2 = new BlockPort(BlockSideEnum.South, "SouthPortStyle2", "SouthPortLabel2"); lineBlock.AddPort(southPort2); AddTerminalsToPort(southPort2, 3); //lineBlock.AddPortConnection(BlockSideEnum.Vest, 1, BlockSideEnum.East, 2); lineBlock.AddTerminalConnection(BlockSideEnum.West, 1, 1, BlockSideEnum.North, 2, 1, "Hest", "Cable", LineShapeTypeEnum.Polygon); var diagramObjects = lineBlock.CreateDiagramObjects(diagram, 0, 0); if (System.Environment.OSVersion.Platform.ToString() == "Win32NT") { new GeoJsonExporter(diagram).Export("c:/temp/diagram/test.geojson"); } }
private LineBlock CreateCableOutsideConduitPassThroughBlock() { // Create outer conduits var rootSpanInfo = _spanEquipmentViewModel.RootSpanDiagramInfo("OuterConduit"); var spanEquipmentBlock = new LineBlock() { MinWidth = _spanEquipmentAreaWidth, IsVisible = false, Style = rootSpanInfo.StyleName, Margin = _spanEquipmentViewModel.IsSingleSpan ? 0 : _spanEquipmentBlockMargin, DrawingOrder = 400 }; spanEquipmentBlock.SetReference(rootSpanInfo.IngoingSegmentId, "SpanSegment"); var fromPort = new BlockPort(BlockSideEnum.West, null, null, 0, -1, 0) { IsVisible = false, DrawingOrder = 420 }; spanEquipmentBlock.AddPort(fromPort); var toPort = new BlockPort(BlockSideEnum.East, null, null, 0, -1, 0) { IsVisible = false, DrawingOrder = 420 }; spanEquipmentBlock.AddPort(toPort); int terminalNo = 1; var fromTerminal = new BlockPortTerminal(fromPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "WestTerminalLabel", PointLabel = _spanEquipmentViewModel.GetIngoingRouteNodeName(rootSpanInfo.SegmentId), DrawingOrder = 520 }; fromTerminal.SetReference(rootSpanInfo.IngoingSegmentId, "SpanSegment"); var toTerminal = new BlockPortTerminal(toPort) { IsVisible = true, ShapeType = TerminalShapeTypeEnum.Point, PointStyle = "EastTerminalLabel", PointLabel = _spanEquipmentViewModel.GetOutgoingRouteNodeName(rootSpanInfo.SegmentId), DrawingOrder = 520 }; toTerminal.SetReference(rootSpanInfo.OutgoingSegmentId, "SpanSegment"); var fiberCableLineLabel = _spanEquipmentViewModel.Data.GetCableEquipmentLineLabel(_spanEquipmentViewModel.SpanEquipment.Id); var terminalConnection = spanEquipmentBlock.AddTerminalConnection(BlockSideEnum.West, 1, terminalNo, BlockSideEnum.East, 1, terminalNo, fiberCableLineLabel, "FiberCable", LineShapeTypeEnum.Line); terminalConnection.DrawingOrder = 600; terminalConnection.SetReference(rootSpanInfo.SegmentId, "SpanSegment"); return(spanEquipmentBlock); }