private void UcLabelTextBox_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { try { try { var uctxt = ViewBaseCommon.FindLogicalChildList <UcTextBox>(sender as DependencyObject).FirstOrDefault(); uctxt.ApplyFormat(); DateTime dt = Convert.ToDateTime(uctxt.Text); 集計期間To = dt; } catch (Exception) { } var uctxt1 = ViewBaseCommon.FindLogicalChildList <UcTextBox>(sender as DependencyObject).FirstOrDefault(); uctxt1.ApplyFormat(); DateTime dt1 = Convert.ToDateTime(uctxt1.Text); 集計期間To = dt1; } catch (Exception) { } var yesno = MessageBox.Show("プレビューを表示しますか?", "確認", MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.Yes); if (yesno == MessageBoxResult.No) { return; } OnF8Key(sender, null); } }
protected override void OnClosed(EventArgs e) { base.OnClosed(e); this.Enabled = true; System.Windows.Input.Mouse.OverrideCursor = null; crviewToolbar = ViewBaseCommon.FindLogicalChildList <System.Windows.Controls.ToolBar>(this.CRVIEWER as System.Windows.DependencyObject).First(); crviewToolbar.Items.Clear(); if (btnPrintOut != null) { AppLogger.Instance.Debug("btnPrintOut is alive"); btnPrintOut.Click -= ReportPreviewPrintButton_Click; btnPrintOut = null; } if (btnClose != null) { AppLogger.Instance.Debug("btnClose is alive"); btnClose.Click -= closebtn_Click; btnClose = null; } if (cboxCustom != null) { AppLogger.Instance.Debug("cboxCustom is alive"); cboxCustom.Checked -= cbox_Checked; cboxCustom.UnChecked -= cbox_Unchecked; cboxCustom = null; } if (targetReportDocument != null) { AppLogger.Instance.Debug("targetReportDocument is alive"); targetReportDocument.Close(); targetReportDocument.Dispose(); targetReportDocument = null; } if (_ReportData is DataTable) { (_ReportData as DataTable).Dispose(); } else if (_ReportData is DataSet) { var ds = (_ReportData as DataSet); foreach (DataTable tbl in ds.Tables) { tbl.Dispose(); } ds.Tables.Clear(); ds.Dispose(); } _ReportData = null; }
private void UcLabelTextBox_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key == Key.Enter) { try { var uctxt = ViewBaseCommon.FindLogicalChildList <UcTextBox>(sender as DependencyObject).FirstOrDefault(); uctxt.ApplyFormat(); DateTime dt = Convert.ToDateTime(uctxt.Text); 集計期間To = dt; } catch (Exception) { } OnF8Key(sender, null); } }
//#region PDF関連 ///// <summary> ///// PDF生成&表示 ///// </summary> //public void PreviewPDF(int i部数 = 1) //{ // try // { // string docfnm = string.Empty; // DirectoryInfo dir = new DirectoryInfo(basedir); // if (!dir.Exists) // { // dir.Create(); // } // string outfnm = string.Format(@"{0}\{1}.pdf", dir.FullName, this.ReportName); // MergePDFs(printfiles.ToArray(), outfnm); // var prc = Process.Start(outfnm); // prc.WaitForExit(); // this.Close(); // } // catch (Exception ex) // { // throw ex; // } //} //public string GetPdfViewerPath() //{ // string path = String.Empty; // Microsoft.Win32.RegistryKey rKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\Acrobat.exe"); // if (rKey == null) rKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\AcroRd32.exe"); // try // { // // レジストリから読み込み // path = rKey.GetValue("").ToString(); // } // catch (System.Security.SecurityException) { throw; } //レジストリキーからの読み取りに必要なアクセス許可がユーザーにありません。 // catch (System.UnauthorizedAccessException) { throw; } //必要なレジストリ権限がユーザーにありません。 // //catch (System.ObjectDisposedException) { throw; } //破棄されたキーを参照した場合 // //catch (System.IO.IOException) { throw; } // catch // { // throw new ApplicationException("AdobeR AcrobatR もしくは ReaderR がインストールされていないため、PDFファイルの印刷ができません。"); // } // finally // { // rKey.Close(); // rKey = null; // } // return path; //} ///// <summary> ///// 複数PDFのマージ ///// </summary> ///// <param name="fileNames"></param> ///// <param name="outFile"></param> //public void MergePDFs(String[] fileNames, string outFile) //{ // try // { // int pageOffset = 0; // int f = 0; // Document document = null; // PdfCopy writer = null; // while (f < fileNames.Length) // { // PdfReader reader = new PdfReader(fileNames[f]); // reader.ConsolidateNamedDestinations(); // int n = reader.NumberOfPages; // pageOffset += n; // if (f == 0) // { // document = new Document(reader.GetPageSizeWithRotation(1)); // writer = new PdfCopy(document, new FileStream(outFile, FileMode.Create)); // document.Open(); // } // for (int i = 0; i < n; ) // { // ++i; // if (writer != null) // { // PdfImportedPage page = writer.GetImportedPage(reader, i); // writer.AddPage(page); // } // } // PRAcroForm form = reader.AcroForm; // if (form != null && writer != null) // { // writer.Close(); // } // f++; // } // if (document != null) // { // document.Close(); // document = null; // } // if (writer != null) // { // writer.Close(); // writer = null; // } // } // catch (Exception ex) // { // throw ex; // } //} ///// <summary> ///// PDFファイル作成(各請求書毎) ///// </summary> //public void PrintOutPDF() //{ // if (this.targetReportDocument == null) // { // throw new ReportException(CommonConst.ErrReportObjectNotReady, new NullReferenceException()); // } // try // { // DirectoryInfo dir = new DirectoryInfo(basedir); // if (!dir.Exists) // { // dir.Create(); // } // string filepath = string.Format(basedir + @"\wk_{0:D5}.pdf", this.printfiles.Count); // this.printfiles.Add(filepath); // targetReportDocument.ExportToDisk(ExportFormatType.PortableDocFormat, filepath); // targetReportDocument.Close(); // targetReportDocument.Dispose(); // targetReportDocument = null; // } // catch (Exception ex) // { // MessageBox.Show(ex.Message); // } //} //#endregion #region 印刷ボタン関連 private void SetupPrintButton(SAPBusinessObjects.WPF.Viewer.CrystalReportsViewer target) { crviewToolbar = ViewBaseCommon.FindLogicalChildList <System.Windows.Controls.ToolBar>(target as System.Windows.DependencyObject).First(); // ToolBarは必ず1つだけ存在する foreach (var item in crviewToolbar.Items) { originalPrintbtn = item as System.Windows.Controls.Button; if (originalPrintbtn == null) { continue; } if (originalPrintbtn.ToolTip == null) { continue; } if ((originalPrintbtn.ToolTip as string).Contains("印刷") || (originalPrintbtn.ToolTip as string).Contains("Print")) { originalPrintbtn.Visibility = System.Windows.Visibility.Collapsed; originalPrintbtn.IsEnabled = false; break; } else { originalPrintbtn = null; } } if (originalPrintbtn == null) { return; } // 置換用印刷ボタン btnPrintOut = new System.Windows.Controls.Button() { Height = originalPrintbtn.Height, Width = originalPrintbtn.Width, Content = originalPrintbtn.Content, Padding = originalPrintbtn.Padding, Margin = originalPrintbtn.Margin, //Foreground = obtn.Foreground, Background = originalPrintbtn.Background, ToolTip = "印刷します。", Language = originalPrintbtn.Language, Template = originalPrintbtn.Template, HorizontalAlignment = originalPrintbtn.HorizontalAlignment, HorizontalContentAlignment = originalPrintbtn.HorizontalContentAlignment, ClickMode = originalPrintbtn.ClickMode, Style = originalPrintbtn.Style, Tag = originalPrintbtn.Tag, }; crviewToolbar.Items.Insert(1, btnPrintOut); btnPrintOut.Click += ReportPreviewPrintButton_Click; // 閉じるボタン btnClose = new System.Windows.Controls.Button() { BorderBrush = System.Windows.Media.Brushes.Black, BorderThickness = new System.Windows.Thickness(1, 1, 1, 1), Content = " 閉じる ", Height = originalPrintbtn.Height, Padding = new System.Windows.Thickness(1, 1, 1, 1), Margin = marginCloseButton, //Foreground = obtn.Foreground, //Background = obtn.Background, ToolTip = "この画面を閉じます", Language = originalPrintbtn.Language, HorizontalAlignment = System.Windows.HorizontalAlignment.Center, HorizontalContentAlignment = System.Windows.HorizontalAlignment.Center, ClickMode = originalPrintbtn.ClickMode, }; btnClose.Click += closebtn_Click; if (posCloseButton < crviewToolbar.Items.Count) { crviewToolbar.Items.Insert(posCloseButton, btnClose); } else { crviewToolbar.Items.Add(btnClose); } return; }