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);
            }
Beispiel #2
0
 /// <summary>
 /// Рисует исключительно себя - просто фон.
 /// </summary>
 /// <param name="buffer"></param>
 public override void Render(RenderingBuffer buffer)
 {
     for (int x = 0; x < ActualWidth; ++x)
     {
         for (int y = 0; y < ActualHeight; ++y)
         {
             buffer.SetPixel(x, y, ' ', Attr.BACKGROUND_BLUE |
                             Attr.BACKGROUND_GREEN | Attr.BACKGROUND_RED | Attr.FOREGROUND_BLUE |
                             Attr.FOREGROUND_GREEN | Attr.FOREGROUND_RED | Attr.FOREGROUND_INTENSITY);
             buffer.SetOpacity(x, y, 4);
         }
     }
 }
Beispiel #3
0
            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);
                }
            }
Beispiel #4
0
            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);
                }
            }
Beispiel #5
0
        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);
                }
            }
        }