Ejemplo n.º 1
0
        /*Builds the cached matrix consisting out of edges, borders, title and cursor.
         * Parts will be rendered new depending on changes on runtime.
         * If entry is NOT graphical, boders and edges will not be rendered.*/
        private bool[,] buildContentMatrix(IViewBoxModel view)
        {
            bool[,] boxMatrix = emptyMatrix;

            if (view != null && editFieldEntry != null && editFieldEntry.Title != null)
            {
                //Renders the field text, if needed with cursor
                bool[,] renderedText = buildTextMatrix(view);

                //Renders Box that will contain text. If Graphical, it gets borders and edges. If Not, it will have enough
                // space for an indenting and will get 1 extra pin line to seperate label and content
                boxMatrix = boxRenderer.RenderBoxMatrix(boxProperties.BoxDimensions, borderOrEdgeHaveChanged,
                                                        editFieldEntry.InputBox.IsGraphical, EditField_BoxProperties.BORDER_THICKNESS);

                //if editFieldEntry.Title is not empty, fill the box matrix with text matrix
                if (editFieldEntry.Title.Length > 0 || editFieldEntry.Status.HasFlag(DialogEntryStatus.Editing))
                {
                    boxMatrix = fillBoxMatrixWithTextMatrix(boxMatrix, renderedText);
                }

                lastView           = view;
                lastTitle          = Entry.Title;
                lastCursorPosition = editFieldEntry.GetCursorPosition();
                lastIsMinimized    = editFieldEntry.InputBox.IsMinimized;
            }
            return(boxMatrix);
        }
        /// <summary>
        /// Renders  a single line type edit field.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <returns></returns>
        private bool[,] renderSingleLineTitle(IViewBoxModel view, EditField_DialogEntry entry, int LineContentWidth, int LineCount, int CharsPerLine, Boolean needsUpdate)
        {
            bool[,] renderedText = emptyMatrix;

            if (view != null && Entry != null && entry != null && entry.Title != null)
            {
                int width = LineContentWidth - (CHAR_WIDTH * DOTAMOUNT);

                string titleSegment = "";

                string titleBackup = Entry.Title;

                titleSegment = getTitleSegmentOfSingleLine(width, Entry.Title, entry.GetCursorPosition(), CharsPerLine, needsUpdate);

                Entry.Title  = titleSegment;
                renderedText = renderDialogEntry(view);
                Entry.Title  = titleBackup;

                LastTitleSegment = titleSegment;
            }

            return(renderedText);
        }
        /// <summary>
        /// Renders the title matrix. Is the content of the edit field box.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <returns></returns>
        public bool[,] RenderTitleMatrix(IViewBoxModel view, EditField_DialogEntry entry, int LineContentWidth, int LineCount, int CharsPerLine, Boolean needsUpdate)
        {
            bool[,] renderedText = new bool[0, 0];

            if (view != null && entry != null)
            {
                if (!needsUpdate && cachedTitleMatrix != null)
                {
                    renderedText = (bool[, ])cachedTitleMatrix.Clone();
                }
                else
                {
                    Entry = entry;
                    /*Content of Box has smaller Space, so temporary view with smaller content box is needed.*/
                    IViewBoxModel smallerView = new DummyViewBox(view);
                    Rectangle     contentBox  = smallerView.ContentBox;
                    //+1 da sonst statt 105, 104 raus kommt. Benötigt wird %mod3
                    contentBox.Width       = LineContentWidth + 1;
                    smallerView.ContentBox = contentBox;

                    if (entry.Title.Length == 0)
                    {
                        //if content is empty
                        renderedText = new bool[CHAR_HEIGHT, LineContentWidth];
                    }
                    else if (entry.Title.Length * CHAR_WIDTH > LineContentWidth && (entry.InputBox.BoxHeightType == BoxHeightTypes.SingleLine || entry.InputBox.MinimizeType == MinimizeTypes.AlwaysMinimize))
                    {
                        //if editfield box is always minimized or single line type and bigger than a simple line
                        renderedText = renderSingleLineTitle(smallerView, entry, LineContentWidth, LineCount, CharsPerLine, needsUpdate);
                    }
                    else
                    {
                        //If through Minimization some text will not be shown until further action. show "TEXTPART...." instead
                        if (entry.InputBox.IsMinimized && (entry.InputBox.MinimizeType != MinimizeTypes.NeverMinimize) && entry.Title.Length > CharsPerLine)
                        {
                            //backup title, since entry is needed for rendering, but title will be displayed shortened
                            string titleBackup = entry.Title;

                            LastTitleSegment = entry.Title.Substring(0, (CharsPerLine - DOTAMOUNT)) + ALLDOTS;
                            entry.Title      = LastTitleSegment;
                            renderedText     = renderDialogEntry(smallerView);
                            entry.Title      = titleBackup;
                        }
                        //if edit field box will be a simple line: default rendering
                        else if (LineCount == 1)
                        {
                            renderedText = renderDialogEntry(smallerView);
                        }
                        //if edit field box will have more than one line
                        else
                        {
                            renderedText = renderMultiLineTitle(smallerView, entry, LineContentWidth, LineCount, CharsPerLine);
                        }
                    };

                    if (renderedText.GetLength(0) == 0 && renderedText.GetLength(1) == 0)
                    {
                        renderedText = new bool[4, LineContentWidth];
                    }

                    cachedTitleMatrix = (bool[, ])renderedText.Clone();
                }
                lastCursorPosition = entry.GetCursorPosition();
            }

            return(renderedText);
        }