Changeset 9496 for trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ImageExportDialog.cs
- Timestamp:
- 05/16/13 09:11:15 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ImageExportDialog.cs
r9456 r9496 25 25 using System.Drawing.Imaging; 26 26 using System.IO; 27 using System.Linq; 27 28 using System.Windows.Forms; 28 29 using System.Windows.Forms.DataVisualization.Charting; … … 58 59 else lengthUnitComboBox.SelectedIndex = 0; 59 60 60 titleFontSizeComboBox.Text = "1 2";61 titleFontSizeComboBox.Text = "10"; 61 62 axisFontSizeComboBox.Text = "8"; 62 63 scalesFontSizeComboBox.Text = "6"; 63 64 legendFontSizeComboBox.Text = "6"; 64 resolutionComboBox.Text = " 300";65 resolutionComboBox.Text = "150"; 65 66 SuppressEvents = false; 66 67 splitContainer.Panel2Collapsed = true; 67 68 Width = 305; 68 Height = 5 50;69 Height = 560; 69 70 } finally { SuppressEvents = false; } 70 71 #endregion … … 72 73 73 74 private void UpdateFields() { 74 ChartAreaarea = GetCurrentChartArea();75 var area = GetCurrentChartArea(); 75 76 76 77 try { 77 78 SuppressEvents = true; 78 79 79 if (workingChart.Titles.Count == 0) titleFontSizeComboBox.Text = "1 2";80 if (workingChart.Titles.Count == 0) titleFontSizeComboBox.Text = "10"; 80 81 else { 81 82 titleTextBox.Text = workingChart.Titles[0].Text; … … 90 91 axisFontSizeComboBox.Text = area.AxisX.TitleFont.SizeInPoints.ToString(); 91 92 scalesFontSizeComboBox.Text = area.AxisX.LabelStyle.Font.SizeInPoints.ToString(); 92 if (workingChart.Legends.Count == 0) legendFontSizeComboBox.Text = " 8";93 if (workingChart.Legends.Count == 0) legendFontSizeComboBox.Text = "6"; 93 94 else legendFontSizeComboBox.Text = workingChart.Legends[0].Font.SizeInPoints.ToString(); 94 95 } finally { … … 121 122 } 122 123 123 floatscaleFactor = (float)Math.Min(previewWidth / width, previewHeight / height);124 var scaleFactor = (float)Math.Min(previewWidth / width, previewHeight / height); 124 125 if (scaleFactor >= 1) { 125 126 previewZoomLabel.Text = "100%"; … … 129 130 rawImageSizeLabel.Text = GetRawImageSizeInMegabytes(width, height).ToString("0.00") + "M " + "(" + Math.Round(width).ToString("0") + " x " + Math.Round(height).ToString("0") + ") pixels"; 130 131 131 Bitmapimage = new Bitmap(previewWidth, previewHeight);132 var image = new Bitmap(previewWidth, previewHeight); 132 133 image.SetResolution(dpi, dpi); 133 134 using (Graphics graphics = Graphics.FromImage(image)) { … … 155 156 originalChart.Serializer.Content = SerializationContents.Default; 156 157 originalChart.Serializer.Format = SerializationFormat.Binary; 157 MemoryStreamms = new MemoryStream();158 var ms = new MemoryStream(); 158 159 originalChart.Serializer.Save(ms); 159 160 … … 169 170 170 171 chartAreaComboBox.Items.Clear(); 171 foreach ( ChartAreaarea in originalChart.ChartAreas) {172 foreach (var area in originalChart.ChartAreas) { 172 173 chartAreaComboBox.Items.Add(area.Name); 173 174 } 174 175 chartAreaComboBox.SelectedIndex = 0; 176 SuppressEvents = true; 177 try { 178 showPrimaryXAxisCheckBox.Checked = originalChart.Series.Any(x => x.XAxisType == AxisType.Primary); 179 showPrimaryYAxisCheckBox.Checked = originalChart.Series.Any(x => x.YAxisType == AxisType.Primary); 180 showSecondaryXAxisCheckBox.Checked = originalChart.Series.Any(x => x.XAxisType == AxisType.Secondary); 181 showSecondaryYAxisCheckBox.Checked = originalChart.Series.Any(x => x.YAxisType == AxisType.Secondary); 182 } finally { SuppressEvents = false; } 175 183 base.OnShown(e); 176 184 … … 195 203 private void titleTextBox_TextChanged(object sender, EventArgs e) { 196 204 if (!SuppressEvents) { 197 if (workingChart.Titles.Count > 0) { 198 workingChart.Titles[0].Text = titleTextBox.Text; 199 } else { 200 Title t = new Title(titleTextBox.Text); 201 t.Font = ChangeFontSizePt(t.Font, float.Parse(titleFontSizeComboBox.Text)); 202 workingChart.Titles.Add(t); 205 if (string.IsNullOrEmpty(titleTextBox.Text)) 206 workingChart.Titles.Clear(); 207 else { 208 if (workingChart.Titles.Count > 0) { 209 workingChart.Titles[0].Text = titleTextBox.Text; 210 } else { 211 var t = new Title(titleTextBox.Text); 212 t.Font = ChangeFontSizePt(t.Font, float.Parse(titleFontSizeComboBox.Text)); 213 workingChart.Titles.Add(t); 214 } 203 215 } 204 216 if (togglePreviewCheckBox.Checked) UpdatePreview(); … … 208 220 private void primaryXTextBox_TextChanged(object sender, EventArgs e) { 209 221 if (!SuppressEvents) { 210 ChartAreaarea = GetCurrentChartArea();222 var area = GetCurrentChartArea(); 211 223 area.AxisX.Title = primaryXTextBox.Text; 212 224 if (togglePreviewCheckBox.Checked) UpdatePreview(); … … 216 228 private void primaryYTextBox_TextChanged(object sender, EventArgs e) { 217 229 if (!SuppressEvents) { 218 ChartAreaarea = GetCurrentChartArea();230 var area = GetCurrentChartArea(); 219 231 area.AxisY.Title = primaryYTextBox.Text; 220 232 if (togglePreviewCheckBox.Checked) UpdatePreview(); … … 224 236 private void secondaryXTextBox_TextChanged(object sender, EventArgs e) { 225 237 if (!SuppressEvents) { 226 ChartAreaarea = GetCurrentChartArea();238 var area = GetCurrentChartArea(); 227 239 area.AxisX2.Title = secondaryXTextBox.Text; 228 240 if (togglePreviewCheckBox.Checked) UpdatePreview(); … … 232 244 private void secondaryYTextBox_TextChanged(object sender, EventArgs e) { 233 245 if (!SuppressEvents) { 234 ChartAreaarea = GetCurrentChartArea();246 var area = GetCurrentChartArea(); 235 247 area.AxisY2.Title = secondaryYTextBox.Text; 248 if (togglePreviewCheckBox.Checked) UpdatePreview(); 249 } 250 } 251 252 private void showPrimaryXAxisCheckBox_CheckedChanged(object sender, EventArgs e) { 253 if (!SuppressEvents) { 254 var area = GetCurrentChartArea(); 255 var isChecked = ((CheckBox)sender).Checked; 256 area.AxisX.Enabled = isChecked ? AxisEnabled.True : AxisEnabled.False; 257 if (togglePreviewCheckBox.Checked) UpdatePreview(); 258 } 259 } 260 261 private void showPrimaryYAxisCheckBox_CheckedChanged(object sender, EventArgs e) { 262 if (!SuppressEvents) { 263 var area = GetCurrentChartArea(); 264 var isChecked = ((CheckBox)sender).Checked; 265 area.AxisY.Enabled = isChecked ? AxisEnabled.True : AxisEnabled.False; 266 if (togglePreviewCheckBox.Checked) UpdatePreview(); 267 } 268 } 269 270 private void showSecondaryXAxisCheckBox_CheckedChanged(object sender, EventArgs e) { 271 if (!SuppressEvents) { 272 var area = GetCurrentChartArea(); 273 var isChecked = ((CheckBox)sender).Checked; 274 area.AxisX2.Enabled = isChecked ? AxisEnabled.True : AxisEnabled.False; 275 if (togglePreviewCheckBox.Checked) UpdatePreview(); 276 } 277 } 278 279 private void showSecondaryYAxisCheckBox_CheckedChanged(object sender, EventArgs e) { 280 if (!SuppressEvents) { 281 var area = GetCurrentChartArea(); 282 var isChecked = ((CheckBox)sender).Checked; 283 area.AxisY2.Enabled = isChecked ? AxisEnabled.True : AxisEnabled.False; 236 284 if (togglePreviewCheckBox.Checked) UpdatePreview(); 237 285 } … … 270 318 float fontSize; 271 319 if (float.TryParse(axisFontSizeComboBox.Text, out fontSize)) { 272 ChartAreaarea = GetCurrentChartArea();273 foreach (Axis a in area.Axes) {320 var area = GetCurrentChartArea(); 321 foreach (Axis a in area.Axes) 274 322 a.TitleFont = ChangeFontSizePt(a.TitleFont, fontSize); 275 }276 323 } 277 324 if (togglePreviewCheckBox.Checked) UpdatePreview(); … … 283 330 float fontSize; 284 331 if (float.TryParse(scalesFontSizeComboBox.Text, out fontSize)) { 285 ChartAreaarea = GetCurrentChartArea();286 foreach ( Axis a in area.Axes) {332 var area = GetCurrentChartArea(); 333 foreach (var a in area.Axes) 287 334 a.LabelStyle.Font = ChangeFontSizePt(a.LabelStyle.Font, fontSize); 288 }289 335 } 290 336 if (togglePreviewCheckBox.Checked) UpdatePreview(); … … 296 342 float fontSize; 297 343 if (float.TryParse(legendFontSizeComboBox.Text, out fontSize)) { 298 foreach ( Legend l in workingChart.Legends) {344 foreach (var l in workingChart.Legends) 299 345 l.Font = ChangeFontSizePt(l.Font, fontSize); 300 }301 346 } 302 347 if (togglePreviewCheckBox.Checked) UpdatePreview(); … … 336 381 GetImageParameters(out dpi, out width, out height); 337 382 338 Bitmapimage = new Bitmap((int)Math.Round(width), (int)Math.Round(height));383 var image = new Bitmap((int)Math.Round(width), (int)Math.Round(height)); 339 384 image.SetResolution(dpi, dpi); 340 using ( Graphicsgraphics = Graphics.FromImage(image)) {385 using (var graphics = Graphics.FromImage(image)) { 341 386 workingChart.Printing.PrintPaint(graphics, new Rectangle(0, 0, image.Width, image.Height)); 342 387 } … … 344 389 if (titleTextBox.Text.Trim() != String.Empty) saveFileDialog.FileName = titleTextBox.Text.Trim(); 345 390 if (saveFileDialog.ShowDialog() == DialogResult.OK) { 346 ImageFormatformat = ImageFormat.Bmp;347 stringfilename = saveFileDialog.FileName.ToLower();391 var format = ImageFormat.Bmp; 392 var filename = saveFileDialog.FileName.ToLower(); 348 393 if (filename.EndsWith("jpg")) { 349 394 format = ImageFormat.Jpeg;
Note: See TracChangeset
for help on using the changeset viewer.