MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit

MaterialDesignFlowDocument style missing?

Abierto
#3,275 1 comentario 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

enhancement up-for-grabs
Lenguaje dominante
C#
Estrellas
16.3k
Forks
3.5k
Merge medio
1 d 22 h
PR fusionados (30 d)
8

Descripción

Is your feature request related to a problem? Please describe.
In order to get better performance compared to RichTextBox, I display a FlowDocumentScrollViewer with a binding to a FlowDocument of the ViewModel.

                <FlowDocumentScrollViewer Document="{Binding FlowDocument1}"
                                          Loaded="FlowDocumentScrollViewer_Loaded"
                                          Unloaded="FlowDocumentScrollViewer_Unloaded">
                </FlowDocumentScrollViewer>

Describe the solution you'd like
I'd like a simple:

                <FlowDocumentScrollViewer Document="{Binding FlowDocument1}"
                                          Loaded="FlowDocumentScrollViewer_Loaded"
                                          Unloaded="FlowDocumentScrollViewer_Unloaded"
                                          Style="{StaticResource MaterialDesignFlowDocument}">
                </FlowDocumentScrollViewer>

Describe alternatives you've considered
Here is the extension method dealing manually with style..

        public static void AppendLogEvents(this FlowDocument flowDocument, IList<LogEvent> logEvents)
        {
            var lastParagraph = flowDocument.Blocks.LastBlock as Paragraph;
            if (lastParagraph == null)
            {
                lastParagraph = new Paragraph();
                flowDocument.Blocks.Add(lastParagraph);
            }

            // Create a new style based on the MaterialDesignTextBoxBase style
            var spanStyle = new Style(typeof(Span));
            //spanStyle.BasedOn = (Style)Application.Current.Resources["MaterialDesignTextBoxBase"];
            //spanStyle.Setters.Add(new Setter(TextElement.FontSizeProperty, 7.0));

            var materialDesignSourceStyle = (Style)Application.Current.Resources["MaterialDesignWindow"]; //MaterialDesignTextBlock
            var materialDesignSourceStyle2 = (Style)Application.Current.Resources[typeof(MaterialDesignExtensions.Controls.MaterialWindow)];
            // Transfer all properties to spanStyle
            foreach (Setter setter in materialDesignSourceStyle.Setters.Union(materialDesignSourceStyle2.Setters))
                spanStyle.Setters.Add(new Setter(setter.Property, setter.Value));

            foreach (var logEvent in logEvents)
            {
                // Render log message with a template
                var renderedMessage = logEvent.RenderMessage();
                var span = new Span(new Run(renderedMessage));
                span.Style = spanStyle; // Apply the new style to the Span
                if (logEvent.Level == LogEventLevel.Warning)
                    span.Foreground = Brushes.Orange;
                else if (logEvent.Level == LogEventLevel.Error || logEvent.Level == LogEventLevel.Fatal)
                    span.Foreground = Brushes.Red;
                else { } //NTD, will let light/dark mode fontcolor
                lastParagraph.Inlines.Add(span);
                lastParagraph.Inlines.Add(Environment.NewLine);
            }
        }

Additional context
Add any other context or screenshots about the feature request here.

Any thing I missed?
Feel free to recommend another approach!

Regards,

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con el ejemplo de FlowDocumentScrollViewer e inspecciona los recursos existentes MaterialDesignWindow y MaterialDesignTextBoxBase que se utilizan en el método de extensión del issue. Determina dónde debe ubicarse un estilo de FlowDocumentScrollViewer y verifica que el ejemplo pueda hacer referencia a MaterialDesignFlowDocument manteniendo los colores de tema y el estilo de texto esperados.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
csharp
Área
design, desktop
Tipo de issue
Nueva funcionalidad
Dificultad
3/5
Tiempo estimado
1-2 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.