예제 #1
0
        /// <summary>
        /// Renders the dialog entries and add the results into the global list of
        /// rendered entries for a combination afterwards.
        /// </summary>
        /// <param name="view">The view.</param>
        /// <param name="activeDialog">The active dialog to render.</param>
        /// <param name="renderedEntries">The rendered entries for touch interaction where the
        /// rendering results where added to.</param>
        /// <param name="horizontalOffset">The horizontal offset (spacing/indentation)
        /// from the left for some kind of indentation.</param>
        /// <returns>
        ///   <c>true</c> if the entries were rendered successfully.
        /// </returns>
        protected virtual bool renderDialogEntries(IViewBoxModel view, Dialog activeDialog, ref List <RenderedDialogEntry> renderedEntries, int horizontalOffset = 0)
        {
            // var entries2render = activeDialog.GetEntryList().ToList<IDialogComponent>();

            // get only top-level entries
            List <IDialogComponent> entries2render = activeDialog.GetEntryList().FindAll(
                (entry) => { return(entry != null && !entry.IsInGroup()); }).ToList <IDialogComponent>();

            using (DialogEntryRenderer der = new DialogEntryRenderer())
            {
                renderEntries(view, entries2render, ref renderedEntries, horizontalOffset, der);
            }
            return(true);
        }
예제 #2
0
        /// <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
                    }
                }
            }
        }