/// <summary> /// 確認メッセージダイアログを表示する /// </summary> /// <param name="message">表示するメッセージ内容を指定</param> /// <returns></returns> private MessageBoxResult ShowMessageDlg(string message) { this.Grid_Opa.Visibility = Visibility.Visible; OKCancelDlg re = new OKCancelDlg(message); re.WindowStartupLocation = WindowStartupLocation.CenterScreen; re.ShowDialog(); this.Grid_Opa.Visibility = Visibility.Collapsed; return(re.result); }
private void button_LoadDekidaka_Press(object sender) { if (Main == null) { return; } this.Topmost = false; var dlg = new CommonOpenFileDialog("出来高ファイル選択"); // フォルダ選択モード。 dlg.IsFolderPicker = false; //if (pwContext.pwBackFolderPath != "") //{ // dlg.InitialDirectory = pwContext.pwBackFolderPath; //} var ret = dlg.ShowDialog(); if (ret == CommonFileDialogResult.Ok) { //確認ダイアログを表示 string message = "出来高を読み込んで末尾に追加します。\nよろしいですか?"; OKCancelDlg re = new OKCancelDlg(message); re.WindowStartupLocation = WindowStartupLocation.CenterScreen; re.ShowDialog(); if (re.result == MessageBoxResult.Cancel) { this.Topmost = true; return; } Main.Load_Data(dlg.FileName); Main.SaveTempData(); } this.Topmost = true; }
private void Button_Print_Press(object sender) { //確認ダイアログで枚数を確認させる string message = TagContext.iQuantity.ToString() + "入を" + TagContext.iCopyCount.ToString() + "枚印刷します。"; OKCancelDlg re = new OKCancelDlg(message); re.WindowStartupLocation = WindowStartupLocation.CenterScreen; re.ShowDialog(); //返事がキャンセルならなにもせず戻る if (re.result == MessageBoxResult.Cancel) { return; } StateWindow StateW = new StateWindow("印刷データ作成中"); StateW.WindowStartupLocation = WindowStartupLocation.CenterScreen; StateW.Topmost = true; StateW.Show(); //タグを設定する PrintingTag Pt = new PrintingTag(DData); Pt.TagSetting(TagContext.iQuantity, TagContext.iCopyCount); //印刷する Pt.Print(); StateW.Close(); StateW = null; this.Close(); }
public TagEdit(Dekidaka_Data Dekidaka) { if (Dekidaka.strContentsOfWork == null || Dekidaka.strCommodity == null) { OKCancelDlg re = new OKCancelDlg("品名か作業内容に入力がありません"); re.WindowStartupLocation = WindowStartupLocation.CenterScreen; re.ShowDialog(); TagContext.strCow = ""; TagContext.strCommodity = ""; } else { TagContext.strCow = Dekidaka.strContentsOfWork.Split('(')[0]; TagContext.strCommodity = Dekidaka.strCommodity; } TagContext.strArea = Dekidaka.strProductionArea + (Dekidaka.strProductionArea != "" && Dekidaka.strProductionArea != null ? "産 " : " "); TagContext.iQuantity = Dekidaka.iaOutputQuantity[0]; TagContext.strSize = Dekidaka.strSize; TagContext.iCopyCount = 1; DData = Dekidaka; //tag = new Tag_Control(stryArea, strComodity, CoW, iQuantity); InitializeComponent(); DataContext = TagContext; //this.RootGrid.Children.Add(tag); }
public void TagSetting(int Quantity, int number) { if (number > 1) { iNumberCopies = number; } //ドキュメントを実体化する fixedDoc = new FixedDocument(); //関連オブジェクトを作成 PageContent pageContent; FixedPage fixedPage; Tag_Control tc; if (Dekidaka.strContentsOfWork == null || Dekidaka.strCommodity == null) { OKCancelDlg re = new OKCancelDlg("品名か作業内容に入力がありません"); re.WindowStartupLocation = WindowStartupLocation.CenterScreen; re.ShowDialog(); return; } //出来高内容 string CoW = Dekidaka.strContentsOfWork.Split('(')[0]; string stryArea = Dekidaka.strProductionArea + (Dekidaka.strProductionArea != "" && Dekidaka.strProductionArea != null ? "産 " : " "); string strComodity = Dekidaka.strCommodity; int iQuantity = Quantity; string strSize = Dekidaka.strSize; //関連オブジェクトを作成 pageContent = new PageContent(); fixedPage = new FixedPage(); //印刷内容を作成する tc = new Tag_Control(stryArea, strComodity, CoW, iQuantity, strSize); tc.TagContext.IsDialog = false; //印刷可能範囲に合わせてViewboxで拡大縮小する tc.ViewBox.Height = PageWidth; tc.ViewBox.Width = PageHeight; //ページに追加する fixedPage.Children.Add(tc); //ページの大きさを設定し直す fixedPage.Arrange(new Rect(0, 0, PageWidth, PageHeight)); fixedPage.UpdateLayout(); fixedPage.Width = PageHeight; fixedPage.Height = PageWidth; //ページをコンテントに追加する ((IAddChild)pageContent).AddChild(fixedPage); //コンテントをドキュメントに追加する fixedDoc.Pages.Add(pageContent); Pt.PageOrientation = System.Printing.PageOrientation.Landscape; Pt.CopyCount = iNumberCopies; }
/// <summary> /// テロップのドキュメントを設定して作成する /// </summary> public void TelopSetting() { //ドキュメントを実体化する fixedDoc = new FixedDocument(); //横向き印刷設定 bool LandScape = Settings.PrintLandscape; // if (Dekidaka.strContentsOfWork == null || Dekidaka.strCommodity == null) { OKCancelDlg re = new OKCancelDlg("品名か作業内容に入力がありません"); re.WindowStartupLocation = WindowStartupLocation.CenterScreen; re.ShowDialog(); return; } //複数日分の出来高の場合 if (Dekidaka.bMulti) { //関連オブジェクトの定義 PageContent[] pageContent = new PageContent[6]; FixedPage[] fixedPage = new FixedPage[6]; Telop_Control[] tc = new Telop_Control[6]; //ページ数のカウント int TpCount = 0; int[] ShipmentBlock = new int[6]; int Blockcount = 0; string Blockstr = ""; //日付入力を調べてブロックを分ける for (int i = 0; i < 6; i++) { if (Dekidaka.straShipment[i] != "" && Dekidaka.straShipment[i] != null && Dekidaka.straShipment[i] != Blockstr) { Blockstr = Dekidaka.straShipment[i]; ShipmentBlock[Blockcount] = i; Blockcount++; } } //日付有効なのに日付項目が未記入の時 if (Blockcount == 0) { OKCancelDlg re = new OKCancelDlg("日付項目無しで出力しますか?"); re.WindowStartupLocation = WindowStartupLocation.CenterScreen; re.ShowDialog(); if (re.result == MessageBoxResult.Cancel) { return; } //キャンセルじゃなければ印刷用の設定 ShipmentBlock[0] = 0; Blockcount = 1; } //出来高データの出来高を調べてデータを作成する for (int i = 0; i < Blockcount; i++) { if (Dekidaka.iaOutputNumber[ShipmentBlock[i]] != 0) { int outputrows = 1; if (i < Blockcount - 1) { outputrows = ShipmentBlock[i + 1] - ShipmentBlock[i]; } else { outputrows = 6 - ShipmentBlock[i]; } string strDayArea; string strSubtotal = ""; DateTime dt; bool IsDateTime = DateTime.TryParse(Dekidaka.straShipment[ShipmentBlock[i]], out dt); //出来高文字列を作成 string Output = ""; int OutputNum = 0; int iSubtotal = 0; if (LandScape) { for (int Count = ShipmentBlock[i]; Count < ShipmentBlock[i] + outputrows; Count++) { //出来高が3項目なら改行をして連結する if (Count % 3 == 2) { if (Dekidaka.iaOutputNumber[Count] != 0 && Dekidaka.iaOutputQuantity[Count] != 0) { Output = Output + Dekidaka.iaOutputQuantity[Count].ToString() + "×" + Dekidaka.iaOutputNumber[Count].ToString() + "\n"; OutputNum++; } } else { //それ以外ならカンマでつなげる if (Dekidaka.iaOutputNumber[Count] != 0 && Dekidaka.iaOutputQuantity[Count] != 0) { Output = Output + Dekidaka.iaOutputQuantity[Count].ToString() + "×" + Dekidaka.iaOutputNumber[Count].ToString() + ", "; OutputNum++; } } iSubtotal = iSubtotal + Dekidaka.iaOutputQuantity[Count] * Dekidaka.iaOutputNumber[Count]; } //産地日付に計も表示 strDayArea = Dekidaka.strProductionArea + (Dekidaka.strProductionArea != "" && Dekidaka.strProductionArea != null ? "産 " : " ") + Dekidaka.straShipment[ShipmentBlock[i]] + (IsDateTime ? "分" : "") + " 計" + iSubtotal; } else { for (int j = 0; j < outputrows; j++) { if (Dekidaka.iaOutputNumber[ShipmentBlock[i] + j] != 0) { Output = Output + string.Format("{0}×{1}\n", Dekidaka.iaOutputQuantity[ShipmentBlock[i] + j], Dekidaka.iaOutputNumber[ShipmentBlock[i] + j]); } iSubtotal = iSubtotal + Dekidaka.iaOutputQuantity[ShipmentBlock[i] + j] * Dekidaka.iaOutputNumber[ShipmentBlock[i] + j]; } //産地日付と計を設定 strDayArea = Dekidaka.strProductionArea + (Dekidaka.strProductionArea != "" && Dekidaka.strProductionArea != null ? "産\n" : "") + Dekidaka.straShipment[ShipmentBlock[i]] + (IsDateTime ? "分" : ""); strSubtotal = "計" + iSubtotal.ToString(); } //中身があれば最後の改行かカンマを削除 if (Output != "") { //最後の改行もしくはカンマを除去する if (Output.Substring(Output.Count() - 1, 1) == "\n") { Output = Output.Substring(0, Output.Count() - 1); //"\n"1文字を除去 } else { Output = Output.Substring(0, Output.Count() - 2); //", "2文字を除去 } } //ページとコンテントを初期化 fixedPage[TpCount] = new FixedPage(); pageContent[TpCount] = new PageContent(); //作業内容文字列を作成 string CoW = ""; if (LandScape) { CoW = Dekidaka.strCommodity + " " + (Dekidaka.strSize == "" || Dekidaka.strSize == null ? "" : Dekidaka.strSize + ", ") + Dekidaka.strContentsOfWork.Split('(')[0]; } else { CoW = Dekidaka.strCommodity + "\n" + (Dekidaka.strSize == "" || Dekidaka.strSize == null ? "" : Dekidaka.strSize + ", ") + Dekidaka.strContentsOfWork.Split('(')[0]; } //印刷内容を作成する tc[TpCount] = new Telop_Control(Dekidaka.strCustomar, CoW, Output, strDayArea, strSubtotal); //印刷可能範囲に合わせてViewboxで拡大縮小する if (LandScape) { tc[TpCount].ViewBox.Height = PageWidth; tc[TpCount].ViewBox.Width = PageHeight; } else { tc[TpCount].ViewBox.Height = PageHeight; tc[TpCount].ViewBox.Width = PageWidth; } //ページに追加する fixedPage[TpCount].Children.Add(tc[TpCount]); //fixedPage[TpCount].Arrange(new Rect(0, 0, PageHeight, PageWidth)); //ページの大きさを設定し直す if (LandScape) { //fixedPage[TpCount].Arrange(new Rect(0, 0, PageWidth, PageHeight)); //これ付けると最後のページ以外が空白になる、なぜだ? fixedPage[TpCount].UpdateLayout(); fixedPage[TpCount].Width = PageHeight; fixedPage[TpCount].Height = PageWidth; } else { fixedPage[TpCount].Width = PageWidth; fixedPage[TpCount].Height = PageHeight; fixedPage[TpCount].UpdateLayout(); } //ページをコンテントに追加する ((IAddChild)pageContent[TpCount]).AddChild(fixedPage[TpCount]); //コンテントをドキュメントに追加する fixedDoc.Pages.Add(pageContent[TpCount]); //ページのカウントを増やす TpCount++; } } if (LandScape) { Pt.PageOrientation = System.Printing.PageOrientation.Landscape; } Pt.CopyCount = 1; } else //単一出来高の時 { //関連オブジェクトを作成 var pageContent = new PageContent(); var fixedPage = new FixedPage(); //出来高内容 string CoW = ""; string strDayArea = Dekidaka.strProductionArea + (Dekidaka.strProductionArea != "" && Dekidaka.strProductionArea != null ? "産 " : " "); string strSubtotal = "計" + Dekidaka.iOutputSubTotal.ToString(); string Output = null; //横向き印刷時 if (LandScape) { //産地日付に計も表示する strDayArea = strDayArea + " " + strSubtotal; CoW = Dekidaka.strCommodity + " " + (Dekidaka.strSize == "" || Dekidaka.strSize == null ? "" : Dekidaka.strSize + ", ") + Dekidaka.strContentsOfWork.Split('(')[0]; int OutputNum = 0; //出来高に入力があれば連結してひとつの文字列にする for (int Count = 0; Count < Dekidaka.iaOutputQuantity.Length; Count++) { //出来高が3項目なら改行をして連結する if (Count % 3 == 2) { if (Dekidaka.iaOutputNumber[Count] != 0 && Dekidaka.iaOutputQuantity[Count] != 0) { Output = Output + Dekidaka.iaOutputQuantity[Count].ToString() + "×" + Dekidaka.iaOutputNumber[Count].ToString() + "\n"; OutputNum++; } } else { //それ以外ならカンマでつなげる if (Dekidaka.iaOutputNumber[Count] != 0 && Dekidaka.iaOutputQuantity[Count] != 0) { Output = Output + Dekidaka.iaOutputQuantity[Count].ToString() + "×" + Dekidaka.iaOutputNumber[Count].ToString() + ", "; OutputNum++; } } } //中身があれば最後の改行かカンマを削除 if (Output != null) { //出来高が2つ以下ならカンマを改行に置換する if (OutputNum < 3) { Output = Output.Replace(", ", "\n"); } //最後の改行もしくはカンマを除去する if (Output.Substring(Output.Count() - 1, 1) == "\n") { Output = Output.Substring(0, Output.Count() - 1); //"\n"1文字を除去 } else { Output = Output.Substring(0, Output.Count() - 2); //", "2文字を除去 } } } else //横向きじゃないとき { CoW = Dekidaka.strCommodity + "\n" + (Dekidaka.strSize == "" || Dekidaka.strSize == null ? "" : Dekidaka.strSize + ", ") + Dekidaka.strContentsOfWork.Split('(')[0]; if (Dekidaka.strOutput != null) { //カンマを全て改行に置換 Output = Dekidaka.strOutput.Replace(", ", "\n"); //最後の文字が改行なら除去 if (Output.Substring(Output.Count() - 1, 1) == "\n") { Output = Output.Substring(0, Output.Count() - 1); //"\n"1文字を除去 } } else { Output = ""; } } //印刷内容を作成する Telop_Control tc = new Telop_Control(Dekidaka.strCustomar, CoW, Output, strDayArea, strSubtotal); //印刷可能範囲に合わせてViewboxで拡大縮小する if (LandScape) { tc.ViewBox.Height = PageWidth; tc.ViewBox.Width = PageHeight; } else { tc.ViewBox.Height = PageHeight; tc.ViewBox.Width = PageWidth; } //ページに追加する fixedPage.Children.Add(tc); //ページの大きさを設定し直す //fixedPage.Arrange(new Rect(0, 0, PageHeight, PageWidth)); if (LandScape) { //fixedPage.Arrange(new Rect(0, 0, PageWidth, PageHeight)); fixedPage.UpdateLayout(); fixedPage.Width = PageHeight; fixedPage.Height = PageWidth; } else { fixedPage.Width = PageWidth; fixedPage.Height = PageHeight; fixedPage.UpdateLayout(); } //ページをコンテントに追加する ((IAddChild)pageContent).AddChild(fixedPage); //コンテントをドキュメントに追加する fixedDoc.Pages.Add(pageContent); if (LandScape) { Pt.PageOrientation = System.Printing.PageOrientation.Landscape; } Pt.CopyCount = 1; } }