Exemplo n.º 1
0
        internal void DisplayReportResults(DataMatrix data)
        {
            StatusMessage("Preparing view...");

            if (this.Report != null) {
                reportContent.Children.Clear();
                if (Report.Viewers.Count == 0 || Report.Viewers.Count == 1) {
                    IReportViewerSource viewerSource = null;
                    if (Report.Viewers.Count == 0) {
                        viewerSource = new TabularDataViewerSource();
                    } else {
                        viewerSource = Report.Viewers[0];
                    }
                    FrameworkElement control = viewerSource.ConstructView(Report, data, this);
                    reportContent.Children.Add(control);
                } else {
                    TabControl tab = new TabControl();
                    int count = 0;
                    foreach (IReportViewerSource tmpViewerSource in Report.Viewers) {
                        var viewerSource = tmpViewerSource; // need to capture a local because of the closure below
                        var tabItem = new TabItem { Header = viewerSource.Name };

                        // Create the first view straight away...
                        if (count == 0) {
                            var scroller = new ScrollViewer();
                            scroller.Content = viewerSource.ConstructView(Report, data, this);
                            tabItem.Content = scroller;
                        } else {
                            tabItem.RequestBringIntoView += new RequestBringIntoViewEventHandler((s, e) => {

                                if (tabItem.Content == null) {
                                    var scroller = new ScrollViewer();
                                    scroller.Content = viewerSource.ConstructView(Report, data, this);
                                    tabItem.Content = scroller;
                                }
                            });
                        }

                        tab.Items.Add(tabItem);
                        count++;
                    }
                    reportContent.Children.Add(tab);
                }
            }

            StatusMessage("{0} records retrieved.", data.Rows.Count);
        }
        internal void DisplayReportResults(DataMatrix data)
        {
            StatusMessage("Preparing view...");

            if (this.Report != null)
            {
                reportContent.Children.Clear();
                if (Report.Viewers.Count == 0 || Report.Viewers.Count == 1)
                {
                    IReportViewerSource viewerSource = null;
                    if (Report.Viewers.Count == 0)
                    {
                        viewerSource = new TabularDataViewerSource();
                    }
                    else
                    {
                        viewerSource = Report.Viewers[0];
                    }
                    FrameworkElement control = viewerSource.ConstructView(Report, data, this);
                    reportContent.Children.Add(control);
                }
                else
                {
                    TabControl tab   = new TabControl();
                    int        count = 0;
                    foreach (IReportViewerSource tmpViewerSource in Report.Viewers)
                    {
                        var viewerSource = tmpViewerSource; // need to capture a local because of the closure below
                        var tabItem      = new TabItem {
                            Header = viewerSource.Name
                        };

                        // Create the first view straight away...
                        if (count == 0)
                        {
                            var scroller = new ScrollViewer();
                            scroller.Content = viewerSource.ConstructView(Report, data, this);
                            tabItem.Content  = scroller;
                        }
                        else
                        {
                            tabItem.RequestBringIntoView += new RequestBringIntoViewEventHandler((s, e) => {
                                if (tabItem.Content == null)
                                {
                                    var scroller     = new ScrollViewer();
                                    scroller.Content = viewerSource.ConstructView(Report, data, this);
                                    tabItem.Content  = scroller;
                                }
                            });
                        }


                        tab.Items.Add(tabItem);
                        count++;
                    }
                    reportContent.Children.Add(tab);
                }
            }

            StatusMessage("{0} records retrieved.", data.Rows.Count);
        }