/// <summary> /// Renders the given entry list into the global list of rendered elements to be /// combined afterwards. /// </summary> /// <param name="view">The view.</param> /// <param name="entries2render">The entries to render.</param> /// <param name="renderedEntries">The rendered entries to add the rendering results to.</param> /// <param name="horizontalOffset">The horizontal offset to allow some indentation.</param> /// <param name="der">A renderer for entries, if they do not have their own..</param> private void renderEntries(IViewBoxModel view, List <IDialogComponent> entries2render, ref List <RenderedDialogEntry> renderedEntries, int horizontalOffset, DialogEntryRenderer der) { IViewBoxModel view4rendering = view; if (horizontalOffset != 0) { view4rendering = new DummyViewBox(view); // remove 3 pins on the right for scroll bars var cBox = view4rendering.ContentBox; cBox.Width -= 3; view4rendering.ContentBox = cBox; view4rendering.ContentBox = new Rectangle(view4rendering.ContentBox.X + horizontalOffset, view4rendering.ContentBox.Y, view4rendering.ContentBox.Width - horizontalOffset, view4rendering.ContentBox.Height); } foreach (var item in entries2render) { if (item is DialogEntry) { if (item is SelfRenderingDialogEntry) { renderedEntries.Add( new RenderedDialogEntry( item as DialogEntry, ((SelfRenderingDialogEntry)item).Renderer.RenderMatrix(view4rendering, item)) { HorizontalOffset = horizontalOffset }); } else { renderedEntries.Add(new RenderedDialogEntry(item as DialogEntry, der.RenderMatrix(view4rendering, item)) { HorizontalOffset = horizontalOffset }); } if (((DialogEntry)item).Status.HasFlag(DialogEntryStatus.Selected)) // selection marking { renderedEntries.Add(getSolidDividerEntry(view.ContentBox.Width)); } else { renderedEntries.Add(onePinSpacerEntry); // spacing } // Child handling if (((DialogEntry)item).Type == DialogEntryType.Group) { renderedEntries.Add(onePinSpacerEntry); // spacing if (!Properties.HasFlag(DialogRenderingProperties.HideDividers)) { renderedEntries.Add(getDividerEntry(view.ContentBox.Width)); // separation renderedEntries.Add(onePinSpacerEntry); // spacing } var children = ((DialogEntry)item).GetChildEntryList(); if (children != null && children.Count > 0) { // call Dialog entry rendering recursive with increased indentation renderEntries(view, children, ref renderedEntries, horizontalOffset + GroupIndentation, der); } } if (!Properties.HasFlag(DialogRenderingProperties.HideDividers)) { renderedEntries.Add(getDividerEntry(view.ContentBox.Width)); // separation renderedEntries.Add(onePinSpacerEntry); // spacing } } } }
protected virtual bool[,] renderDialogEntry(IViewBoxModel view) { int i = 0; while (_isRendering && i++ < 10) { Thread.Sleep(5); } if (i >= 10) { return(cachedResult); } try { bool[,] m = cachedResult; lock (_synckLock) { _isRendering = true; if (HasChanged && Entry != null && view != null && view.ContentBox.Width > 0) // renew rendering result { bool[,] icon = emptyMatrix; // get icon if (IconRenderer != null) { icon = IconRenderer.RenderMatrix(view, Entry); } // calculate the space for the text to start int padding_left = (icon != null && icon.GetLength(1) > 0) ? icon.GetLength(1) + IconTextSpace : 0; // adapt the view IViewBoxModel view2 = new DummyViewBox(view); if (padding_left > 0) { var contentBox = view2.ContentBox; contentBox.Width = contentBox.Width - padding_left; view2.ContentBox = contentBox; } bool[,] text = emptyMatrix; if (BrailleRenderer != null) { string title = Entry.Title; if (Entry.Type == DialogEntryType.Group) { title = ll.GetTrans("grp.title.wrap", title); } text = BrailleRenderer.RenderMatrix(view2, title); } m = combineMatrices(icon, text, view); // TODO: set content dimensions? } cachedResult = m; HasChanged = false; } return(m); } finally { _isRendering = false; } }
/// <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); }