public override void Render(RenderingBuffer buffer) { Attr borderAttrs = Colors.Blend(Color.Black, Color.Gray); // Background buffer.FillRectangle(0, 1, ActualWidth, ActualHeight - 1, ' ', borderAttrs); // Первые width пикселей первой строки - прозрачные, но события мыши не пропускают // По нажатию на них мы закрываем всплывающее окно вручную buffer.SetOpacityRect(0, 0, parentItemWidth, 1, 2); // Оставшиеся пиксели первой строки - пропускают события мыши // И WindowsHost закроет всплывающее окно автоматически при нажатии или // перемещении нажатого курсора над этим местом buffer.SetOpacityRect(parentItemWidth, 0, ActualWidth - parentItemWidth, 1, 6); if (shadow) { buffer.SetOpacity(0, ActualHeight - 1, 2 + 4); buffer.SetOpacity(ActualWidth - 1, 1, 2 + 4); buffer.SetOpacityRect(ActualWidth - 1, 2, 1, ActualHeight - 2, 1 + 4); buffer.FillRectangle(ActualWidth - 1, 2, 1, ActualHeight - 2, UnicodeTable.FullBlock, borderAttrs); buffer.SetOpacityRect(1, ActualHeight - 1, ActualWidth - 1, 1, 3 + 4); buffer.FillRectangle(1, ActualHeight - 1, ActualWidth - 1, 1, UnicodeTable.UpperHalfBlock, Attr.NO_ATTRIBUTES); } RenderBorders(buffer, new Point(1, 1), shadow ? new Point(ActualWidth - 3, ActualHeight - 2) : new Point(ActualWidth - 2, ActualHeight - 1), true, borderAttrs); }
public override void Render(RenderingBuffer buffer) { Attr captionAttrs; if (Disabled) { captionAttrs = Colors.Blend(Color.Gray, Color.DarkGray); } else { if (HasFocus) { captionAttrs = Colors.Blend(Color.White, Color.DarkGreen); } else { captionAttrs = Colors.Blend(Color.Black, Color.DarkGreen); } } if (pressed) { buffer.FillRectangle(1, 0, ActualWidth - 1, ActualHeight - 1, ' ', captionAttrs); buffer.SetOpacityRect(0, 0, 1, ActualHeight, 3); buffer.FillRectangle(0, 0, 1, ActualHeight, ' ', captionAttrs); if (!string.IsNullOrEmpty(Caption)) { RenderString(Caption, buffer, 2 + 1 + (ActualWidth - 2 * 2 - Caption.Length) / 2, (ActualHeight - 1) / 2, ActualWidth - 2 * 2, captionAttrs); } buffer.SetOpacityRect(0, ActualHeight - 1, ActualWidth, 1, 3); buffer.FillRectangle(0, ActualHeight - 1, ActualWidth, 1, ' ', Attr.NO_ATTRIBUTES); } else { buffer.FillRectangle(0, 0, ActualWidth - 1, ActualHeight, ' ', captionAttrs); if (!string.IsNullOrEmpty(Caption)) { RenderString(Caption, buffer, 2 + (ActualWidth - 2 * 2 - Caption.Length) / 2, (ActualHeight - 1) / 2, ActualWidth - 2 * 2, captionAttrs); } buffer.SetPixel(0, ActualHeight - 1, ' '); buffer.SetOpacityRect(0, ActualHeight - 1, ActualWidth, 1, 3); buffer.FillRectangle(1, ActualHeight - 1, ActualWidth - 1, 1, UnicodeTable.UpperHalfBlock, Attr.NO_ATTRIBUTES); buffer.SetOpacityRect(ActualWidth - 1, 0, 1, ActualHeight, 3); buffer.FillRectangle(ActualWidth - 1, 1, 1, ActualHeight - 2, UnicodeTable.FullBlock, Attr.NO_ATTRIBUTES); buffer.SetPixel(ActualWidth - 1, 0, UnicodeTable.LowerHalfBlock); } }
public override void Render(RenderingBuffer buffer) { Attr captionAttrs; if (HasFocus) { captionAttrs = Colors.Blend(Color.White, Color.DarkGreen); } else { captionAttrs = Colors.Blend(Color.Black, Color.DarkGreen); } Attr buttonAttrs = captionAttrs; // if ( pressed ) // buttonAttrs = Colors.Blend(Color.Black, Color.DarkGreen); buffer.SetOpacityRect(0, 0, ActualWidth, ActualHeight, 3); buffer.SetPixel(0, 0, pressed ? '<' : '[', buttonAttrs); buffer.SetPixel(1, 0, Checked ? 'X' : ' ', buttonAttrs); buffer.SetPixel(2, 0, pressed ? '>' : ']', buttonAttrs); buffer.SetPixel(3, 0, ' ', buttonAttrs); if (null != caption) { RenderString(caption, buffer, 4, 0, ActualWidth - 4, captionAttrs); } }
public override void Render(RenderingBuffer buffer) { Attr borderAttrs = Colors.Blend(Color.Black, Color.DarkCyan); // Background buffer.FillRectangle(1, 1, this.ActualWidth - 1, this.ActualHeight - 1, ' ', borderAttrs); // First row and first column are transparent // Column is also transparent for mouse events buffer.SetOpacityRect(0, 0, ActualWidth, 1, 2); buffer.SetOpacityRect(0, 1, 1, ActualHeight - 1, 6); if (shadow) { buffer.SetOpacity(1, ActualHeight - 1, 2 + 4); buffer.SetOpacity(ActualWidth - 1, 0, 2 + 4); buffer.SetOpacityRect(ActualWidth - 1, 1, 1, ActualHeight - 1, 1 + 4); buffer.FillRectangle(ActualWidth - 1, 1, 1, ActualHeight - 1, UnicodeTable.FullBlock, borderAttrs); buffer.SetOpacityRect(2, ActualHeight - 1, ActualWidth - 2, 1, 3 + 4); buffer.FillRectangle(2, ActualHeight - 1, ActualWidth - 2, 1, UnicodeTable.UpperHalfBlock, Attr.NO_ATTRIBUTES); } }
public override void Render(RenderingBuffer buffer) { Attr borderAttrs = Colors.Blend(Color.Black, Color.DarkCyan); // устанавливаем прозрачными первую строку и первый столбец // для столбца дополнительно включена прозрачность для событий мыши // background buffer.FillRectangle(1, 1, this.ActualWidth - 1, this.ActualHeight - 1, ' ', borderAttrs); buffer.SetOpacityRect(0, 0, ActualWidth, 1, 2); buffer.SetOpacityRect(0, 1, 1, ActualHeight - 1, 6); if (shadow) { buffer.SetOpacity(1, ActualHeight - 1, 2 + 4); buffer.SetOpacity(ActualWidth - 1, 0, 2 + 4); buffer.SetOpacityRect(ActualWidth - 1, 1, 1, ActualHeight - 1, 1 + 4); buffer.FillRectangle(ActualWidth - 1, 1, 1, ActualHeight - 1, UnicodeTable.FullBlock, borderAttrs); buffer.SetOpacityRect(2, ActualHeight - 1, ActualWidth - 2, 1, 3 + 4); buffer.FillRectangle(2, ActualHeight - 1, ActualWidth - 2, 1, UnicodeTable.UpperHalfBlock, Attr.NO_ATTRIBUTES); } }
public override void Render(RenderingBuffer buffer) { Attr attr = Colors.Blend(Color.Black, Color.DarkYellow); buffer.FillRectangle(0, 0, ActualWidth, ActualHeight, ' ', attr); for (int x = 0; x < ActualWidth; ++x) { for (int y = 0; y < ActualHeight; ++y) { if (y == 0 && x < text.Length) { buffer.SetPixel(x, y, text[x], attr); } } } buffer.SetOpacityRect(0, 0, ActualWidth, ActualHeight, 3); }
public override void Render(RenderingBuffer buffer) { Attr attr = Colors.Blend(Color.DarkCyan, Color.DarkBlue); buffer.SetOpacityRect(0, 0, ActualWidth, ActualHeight, 2); if (horizontalScrollVisible) { buffer.SetOpacityRect(0, ActualHeight - 1, ActualWidth, 1, 0); buffer.SetPixel(0, ActualHeight - 1, UnicodeTable.ArrowLeft, attr); // ◄ // оставляем дополнительный пиксель справа, если одновременно видны оба скроллбара int rightOffset = verticalScrollVisible ? 1 : 0; if (ActualWidth > 2 + rightOffset) { buffer.FillRectangle(1, ActualHeight - 1, ActualWidth - (2 + rightOffset), 1, UnicodeTable.MediumShade, attr); // ▒ } if (ActualWidth > 1 + rightOffset) { buffer.SetPixel(ActualWidth - (1 + rightOffset), ActualHeight - 1, UnicodeTable.ArrowRight, attr); // ► } // определим, в каком месте находится ползунок if (ActualWidth > 3 + (verticalScrollVisible ? 1 : 0)) { int remainingWidth = ActualWidth - (verticalScrollVisible ? 1 : 0); int extraWidth = Content.RenderSize.Width - remainingWidth; int pages = extraWidth / (remainingWidth - 2 - 1); //Debugger.Log( 1, "", "pages: " + pages + "\n" ); int scrollerPos; if (pages == 0) { double posInDelta = (remainingWidth * 1.0 - 2 - 1) / extraWidth; //Debugger.Log( 1, "", "posInDelta: " + posInDelta + "\n" ); scrollerPos = ( int )Math.Round(posInDelta * deltaX); } else { double deltaInPos = (extraWidth * 1.0) / (remainingWidth - 2 - 1); //Debugger.Log( 1, "", "deltaX/( deltaInPos ): " + deltaX/( deltaInPos ) + "\n" ); scrollerPos = ( int )Math.Round(deltaX / (deltaInPos)); } buffer.SetPixel(1 + scrollerPos, ActualHeight - 1, UnicodeTable.BlackSquare, attr); // ■ } else if (ActualWidth == 3 + (verticalScrollVisible ? 1 : 0)) { buffer.SetPixel(1, ActualHeight - 1, UnicodeTable.BlackSquare, attr); // ■ } } if (verticalScrollVisible) { buffer.SetOpacityRect(ActualWidth - 1, 0, 1, ActualHeight, 0); buffer.SetPixel(ActualWidth - 1, 0, UnicodeTable.ArrowUp, attr); // ▲ // оставляем дополнительный пиксель снизу, если одновременно видны оба скроллбара int downOffset = horizontalScrollVisible ? 1 : 0; if (ActualHeight > 2 + downOffset) { buffer.FillRectangle(ActualWidth - 1, 1, 1, ActualHeight - (2 + downOffset), UnicodeTable.MediumShade, attr); // ▒ } if (ActualHeight > 1 + downOffset) { buffer.SetPixel(ActualWidth - 1, ActualHeight - (1 + downOffset), UnicodeTable.ArrowDown, attr); // ▼ } // определим, в каком месте находится ползунок if (ActualHeight > 3 + (horizontalScrollVisible ? 1 : 0)) { int remainingHeight = ActualHeight - (horizontalScrollVisible ? 1 : 0); int extraHeight = Content.RenderSize.Height - remainingHeight; int pages = extraHeight / (remainingHeight - 2 - 1); //Debugger.Log( 1, "", "pages: " + pages + "\n" ); int scrollerPos; if (pages == 0) { double posInDelta = (remainingHeight * 1.0 - 2 - 1) / extraHeight; //Debugger.Log( 1, "", "posInDelta: " + posInDelta + "\n" ); scrollerPos = ( int )Math.Round(posInDelta * deltaY); } else { double deltaInPos = (extraHeight * 1.0) / (remainingHeight - 2 - 1); //Debugger.Log( 1, "", "deltaY/( deltaInPos ): " + deltaY/( deltaInPos ) + "\n" ); scrollerPos = ( int )Math.Round(deltaY / (deltaInPos)); } buffer.SetPixel(ActualWidth - 1, 1 + scrollerPos, UnicodeTable.BlackSquare, attr); // ■ } else if (ActualHeight == 3 + (horizontalScrollVisible ? 1 : 0)) { buffer.SetPixel(ActualWidth - 1, 1, UnicodeTable.BlackSquare, attr); // ■ } } if (horizontalScrollVisible && verticalScrollVisible) { buffer.SetPixel(ActualWidth - 1, ActualHeight - 1, UnicodeTable.SingleFrameBottomRightCorner, attr); // ┘ } }
public override void Render(RenderingBuffer buffer) { Attr attr = Colors.Blend(Color.Black, Color.DarkGreen); // прозрачный фон для рамки buffer.SetOpacityRect(0, 0, ActualWidth, ActualHeight, 3); // полностью прозрачный внутри if (ActualWidth > 2 && ActualHeight > 2) { buffer.SetOpacityRect(1, 1, ActualWidth - 2, ActualHeight - 2, 2); } // title int titleRenderedWidth = 0; if (!string.IsNullOrEmpty(title)) { titleRenderedWidth = RenderString(title, buffer, 2, 0, ActualWidth - 4, attr); } // upper border for (int x = 0; x < ActualWidth; x++) { char?c = null; if (x == 0) { c = UnicodeTable.SingleFrameTopLeftCorner; } else if (x == ActualWidth - 1) { c = UnicodeTable.SingleFrameTopRightCorner; } else if (x == 1 || x == 2 + titleRenderedWidth) { c = ' '; } else if (x > 2 + titleRenderedWidth && x < ActualWidth - 1) { c = UnicodeTable.SingleFrameHorizontal; } if (c != null) { buffer.SetPixel(x, 0, c.Value, attr); } } // left border if (ActualHeight > 2) { buffer.FillRectangle(0, 1, 1, ActualHeight - 2, UnicodeTable.SingleFrameVertical, attr); } if (ActualHeight > 1) { buffer.SetPixel(0, ActualHeight - 1, UnicodeTable.SingleFrameBottomLeftCorner, attr); } // right border if (ActualWidth > 1) { if (ActualHeight > 2) { buffer.FillRectangle(ActualWidth - 1, 1, 1, ActualHeight - 2, UnicodeTable.SingleFrameVertical, attr); } if (ActualHeight > 1) { buffer.SetPixel(ActualWidth - 1, ActualHeight - 1, UnicodeTable.SingleFrameBottomRightCorner, attr); } } // bottom border if (ActualHeight > 1 && ActualWidth > 2) { buffer.FillRectangle(1, ActualHeight - 1, ActualWidth - 2, 1, UnicodeTable.SingleFrameHorizontal, attr); } }
public override void Render(RenderingBuffer buffer) { Attr attr = Colors.Blend(Color.Black, Color.DarkGreen); Attr inactiveAttr = Colors.Blend(Color.DarkGray, Color.DarkGreen); // Transparent background for borders buffer.SetOpacityRect(0, 0, ActualWidth, ActualHeight, 3); buffer.FillRectangle(0, 0, ActualWidth, ActualHeight, ' ', attr); // Transparent child content part if (ActualWidth > 2 && ActualHeight > 3) { buffer.SetOpacityRect(1, 3, ActualWidth - 2, ActualHeight - 4, 2); } renderBorderSafe(buffer, 0, 2, Math.Max(getTabHeaderWidth( ) - 1, ActualWidth - 1), ActualHeight - 1); // Start to render header buffer.FillRectangle(0, 0, ActualWidth, Math.Min(2, ActualHeight), ' ', attr); int x = 0; // Render tabs before active tab for (int tab = 0; tab < tabDefinitions.Count; x += TabDefinitions[tab++].Title.Length + 3) { var tabDefinition = TabDefinitions[tab]; if (tab <= activeTabIndex) { buffer.SetPixelSafe(x, 0, UnicodeTable.SingleFrameTopLeftCorner); buffer.SetPixelSafe(x, 1, UnicodeTable.SingleFrameVertical); } if (tab == activeTabIndex) { buffer.SetPixelSafe(x, 2, activeTabIndex == 0 ? UnicodeTable.SingleFrameVertical : UnicodeTable.SingleFrameBottomRightCorner); } for (int i = 0; i < tabDefinition.Title.Length + 2; i++) { buffer.SetPixelSafe(x + 1 + i, 0, UnicodeTable.SingleFrameHorizontal); if (tab == activeTabIndex) { buffer.SetPixelSafe(x + 1 + i, 2, ' '); } } buffer.RenderStringSafe(" " + tabDefinition.Title + " ", x + 1, 1, activeTabIndex == tab ? attr : inactiveAttr); if (tab >= activeTabIndex) { buffer.SetPixelSafe(x + tabDefinition.Title.Length + 3, 0, UnicodeTable.SingleFrameTopRightCorner); buffer.SetPixelSafe(x + tabDefinition.Title.Length + 3, 1, UnicodeTable.SingleFrameVertical); } if (tab == activeTabIndex) { buffer.SetPixelSafe(x + tabDefinition.Title.Length + 3, 2, activeTabIndex == tabDefinitions.Count - 1 && ActualWidth - 1 == x + tabDefinition.Title.Length + 3 ? UnicodeTable.SingleFrameVertical : UnicodeTable.SingleFrameBottomLeftCorner); } } }
public override void Render(RenderingBuffer buffer) { buffer.SetOpacityRect(0, 0, ActualWidth, ActualHeight, 2); }
public override void Render(RenderingBuffer buffer) { Attr borderAttrs = moving ? Colors.Blend(Color.Green, Color.Gray) : Colors.Blend(Color.White, Color.Gray); // background buffer.FillRectangle(0, 0, this.ActualWidth, this.ActualHeight, ' ', borderAttrs); // Borders RenderBorders(buffer, new Point(0, 0), new Point(ActualWidth - 3, ActualHeight - 2), this.moving || this.resizing, borderAttrs); // close button if (ActualWidth > 4) { buffer.SetPixel(2, 0, '['); buffer.SetPixel(3, 0, showClosingGlyph ? UnicodeTable.WindowClosePressedSymbol : UnicodeTable.WindowCloseSymbol, Colors.Blend(Color.Green, Color.Gray)); buffer.SetPixel(4, 0, ']'); } // shadows buffer.SetOpacity(0, ActualHeight - 1, 2 + 4); buffer.SetOpacity(1, ActualHeight - 1, 2 + 4); buffer.SetOpacity(ActualWidth - 1, 0, 2 + 4); buffer.SetOpacity(ActualWidth - 2, 0, 2 + 4); buffer.SetOpacityRect(2, ActualHeight - 1, ActualWidth - 2, 1, 1 + 4); buffer.SetOpacityRect(ActualWidth - 2, 1, 2, ActualHeight - 1, 1 + 4); // title if (!string.IsNullOrEmpty(Title)) { int titleStartX = 7; bool renderTitle = false; string renderTitleString = null; int availablePixelsCount = ActualWidth - titleStartX * 2; if (availablePixelsCount > 0) { renderTitle = true; if (Title.Length <= availablePixelsCount) { // dont truncate title titleStartX += (availablePixelsCount - Title.Length) / 2; renderTitleString = Title; } else { renderTitleString = Title.Substring(0, availablePixelsCount); if (renderTitleString.Length > 2) { renderTitleString = renderTitleString.Substring(0, renderTitleString.Length - 2) + ".."; } else { renderTitle = false; } } } if (renderTitle) { // assert !string.IsNullOrEmpty(renderingTitleString); buffer.SetPixel(titleStartX - 1, 0, ' ', borderAttrs); for (int i = 0; i < renderTitleString.Length; i++) { buffer.SetPixel(titleStartX + i, 0, renderTitleString[i], borderAttrs); } buffer.SetPixel(titleStartX + renderTitleString.Length, 0, ' ', borderAttrs); } } }