コード例 #1
0
        public bool SettingDialogStandard(PageSettings pages)
        {
            System.Windows.Forms.PrintDialog prtdlg = new System.Windows.Forms.PrintDialog();
            if (pages.PrinterSettings.PrintRange == PrintRange.AllPages)
            {
                pages.PrinterSettings.FromPage = 0;
                pages.PrinterSettings.ToPage   = 0;
            }
            prtdlg.PrinterSettings  = pages.PrinterSettings;
            prtdlg.AllowCurrentPage = false;                            // 使えないので必ずfalse
            prtdlg.AllowPrintToFile = false;                            // 使えないので必ずfalse
            prtdlg.AllowSelection   = false;                            // 使えないので必ずfalse
            prtdlg.AllowSomePages   = true;
            var result = prtdlg.ShowDialog();

            if (result != System.Windows.Forms.DialogResult.OK)
            {
                return(false);
            }
            pages.PrinterSettings = prtdlg.PrinterSettings;
            if (pages.PrinterSettings.PrintRange == PrintRange.AllPages)
            {
                pages.PrinterSettings.FromPage = 0;
                pages.PrinterSettings.ToPage   = 0;
            }
            this.Margins = pages.Margins;
            //if (this.IsCustomPageSize)
            //{
            //	System.Windows.Forms.PageSetupDialog pgdlg = new System.Windows.Forms.PageSetupDialog();
            //	pgdlg.PageSettings = pages;
            //	pgdlg.EnableMetric = true;
            //	pgdlg.PrinterSettings = pages.PrinterSettings;
            //	result = pgdlg.ShowDialog();
            //	if (result != System.Windows.Forms.DialogResult.OK)
            //	{
            //		return false;
            //	}
            //	pages = pgdlg.PageSettings;
            //}
            this.PageSettings = pages;
            if (PrinterNames.Contains(pages.PrinterSettings.PrinterName))
            {
                this.SelectedPrinterName = pages.PrinterSettings.PrinterName;
            }
            else
            {
                this.SelectedPrinterName = defaultPrinterName;
                InitPaperName();
                InitPaperSource();
            }
            this.PaperSizeName   = pages.PaperSize.PaperName;
            this.PaperSourceName = pages.PaperSource.SourceName;
            this.Margins         = pages.Margins;
            this.CustomWidth     = pages.PaperSize.Width;
            this.CustomHeight    = pages.PaperSize.Height;

            return(true);
        }
コード例 #2
0
        public bool SettingDialogCustom(PageSettings pages)
        {
            this.PrinterNameVisibility = System.Windows.Visibility.Visible;
            if (pages == null)
            {
                throw new ReportException("システムエラー(プリンター設定なし)");
            }
            else
            {
                if (pages.PrinterSettings == null)
                {
                    throw new ReportException("システムエラー(プリンター設定なし)");
                }
            }
            this.PageSettings = pages;
            if (PrinterNames.Contains(pages.PrinterSettings.PrinterName))
            {
                this.SelectedPrinterName = pages.PrinterSettings.PrinterName;
                this.PaperSizeName       = pages.PaperSize.PaperName;
                this.PaperSourceName     = pages.PaperSource.SourceName;
            }
            else
            {
                this.SelectedPrinterName = defaultPrinterName;
                InitPaperName();
                InitPaperSource();
            }
            this.IsCustomPageSize = (this.PaperSizeName == "Custom");
            this.Margins          = pages.Margins;

            this.Landscape.IsChecked = pages.Landscape;
            switch (pages.PrinterSettings.LandscapeAngle)
            {
            case 0:
                this.Landscape0.IsChecked = true;
                break;

            case 90:
                this.Landscape90.IsChecked = true;
                break;

            case 180:
                this.Landscape180.IsChecked = true;
                break;

            case 270:
                this.Landscape270.IsChecked = true;
                break;
            }
            this.Landscape.Content = string.Format("回転", pages.PrinterSettings.LandscapeAngle);

            PrinterName_SelectionChanged(null, null);

            return(this.ShowDialog() ?? false);
        }
コード例 #3
0
        public SettingsViewModel()
        {
            PrinterNames = System.Drawing.Printing.PrinterSettings.InstalledPrinters.Cast <string>().ToList();
            if (PrinterNames.Contains(Properties.Settings.Default.PrinterName))
            {
                SelectedPrinter = Properties.Settings.Default.PrinterName;
            }
            else
            {
            }

            SaveCommand = new RelayCommand(Save);
        }