Beispiel #1
0
        private void InternalDisplayPart(ref DisplayConsolePartInfo partInfo)
        {
            int dummy;                                                                 // TODO

            partInfo.width  = Math.Min(partInfo.width, (this.width - partInfo.col));   // TODO: this.width  must correction with Border+Scrollbar
            partInfo.height = Math.Min(partInfo.height, (this.height - partInfo.row)); // TODO: this.height must correction with Border+Scrollbar

            partInfo.row += this.row;
            partInfo.col += this.col;

            if (partInfo.style.background == WinColor.None)
            {
                partInfo.style.background = style.background;
            }

            if (partInfo.style.foreground == WinColor.None)
            {
                partInfo.style.foreground = style.foreground;
            }

            if (isRootWindow)
            {
                this.consoleWindows.DisplayPart(ref partInfo);
            }
            else if (parentWindow != null)
            {
                parentWindow.InternalDisplayPart(ref partInfo);                                // recursion: position&size correction to the root.
            }
        }
Beispiel #2
0
        private void InternalDisplay()
        {
            //var partInfo = DisplayConsolePartInfo.CreateFrom(this);
            var partInfo = new DisplayConsolePartInfo(this, GetStyle(this.styleIndex));

            InternalDisplayPart(ref partInfo);                                                          // Display window's IArea

            var orderedElements = GetDisplayOrderedElements();

            foreach (var element in orderedElements)
            {
                if (element is Window <IViewModel> childWindow)
                {
                    if (childWindow.visible)
                    {
                        //var partInfo2 = new DisplayConsolePartInfo(childWindow, GetStyle(childWindow.styleIndex));
                        var partInfo2 = DisplayConsolePartInfo.CreateFrom(childWindow);

                        InternalDisplayPart(ref partInfo2);                                              // Display window's IArea

                        childWindow.InternalDisplay();
                    }
                }
                else
                {
                    var partInfo3 = new DisplayConsolePartInfo(element, GetStyle(element.styleIndex));

                    InternalDisplayPart(ref partInfo3);
                }
            }
        }
Beispiel #3
0
        private void SetVirtualConsoleCursorPosition(ref DisplayConsolePartInfo partInfo)
        {
            var editElement = actualWindow.actualElement as TextEditElement;
            int relativeRow = 0;
            int relativeCol = 0;

            if (editElement != null)
            {
                var relativePosition = editElement.CursorPosition;

                relativeRow = relativePosition.row;
                relativeCol = relativePosition.col;
            }

            virtualConsole.actualCursorPosition.row = partInfo.row + relativeRow;
            virtualConsole.actualCursorPosition.col = partInfo.col + relativeCol;
        }
Beispiel #4
0
        //public static ElementDescriptionInfo? GetDescription(Type type)
        //{
        //  var attribute = type.GetTypeInfo().GetCustomAttribute<ElementDescriptionAttribute>();

        //  if (attribute == null)
        //  {
        //    return null;
        //  }
        //  else
        //  {
        //    return attribute.description;
        //  }
        //}

        internal void DisplayPart(ref DisplayConsolePartInfo partInfo)
        {
            if ((partInfo.width < 1) || (partInfo.height < 1))
            {
                return;                                                                           // there is no work to do
            }

            Debug.Assert(actualWindow != null);

            bool   isActualWindow  = ReferenceEquals(partInfo.region, actualWindow);
            bool   isActualElement = ReferenceEquals(partInfo.region, actualWindow.actualElement);
            bool   isActualItem    = isActualWindow || isActualElement;
            string displayText     = isActualItem ? partInfo.editText : partInfo.displayText;

            if (isActualElement)
            {
                SetVirtualConsoleCursorPosition(ref partInfo);
            }

            if (isActualItem)
            {
                var styleActual = styles[isActualWindow ? actualWindow.styleIndexActualWindow : actualWindow.styleIndexActualElement];

                if (styleActual.foreground != WinColor.None)
                {
                    partInfo.style.foreground = styleActual.foreground;
                }

                if (styleActual.background != WinColor.None)
                {
                    partInfo.style.background = styleActual.background;
                }
            }

            if (displayText == null)
            { // Only paint area by space
                var text = new string(' ', partInfo.width);

                for (int rowLoop = 0; rowLoop < partInfo.height; rowLoop++)
                {
                    this.virtualConsole.Write(partInfo.row + rowLoop, partInfo.col, text, ref partInfo.style);
                }

                Border?partInfoBorder = partInfo.border;

                if (isActualItem)
                {
                    Border?borderActual = partInfo.borderActual;

                    if (borderActual != null)
                    {
                        partInfoBorder = borderActual;
                    }
                }

                if (partInfoBorder != null)
                {
                    var border = (Border)partInfoBorder;

                    if (border.isVisible())
                    {
                        int lastCol     = partInfo.col + partInfo.width - 1;
                        int lastRow     = partInfo.row + partInfo.height - 1;
                        var borderStyle = styles[border.styleIndex];

                        if (borderStyle.foreground == WinColor.None)
                        {
                            borderStyle.foreground = partInfo.style.foreground;
                        }

                        if (borderStyle.background == WinColor.None)
                        {
                            borderStyle.background = partInfo.style.background;
                        }

                        if (border.topLeft != '\0')
                        {
                            this.virtualConsole.Write(partInfo.row, partInfo.col, border.topLeft.ToString(), ref borderStyle);
                        }

                        if (border.topRight != '\0')
                        {
                            this.virtualConsole.Write(partInfo.row, lastCol, border.topRight.ToString(), ref borderStyle);
                        }

                        if (border.bottomLeft != '\0')
                        {
                            this.virtualConsole.Write(lastRow, partInfo.col, border.bottomLeft.ToString(), ref borderStyle);
                        }

                        if (border.bottomRight != '\0')
                        {
                            this.virtualConsole.Write(lastRow, lastCol, border.bottomRight.ToString(), ref borderStyle);
                        }

                        if ((border.top != '\0') && (partInfo.width > 2))
                        {
                            var line = new string(border.top, partInfo.width - 2);

                            this.virtualConsole.Write(partInfo.row, partInfo.col + 1, line, ref borderStyle);
                        }

                        if ((border.bottom != '\0') && (partInfo.width > 2))
                        {
                            var line = new string(border.bottom, partInfo.width - 2);

                            this.virtualConsole.Write(lastRow, partInfo.col + 1, line, ref borderStyle);
                        }

                        if ((border.left != '\0') && (partInfo.height > 2))
                        {
                            for (int rowLoop = 1; rowLoop < partInfo.height - 1; rowLoop++)
                            {
                                this.virtualConsole.Write(partInfo.row + rowLoop, partInfo.col, border.left.ToString(), ref borderStyle);
                            }
                        }

                        if ((border.right != '\0') && (partInfo.height > 2))
                        {
                            for (int rowLoop = 1; rowLoop < partInfo.height - 1; rowLoop++)
                            {
                                this.virtualConsole.Write(partInfo.row + rowLoop, lastCol, border.right.ToString(), ref borderStyle);
                            }
                        }
                    }
                }

                if ((partInfo.scrollbars != null) && (partInfo.scrollbarsInfo != null) && (partInfo.width >= 4) && (partInfo.height >= 4))
                {
                    var scrollbars     = (Scrollbars)partInfo.scrollbars;
                    var scrollbarsInfo = partInfo.scrollbarsInfo;

                    int lastCol = partInfo.col + partInfo.width - 1;
                    int lastRow = partInfo.row + partInfo.height - 1;

                    var scrollbarStyle = styles[scrollbars.styleIndex];

                    if (scrollbarStyle.foreground == WinColor.None)
                    {
                        scrollbarStyle.foreground = partInfo.style.foreground;
                    }

                    if (scrollbarStyle.background == WinColor.None)
                    {
                        scrollbarStyle.background = partInfo.style.background;
                    }

                    if (scrollbarsInfo.leftArrowVisible && (scrollbars.horizontalLeft != '\0'))
                    {
                        // TODO
                    }

                    if (scrollbarsInfo.rightArrowVisible && (scrollbars.horizontalRight != '\0'))
                    {
                        // TODO
                    }

                    if (scrollbarsInfo.upArrowVisible && (scrollbars.verticalUp != '\0'))
                    {
                        // TODO
                    }

                    if (scrollbarsInfo.downArrowVisible && (scrollbars.verticalBottom != '\0'))
                    {
                        // TODO
                    }

                    if ((scrollbarsInfo.horizontalPosition != null) && (scrollbars.horizontalLine != '\0') && (partInfo.width >= 5))
                    {
                        // TODO
                    }

                    if ((scrollbarsInfo.verticalPosition != null) && (scrollbars.verticalLine != '\0') && (partInfo.height >= 5))
                    {
                        // TODO
                    }
                }
            }
            else if (partInfo.height == 1)
            { // Only one line
                this.virtualConsole.Write(partInfo.row, partInfo.col, FormattedDisplayText(displayText, partInfo.width), ref partInfo.style);
            }
            else
            { // multiple line
                var lines = displayText.Split('\n');

                for (int rowLoop = 0; rowLoop < partInfo.height; rowLoop++)
                {
                    string text = null;

                    if (rowLoop < lines.Length)
                    {
                        text = lines[rowLoop];
                    }

                    this.virtualConsole.Write(partInfo.row + rowLoop, partInfo.col, FormattedDisplayText(text, partInfo.width), ref partInfo.style);
                }
            }
        }