Exemple #1
0
        //显示图表
        private void btnShowChart_Click(object sender, RoutedEventArgs e)
        {
            List <Model.TestInfoModel> selectedTestInfoList = testInfoModelList.FindAll(x => x.IsChecked == true);

            if (selectedTestInfoList.Count == 0)
            {
                MessageBox.Show("请至少选择一条信息查看!", "系统信息");
                return;
            }
            foreach (Model.TestInfoModel model in selectedTestInfoList)
            {
                ShowChartWindow chartWindow = new ShowChartWindow();
                chartWindow.WindowStartupLocation = WindowStartupLocation.Manual;
                chartWindow.DataModel             = model;
                chartWindow.Owner = Application.Current.MainWindow;
                chartWindow.Show();
            }
        }
        private void btnExport_Click(object sender, RoutedEventArgs e)
        {
            btnCancle.IsEnabled = true;
            btnExport.IsEnabled = false;
            double screenWidth = SystemParameters.PrimaryScreenWidth;
            //double value = 0;
            //UpdateProgressBarDelegate updatePbDelegate = new UpdateProgressBarDelegate(exportProgress.SetValue);
            //List<ShowChartWindow> windowList = new List<ShowChartWindow>();

            Task exportReportTask = new Task(() =>
            {
                for (int i = 0; i < TestInfoList.Count; i++)
                {
                    //quxiao
                    if (isExportReportCancled)
                    {
                        isExportReportCancled = false;
                        this.Dispatcher.Invoke(
                            new Action(() =>
                        {
                            btnExport.IsEnabled = true;
                            btnCancle.IsEnabled = false;
                        })
                            );
                        break;
                    }

                    //gengxin jindu
                    this.Dispatcher.Invoke(
                        new Action(() =>
                    {
                        tbCurrent.Text        = "正在导出:" + TestInfoList[i].Ath_Name;
                        tbProgress.Text       = (i + 1) + "/" + TestInfoList.Count;
                        exportProgress.Value += 1;

                        //diaoyong daochu
                        ShowChartWindow window = new ShowChartWindow();
                        window.DataModel       = TestInfoList[i];
                        window.Left            = screenWidth;
                        window.Visibility      = Visibility.Hidden;
                        window.IsExport        = true;
                        window.Show();
                        window.ExportReport(choosePath);
                        window.Close();
                        window = null;
                    }
                                   )
                        );
                }//for end
                this.Dispatcher.Invoke
                (
                    new Action(() =>
                {
                    MessageBox.Show("导出完成!", "系统信息");
                    this.Close();
                }
                               )
                );
            });

            exportReportTask.Start();
        }