MaterialDesignInXAML / MaterialDesignInXAML/MaterialDesignInXamlToolkit

MaterialDesignFlowDocument style missing?

Đang mở
#3,275 1 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

enhancement up-for-grabs
Ngôn ngữ chính
C#
Star
16.3k
Fork
3.5k
Merge trung bình
1 ngày 22 giờ
Pull request đã merge (30 ngày)
8

Mô tả

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,

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Bắt đầu từ ví dụ FlowDocumentScrollViewer và kiểm tra các tài nguyên MaterialDesignWindow và MaterialDesignTextBoxBase hiện có được sử dụng trong phương thức mở rộng của issue. Xác định vị trí mà một kiểu FlowDocumentScrollViewer thuộc về và xác minh rằng ví dụ có thể tham chiếu đến MaterialDesignFlowDocument trong khi vẫn giữ nguyên các màu theme và kiểu văn bản như mong đợi.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
csharp
Lĩnh vực
design, desktop
Loại issue
Tính năng
Độ khó
3/5
Thời gian dự kiến
1-2 ngày
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Khá rõ ràng
Mức phù hợp với người mới
35/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.