diff --git a/AdvertsingProfitControl/AdvertisingProfitControlModel.cs b/AdvertsingProfitControl/AdvertisingProfitControlModel.cs index 860d4a9..ff8c5ce 100644 --- a/AdvertsingProfitControl/AdvertisingProfitControlModel.cs +++ b/AdvertsingProfitControl/AdvertisingProfitControlModel.cs @@ -2,10 +2,7 @@ using AdvertsingProfitControl.Properties; namespace AdvertsingProfitControl { - using System; using System.Data.Entity; - using System.ComponentModel.DataAnnotations.Schema; - using System.Linq; public partial class AdvertisingProfitControlModel : DbContext { diff --git a/AdvertsingProfitControl/AdvertsingProfitControl.csproj b/AdvertsingProfitControl/AdvertsingProfitControl.csproj index 53f2183..33e3e28 100644 --- a/AdvertsingProfitControl/AdvertsingProfitControl.csproj +++ b/AdvertsingProfitControl/AdvertsingProfitControl.csproj @@ -175,6 +175,12 @@ FrmRegisterAdSpecial.cs + + Form + + + FrmReportSettings.cs + @@ -255,6 +261,9 @@ FrmRegisterAdSpecial.cs + + FrmReportSettings.cs + NewModifyRecord.cs diff --git a/AdvertsingProfitControl/App.config b/AdvertsingProfitControl/App.config index 6b10b1c..1334385 100644 --- a/AdvertsingProfitControl/App.config +++ b/AdvertsingProfitControl/App.config @@ -28,6 +28,27 @@ (LocalDb)\MSSQLLocalDB + + A4 + + + 100% + + + 100% + + + 100% + + + 100% + + + 14px + + + 20px + diff --git a/AdvertsingProfitControl/BackPageGenerator.cs b/AdvertsingProfitControl/BackPageGenerator.cs index e1413aa..957c954 100644 --- a/AdvertsingProfitControl/BackPageGenerator.cs +++ b/AdvertsingProfitControl/BackPageGenerator.cs @@ -19,7 +19,11 @@ namespace AdvertsingProfitControl var stringWriter = new StringWriter(); var writer = new HtmlTextWriter(stringWriter); BuildReportBackPage(date, ref writer); - var backPage = new SimplePechkin(new GlobalConfig().SetPaperOrientation(false).SetPaperSize(PaperKind.A4)).Convert(stringWriter.ToString()); + if (!Enum.TryParse(Properties.Settings.Default.ReportPaperKind, out PaperKind paperKind)) + { + paperKind = PaperKind.A4; + } + var backPage = new SimplePechkin(new GlobalConfig().SetPaperOrientation(false).SetPaperSize(paperKind)).Convert(stringWriter.ToString()); // using (var fs = new FileStream(GlobalClasses.LogFilePath + "Back.pdf", FileMode.Create, FileAccess.Write)) { @@ -45,13 +49,13 @@ namespace AdvertsingProfitControl writer.RenderBeginTag(HtmlTextWriterTag.Head); writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/css"); writer.RenderBeginTag(HtmlTextWriterTag.Style); - writer.Write("td{margins:0px; padding:2px; border:1px solid black; text-align:left; vertical-align:bottom; font-size:20px}"); + writer.Write("td{margins:0px; padding:2px; border:1px solid black; text-align:left; vertical-align:bottom; font-size:" + Properties.Settings.Default.WicFontSize + "}"); writer.RenderEndTag();//style writer.RenderEndTag();//Head writer.RenderBeginTag(HtmlTextWriterTag.Body); //writer.AddAttribute(HtmlTextWriterAttribute.Style, "page-break-inside: avoid; page-break-before:always"); //writer.RenderBeginTag(HtmlTextWriterTag.Div);//div - writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-collapse: collapse; width:100%; height:100%"); + writer.AddAttribute(HtmlTextWriterAttribute.Style, "border-collapse: collapse; " + Properties.Settings.Default.WicReportWidth + "; " + Properties.Settings.Default.WicReportHeight); writer.RenderBeginTag(HtmlTextWriterTag.Table); //Create the header as the first row. writer.RenderBeginTag(HtmlTextWriterTag.Tr); diff --git a/AdvertsingProfitControl/FrmMain.Designer.cs b/AdvertsingProfitControl/FrmMain.Designer.cs index e6860b9..e70e230 100644 --- a/AdvertsingProfitControl/FrmMain.Designer.cs +++ b/AdvertsingProfitControl/FrmMain.Designer.cs @@ -37,6 +37,7 @@ this.addRecordsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.modifyRecordMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.reportsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); + this.settingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.toolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.clearRecordToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); this.clearCurrentRecordSelectedDateToolsMainMenu = new System.Windows.Forms.ToolStripMenuItem(); @@ -110,6 +111,7 @@ this.grossProfitEstimatedWeeklyDeptmartmentExpenseLabel = new System.Windows.Forms.Label(); this.perfectGrossProfitLabel = new System.Windows.Forms.Label(); this.grossProfitDollarGrossProfitLabel = new System.Windows.Forms.Label(); + this.generateReportMenuItem = new System.Windows.Forms.ToolStripMenuItem(); this.mainMenu.SuspendLayout(); this.mainTableLayoutPanel.SuspendLayout(); this.commentMainTableLayoutPanel.SuspendLayout(); @@ -203,10 +205,19 @@ // // reportsMainMenu // + this.reportsMainMenu.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] { + this.generateReportMenuItem, + this.settingsToolStripMenuItem}); this.reportsMainMenu.Name = "reportsMainMenu"; this.reportsMainMenu.Size = new System.Drawing.Size(95, 34); this.reportsMainMenu.Text = "R&eports"; - this.reportsMainMenu.Visible = false; + // + // settingsToolStripMenuItem + // + this.settingsToolStripMenuItem.Name = "settingsToolStripMenuItem"; + this.settingsToolStripMenuItem.Size = new System.Drawing.Size(256, 34); + this.settingsToolStripMenuItem.Text = "&Paper Settings"; + this.settingsToolStripMenuItem.Click += new System.EventHandler(this.DisplayReportSizeSettingsForm); // // toolsMainMenu // @@ -997,6 +1008,13 @@ this.grossProfitDollarGrossProfitLabel.TabIndex = 2; this.grossProfitDollarGrossProfitLabel.Text = "Dollar Gross Profit: "; // + // generateReportMenuItem + // + this.generateReportMenuItem.Name = "generateReportMenuItem"; + this.generateReportMenuItem.Size = new System.Drawing.Size(256, 34); + this.generateReportMenuItem.Text = "&Generate Report"; + this.generateReportMenuItem.Click += new System.EventHandler(this.GenerateReportMenuItemClick); + // // FrmMain // this.AutoScaleDimensions = new System.Drawing.SizeF(168F, 168F); @@ -1126,6 +1144,8 @@ private System.Windows.Forms.ToolStripMenuItem clearCurrentActiveYearTools; private System.Windows.Forms.ToolStripMenuItem examineLogsToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem testToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem settingsToolStripMenuItem; + private System.Windows.Forms.ToolStripMenuItem generateReportMenuItem; } } diff --git a/AdvertsingProfitControl/FrmMain.cs b/AdvertsingProfitControl/FrmMain.cs index 49b7fa3..0aaa4ee 100644 --- a/AdvertsingProfitControl/FrmMain.cs +++ b/AdvertsingProfitControl/FrmMain.cs @@ -283,6 +283,20 @@ namespace AdvertsingProfitControl Close(); } + private void DisplayReportSizeSettingsForm(object sender, EventArgs e) + { + var form = new FrmReportSettings(); + form.ShowDialog(); + } + + private void GenerateReportMenuItemClick(object sender, EventArgs e) + { + printPreviewButton.Enabled = false; + var report = new ReportGenerator(); + report.GeneratePdfReport(_currentActiveDate); + printPreviewButton.Enabled = true; + } + #endregion #region Print Handler Methods diff --git a/AdvertsingProfitControl/FrmReportSettings.Designer.cs b/AdvertsingProfitControl/FrmReportSettings.Designer.cs new file mode 100644 index 0000000..531e0dc --- /dev/null +++ b/AdvertsingProfitControl/FrmReportSettings.Designer.cs @@ -0,0 +1,519 @@ +namespace AdvertsingProfitControl +{ + partial class FrmReportSettings + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.mainTableLayoutPanel = new System.Windows.Forms.TableLayoutPanel(); + this.panel1 = new System.Windows.Forms.Panel(); + this.wicFontSizeNumericUpdown = new System.Windows.Forms.NumericUpDown(); + this.wicFontSizeLabel = new System.Windows.Forms.Label(); + this.apcFontSizeNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.fontSizeLabel = new System.Windows.Forms.Label(); + this.apcReportSizePanel = new System.Windows.Forms.Panel(); + this.apcReportHeightNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.apcReportHeightLabel = new System.Windows.Forms.Label(); + this.apcReportWidthNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.apcReportWidthLabel = new System.Windows.Forms.Label(); + this.apcUnitTypeGroupBox = new System.Windows.Forms.GroupBox(); + this.frontPageUnitDetails = new System.Windows.Forms.Label(); + this.apcCentimetersRadioButton = new System.Windows.Forms.RadioButton(); + this.apcInchesRadioButton = new System.Windows.Forms.RadioButton(); + this.apcPercentagesRadioButton = new System.Windows.Forms.RadioButton(); + this.backPageUnitGroupBox = new System.Windows.Forms.GroupBox(); + this.backPageUnitsDetailLabel = new System.Windows.Forms.Label(); + this.wicCentimetersRadioButton = new System.Windows.Forms.RadioButton(); + this.wicInchesRadioButton = new System.Windows.Forms.RadioButton(); + this.wicPercentageRadioButton = new System.Windows.Forms.RadioButton(); + this.backPageSizePanel = new System.Windows.Forms.Panel(); + this.wicReportHeightNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.label1 = new System.Windows.Forms.Label(); + this.wicReportWidthNumericUpDown = new System.Windows.Forms.NumericUpDown(); + this.label2 = new System.Windows.Forms.Label(); + this.paperKindGroupBox = new System.Windows.Forms.GroupBox(); + this.paperKindDetailLabel = new System.Windows.Forms.Label(); + this.paperKindComboBox = new System.Windows.Forms.ComboBox(); + this.mainTableLayoutPanel.SuspendLayout(); + this.panel1.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.wicFontSizeNumericUpdown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.apcFontSizeNumericUpDown)).BeginInit(); + this.apcReportSizePanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.apcReportHeightNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.apcReportWidthNumericUpDown)).BeginInit(); + this.apcUnitTypeGroupBox.SuspendLayout(); + this.backPageUnitGroupBox.SuspendLayout(); + this.backPageSizePanel.SuspendLayout(); + ((System.ComponentModel.ISupportInitialize)(this.wicReportHeightNumericUpDown)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.wicReportWidthNumericUpDown)).BeginInit(); + this.paperKindGroupBox.SuspendLayout(); + this.SuspendLayout(); + // + // mainTableLayoutPanel + // + this.mainTableLayoutPanel.ColumnCount = 2; + this.mainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 40F)); + this.mainTableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 60F)); + this.mainTableLayoutPanel.Controls.Add(this.panel1, 0, 0); + this.mainTableLayoutPanel.Controls.Add(this.apcReportSizePanel, 0, 1); + this.mainTableLayoutPanel.Controls.Add(this.apcUnitTypeGroupBox, 1, 1); + this.mainTableLayoutPanel.Controls.Add(this.backPageUnitGroupBox, 1, 2); + this.mainTableLayoutPanel.Controls.Add(this.backPageSizePanel, 0, 2); + this.mainTableLayoutPanel.Controls.Add(this.paperKindGroupBox, 1, 0); + this.mainTableLayoutPanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.mainTableLayoutPanel.Location = new System.Drawing.Point(0, 0); + this.mainTableLayoutPanel.Name = "mainTableLayoutPanel"; + this.mainTableLayoutPanel.RowCount = 3; + this.mainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33F)); + this.mainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 33F)); + this.mainTableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 34F)); + this.mainTableLayoutPanel.Size = new System.Drawing.Size(1002, 546); + this.mainTableLayoutPanel.TabIndex = 0; + // + // panel1 + // + this.panel1.Controls.Add(this.wicFontSizeNumericUpdown); + this.panel1.Controls.Add(this.wicFontSizeLabel); + this.panel1.Controls.Add(this.apcFontSizeNumericUpDown); + this.panel1.Controls.Add(this.fontSizeLabel); + this.panel1.Dock = System.Windows.Forms.DockStyle.Fill; + this.panel1.Location = new System.Drawing.Point(3, 3); + this.panel1.Name = "panel1"; + this.panel1.Size = new System.Drawing.Size(394, 174); + this.panel1.TabIndex = 1; + // + // wicFontSizeNumericUpdown + // + this.wicFontSizeNumericUpdown.Location = new System.Drawing.Point(251, 71); + this.wicFontSizeNumericUpdown.Maximum = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.wicFontSizeNumericUpdown.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.wicFontSizeNumericUpdown.Name = "wicFontSizeNumericUpdown"; + this.wicFontSizeNumericUpdown.Size = new System.Drawing.Size(120, 29); + this.wicFontSizeNumericUpdown.TabIndex = 2; + this.wicFontSizeNumericUpdown.Value = new decimal(new int[] { + 20, + 0, + 0, + 0}); + this.wicFontSizeNumericUpdown.ValueChanged += new System.EventHandler(this.UpdateBackPageFontSize); + // + // wicFontSizeLabel + // + this.wicFontSizeLabel.AutoSize = true; + this.wicFontSizeLabel.Location = new System.Drawing.Point(9, 73); + this.wicFontSizeLabel.Name = "wicFontSizeLabel"; + this.wicFontSizeLabel.Size = new System.Drawing.Size(236, 25); + this.wicFontSizeLabel.TabIndex = 2; + this.wicFontSizeLabel.Text = "Set Back Page Font Size:"; + // + // apcFontSizeNumericUpDown + // + this.apcFontSizeNumericUpDown.Location = new System.Drawing.Point(251, 20); + this.apcFontSizeNumericUpDown.Maximum = new decimal(new int[] { + 50, + 0, + 0, + 0}); + this.apcFontSizeNumericUpDown.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.apcFontSizeNumericUpDown.Name = "apcFontSizeNumericUpDown"; + this.apcFontSizeNumericUpDown.Size = new System.Drawing.Size(120, 29); + this.apcFontSizeNumericUpDown.TabIndex = 1; + this.apcFontSizeNumericUpDown.Value = new decimal(new int[] { + 14, + 0, + 0, + 0}); + this.apcFontSizeNumericUpDown.ValueChanged += new System.EventHandler(this.UpdateFrontPageFontSize); + // + // fontSizeLabel + // + this.fontSizeLabel.AutoSize = true; + this.fontSizeLabel.Location = new System.Drawing.Point(9, 22); + this.fontSizeLabel.Name = "fontSizeLabel"; + this.fontSizeLabel.Size = new System.Drawing.Size(237, 25); + this.fontSizeLabel.TabIndex = 0; + this.fontSizeLabel.Text = "Set Front Page Font Size:"; + // + // apcReportSizePanel + // + this.apcReportSizePanel.Controls.Add(this.apcReportHeightNumericUpDown); + this.apcReportSizePanel.Controls.Add(this.apcReportHeightLabel); + this.apcReportSizePanel.Controls.Add(this.apcReportWidthNumericUpDown); + this.apcReportSizePanel.Controls.Add(this.apcReportWidthLabel); + this.apcReportSizePanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.apcReportSizePanel.Location = new System.Drawing.Point(3, 183); + this.apcReportSizePanel.Name = "apcReportSizePanel"; + this.apcReportSizePanel.Size = new System.Drawing.Size(394, 174); + this.apcReportSizePanel.TabIndex = 2; + // + // apcReportHeightNumericUpDown + // + this.apcReportHeightNumericUpDown.DecimalPlaces = 2; + this.apcReportHeightNumericUpDown.Location = new System.Drawing.Point(257, 55); + this.apcReportHeightNumericUpDown.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.apcReportHeightNumericUpDown.Name = "apcReportHeightNumericUpDown"; + this.apcReportHeightNumericUpDown.Size = new System.Drawing.Size(120, 29); + this.apcReportHeightNumericUpDown.TabIndex = 4; + this.apcReportHeightNumericUpDown.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.apcReportHeightNumericUpDown.ValueChanged += new System.EventHandler(this.UpdateApcReportHeight); + // + // apcReportHeightLabel + // + this.apcReportHeightLabel.AutoSize = true; + this.apcReportHeightLabel.Location = new System.Drawing.Point(9, 57); + this.apcReportHeightLabel.Name = "apcReportHeightLabel"; + this.apcReportHeightLabel.Size = new System.Drawing.Size(237, 25); + this.apcReportHeightLabel.TabIndex = 3; + this.apcReportHeightLabel.Text = "Front Page Report Height:"; + // + // apcReportWidthNumericUpDown + // + this.apcReportWidthNumericUpDown.DecimalPlaces = 2; + this.apcReportWidthNumericUpDown.Location = new System.Drawing.Point(257, 12); + this.apcReportWidthNumericUpDown.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.apcReportWidthNumericUpDown.Name = "apcReportWidthNumericUpDown"; + this.apcReportWidthNumericUpDown.Size = new System.Drawing.Size(120, 29); + this.apcReportWidthNumericUpDown.TabIndex = 3; + this.apcReportWidthNumericUpDown.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.apcReportWidthNumericUpDown.ValueChanged += new System.EventHandler(this.UpdateApcReportWidth); + // + // apcReportWidthLabel + // + this.apcReportWidthLabel.AutoSize = true; + this.apcReportWidthLabel.Location = new System.Drawing.Point(9, 14); + this.apcReportWidthLabel.Name = "apcReportWidthLabel"; + this.apcReportWidthLabel.Size = new System.Drawing.Size(232, 25); + this.apcReportWidthLabel.TabIndex = 0; + this.apcReportWidthLabel.Text = "Front Page Report Width:"; + // + // apcUnitTypeGroupBox + // + this.apcUnitTypeGroupBox.Controls.Add(this.frontPageUnitDetails); + this.apcUnitTypeGroupBox.Controls.Add(this.apcCentimetersRadioButton); + this.apcUnitTypeGroupBox.Controls.Add(this.apcInchesRadioButton); + this.apcUnitTypeGroupBox.Controls.Add(this.apcPercentagesRadioButton); + this.apcUnitTypeGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.apcUnitTypeGroupBox.Location = new System.Drawing.Point(403, 183); + this.apcUnitTypeGroupBox.Name = "apcUnitTypeGroupBox"; + this.apcUnitTypeGroupBox.Size = new System.Drawing.Size(596, 174); + this.apcUnitTypeGroupBox.TabIndex = 3; + this.apcUnitTypeGroupBox.TabStop = false; + this.apcUnitTypeGroupBox.Text = "Front Page Units"; + // + // frontPageUnitDetails + // + this.frontPageUnitDetails.AutoSize = true; + this.frontPageUnitDetails.Location = new System.Drawing.Point(19, 135); + this.frontPageUnitDetails.Name = "frontPageUnitDetails"; + this.frontPageUnitDetails.Size = new System.Drawing.Size(0, 25); + this.frontPageUnitDetails.TabIndex = 8; + // + // apcCentimetersRadioButton + // + this.apcCentimetersRadioButton.AutoSize = true; + this.apcCentimetersRadioButton.Location = new System.Drawing.Point(19, 99); + this.apcCentimetersRadioButton.Name = "apcCentimetersRadioButton"; + this.apcCentimetersRadioButton.Size = new System.Drawing.Size(142, 29); + this.apcCentimetersRadioButton.TabIndex = 7; + this.apcCentimetersRadioButton.Text = "Centimeters"; + this.apcCentimetersRadioButton.UseVisualStyleBackColor = true; + this.apcCentimetersRadioButton.CheckedChanged += new System.EventHandler(this.ApcRadioButtonChecked); + // + // apcInchesRadioButton + // + this.apcInchesRadioButton.AutoSize = true; + this.apcInchesRadioButton.Location = new System.Drawing.Point(19, 64); + this.apcInchesRadioButton.Name = "apcInchesRadioButton"; + this.apcInchesRadioButton.Size = new System.Drawing.Size(95, 29); + this.apcInchesRadioButton.TabIndex = 6; + this.apcInchesRadioButton.Text = "Inches"; + this.apcInchesRadioButton.UseVisualStyleBackColor = true; + this.apcInchesRadioButton.CheckedChanged += new System.EventHandler(this.ApcRadioButtonChecked); + // + // apcPercentagesRadioButton + // + this.apcPercentagesRadioButton.AutoSize = true; + this.apcPercentagesRadioButton.Checked = true; + this.apcPercentagesRadioButton.Location = new System.Drawing.Point(19, 29); + this.apcPercentagesRadioButton.Name = "apcPercentagesRadioButton"; + this.apcPercentagesRadioButton.Size = new System.Drawing.Size(147, 29); + this.apcPercentagesRadioButton.TabIndex = 5; + this.apcPercentagesRadioButton.TabStop = true; + this.apcPercentagesRadioButton.Text = "Percentages"; + this.apcPercentagesRadioButton.UseVisualStyleBackColor = true; + this.apcPercentagesRadioButton.CheckedChanged += new System.EventHandler(this.ApcRadioButtonChecked); + // + // backPageUnitGroupBox + // + this.backPageUnitGroupBox.Controls.Add(this.backPageUnitsDetailLabel); + this.backPageUnitGroupBox.Controls.Add(this.wicCentimetersRadioButton); + this.backPageUnitGroupBox.Controls.Add(this.wicInchesRadioButton); + this.backPageUnitGroupBox.Controls.Add(this.wicPercentageRadioButton); + this.backPageUnitGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.backPageUnitGroupBox.Location = new System.Drawing.Point(403, 363); + this.backPageUnitGroupBox.Name = "backPageUnitGroupBox"; + this.backPageUnitGroupBox.Size = new System.Drawing.Size(596, 180); + this.backPageUnitGroupBox.TabIndex = 4; + this.backPageUnitGroupBox.TabStop = false; + this.backPageUnitGroupBox.Text = "Back Page Units"; + // + // backPageUnitsDetailLabel + // + this.backPageUnitsDetailLabel.AutoSize = true; + this.backPageUnitsDetailLabel.Location = new System.Drawing.Point(19, 155); + this.backPageUnitsDetailLabel.Name = "backPageUnitsDetailLabel"; + this.backPageUnitsDetailLabel.Size = new System.Drawing.Size(0, 25); + this.backPageUnitsDetailLabel.TabIndex = 13; + // + // wicCentimetersRadioButton + // + this.wicCentimetersRadioButton.AutoSize = true; + this.wicCentimetersRadioButton.Location = new System.Drawing.Point(19, 107); + this.wicCentimetersRadioButton.Name = "wicCentimetersRadioButton"; + this.wicCentimetersRadioButton.Size = new System.Drawing.Size(142, 29); + this.wicCentimetersRadioButton.TabIndex = 12; + this.wicCentimetersRadioButton.Text = "Centimeters"; + this.wicCentimetersRadioButton.UseVisualStyleBackColor = true; + this.wicCentimetersRadioButton.CheckedChanged += new System.EventHandler(this.WicRadioButtonCheckedChanged); + // + // wicInchesRadioButton + // + this.wicInchesRadioButton.AutoSize = true; + this.wicInchesRadioButton.Location = new System.Drawing.Point(19, 72); + this.wicInchesRadioButton.Name = "wicInchesRadioButton"; + this.wicInchesRadioButton.Size = new System.Drawing.Size(95, 29); + this.wicInchesRadioButton.TabIndex = 11; + this.wicInchesRadioButton.Text = "Inches"; + this.wicInchesRadioButton.UseVisualStyleBackColor = true; + this.wicInchesRadioButton.CheckedChanged += new System.EventHandler(this.WicRadioButtonCheckedChanged); + // + // wicPercentageRadioButton + // + this.wicPercentageRadioButton.AutoSize = true; + this.wicPercentageRadioButton.Checked = true; + this.wicPercentageRadioButton.Location = new System.Drawing.Point(19, 37); + this.wicPercentageRadioButton.Name = "wicPercentageRadioButton"; + this.wicPercentageRadioButton.Size = new System.Drawing.Size(147, 29); + this.wicPercentageRadioButton.TabIndex = 10; + this.wicPercentageRadioButton.TabStop = true; + this.wicPercentageRadioButton.Text = "Percentages"; + this.wicPercentageRadioButton.UseVisualStyleBackColor = true; + this.wicPercentageRadioButton.CheckedChanged += new System.EventHandler(this.WicRadioButtonCheckedChanged); + // + // backPageSizePanel + // + this.backPageSizePanel.Controls.Add(this.wicReportHeightNumericUpDown); + this.backPageSizePanel.Controls.Add(this.label1); + this.backPageSizePanel.Controls.Add(this.wicReportWidthNumericUpDown); + this.backPageSizePanel.Controls.Add(this.label2); + this.backPageSizePanel.Dock = System.Windows.Forms.DockStyle.Fill; + this.backPageSizePanel.Location = new System.Drawing.Point(3, 363); + this.backPageSizePanel.Name = "backPageSizePanel"; + this.backPageSizePanel.Size = new System.Drawing.Size(394, 180); + this.backPageSizePanel.TabIndex = 5; + // + // wicReportHeightNumericUpDown + // + this.wicReportHeightNumericUpDown.DecimalPlaces = 2; + this.wicReportHeightNumericUpDown.Location = new System.Drawing.Point(257, 66); + this.wicReportHeightNumericUpDown.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.wicReportHeightNumericUpDown.Name = "wicReportHeightNumericUpDown"; + this.wicReportHeightNumericUpDown.Size = new System.Drawing.Size(120, 29); + this.wicReportHeightNumericUpDown.TabIndex = 9; + this.wicReportHeightNumericUpDown.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.wicReportHeightNumericUpDown.ValueChanged += new System.EventHandler(this.UpdateWicHeight); + // + // label1 + // + this.label1.AutoSize = true; + this.label1.Location = new System.Drawing.Point(9, 68); + this.label1.Name = "label1"; + this.label1.Size = new System.Drawing.Size(236, 25); + this.label1.TabIndex = 7; + this.label1.Text = "Back Page Report Height:"; + // + // wicReportWidthNumericUpDown + // + this.wicReportWidthNumericUpDown.DecimalPlaces = 2; + this.wicReportWidthNumericUpDown.Location = new System.Drawing.Point(257, 23); + this.wicReportWidthNumericUpDown.Minimum = new decimal(new int[] { + 1, + 0, + 0, + 0}); + this.wicReportWidthNumericUpDown.Name = "wicReportWidthNumericUpDown"; + this.wicReportWidthNumericUpDown.Size = new System.Drawing.Size(120, 29); + this.wicReportWidthNumericUpDown.TabIndex = 8; + this.wicReportWidthNumericUpDown.Value = new decimal(new int[] { + 100, + 0, + 0, + 0}); + this.wicReportWidthNumericUpDown.ValueChanged += new System.EventHandler(this.UpdateWicReportWidth); + // + // label2 + // + this.label2.AutoSize = true; + this.label2.Location = new System.Drawing.Point(9, 25); + this.label2.Name = "label2"; + this.label2.Size = new System.Drawing.Size(231, 25); + this.label2.TabIndex = 5; + this.label2.Text = "Back Page Report Width:"; + // + // paperKindGroupBox + // + this.paperKindGroupBox.Controls.Add(this.paperKindDetailLabel); + this.paperKindGroupBox.Controls.Add(this.paperKindComboBox); + this.paperKindGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; + this.paperKindGroupBox.Location = new System.Drawing.Point(403, 3); + this.paperKindGroupBox.Name = "paperKindGroupBox"; + this.paperKindGroupBox.Size = new System.Drawing.Size(596, 174); + this.paperKindGroupBox.TabIndex = 6; + this.paperKindGroupBox.TabStop = false; + this.paperKindGroupBox.Text = "Paper Kind"; + // + // paperKindDetailLabel + // + this.paperKindDetailLabel.AutoSize = true; + this.paperKindDetailLabel.Location = new System.Drawing.Point(19, 126); + this.paperKindDetailLabel.Name = "paperKindDetailLabel"; + this.paperKindDetailLabel.Size = new System.Drawing.Size(0, 25); + this.paperKindDetailLabel.TabIndex = 1; + // + // paperKindComboBox + // + this.paperKindComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; + this.paperKindComboBox.FormattingEnabled = true; + this.paperKindComboBox.Location = new System.Drawing.Point(6, 44); + this.paperKindComboBox.Name = "paperKindComboBox"; + this.paperKindComboBox.Size = new System.Drawing.Size(419, 32); + this.paperKindComboBox.TabIndex = 0; + this.paperKindComboBox.TabStop = false; + this.paperKindComboBox.SelectedIndexChanged += new System.EventHandler(this.UpdatePaperKind); + // + // FrmReportSettings + // + this.AutoScaleDimensions = new System.Drawing.SizeF(11F, 24F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1002, 546); + this.Controls.Add(this.mainTableLayoutPanel); + this.MaximizeBox = false; + this.MinimizeBox = false; + this.Name = "FrmReportSettings"; + this.Text = "Report Settings"; + this.Load += new System.EventHandler(this.FrmReportSettings_Load); + this.mainTableLayoutPanel.ResumeLayout(false); + this.panel1.ResumeLayout(false); + this.panel1.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.wicFontSizeNumericUpdown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.apcFontSizeNumericUpDown)).EndInit(); + this.apcReportSizePanel.ResumeLayout(false); + this.apcReportSizePanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.apcReportHeightNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.apcReportWidthNumericUpDown)).EndInit(); + this.apcUnitTypeGroupBox.ResumeLayout(false); + this.apcUnitTypeGroupBox.PerformLayout(); + this.backPageUnitGroupBox.ResumeLayout(false); + this.backPageUnitGroupBox.PerformLayout(); + this.backPageSizePanel.ResumeLayout(false); + this.backPageSizePanel.PerformLayout(); + ((System.ComponentModel.ISupportInitialize)(this.wicReportHeightNumericUpDown)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.wicReportWidthNumericUpDown)).EndInit(); + this.paperKindGroupBox.ResumeLayout(false); + this.paperKindGroupBox.PerformLayout(); + this.ResumeLayout(false); + + } + + #endregion + + private System.Windows.Forms.TableLayoutPanel mainTableLayoutPanel; + private System.Windows.Forms.Panel panel1; + private System.Windows.Forms.NumericUpDown apcFontSizeNumericUpDown; + private System.Windows.Forms.Label fontSizeLabel; + private System.Windows.Forms.NumericUpDown wicFontSizeNumericUpdown; + private System.Windows.Forms.Label wicFontSizeLabel; + private System.Windows.Forms.Panel apcReportSizePanel; + private System.Windows.Forms.NumericUpDown apcReportHeightNumericUpDown; + private System.Windows.Forms.Label apcReportHeightLabel; + private System.Windows.Forms.NumericUpDown apcReportWidthNumericUpDown; + private System.Windows.Forms.Label apcReportWidthLabel; + private System.Windows.Forms.GroupBox apcUnitTypeGroupBox; + private System.Windows.Forms.RadioButton apcCentimetersRadioButton; + private System.Windows.Forms.RadioButton apcInchesRadioButton; + private System.Windows.Forms.RadioButton apcPercentagesRadioButton; + private System.Windows.Forms.GroupBox backPageUnitGroupBox; + private System.Windows.Forms.RadioButton wicCentimetersRadioButton; + private System.Windows.Forms.RadioButton wicInchesRadioButton; + private System.Windows.Forms.RadioButton wicPercentageRadioButton; + private System.Windows.Forms.Panel backPageSizePanel; + private System.Windows.Forms.NumericUpDown wicReportHeightNumericUpDown; + private System.Windows.Forms.Label label1; + private System.Windows.Forms.NumericUpDown wicReportWidthNumericUpDown; + private System.Windows.Forms.Label label2; + private System.Windows.Forms.Label frontPageUnitDetails; + private System.Windows.Forms.Label backPageUnitsDetailLabel; + private System.Windows.Forms.GroupBox paperKindGroupBox; + private System.Windows.Forms.Label paperKindDetailLabel; + private System.Windows.Forms.ComboBox paperKindComboBox; + } +} \ No newline at end of file diff --git a/AdvertsingProfitControl/FrmReportSettings.cs b/AdvertsingProfitControl/FrmReportSettings.cs new file mode 100644 index 0000000..7885638 --- /dev/null +++ b/AdvertsingProfitControl/FrmReportSettings.cs @@ -0,0 +1,322 @@ +using System; +using System.Drawing.Printing; +using System.Linq; +using System.Text; +using System.Windows.Forms; + +namespace AdvertsingProfitControl +{ + public partial class FrmReportSettings : Form + { + public FrmReportSettings() + { + InitializeComponent(); + } + + private void UpdateFrontPageFontSize(object sender, EventArgs e) + { + Properties.Settings.Default.ApcFontSize = apcFontSizeNumericUpDown.Text + @"px"; + } + + private void UpdateBackPageFontSize(object sender, EventArgs e) + { + Properties.Settings.Default.WicFontSize = wicFontSizeNumericUpdown.Text + @"px"; + } + + private void UpdateApcReportWidth(object sender, EventArgs e) + { + string unit; + if (apcPercentagesRadioButton.Checked) + { + unit = "%"; + } + else if (apcInchesRadioButton.Checked) + { + unit = "in"; + } + else + { + unit = "cm"; + } + + Properties.Settings.Default.ApcReportWidth = apcReportWidthNumericUpDown.Value + unit; + } + + private void UpdateApcReportHeight(object sender, EventArgs e) + { + string unit; + if (apcPercentagesRadioButton.Checked) + { + unit = "%"; + } + else if (apcInchesRadioButton.Checked) + { + unit = "in"; + } + else + { + unit = "cm"; + } + + Properties.Settings.Default.ApcReportHeight = apcReportHeightNumericUpDown.Value + unit; + } + + private void ApcRadioButtonChecked(object sender, EventArgs e) + { + if (!((RadioButton) sender).Checked) return; + SetApcNumericUpDowns((Control) sender); + } + + private void FrmReportSettings_Load(object sender, EventArgs e) + { + //Prevent the loading from updating the saved values. + apcFontSizeNumericUpDown.ValueChanged -= UpdateFrontPageFontSize; + wicFontSizeNumericUpdown.ValueChanged -= UpdateBackPageFontSize; + apcReportWidthNumericUpDown.ValueChanged -= UpdateApcReportWidth; + apcReportHeightNumericUpDown.ValueChanged -= UpdateApcReportHeight; + //Load the current settings for font sizes + apcFontSizeNumericUpDown.Text = Properties.Settings.Default.ApcFontSize.Replace("px", ""); + wicFontSizeNumericUpdown.Text = Properties.Settings.Default.WicFontSize.Replace("px", ""); + //Load the width and height settings for the front page. + apcFontSizeNumericUpDown.ValueChanged += UpdateFrontPageFontSize; + wicFontSizeNumericUpdown.ValueChanged += UpdateBackPageFontSize; + LoadApcSettings(); + LoadWicSettings(); + apcReportWidthNumericUpDown.ValueChanged += UpdateApcReportWidth; + apcReportHeightNumericUpDown.ValueChanged += UpdateApcReportHeight; + //Grab the paper kinds + var paperKinds = Enum.GetNames(typeof(PaperKind)).ToList(); + for (var i = 0; i < paperKinds.Count; i ++) + { + if(paperKinds[i] == "Custom") continue; + paperKindComboBox.Items.Add(paperKinds[i]); + } + //Get the paper kind setting. + if (paperKindComboBox.Items.Contains(Properties.Settings.Default.ReportPaperKind)) + { + var index = paperKindComboBox.FindString(Properties.Settings.Default.ReportPaperKind); + paperKindComboBox.SelectedIndex = index; + } + else + { + var index = paperKindComboBox.FindString(PaperKind.A4.ToString()); + paperKindComboBox.SelectedIndex = index; + } + } + + private void LoadApcSettings() + { + var splitSetting = ParseSetting(Properties.Settings.Default.ApcReportWidth); + switch (splitSetting[1]) + { + case "%": + apcPercentagesRadioButton.Checked = true; + SetApcNumericUpDowns(apcPercentagesRadioButton); + break; + case "in": + apcInchesRadioButton.Checked = true; + SetApcNumericUpDowns(apcInchesRadioButton); + break; + case "cm": + apcCentimetersRadioButton.Checked = true; + SetApcNumericUpDowns(apcCentimetersRadioButton); + break; + } + apcReportWidthNumericUpDown.Text = splitSetting[0]; + splitSetting = ParseSetting(Properties.Settings.Default.ApcReportHeight); + apcReportHeightNumericUpDown.Text = splitSetting[0]; + } + + private void LoadWicSettings() + { + var splitSetting = ParseSetting(Properties.Settings.Default.WicReportWidth); + switch (splitSetting[1]) + { + case "%": + wicPercentageRadioButton.Checked = true; + SetWicNumericUpDowns(wicPercentageRadioButton); + break; + case "in": + wicInchesRadioButton.Checked = true; + SetWicNumericUpDowns(wicInchesRadioButton); + break; + case "cm": + wicCentimetersRadioButton.Checked = true; + SetWicNumericUpDowns(wicCentimetersRadioButton); + break; + } + wicReportWidthNumericUpDown.Text = splitSetting[0]; + splitSetting = ParseSetting(Properties.Settings.Default.WicReportHeight); + wicReportHeightNumericUpDown.Text = splitSetting[0]; + } + + private void SetApcNumericUpDowns(Control radioButton) + { + if (radioButton.Name == apcPercentagesRadioButton.Name) + { + apcInchesRadioButton.Checked = false; + apcCentimetersRadioButton.Checked = false; + apcReportWidthNumericUpDown.Minimum = 1; + apcReportWidthNumericUpDown.Maximum = 100; + apcReportWidthNumericUpDown.Text = @"100"; + apcReportHeightNumericUpDown.Minimum = 1; + apcReportHeightNumericUpDown.Maximum = 100; + apcReportHeightNumericUpDown.Text = @"100"; + frontPageUnitDetails.Text = @"Units set to percent of page size (1 to 100%)"; + } + else if (radioButton.Name == apcInchesRadioButton.Name) + { + apcPercentagesRadioButton.Checked = false; + apcCentimetersRadioButton.Checked = false; + apcReportWidthNumericUpDown.Minimum = 1; + apcReportWidthNumericUpDown.Maximum = 25; + apcReportWidthNumericUpDown.Text = @"11"; + apcReportHeightNumericUpDown.Minimum = 1; + apcReportHeightNumericUpDown.Maximum = 25; + apcReportHeightNumericUpDown.Text = @"8"; + frontPageUnitDetails.Text = @"Units set to inches (" + apcReportWidthNumericUpDown.Minimum + @" to "+ apcReportWidthNumericUpDown.Maximum + @" inches)"; + } + else if (radioButton.Name == apcCentimetersRadioButton.Name) + { + apcPercentagesRadioButton.Checked = false; + apcInchesRadioButton.Checked = false; + apcReportWidthNumericUpDown.Minimum = (decimal) 2.54; + apcReportWidthNumericUpDown.Maximum = (decimal) 63.5; + apcReportWidthNumericUpDown.Text = @"27.94"; + apcReportHeightNumericUpDown.Minimum = (decimal) 2.54; + apcReportHeightNumericUpDown.Maximum = (decimal) 63.5; + apcReportHeightNumericUpDown.Text = @"20.32"; + frontPageUnitDetails.Text = @"Units set to centimeters (" + apcReportWidthNumericUpDown.Minimum + @" to " + apcReportWidthNumericUpDown.Maximum + @" centimeters)"; + } + } + + private void SetWicNumericUpDowns(Control radioButton) + { + if (radioButton.Name == wicPercentageRadioButton.Name) + { + wicInchesRadioButton.Checked = false; + wicCentimetersRadioButton.Checked = false; + wicReportWidthNumericUpDown.Minimum = 1; + wicReportWidthNumericUpDown.Maximum = 100; + wicReportWidthNumericUpDown.Text = @"100"; + wicReportHeightNumericUpDown.Minimum = 1; + wicReportHeightNumericUpDown.Maximum = 100; + wicReportHeightNumericUpDown.Text = @"100"; + backPageUnitsDetailLabel.Text = @"Units set to percent of page size (1 to 100%)"; + } + else if (radioButton.Name == wicInchesRadioButton.Name) + { + wicPercentageRadioButton.Checked = false; + wicCentimetersRadioButton.Checked = false; + wicReportWidthNumericUpDown.Minimum = 1; + wicReportWidthNumericUpDown.Maximum = 25; + wicReportWidthNumericUpDown.Text = @"8"; + wicReportHeightNumericUpDown.Minimum = 1; + wicReportHeightNumericUpDown.Maximum = 25; + wicReportHeightNumericUpDown.Text = @"11"; + backPageUnitsDetailLabel.Text = @"Units set to inches (" + wicReportWidthNumericUpDown.Minimum + @" to " + wicReportWidthNumericUpDown.Maximum + @" inches)"; + } + else if (radioButton.Name == wicCentimetersRadioButton.Name) + { + wicPercentageRadioButton.Checked = false; + wicInchesRadioButton.Checked = false; + wicReportWidthNumericUpDown.Minimum = (decimal)2.54; + wicReportWidthNumericUpDown.Maximum = (decimal)63.5; + wicReportWidthNumericUpDown.Text = @"20.32"; + wicReportHeightNumericUpDown.Minimum = (decimal)2.54; + wicReportHeightNumericUpDown.Maximum = (decimal)63.5; + wicReportHeightNumericUpDown.Text = @"27.94"; + backPageUnitsDetailLabel.Text = @"Units set to centimeters (" + wicReportWidthNumericUpDown.Minimum + @" to " + wicReportWidthNumericUpDown.Maximum + @" centimeters)"; + } + } + + private string[] ParseSetting(string setting) + { + var splitString = new string[2]; + var decimalPointFound = false; + var numberEnd = false; + var number = new StringBuilder(); + var unit = new StringBuilder(); + foreach(var character in setting) + { + if (char.IsNumber(character) && !numberEnd) + { + number.Append(character); + continue; + } + + if(char.IsLetter(character)) + { + unit.Append(character); + } + + if (character == '%') + { + unit.Append("%"); + break; + } + + if (character == '.' && !decimalPointFound) + { + decimalPointFound = true; + number.Append('.'); + continue; + } + + numberEnd = true; + } + splitString[0] = number.ToString(); + splitString[1] = unit.ToString(); + return splitString; + } + + private void UpdateWicReportWidth(object sender, EventArgs e) + { + string unit; + if (wicPercentageRadioButton.Checked) + { + unit = "%"; + } + else if (wicInchesRadioButton.Checked) + { + unit = "in"; + } + else + { + unit = "cm"; + } + + Properties.Settings.Default.WicReportWidth = wicReportWidthNumericUpDown.Value + unit; + } + + private void UpdateWicHeight(object sender, EventArgs e) + { + string unit; + if (wicPercentageRadioButton.Checked) + { + unit = "%"; + } + else if (wicInchesRadioButton.Checked) + { + unit = "in"; + } + else + { + unit = "cm"; + } + + Properties.Settings.Default.WicReportHeight = wicReportHeightNumericUpDown.Value + unit; + } + + private void WicRadioButtonCheckedChanged(object sender, EventArgs e) + { + if (!((RadioButton)sender).Checked) return; + SetWicNumericUpDowns((Control)sender); + } + + private void UpdatePaperKind(object sender, EventArgs e) + { + Properties.Settings.Default.ReportPaperKind = paperKindComboBox.SelectedItem.ToString(); + } + } +} diff --git a/AdvertsingProfitControl/FrmReportSettings.resx b/AdvertsingProfitControl/FrmReportSettings.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/AdvertsingProfitControl/FrmReportSettings.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/AdvertsingProfitControl/FrontPageGenerator.cs b/AdvertsingProfitControl/FrontPageGenerator.cs index cc99d8d..a395a35 100644 --- a/AdvertsingProfitControl/FrontPageGenerator.cs +++ b/AdvertsingProfitControl/FrontPageGenerator.cs @@ -19,7 +19,12 @@ namespace AdvertsingProfitControl var stringWriter = new StringWriter(); var writer = new HtmlTextWriter(stringWriter); BuildReportFrontPage(date, ref writer); - var frontPage = new SimplePechkin(new GlobalConfig().SetPaperOrientation(true).SetPaperSize(PaperKind.A4)).Convert(stringWriter.ToString()); + if (!Enum.TryParse(Properties.Settings.Default.ReportPaperKind, out PaperKind paperKind)) + { + //TODO: Report this error to the user. + paperKind = PaperKind.A4; + } + var frontPage = new SimplePechkin(new GlobalConfig().SetPaperOrientation(true).SetPaperSize(paperKind)).Convert(stringWriter.ToString()); // using (var fs = new FileStream(GlobalClasses.LogFilePath + "Front.pdf", FileMode.Create, FileAccess.Write)) { @@ -46,12 +51,12 @@ namespace AdvertsingProfitControl writer.AddAttribute(HtmlTextWriterAttribute.Type, "text/css"); //Set the global style for the data cells. writer.RenderBeginTag(HtmlTextWriterTag.Style); - writer.Write("td{margins:0; padding:2px; border:1px solid black; font-size:14px; text-align:center; vertical-align:bottom}"); + writer.Write("td{margins:0; padding:2px; border:1px solid black; font-size:" + Properties.Settings.Default.ApcFontSize + "; text-align:center; vertical-align:bottom}"); writer.RenderEndTag();// end style writer.RenderEndTag(); // end Head //writer.AddAttribute(HtmlTextWriterAttribute.Style, "width:11in; height:8in"); writer.RenderBeginTag(HtmlTextWriterTag.Body); - writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none; border-collapse: collapse; margin-top:1in; width:100%; height:100%"); //style for the table + writer.AddAttribute(HtmlTextWriterAttribute.Style, "border:none; border-collapse: collapse; margin-top:1in; " + Properties.Settings.Default.ApcReportWidth + "; " + Properties.Settings.Default.ApcReportHeight); //style for the table writer.RenderBeginTag(HtmlTextWriterTag.Table); //Begin rendering the top rows, the form name, store, department and date fields. writer.RenderBeginTag(HtmlTextWriterTag.Tr);//begin first row diff --git a/AdvertsingProfitControl/Properties/Settings.Designer.cs b/AdvertsingProfitControl/Properties/Settings.Designer.cs index c1e6273..ed5acce 100644 --- a/AdvertsingProfitControl/Properties/Settings.Designer.cs +++ b/AdvertsingProfitControl/Properties/Settings.Designer.cs @@ -46,5 +46,89 @@ namespace AdvertsingProfitControl.Properties { this["DefaultServer"] = value; } } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("A4")] + public string ReportPaperKind { + get { + return ((string)(this["ReportPaperKind"])); + } + set { + this["ReportPaperKind"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("100%")] + public string ApcReportWidth { + get { + return ((string)(this["ApcReportWidth"])); + } + set { + this["ApcReportWidth"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("100%")] + public string ApcReportHeight { + get { + return ((string)(this["ApcReportHeight"])); + } + set { + this["ApcReportHeight"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("100%")] + public string WicReportWidth { + get { + return ((string)(this["WicReportWidth"])); + } + set { + this["WicReportWidth"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("100%")] + public string WicReportHeight { + get { + return ((string)(this["WicReportHeight"])); + } + set { + this["WicReportHeight"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("14px")] + public string ApcFontSize { + get { + return ((string)(this["ApcFontSize"])); + } + set { + this["ApcFontSize"] = value; + } + } + + [global::System.Configuration.UserScopedSettingAttribute()] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Configuration.DefaultSettingValueAttribute("20px")] + public string WicFontSize { + get { + return ((string)(this["WicFontSize"])); + } + set { + this["WicFontSize"] = value; + } + } } } diff --git a/AdvertsingProfitControl/Properties/Settings.settings b/AdvertsingProfitControl/Properties/Settings.settings index 7c7b56d..8be5cb2 100644 --- a/AdvertsingProfitControl/Properties/Settings.settings +++ b/AdvertsingProfitControl/Properties/Settings.settings @@ -8,5 +8,26 @@ (LocalDb)\MSSQLLocalDB + + A4 + + + 100% + + + 100% + + + 100% + + + 100% + + + 14px + + + 20px + \ No newline at end of file