public override Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size) { return new _Layout { Block = this, Inner = this.Inner.CreateLayout(null, SizeRange, out Size), Size = Size }; }
public World(Context InputContext, Theme Theme) { this._Arcs = new List<Arc>(); this._Nodes = new List<Node>(); this._Theme = Theme; InputContext.RegisterProbeSignalChange(this._ProbeSignalChange); InputContext.RegisterUpdate(this._Update); this._InputContext = InputContext; }
public Node(Context WorldInputContext, Disposable<Content> Content, Block Block, Point Position, Point Velocity) { this._Content = Content; this._Block = Block; this._Position = Position; this._Velocity = Velocity; this._Layout = this._Block.Object.CreateLayout(null, SizeRange, out this._Size); this._InputContext = new _NodeInputContext(this, WorldInputContext); this._Layout.Link(this._InputContext); }
public override Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size) { Compass<double> margin = this.Margin; Point sizepadding = new Point(margin.Left + margin.Right, margin.Up + margin.Down); Layout inner = this.Inner.CreateLayout(null, SizeRange.Translate(-sizepadding), out Size); Size += sizepadding; return new _Layout { Offset = new Point(margin.Left, margin.Up), Inner = inner }; }
public Node(Context WorldInputContext, Disposable<Content> Content, Block Block, Layout Layout, Point Size, Point Position, Point Velocity) { this._Content = Content; this._Block = Block; this._Position = Position; this._Velocity = Velocity; this._Layout = Layout; this._Size = Size; this._InputContext = new _NodeInputContext(this, WorldInputContext); this._Layout.Link(this._InputContext); }
public override Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size) { int cols = this.Columns; int rows = this.Rows; double sep = this.Seperator.Weight; Rectangle contentsizerange = SizeRange.Translate(-new Point(sep * (cols - 1), sep * (rows - 1))); // Create preliminary cell layouts to estimate sizes needed Point maxcellsize = contentsizerange.BottomRight; double[] widths = new double[cols]; double[] heights = new double[rows]; Layout[,] cells = new Layout[cols, rows]; for (int c = 0; c < cols; c++) { for (int r = 0; r < rows; r++) { Point size; cells[c, r] = this.Cells[c, r].CreateLayout(null, new Rectangle(new Point(widths[c], heights[r]), maxcellsize), out size); widths[c] = Math.Max(widths[c], size.X); heights[r] = Math.Max(heights[r], size.Y); } } _AdjustSizes(widths, contentsizerange.Left, contentsizerange.Right); _AdjustSizes(heights, contentsizerange.Top, contentsizerange.Bottom); // Adjust cells to have the new sizes for (int c = 0; c < cols; c++) { double width = widths[c]; for (int r = 0; r < rows; r++) { double height = heights[r]; cells[c, r] = this.Cells[c, r].CreateLayout(null, new Point(width, height)); } } // Determine offsets double totalwidth; double totalheight; double[] coloffsets = _GetOffsets(widths, sep, out totalwidth); double[] rowoffsets = _GetOffsets(heights, sep, out totalheight); Size = new Point(totalwidth, totalheight); return new _Layout { Block = this, Cells = cells, ColumnOffsets = coloffsets, RowOffsets = rowoffsets, Size = Size }; }
/// <summary> /// Creates a layout for this block with the preferred size within the given size range. /// </summary> public abstract Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size);
/// <summary> /// Creates a layout for this block with the given size. /// </summary> public Layout CreateLayout(Context Context, Point Size) { return this.CreateLayout(Context, new Rectangle(Size, Size), out Size); }
/// <summary> /// Links this layout to an input context and returns a remove handler to later unlink it. Only one layout for each block may be linked /// at one time. /// </summary> /// <remarks>The input context given is not restricted to the area of the layout, and may reference probes that are outside the layout. /// The input context will give positions relative to the layout with (0.0, 0.0) being the top-left corner with ascending /// positions going towards the bottom-right.</remarks> public virtual RemoveHandler Link(Context Context) { return null; }
public override Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size) { FlowBlockStyle style = this.Style; Axis minoraxis = style.MinorAxis; SizeRange.TopLeft = SizeRange.TopLeft.Shift(minoraxis); SizeRange.BottomRight = SizeRange.BottomRight.Shift(minoraxis); // Determine minor size double minor = 0.0; if (this.Fit == CompactFlowFit.Instance) { minor = SizeRange.Right; } else { if (SizeRange.Left == SizeRange.Right) { minor = SizeRange.Left; } else { double pmajor; minor = this._PickMinor(SizeRange.Left, SizeRange.Right, out pmajor); } } // Create lines List<_PlannedLine> lines; switch (style.WrapMode) { case FlowWrap.Greedy: lines = _GetLinesGreedy(this.Items, minor, SizeRange.Right, style); break; default: throw new NotImplementedException(); } // Create a space layout if lines can not be created if (lines == null) { Size = SizeRange.TopLeft; return SpaceBlock.Layout; } // Get minimum minor size needed to display all lines (this becomes the new minor size). double lminor = minor; minor = SizeRange.Left; foreach (_PlannedLine pl in lines) { double waste = lminor - pl.Length; minor = Math.Max(minor, pl.Length); } // Build layout lines double major; List<_Layout.Line> layoutlines = _BuildLayout(lines, this.Items, style, minor, SizeRange.Top, out major); // Create a space layout if the major size exceeds the size range if (major > SizeRange.Bottom + Layout.ErrorThreshold) { Size = SizeRange.TopLeft; return SpaceBlock.Layout; } // Create layout Size = new Point(minor, major).Shift(style.MinorAxis); return new _Layout { Block = this, Lines = layoutlines }; }
public TranslatedInputContext(Point Offset, Context Source) { this._Offset = Offset; this._Source = Source; }
public override RemoveHandler Link(Context Context) { // Update context and link information this._Context = Context; this.TextBlock._Linked = this; RemoveHandler rh = delegate { this._Context = null; this.TextBlock._Linked = null; }; // Probe signal change handler for selection rh += Context.RegisterProbeSignalChange(delegate(Probe Probe, ProbeSignal Signal, bool Value, ref bool Handled) { if (Signal == ProbeSignal.Primary && Value) { _SelectionInfo sel = this.TextBlock._Selection; throw new NotImplementedException(); } }); // Clean up context with remove handler rh += delegate { if (this._ReleaseProbe != null) { this._ReleaseProbe(); } if (this._RemoveUpdate != null) { this._RemoveUpdate(); } if (this._RemoveProbeMessage != null) { this._RemoveProbeMessage(); } }; return rh; }
public override Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size) { TextBlockStyle style = this.Style; Point cellsize = style.CellSize; int minwidth = (int)(SizeRange.Left / cellsize.X); int minheight = (int)(SizeRange.Top / cellsize.Y); // Calculate width, height and line indices List<int> lineindices = new List<int>(); int offset = 0; int width = minwidth; lineindices.Add(0); // Initial line, not explicitly indicated, but still deserves an index _Measure(style, this.Text, 0, lineindices, ref offset, ref width); int height = Math.Max(lineindices.Count, minheight); // Calculate actual size Size = new Point(width * cellsize.X, height * cellsize.Y); Size.X = Math.Min(Size.X, SizeRange.Right); Size.Y = Math.Min(Size.Y, SizeRange.Bottom); _Layout layout = new _Layout { TextBlock = this, Width = width, Height = height, LineIndices = lineindices }; return layout; }
public override RemoveHandler Link(Context Context) { return this.Inner.Link(Context); }
public override Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size) { Size = SizeRange.TopLeft; return _Layout.Instance; }
public override RemoveHandler Link(Context Context) { double iw = -this.Block.Border.Weight; return this.Inner.Link(Context.Translate(new Point(iw, iw))); }
public _NodeInputContext(Node Node, Context Parent) { this._Node = Node; this._Parent = Parent; }
public override Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size) { Point sizepadding = this.SizePadding; Layout inner = this.Inner.CreateLayout(null, SizeRange.Translate(-sizepadding), out Size); Size += sizepadding; return new _Layout { Block = this, Inner = inner, Size = Size }; }
public override RemoveHandler Link(Context Context) { return this.Inner.Link(Context.Translate(-this.Offset)); }
public override Layout CreateLayout(Context Context, Rectangle SizeRange, out Point Size) { return this.Inner.CreateLayout(Context, this.GetLimitedSizeRange(SizeRange), out Size); }
public override RemoveHandler Link(Context Context) { RemoveHandler rh = null; for (int c = 0; c < this.ColumnOffsets.Length; c++) { double coff = this.ColumnOffsets[c]; for (int r = 0; r < this.RowOffsets.Length; r++) { double roff = this.RowOffsets[r]; rh += this.Cells[c, r].Link(Context.Translate(new Point(-coff, -roff))); } } return rh; }