Changeset 6641
- Timestamp:
- 08/07/11 11:38:44 (13 years ago)
- Location:
- trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ImageExportDialog.Designer.cs
r6640 r6641 36 36 this.label5 = new System.Windows.Forms.Label(); 37 37 this.label6 = new System.Windows.Forms.Label(); 38 this.axis ComboBox = new System.Windows.Forms.ComboBox();39 this.scales ComboBox = new System.Windows.Forms.ComboBox();38 this.axisFontSizeComboBox = new System.Windows.Forms.ComboBox(); 39 this.scalesFontSizeComboBox = new System.Windows.Forms.ComboBox(); 40 40 this.cancelButton = new System.Windows.Forms.Button(); 41 41 this.label9 = new System.Windows.Forms.Label(); … … 48 48 this.label15 = new System.Windows.Forms.Label(); 49 49 this.groupBox3 = new System.Windows.Forms.GroupBox(); 50 this.label18 = new System.Windows.Forms.Label(); 50 51 this.label12 = new System.Windows.Forms.Label(); 51 52 this.label11 = new System.Windows.Forms.Label(); 52 53 this.label7 = new System.Windows.Forms.Label(); 53 this.titleComboBox = new System.Windows.Forms.ComboBox(); 54 this.legendFontSizeComboBox = new System.Windows.Forms.ComboBox(); 55 this.label17 = new System.Windows.Forms.Label(); 56 this.titleFontSizeComboBox = new System.Windows.Forms.ComboBox(); 54 57 this.label16 = new System.Windows.Forms.Label(); 55 58 this.heightNumericUD = new System.Windows.Forms.NumericUpDown(); … … 101 104 this.okButton.Size = new System.Drawing.Size(75, 23); 102 105 this.okButton.TabIndex = 13; 103 this.okButton.Text = " Ok";106 this.okButton.Text = "Save"; 104 107 this.okButton.UseVisualStyleBackColor = true; 105 108 this.okButton.Click += new System.EventHandler(this.okButton_Click); … … 170 173 // widthNumericUD 171 174 // 172 this.widthNumericUD.DecimalPlaces = 1; 175 this.widthNumericUD.DecimalPlaces = 2; 176 this.widthNumericUD.Increment = new decimal(new int[] { 177 5, 178 0, 179 0, 180 65536}); 173 181 this.widthNumericUD.Location = new System.Drawing.Point(76, 410); 174 182 this.widthNumericUD.Maximum = new decimal(new int[] { 175 42,183 1000, 176 184 0, 177 185 0, … … 181 189 0, 182 190 0, 183 0});191 131072}); 184 192 this.widthNumericUD.Name = "widthNumericUD"; 185 193 this.widthNumericUD.Size = new System.Drawing.Size(75, 20); … … 210 218 this.label6.Text = "Width:"; 211 219 // 212 // axis ComboBox213 // 214 this.axis ComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)220 // axisFontSizeComboBox 221 // 222 this.axisFontSizeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 215 223 | System.Windows.Forms.AnchorStyles.Right))); 216 this.axis ComboBox.FormattingEnabled = true;217 this.axis ComboBox.Items.AddRange(new object[] {224 this.axisFontSizeComboBox.FormattingEnabled = true; 225 this.axisFontSizeComboBox.Items.AddRange(new object[] { 218 226 "6", 219 227 "8", … … 227 235 "36", 228 236 "72"}); 229 this.axis ComboBox.Location = new System.Drawing.Point(54, 46);230 this.axis ComboBox.Name = "axisComboBox";231 this.axis ComboBox.Size = new System.Drawing.Size(84, 21);232 this.axis ComboBox.TabIndex = 3;233 this.axis ComboBox.TextChanged += new System.EventHandler(this.axisComboBox_TextChanged);234 this.axis ComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.axisComboBox_Validating);235 // 236 // scales ComboBox237 // 238 this.scales ComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)237 this.axisFontSizeComboBox.Location = new System.Drawing.Point(54, 46); 238 this.axisFontSizeComboBox.Name = "axisFontSizeComboBox"; 239 this.axisFontSizeComboBox.Size = new System.Drawing.Size(84, 21); 240 this.axisFontSizeComboBox.TabIndex = 3; 241 this.axisFontSizeComboBox.TextChanged += new System.EventHandler(this.axisFontSizeComboBox_TextChanged); 242 this.axisFontSizeComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.numericComboBox_Validating); 243 // 244 // scalesFontSizeComboBox 245 // 246 this.scalesFontSizeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 239 247 | System.Windows.Forms.AnchorStyles.Right))); 240 this.scales ComboBox.FormattingEnabled = true;241 this.scales ComboBox.Items.AddRange(new object[] {248 this.scalesFontSizeComboBox.FormattingEnabled = true; 249 this.scalesFontSizeComboBox.Items.AddRange(new object[] { 242 250 "4", 243 251 "5", … … 255 263 "36", 256 264 "72"}); 257 this.scales ComboBox.Location = new System.Drawing.Point(54, 73);258 this.scales ComboBox.Name = "scalesComboBox";259 this.scales ComboBox.Size = new System.Drawing.Size(84, 21);260 this.scales ComboBox.TabIndex = 5;261 this.scales ComboBox.TextChanged += new System.EventHandler(this.scalesComboBox_TextChanged);262 this.scales ComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.scalesComboBox_Validating);265 this.scalesFontSizeComboBox.Location = new System.Drawing.Point(54, 73); 266 this.scalesFontSizeComboBox.Name = "scalesFontSizeComboBox"; 267 this.scalesFontSizeComboBox.Size = new System.Drawing.Size(84, 21); 268 this.scalesFontSizeComboBox.TabIndex = 5; 269 this.scalesFontSizeComboBox.TextChanged += new System.EventHandler(this.scalesFontSizeComboBox_TextChanged); 270 this.scalesFontSizeComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.numericComboBox_Validating); 263 271 // 264 272 // cancelButton … … 297 305 this.groupBox1.Controls.Add(this.label4); 298 306 this.groupBox1.Controls.Add(this.label3); 299 this.groupBox1.Location = new System.Drawing.Point(1 3, 166);307 this.groupBox1.Location = new System.Drawing.Point(12, 154); 300 308 this.groupBox1.Name = "groupBox1"; 301 309 this.groupBox1.Size = new System.Drawing.Size(258, 82); … … 310 318 this.groupBox2.Controls.Add(this.label14); 311 319 this.groupBox2.Controls.Add(this.label15); 312 this.groupBox2.Location = new System.Drawing.Point(1 3, 73);320 this.groupBox2.Location = new System.Drawing.Point(12, 64); 313 321 this.groupBox2.Name = "groupBox2"; 314 322 this.groupBox2.Size = new System.Drawing.Size(258, 84); … … 357 365 // groupBox3 358 366 // 367 this.groupBox3.Controls.Add(this.label18); 359 368 this.groupBox3.Controls.Add(this.label12); 360 369 this.groupBox3.Controls.Add(this.label11); … … 362 371 this.groupBox3.Controls.Add(this.label1); 363 372 this.groupBox3.Controls.Add(this.label9); 364 this.groupBox3.Controls.Add(this.scalesComboBox); 373 this.groupBox3.Controls.Add(this.legendFontSizeComboBox); 374 this.groupBox3.Controls.Add(this.label17); 375 this.groupBox3.Controls.Add(this.scalesFontSizeComboBox); 365 376 this.groupBox3.Controls.Add(this.label10); 366 this.groupBox3.Controls.Add(this.axis ComboBox);367 this.groupBox3.Controls.Add(this.title ComboBox);368 this.groupBox3.Location = new System.Drawing.Point(1 3, 259);377 this.groupBox3.Controls.Add(this.axisFontSizeComboBox); 378 this.groupBox3.Controls.Add(this.titleFontSizeComboBox); 379 this.groupBox3.Location = new System.Drawing.Point(12, 242); 369 380 this.groupBox3.Name = "groupBox3"; 370 this.groupBox3.Size = new System.Drawing.Size(258, 1 05);381 this.groupBox3.Size = new System.Drawing.Size(258, 131); 371 382 this.groupBox3.TabIndex = 4; 372 383 this.groupBox3.TabStop = false; 373 384 this.groupBox3.Text = "Font Size"; 385 // 386 // label18 387 // 388 this.label18.AutoSize = true; 389 this.label18.Location = new System.Drawing.Point(144, 105); 390 this.label18.Name = "label18"; 391 this.label18.Size = new System.Drawing.Size(16, 13); 392 this.label18.TabIndex = 0; 393 this.label18.Text = "pt"; 374 394 // 375 395 // label12 … … 400 420 this.label7.Text = "pt"; 401 421 // 402 // titleComboBox403 // 404 this. titleComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)422 // legendFontSizeComboBox 423 // 424 this.legendFontSizeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 405 425 | System.Windows.Forms.AnchorStyles.Right))); 406 this.titleComboBox.FormattingEnabled = true; 407 this.titleComboBox.Items.AddRange(new object[] { 426 this.legendFontSizeComboBox.FormattingEnabled = true; 427 this.legendFontSizeComboBox.Items.AddRange(new object[] { 428 "4", 429 "5", 430 "6", 431 "7", 432 "8", 433 "9", 434 "10", 435 "11", 436 "12", 437 "14", 438 "16", 439 "18", 440 "24", 441 "36", 442 "72"}); 443 this.legendFontSizeComboBox.Location = new System.Drawing.Point(54, 100); 444 this.legendFontSizeComboBox.Name = "legendFontSizeComboBox"; 445 this.legendFontSizeComboBox.Size = new System.Drawing.Size(84, 21); 446 this.legendFontSizeComboBox.TabIndex = 5; 447 this.legendFontSizeComboBox.TextChanged += new System.EventHandler(this.legendFontSizeComboBox_TextChanged); 448 this.legendFontSizeComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.numericComboBox_Validating); 449 // 450 // label17 451 // 452 this.label17.AutoSize = true; 453 this.label17.Location = new System.Drawing.Point(6, 105); 454 this.label17.Name = "label17"; 455 this.label17.Size = new System.Drawing.Size(46, 13); 456 this.label17.TabIndex = 4; 457 this.label17.Text = "Legend:"; 458 // 459 // titleFontSizeComboBox 460 // 461 this.titleFontSizeComboBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 462 | System.Windows.Forms.AnchorStyles.Right))); 463 this.titleFontSizeComboBox.FormattingEnabled = true; 464 this.titleFontSizeComboBox.Items.AddRange(new object[] { 408 465 "6", 409 466 "8", … … 417 474 "36", 418 475 "72"}); 419 this.title ComboBox.Location = new System.Drawing.Point(54, 19);420 this.title ComboBox.Name = "titleComboBox";421 this.title ComboBox.Size = new System.Drawing.Size(84, 21);422 this.title ComboBox.TabIndex = 1;423 this.title ComboBox.TextChanged += new System.EventHandler(this.titleComboBox_TextChanged);424 this.title ComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.titleComboBox_Validating);476 this.titleFontSizeComboBox.Location = new System.Drawing.Point(54, 19); 477 this.titleFontSizeComboBox.Name = "titleFontSizeComboBox"; 478 this.titleFontSizeComboBox.Size = new System.Drawing.Size(84, 21); 479 this.titleFontSizeComboBox.TabIndex = 1; 480 this.titleFontSizeComboBox.TextChanged += new System.EventHandler(this.titleFontSizeComboBox_TextChanged); 481 this.titleFontSizeComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.numericComboBox_Validating); 425 482 // 426 483 // label16 … … 435 492 // heightNumericUD 436 493 // 437 this.heightNumericUD.DecimalPlaces = 1; 494 this.heightNumericUD.DecimalPlaces = 2; 495 this.heightNumericUD.Increment = new decimal(new int[] { 496 5, 497 0, 498 0, 499 65536}); 438 500 this.heightNumericUD.Location = new System.Drawing.Point(76, 436); 439 501 this.heightNumericUD.Maximum = new decimal(new int[] { 440 42,502 1000, 441 503 0, 442 504 0, … … 446 508 0, 447 509 0, 448 0});510 131072}); 449 511 this.heightNumericUD.Name = "heightNumericUD"; 450 512 this.heightNumericUD.Size = new System.Drawing.Size(75, 20); … … 497 559 this.chartAreaComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 498 560 this.chartAreaComboBox.FormattingEnabled = true; 499 this.chartAreaComboBox.Location = new System.Drawing.Point(76, 46);561 this.chartAreaComboBox.Location = new System.Drawing.Point(76, 37); 500 562 this.chartAreaComboBox.Name = "chartAreaComboBox"; 501 563 this.chartAreaComboBox.Size = new System.Drawing.Size(189, 21); … … 521 583 this.lengthUnitComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 522 584 this.lengthUnitComboBox.FormattingEnabled = true; 523 this.lengthUnitComboBox.Items.AddRange(new object[] {524 "inch",525 "cm"});526 585 this.lengthUnitComboBox.Location = new System.Drawing.Point(157, 422); 527 586 this.lengthUnitComboBox.Name = "lengthUnitComboBox"; … … 534 593 this.resolutionUnitComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 535 594 this.resolutionUnitComboBox.FormattingEnabled = true; 536 this.resolutionUnitComboBox.Items.AddRange(new object[] {537 "dpi",538 "dpcm"});539 595 this.resolutionUnitComboBox.Location = new System.Drawing.Point(157, 383); 540 596 this.resolutionUnitComboBox.Name = "resolutionUnitComboBox"; … … 546 602 // 547 603 this.label8.AutoSize = true; 548 this.label8.Location = new System.Drawing.Point(10, 4 9);604 this.label8.Location = new System.Drawing.Point(10, 40); 549 605 this.label8.Name = "label8"; 550 606 this.label8.Size = new System.Drawing.Size(60, 13); … … 634 690 private System.Windows.Forms.Label label5; 635 691 private System.Windows.Forms.Label label6; 636 private System.Windows.Forms.ComboBox axis ComboBox;637 private System.Windows.Forms.ComboBox scales ComboBox;692 private System.Windows.Forms.ComboBox axisFontSizeComboBox; 693 private System.Windows.Forms.ComboBox scalesFontSizeComboBox; 638 694 private System.Windows.Forms.Button cancelButton; 639 695 private System.Windows.Forms.Label label9; … … 654 710 private System.Windows.Forms.Label label11; 655 711 private System.Windows.Forms.Label label7; 656 private System.Windows.Forms.ComboBox title ComboBox;712 private System.Windows.Forms.ComboBox titleFontSizeComboBox; 657 713 private System.Windows.Forms.ComboBox lengthUnitComboBox; 658 714 private System.Windows.Forms.ComboBox resolutionUnitComboBox; … … 662 718 private System.Windows.Forms.Label label13; 663 719 private System.Windows.Forms.Label previewZoomLabel; 720 private System.Windows.Forms.Label label18; 721 private System.Windows.Forms.ComboBox legendFontSizeComboBox; 722 private System.Windows.Forms.Label label17; 664 723 } 665 724 } -
trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ImageExportDialog.cs
r6640 r6641 29 29 30 30 namespace HeuristicLab.Visualization.ChartControlsExtensions { 31 public enum LengthUnit { Centimeters = 1, Inches = 2 };32 33 31 public sealed partial class ImageExportDialog : Form { 34 32 private const float CMPERINCH = 2.54f; 33 private static readonly string DPI = "dpi", DPCM = "dpcm", INCH = "inch", CM = "cm"; 35 34 private Chart originalChart, workingChart; 36 35 private bool SuppressEvents { get; set; } … … 47 46 this.originalChart = chart; 48 47 InitializeComponent(); 48 #region Custom Initialization 49 49 SuppressEvents = true; 50 titleComboBox.Text = "12"; 51 resolutionUnitComboBox.SelectedIndex = 0; 52 lengthUnitComboBox.SelectedIndex = 1; 53 resolutionComboBox.Text = "300"; 54 SuppressEvents = false; 55 splitContainer.Panel2Collapsed = true; 56 Width = 305; 57 Height = 550; 50 try { 51 resolutionUnitComboBox.Items.Add(DPI); 52 resolutionUnitComboBox.Items.Add(DPCM); 53 lengthUnitComboBox.Items.Add(INCH); 54 lengthUnitComboBox.Items.Add(CM); 55 resolutionUnitComboBox.SelectedIndex = 0; 56 if (System.Globalization.RegionInfo.CurrentRegion.IsMetric) 57 lengthUnitComboBox.SelectedIndex = 1; 58 else lengthUnitComboBox.SelectedIndex = 0; 59 60 titleFontSizeComboBox.Text = "12"; 61 axisFontSizeComboBox.Text = "8"; 62 scalesFontSizeComboBox.Text = "6"; 63 legendFontSizeComboBox.Text = "6"; 64 resolutionComboBox.Text = "300"; 65 SuppressEvents = false; 66 splitContainer.Panel2Collapsed = true; 67 Width = 305; 68 Height = 550; 69 } finally { SuppressEvents = false; } 70 #endregion 58 71 } 59 72 … … 64 77 SuppressEvents = true; 65 78 66 if (workingChart.Titles.Count == 0) title ComboBox.Text = "12";79 if (workingChart.Titles.Count == 0) titleFontSizeComboBox.Text = "12"; 67 80 else { 68 81 titleTextBox.Text = workingChart.Titles[0].Text; 69 title ComboBox.Text = workingChart.Titles[0].Font.SizeInPoints.ToString();82 titleFontSizeComboBox.Text = workingChart.Titles[0].Font.SizeInPoints.ToString(); 70 83 } 71 84 … … 75 88 secondaryYTextBox.Text = area.AxisY2.Title; 76 89 77 axisComboBox.Text = area.AxisX.TitleFont.SizeInPoints.ToString(); 78 scalesComboBox.Text = area.AxisX.LabelStyle.Font.SizeInPoints.ToString(); 90 axisFontSizeComboBox.Text = area.AxisX.TitleFont.SizeInPoints.ToString(); 91 scalesFontSizeComboBox.Text = area.AxisX.LabelStyle.Font.SizeInPoints.ToString(); 92 if (workingChart.Legends.Count == 0) legendFontSizeComboBox.Text = "8"; 93 else legendFontSizeComboBox.Text = workingChart.Legends[0].Font.SizeInPoints.ToString(); 79 94 } finally { 80 95 SuppressEvents = false; … … 87 102 88 103 private void UpdatePreview() { 89 float dpi = float.Parse(resolutionComboBox.Text); 90 if (resolutionUnitComboBox.SelectedIndex == 1) dpi *= CMPERINCH; 91 float width = (float)widthNumericUD.Value; 92 float height = (float)heightNumericUD.Value; 93 if (lengthUnitComboBox.SelectedIndex == 1) { 94 width /= CMPERINCH; height /= CMPERINCH; 95 } 96 width *= dpi; height *= dpi; 97 if (previewPictureBox.Image != null) previewPictureBox.Image.Dispose(); 104 float dpi; 105 float width; 106 float height; 107 GetImageParameters(out dpi, out width, out height); 108 109 if (previewPictureBox.Image != null) { 110 previewPictureBox.Image.Dispose(); 111 previewPictureBox.Image = null; 112 } 113 98 114 int previewWidth, previewHeight; 99 115 if (width / height >= 1.0) { … … 104 120 previewWidth = (int)Math.Round(width / height * previewHeight); 105 121 } 122 123 float scaleFactor = (float)Math.Min(previewWidth / width, previewHeight / height); 124 if (scaleFactor >= 1) { 125 previewZoomLabel.Text = "100%"; 126 previewWidth = (int)Math.Round(width); 127 previewHeight = (int)Math.Round(height); 128 } else previewZoomLabel.Text = (scaleFactor * 100).ToString("0") + "%"; 129 106 130 Bitmap image = new Bitmap(previewWidth, previewHeight); 107 131 image.SetResolution(dpi, dpi); 108 132 using (Graphics graphics = Graphics.FromImage(image)) { 109 graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality; 110 graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic; 111 graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality; 112 float scaleFactor = (float)Math.Min(image.Width / width, image.Height / height); 113 previewZoomLabel.Text = (scaleFactor * 100).ToString("0") + "%"; 114 graphics.ScaleTransform(scaleFactor, scaleFactor); 115 workingChart.Printing.PrintPaint(graphics, new Rectangle(0, 0, (int)width, (int)height)); 133 if (scaleFactor < 1) graphics.ScaleTransform(scaleFactor, scaleFactor); 134 workingChart.Printing.PrintPaint(graphics, new Rectangle(0, 0, (int)Math.Round(width), (int)Math.Round(height))); 116 135 } 117 136 previewPictureBox.Image = image; 118 137 } 119 138 139 private void GetImageParameters(out float dpi, out float width, out float height) { 140 dpi = float.Parse(resolutionComboBox.Text); 141 if (resolutionUnitComboBox.Text == DPCM) dpi *= CMPERINCH; 142 width = (float)widthNumericUD.Value; 143 height = (float)heightNumericUD.Value; 144 if (lengthUnitComboBox.Text == CM) { 145 width /= CMPERINCH; height /= CMPERINCH; 146 } 147 width *= dpi; height *= dpi; 148 } 149 120 150 protected override void OnShown(EventArgs e) { 121 var prev = originalChart.Serializer.Content; 151 #region Create copy of chart 152 var prevContent = originalChart.Serializer.Content; 153 var prevFormat = originalChart.Serializer.Format; 122 154 originalChart.Serializer.Content = SerializationContents.Default; 155 originalChart.Serializer.Format = SerializationFormat.Binary; 123 156 MemoryStream ms = new MemoryStream(); 124 157 originalChart.Serializer.Save(ms); 125 originalChart.Serializer.Content = prev; 158 originalChart.Serializer.Content = prevContent; 159 originalChart.Serializer.Format = prevFormat; 126 160 127 161 ms.Seek(0, SeekOrigin.Begin); … … 129 163 workingChart.Serializer.Load(ms); 130 164 ms.Close(); 165 #endregion 131 166 132 167 chartAreaComboBox.Items.Clear(); … … 161 196 } else { 162 197 Title t = new Title(titleTextBox.Text); 198 t.Font = ChangeFontSizePt(t.Font, float.Parse(titleFontSizeComboBox.Text)); 163 199 workingChart.Titles.Add(t); 164 200 } … … 207 243 } 208 244 209 private void title ComboBox_TextChanged(object sender, EventArgs e) {245 private void titleFontSizeComboBox_TextChanged(object sender, EventArgs e) { 210 246 if (!SuppressEvents) { 211 247 float fontSize; 212 if (float.TryParse(title ComboBox.Text, out fontSize)) {248 if (float.TryParse(titleFontSizeComboBox.Text, out fontSize)) { 213 249 if (workingChart.Titles.Count > 0) { 214 250 workingChart.Titles[0].Font = ChangeFontSizePt(workingChart.Titles[0].Font, fontSize); … … 219 255 } 220 256 221 private void titleComboBox_Validating(object sender, CancelEventArgs e) { 222 float number; 223 e.Cancel = !float.TryParse(titleComboBox.Text, out number); 224 } 225 226 private void axisComboBox_TextChanged(object sender, EventArgs e) { 257 private void axisFontSizeComboBox_TextChanged(object sender, EventArgs e) { 227 258 if (!SuppressEvents) { 228 259 float fontSize; 229 if (float.TryParse(axis ComboBox.Text, out fontSize)) {260 if (float.TryParse(axisFontSizeComboBox.Text, out fontSize)) { 230 261 ChartArea area = GetCurrentChartArea(); 231 262 foreach (Axis a in area.Axes) { … … 237 268 } 238 269 239 private void axisComboBox_Validating(object sender, CancelEventArgs e) { 240 float number; 241 e.Cancel = !float.TryParse(axisComboBox.Text, out number); 242 } 243 244 private void scalesComboBox_TextChanged(object sender, EventArgs e) { 270 private void scalesFontSizeComboBox_TextChanged(object sender, EventArgs e) { 245 271 if (!SuppressEvents) { 246 272 float fontSize; 247 if (float.TryParse(scales ComboBox.Text, out fontSize)) {273 if (float.TryParse(scalesFontSizeComboBox.Text, out fontSize)) { 248 274 ChartArea area = GetCurrentChartArea(); 249 275 foreach (Axis a in area.Axes) { … … 255 281 } 256 282 257 private void scalesComboBox_Validating(object sender, CancelEventArgs e) { 283 private void legendFontSizeComboBox_TextChanged(object sender, EventArgs e) { 284 if (!SuppressEvents) { 285 float fontSize; 286 if (float.TryParse(legendFontSizeComboBox.Text, out fontSize)) { 287 foreach (Legend l in workingChart.Legends) { 288 l.Font = ChangeFontSizePt(l.Font, fontSize); 289 } 290 } 291 if (togglePreviewCheckBox.Checked) UpdatePreview(); 292 } 293 } 294 295 private void numericComboBox_Validating(object sender, CancelEventArgs e) { 296 if (!(sender is ComboBox)) return; 258 297 float number; 259 e.Cancel = !float.TryParse( scalesComboBox.Text, out number);298 e.Cancel = !float.TryParse((sender as ComboBox).Text, out number); 260 299 } 261 300 … … 281 320 282 321 private void okButton_Click(object sender, EventArgs e) { 283 float dpi = float.Parse(resolutionComboBox.Text); 284 if (resolutionUnitComboBox.SelectedIndex == 1) dpi *= CMPERINCH; 285 float width = (float)widthNumericUD.Value; 286 float height = (float)heightNumericUD.Value; 287 if (lengthUnitComboBox.SelectedIndex == 1) { 288 width /= CMPERINCH; 289 height /= CMPERINCH; 290 } 291 Bitmap image = new Bitmap((int)Math.Round(width * dpi), (int)Math.Round(height * dpi)); 322 float dpi; 323 float width; 324 float height; 325 GetImageParameters(out dpi, out width, out height); 326 327 Bitmap image = new Bitmap((int)Math.Round(width), (int)Math.Round(height)); 292 328 image.SetResolution(dpi, dpi); 293 329 using (Graphics graphics = Graphics.FromImage(image)) { … … 295 331 } 296 332 333 if (titleTextBox.Text.Trim() != String.Empty) saveFileDialog.FileName = titleTextBox.Text.Trim(); 297 334 if (saveFileDialog.ShowDialog() == DialogResult.OK) { 298 335 ImageFormat format = ImageFormat.Bmp;
Note: See TracChangeset
for help on using the changeset viewer.