Exemple #1
0
 public SavingWaitingWindows(ProgressListener pl)
 {
     InitializeComponent();
     pl.ValueChanged += (sender, value) =>
     {
         this.Dispatcher.Invoke(() =>
         {
             SetProgressBarValue(value);
         });
     };
     pl.ExceptionHappened += (sender, e) =>
     {
         this.Dispatcher.Invoke(() => this.Close());
     };
 }
Exemple #2
0
        private void BtnSavePDF_Click(object sender, RoutedEventArgs e)
        {
            if (!manager.HasAccess)
            {
                new TipDialog("需要认证", "该功能需要认证产品密钥才可使用,请在“关于设置”选项中认证产品密钥").ShowDialog();
                return;
            }
            if (this.spThumbnails.Children.Count == 0)
            {
                return;
            }
            savePdfFileDialog.InitialDirectory = Properties.Settings.Default.LastSavePath;
            if (savePdfFileDialog.ShowDialog(ZebraManager.Instance.MainWindow) == false)
            {
                return;
            }

            ProgressListener pl     = new ProgressListener();
            Thread           thread = new Thread(() =>
            {
                SavingWaitingWindows waiting;
                waiting = new SavingWaitingWindows(pl);
                waiting.ShowDialog();
            });

            thread.SetApartmentState(ApartmentState.STA);
            thread.Start();
            try
            {
                FileInfo fileInfo = new FileInfo(savePdfFileDialog.FileName);
                images.SaveAllToPDF(fileInfo, pl);
                SetThumbnailsCount(0);
                imgViewing.Source = null;
                Properties.Settings.Default.LastSavePath = fileInfo.DirectoryName;
            }
            catch (Exception ex)
            {
                new TipDialog("错误", ex.Message).ShowDialog();
                pl.ThrowException(new Exception("exit"));
            }
        }