public void SetRowSpan(object control, int value) { ArgumentNullException.ThrowIfNull(control); if (value < 1) { throw new ArgumentOutOfRangeException(nameof(value), value, string.Format(SR.InvalidArgument, nameof(value), value)); } if (IsStub) { _stub.SetRowSpan(control, value); } else { IArrangedElement element = LayoutEngine.CastToArrangedElement(control); if (element.Container is not null) { TableLayout.ClearCachedAssignments(TableLayout.GetContainerInfo(element.Container)); } TableLayout.GetLayoutInfo(element).RowSpan = value; LayoutTransaction.DoLayout(element.Container, element, PropertyNames.RowSpan); Debug.Assert(GetRowSpan(element) == value, "row span should equal to the value we set"); } }
protected override void WndProc(ref Message m) { bool handled = false; if (m.MessageId == WindowMessages.WM_CREATE) { if (LayoutEngine == null) { LayoutEngine = new DefaultLayoutEngine(); } if (!m_LayoutEngineInitialized) { LayoutEngine.Initialize(this); m_LayoutEngineInitialized = true; } } else if (m.MessageId == WindowMessages.WM_SIZE) { LayoutEngine.DoLayout(this, ChildControls); } if (!handled) { base.WndProc(ref m); } }
public void RenderRPLPage(RPLReport report, bool headerInBody, bool suppressOutlines) { string key = null; LayoutEngine layoutEngine = new LayoutEngine(report, headerInBody, this.m_streamDelegate); RPLPageContent rPLPageContent = report.RPLPaginatedPages[0]; this.m_excel.GenerateWorksheetName(rPLPageContent.PageLayout.PageName); RPLReportSection nextReportSection = rPLPageContent.GetNextReportSection(); this.AddBackgroundImage(rPLPageContent, nextReportSection); Reader.ReadReportMeasurements(report, layoutEngine, suppressOutlines, nextReportSection); try { layoutEngine.RenderPageToExcel(this.m_excel, key, this.m_sharedBorderCache, this.m_sharedImageCache); if (layoutEngine.ScalabilityCache != null) { this.m_totalScaleTimeMs += layoutEngine.ScalabilityCache.ScalabilityDurationMs; this.m_peakMemoryUsageKB = Math.Max(this.m_peakMemoryUsageKB, layoutEngine.ScalabilityCache.PeakMemoryUsageKBytes); } } finally { layoutEngine.Dispose(); } }
private void SetCellPosition(object control, int row, int column, bool rowSpecified, bool colSpecified) { if (IsStub) { if (colSpecified) { _stub.SetColumn(control, column); } if (rowSpecified) { _stub.SetRow(control, row); } } else { IArrangedElement element = LayoutEngine.CastToArrangedElement(control); if (element.Container != null) { TableLayout.ClearCachedAssignments(TableLayout.GetContainerInfo(element.Container)); } TableLayout.LayoutInfo layoutInfo = TableLayout.GetLayoutInfo(element); if (colSpecified) { layoutInfo.ColumnPosition = column; } if (rowSpecified) { layoutInfo.RowPosition = row; } LayoutTransaction.DoLayout(element.Container, element, PropertyNames.TableIndex); Debug.Assert(!colSpecified || GetColumn(element) == column, "column position shoule equal to what we set"); Debug.Assert(!rowSpecified || GetRow(element) == row, "row position shoule equal to what we set"); } }
public void LayoutEngine_InitLayout_ValidChild_Nop() { using var control = new FlowLayoutPanel(); LayoutEngine engine = control.LayoutEngine; engine.InitLayout(control, BoundsSpecified.All); }
public void LayoutEngine_Layout_ValidContainerBottomUp_Success() { using var control = new FlowLayoutPanel { FlowDirection = FlowDirection.BottomUp }; control.SuspendLayout(); using var child1 = new Control { Margin = Padding.Empty, Size = new Size(10, 20) }; using var child2 = new Control { Margin = new Padding(1, 2, 3, 4), Size = new Size(10, 20) }; using var largeChild = new Control { Margin = Padding.Empty, Size = new Size(100, 200) }; using var emptyChild = new Control { Size = Size.Empty }; using var emptyChildWithMargin = new Control { Margin = new Padding(1, 2, 3, 4), Size = Size.Empty }; using var child3 = new Control { Margin = Padding.Empty, Size = new Size(50, 100) }; using var child4 = new Control { Margin = Padding.Empty, Size = new Size(10, 20) }; control.Controls.Add(child1); control.Controls.Add(child2); control.Controls.Add(largeChild); control.Controls.Add(emptyChild); control.Controls.Add(emptyChildWithMargin); control.Controls.Add(child3); control.Controls.Add(child4); LayoutEngine engine = control.LayoutEngine; engine.Layout(control, null); Assert.Equal(new Rectangle(0, 80, 10, 20), child1.Bounds); Assert.Equal(new Rectangle(1, 56, 10, 20), child2.Bounds); Assert.Equal(new Rectangle(14, -100, 100, 200), largeChild.Bounds); Assert.Equal(new Rectangle(117, 97, 0, 0), emptyChild.Bounds); Assert.Equal(new Rectangle(115, 90, 0, 0), emptyChildWithMargin.Bounds); Assert.Equal(new Rectangle(120, 0, 50, 100), child3.Bounds); Assert.Equal(new Rectangle(170, 80, 10, 20), child4.Bounds); }
public DomainEditor(MainForm Parent, Domain Domain) { InitializeComponent(); this.Parent = Parent; MainLayout = new LayoutEngine(pnlMain) { ClearOnProcess = true, UpdateContainerSize = true, Margin = new Padding(0, 6, 0, 0), Padding = new Padding(6) }; NodeLayout = new LayoutEngine(pnlNodes) { ClearOnProcess = true, Margin = new Padding(0, 6, 0, 0), Padding = new Padding(6) }; // Fill comboboxes. cmbMobilityModel.Items.AddRange(Apex.EnumUtil.GetValuesCombo <Domain.MobilityModel>()); cmbDomainType.Items.AddRange(Apex.EnumUtil.GetValuesCombo <Domain.DomainType>()); cmbSchedulerType.Items.AddRange(Apex.EnumUtil.GetValuesCombo <Domain.SchedulerType>()); cmbWifiMode.Items.AddRange(Apex.EnumUtil.GetValuesCombo <Domain.WifiMode>()); cmbWifiStandard.Items.AddRange(Apex.EnumUtil.GetValuesCombo <Domain.WifiStandard>()); LoadDomain(Domain); }
public void TestStressCtor() { long start = Environment.TickCount; for (int i = 1; i <= Times; ++i) { LayoutEngine engine = new LayoutEngine(StressTestsHelper.CreateConfig()); // check results Assert.AreEqual(1, (int)engine.DefaultFontSize, "DefaultFontSize should be correct."); Assert.AreEqual(1, (int)engine.FontUnits, "FontUnits should be correct."); Assert.AreEqual(1, (int)engine.CharacterUnits, "CharacterUnits should be correct."); Assert.AreEqual(1, engine.MinimumPortWidth, "MinimumPortWidth should be correct."); Assert.AreEqual(1, engine.MinimumPortHeight, "MinimumPortHeight should be correct."); Assert.AreEqual(1, engine.MinimumLinkSpace, "MinimumLinkSpace should be correct."); Assert.AreEqual(1, engine.MinimumUnlinkedPortSpace, "MinimumUnlinkedPortSpace should be correct."); Assert.AreEqual(1, engine.MinimumNodeWidth, "MinimumNodeWidth should be correct."); Assert.AreEqual(1, engine.MinimumNodeHeight, "MinimumNodeHeight should be correct."); Assert.AreEqual(1, engine.MinimumSyntheticNodeWidth, "MinimumSyntheticNodeWidth should be correct."); Assert.AreEqual(1, engine.MinimumSyntheticNodeHeight, "FontUnits should be correct."); } Console.WriteLine("Total time : " + (Environment.TickCount - start) + "ms."); }
public void LayoutEngine_Layout_NullContainer_ThrowsArgumentNullException() { using var control = new FlowLayoutPanel(); LayoutEngine engine = control.LayoutEngine; Assert.Throws <ArgumentNullException>("container", () => engine.Layout(null, new LayoutEventArgs(control, "affectedProperty"))); }
public void LayoutEngine_InitLayout_NullChild_ThrowsArgumentNullException() { using var control = new FlowLayoutPanel(); LayoutEngine engine = control.LayoutEngine; Assert.Throws <ArgumentNullException>("child", () => engine.InitLayout(null, BoundsSpecified.All)); }
public void LayoutEngine_InitLayout_InvalidChild_ThrowsNotSupportedException() { using var control = new FlowLayoutPanel(); LayoutEngine engine = control.LayoutEngine; Assert.Throws <NotSupportedException>(() => engine.InitLayout("child", BoundsSpecified.All)); }
public void LayoutEngine_Layout_InvalidContainer_Nop() { using var control = new FlowLayoutPanel(); LayoutEngine engine = control.LayoutEngine; Assert.Throws <NotSupportedException>(() => engine.Layout("container", new LayoutEventArgs(control, "affectedProperty"))); }
public void TestComponentTreeStructure() { var layoutEngine = new LayoutEngine(); var componentTree = new ElementTree(null); var testData = new BasicTestData(componentTree); Assert.Contains(testData.ComponentRoot, componentTree.GetAllElements()); Assert.Contains(testData.ComponentTop, componentTree.GetAllElements()); Assert.Contains(testData.ComponentBottom, componentTree.GetAllElements()); Assert.Contains(testData.ComponentLeft, componentTree.GetAllElements()); Assert.Contains(testData.ComponentLeft1, componentTree.GetAllElements()); Assert.Contains(testData.ComponentLeft2, componentTree.GetAllElements()); Assert.Contains(testData.ComponentRight, componentTree.GetAllElements()); Assert.Contains(testData.ComponentRight1, componentTree.GetAllElements()); Assert.Contains(testData.ComponentRight2, componentTree.GetAllElements()); //Assert.Contains(testData.ComponentTop, componentTree.LeafComponents); //Assert.Contains(testData.ComponentLeft1, componentTree.LeafComponents); //Assert.Contains(testData.ComponentLeft2, componentTree.LeafComponents); //Assert.Contains(testData.ComponentRight1, componentTree.LeafComponents); //Assert.Contains(testData.ComponentRight2, componentTree.LeafComponents); //Assert.DoesNotContain(testData.ComponentRoot, componentTree.LeafComponents); //Assert.DoesNotContain(testData.ComponentBottom, componentTree.LeafComponents); //Assert.DoesNotContain(testData.ComponentLeft, componentTree.LeafComponents); //Assert.DoesNotContain(testData.ComponentRight, componentTree.LeafComponents); }
private void RunGraphViz(string dotFile, string imageFile, LayoutEngine layoutEngine, string outputFomat) { if (!Directory.Exists(_graphVizFolder)) { throw new DirectoryNotFoundException("Please install GraphViz and asign the installation folder!"); } var prop = new ProcessStartInfo { FileName = Path.Combine(_graphVizFolder, layoutEngine.ToString() + ".exe"), Arguments = "-" + outputFomat + " \"" + dotFile + "\" -o \"" + imageFile + "\"", WindowStyle = ProcessWindowStyle.Hidden, UseShellExecute = false, RedirectStandardOutput = true, RedirectStandardError = true, }; Process process = Process.Start(prop); string errorText = process.StandardError.ReadToEnd(); if (errorText != null && errorText.Contains("syntax error")) { throw new FormatException(errorText); } else if (errorText != null && errorText.Contains("Error:")) { throw new InvalidOperationException(errorText); } process.WaitForExit(120000); }
public void WhitespaceHandling1() { string test = "aaaa bbbb cccc"; XmlDocument doc = new XmlDocument(); doc.LoadXml("<doc>" + test + "</doc>"); Stylesheet s = new Stylesheet(); s.BindStyles(doc.NameTable); // Rectangle rc=new Rectangle(0, 0, 480, int.MaxValue); Rectangle rc = new Rectangle(0, 0, 110, int.MaxValue); using (IGraphics gr = new DummyGraphics()) { DrawContext ctx = new DrawContext(gr, Point.Empty, rc, rc, null, new DocumentType(), null); LayoutEngine layoutEngine = new LayoutEngine(s); layoutEngine.Reflow(ctx, doc.DocumentElement); SelectionPoint start = new TextSelectionPoint(doc.DocumentElement.FirstChild, 11); Console.WriteLine("Getting caret pos for {0}", start); Rectangle c = layoutEngine.GetCaretPosition(gr, start, CaretDirection.None); Console.WriteLine("Char {0} at {1}", start.ToString(), c); } }
public void SetRowSpan(object control, int value) { if (value < 1) { throw new ArgumentOutOfRangeException(nameof(value), string.Format(SR.InvalidArgument, "RowSpan", (value).ToString(CultureInfo.CurrentCulture))); } if (control == null) { throw new ArgumentNullException(nameof(control)); } if (IsStub) { _stub.SetRowSpan(control, value); } else { IArrangedElement element = LayoutEngine.CastToArrangedElement(control); // LayoutInfo.SetColumnSpan() throws ArgumentException if out of range. if (element.Container != null) { TableLayout.ClearCachedAssignments(TableLayout.GetContainerInfo(element.Container)); } TableLayout.GetLayoutInfo(element).RowSpan = value; LayoutTransaction.DoLayout(element.Container, element, PropertyNames.RowSpan); Debug.Assert(GetRowSpan(element) == value, "row span should equal to the value we set"); } }
public void CommentHitTestError() { string test = "<p><!--OddPage--></p>"; XmlDocument doc = new XmlDocument(); doc.LoadXml(test); Stylesheet s = new Stylesheet(); s.BindStyles(doc.NameTable); Rectangle rc = new Rectangle(0, 0, 500, int.MaxValue); using (IGraphics gr = new DummyGraphics()) { DrawContext ctx = new DrawContext(gr, Point.Empty, rc, rc, null, new DocumentType(), null); LayoutEngine layoutEngine = new LayoutEngine(s); layoutEngine.Reflow(ctx, doc.DocumentElement); Console.WriteLine("Bounds {0}", layoutEngine.BoundingRect); for (int x = 0; x < layoutEngine.BoundingRect.Width; x += 10) { HitTestInfo hti = layoutEngine.GetHitTestInfo(gr, new Point(x, 8)); SelectionPoint sp = hti.SelectionPoint; Console.WriteLine("Hit test at {0} = {1}", x, sp); } } }
public ToolStripPanelRow(ToolStripPanel parent) { this.bounds = Rectangle_.Empty; this.controls = new List <Control> (); this.layout_engine = new DefaultLayout(); this.parent = parent; }
protected override void OnLayout(LayoutEventArgs levent) { AdjustFormScrollbars(true); if (LayoutEngine.Layout(this, levent) && Parent != null) { Parent.PerformLayout(levent.AffectedControl, levent.AffectedProperty); } }
internal override Size GetPreferredSizeCore(Size proposedSize) { // Translating 0,0 from ClientSize to actual Size tells us how much space // is required for the borders. Size borderSize = SizeFromClientSize(Size.Empty); Size totalPadding = borderSize + Padding.Size; return(LayoutEngine.GetPreferredSize(this, proposedSize - totalPadding) + totalPadding); }
public void LayoutEngine_Layout_ValidContainerLeftToRight_Success() { using var control = new FlowLayoutPanel(); control.SuspendLayout(); using var child1 = new Control { Margin = Padding.Empty, Size = new Size(10, 20) }; using var child2 = new Control { Margin = new Padding(1, 2, 3, 4), Size = new Size(10, 20) }; using var largeChild = new Control { Margin = Padding.Empty, Size = new Size(100, 200) }; using var emptyChild = new Control { Size = Size.Empty }; using var emptyChildWithMargin = new Control { Margin = new Padding(1, 2, 3, 4), Size = Size.Empty }; using var child3 = new Control { Margin = Padding.Empty, Size = new Size(50, 100) }; using var child4 = new Control { Margin = Padding.Empty, Size = new Size(10, 20) }; control.Controls.Add(child1); control.Controls.Add(child2); control.Controls.Add(largeChild); control.Controls.Add(emptyChild); control.Controls.Add(emptyChildWithMargin); control.Controls.Add(child3); control.Controls.Add(child4); LayoutEngine engine = control.LayoutEngine; engine.Layout(control, null); Assert.Equal(new Rectangle(0, 0, 10, 20), child1.Bounds); Assert.Equal(new Rectangle(11, 2, 10, 20), child2.Bounds); Assert.Equal(new Rectangle(24, 0, 100, 200), largeChild.Bounds); Assert.Equal(new Rectangle(127, 3, 0, 0), emptyChild.Bounds); Assert.Equal(new Rectangle(131, 2, 0, 0), emptyChildWithMargin.Bounds); Assert.Equal(new Rectangle(134, 0, 50, 100), child3.Bounds); Assert.Equal(new Rectangle(184, 0, 10, 20), child4.Bounds); }
public Stream Generate(string dotSource, LayoutEngine engine, OutputFormat fmt) { var res = processRunner.Run(dotExe, new MemoryStream(Encoding.ASCII.GetBytes(dotSource)), engine.AsCmdLineParam(), fmt.AsCmdLineParam()); if (res.ExitCode!=0) throw new Exception( string.Format("Process [{4}] finished with non-zero code:[{0}] \nwhile generating data format: [{1}] using layout engine: [{2}]\nsrc={3}", res.ExitCode, fmt, engine, dotSource.Shorter(), dotExe)); return res.StdOut; }
public void RenderImage(List <string> dotText, string imageFile, LayoutEngine layoutEngine = LayoutEngine.dot, ImageFormat imageFormat = ImageFormat.png) { var tempFileCollection = new TempFileCollection(); var dotFile = InitializeRendering(dotText, tempFileCollection); this.RunGraphViz(dotFile, imageFile, layoutEngine, "T" + imageFormat.ToString()); tempFileCollection.Delete(); }
public void PerformLayout() { if (isPerformingLayout) { return; } isPerformingLayout = true; LayoutEngine.Layout(this); isPerformingLayout = false; }
public void BlockTest() { var block = SyntaxFactory.ParseExpression("() => { foo(); bar(); baz(); }") .DescendantNodes() .Single(n => n.Kind() == SyntaxKind.Block); var result = new LayoutEngine(LayoutOptions.Default).PerformLayout(block); Console.WriteLine(result.ToFullString().Replace("\t", @"\t")); }
public CompositPanel(LayoutEngine layoutEngine, IEnumerable <UserControl> childControls, string title, int headerHeight, UserControl headerControl) { InitializeComponent(); var containerPanel = new ContainerPanel(layoutEngine ?? new HorizontalLayoutEngine()) { Dock = DockStyle.Fill, Margin = new Padding(0) }; var tableLayoutPanel = new TableLayoutPanel { Dock = DockStyle.Fill }; tableLayoutPanel.ColumnCount = 2; foreach (var control in childControls) { containerPanel.Controls.Add(control); } if (title != null) { var titlePanel = new TextPanel { Text = title, Dock = DockStyle.Fill, ForeColor = Color.LightGray }; tableLayoutPanel.RowCount = 2; tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Absolute, headerHeight)); tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); if (headerControl != null) { tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Absolute, headerHeight)); tableLayoutPanel.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 100)); tableLayoutPanel.Controls.Add(headerControl, 0, 0); tableLayoutPanel.Controls.Add(titlePanel, 1, 0); } else { tableLayoutPanel.Controls.Add(titlePanel, 0, 0); tableLayoutPanel.SetColumnSpan(titlePanel, 2); } tableLayoutPanel.Controls.Add(containerPanel, 0, 1); } else { tableLayoutPanel.RowCount = 1; tableLayoutPanel.RowStyles.Add(new RowStyle(SizeType.Percent, 100)); tableLayoutPanel.Controls.Add(containerPanel, 0, 0); } tableLayoutPanel.SetColumnSpan(containerPanel, 2); Controls.Add(tableLayoutPanel); }
private static void WritePdf(IEnumerable <string> aozoraText, string output, Layout layout) { ILatinWordMetric latinMetric = new PdfLatinWordMetric(fontSetting.LatinFont, layout.FontSize); var engine = new LayoutEngine(layout, latinMetric); var printer = new PdfPrinter(output, layout, fontSetting); using (printer) { engine.SendTo(aozoraText, printer); } }
public Traces(MainForm Parent) { InitializeComponent(); this.Parent = Parent; Layout = new LayoutEngine(pnlMain, Apex.Layout.LayoutEngine.ContainerType.Panel) { ClearOnProcess = true, }; RefreshTraces(); }
public Plots(MainForm Parent) { InitializeComponent(); this.Parent = Parent; Layout = new LayoutEngine(pnlMain, Apex.Layout.LayoutEngine.ContainerType.Panel) { ClearOnProcess = true, Padding = new Padding(6) }; RefreshPlots(); }
public int GetRowSpan(object control) { if (IsStub) { return(_stub.GetRowSpan(control)); } else { IArrangedElement element = LayoutEngine.CastToArrangedElement(control); return(TableLayout.GetLayoutInfo(element).RowSpan); } }
public TraceEditor(Traces Parent, Trace Trace) { InitializeComponent(); this.Parent = Parent; Layout = new LayoutEngine(this) { ClearOnProcess = true, Padding = new Padding(6), Margin = new Padding(6) }; LoadTrace(Trace); }
private void BuildDocument() { if (_document != null) return; try { throw new NotImplementedException("ラテン対応してません"); ILatinWordMetric latinWordMetric; //TODO: 実装 var engine = new LayoutEngine(_layout, latinWordMetric); var aozoraText = ReadFromFile(); _document = engine.Compose(aozoraText); } catch (Exception ex) { System.Diagnostics.Debugger.Break(); throw ex; } }
/// <summary> /// Default constructor. /// </summary> public LayoutManager(ORMDiagram diagram, LayoutEngine engine) { myDiagram = diagram; myLayoutEngine = engine; }