Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6641


Ignore:
Timestamp:
08/07/11 11:38:44 (13 years ago)
Author:
abeham
Message:

#1611

  • allow to specify font size of legend items
  • cleaned up code a little (dpi/dpcm, cm/inch)
  • added detection for region settings to select either cm or inch
  • improved preview view (now doesn't scale images beyond 100%)
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  
    3636      this.label5 = new System.Windows.Forms.Label();
    3737      this.label6 = new System.Windows.Forms.Label();
    38       this.axisComboBox = new System.Windows.Forms.ComboBox();
    39       this.scalesComboBox = new System.Windows.Forms.ComboBox();
     38      this.axisFontSizeComboBox = new System.Windows.Forms.ComboBox();
     39      this.scalesFontSizeComboBox = new System.Windows.Forms.ComboBox();
    4040      this.cancelButton = new System.Windows.Forms.Button();
    4141      this.label9 = new System.Windows.Forms.Label();
     
    4848      this.label15 = new System.Windows.Forms.Label();
    4949      this.groupBox3 = new System.Windows.Forms.GroupBox();
     50      this.label18 = new System.Windows.Forms.Label();
    5051      this.label12 = new System.Windows.Forms.Label();
    5152      this.label11 = new System.Windows.Forms.Label();
    5253      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();
    5457      this.label16 = new System.Windows.Forms.Label();
    5558      this.heightNumericUD = new System.Windows.Forms.NumericUpDown();
     
    101104      this.okButton.Size = new System.Drawing.Size(75, 23);
    102105      this.okButton.TabIndex = 13;
    103       this.okButton.Text = "Ok";
     106      this.okButton.Text = "Save";
    104107      this.okButton.UseVisualStyleBackColor = true;
    105108      this.okButton.Click += new System.EventHandler(this.okButton_Click);
     
    170173      // widthNumericUD
    171174      //
    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});
    173181      this.widthNumericUD.Location = new System.Drawing.Point(76, 410);
    174182      this.widthNumericUD.Maximum = new decimal(new int[] {
    175             42,
     183            1000,
    176184            0,
    177185            0,
     
    181189            0,
    182190            0,
    183             0});
     191            131072});
    184192      this.widthNumericUD.Name = "widthNumericUD";
    185193      this.widthNumericUD.Size = new System.Drawing.Size(75, 20);
     
    210218      this.label6.Text = "Width:";
    211219      //
    212       // axisComboBox
    213       //
    214       this.axisComboBox.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)
    215223                  | System.Windows.Forms.AnchorStyles.Right)));
    216       this.axisComboBox.FormattingEnabled = true;
    217       this.axisComboBox.Items.AddRange(new object[] {
     224      this.axisFontSizeComboBox.FormattingEnabled = true;
     225      this.axisFontSizeComboBox.Items.AddRange(new object[] {
    218226            "6",
    219227            "8",
     
    227235            "36",
    228236            "72"});
    229       this.axisComboBox.Location = new System.Drawing.Point(54, 46);
    230       this.axisComboBox.Name = "axisComboBox";
    231       this.axisComboBox.Size = new System.Drawing.Size(84, 21);
    232       this.axisComboBox.TabIndex = 3;
    233       this.axisComboBox.TextChanged += new System.EventHandler(this.axisComboBox_TextChanged);
    234       this.axisComboBox.Validating += new System.ComponentModel.CancelEventHandler(this.axisComboBox_Validating);
    235       //
    236       // scalesComboBox
    237       //
    238       this.scalesComboBox.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)
    239247                  | System.Windows.Forms.AnchorStyles.Right)));
    240       this.scalesComboBox.FormattingEnabled = true;
    241       this.scalesComboBox.Items.AddRange(new object[] {
     248      this.scalesFontSizeComboBox.FormattingEnabled = true;
     249      this.scalesFontSizeComboBox.Items.AddRange(new object[] {
    242250            "4",
    243251            "5",
     
    255263            "36",
    256264            "72"});
    257       this.scalesComboBox.Location = new System.Drawing.Point(54, 73);
    258       this.scalesComboBox.Name = "scalesComboBox";
    259       this.scalesComboBox.Size = new System.Drawing.Size(84, 21);
    260       this.scalesComboBox.TabIndex = 5;
    261       this.scalesComboBox.TextChanged += new System.EventHandler(this.scalesComboBox_TextChanged);
    262       this.scalesComboBox.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);
    263271      //
    264272      // cancelButton
     
    297305      this.groupBox1.Controls.Add(this.label4);
    298306      this.groupBox1.Controls.Add(this.label3);
    299       this.groupBox1.Location = new System.Drawing.Point(13, 166);
     307      this.groupBox1.Location = new System.Drawing.Point(12, 154);
    300308      this.groupBox1.Name = "groupBox1";
    301309      this.groupBox1.Size = new System.Drawing.Size(258, 82);
     
    310318      this.groupBox2.Controls.Add(this.label14);
    311319      this.groupBox2.Controls.Add(this.label15);
    312       this.groupBox2.Location = new System.Drawing.Point(13, 73);
     320      this.groupBox2.Location = new System.Drawing.Point(12, 64);
    313321      this.groupBox2.Name = "groupBox2";
    314322      this.groupBox2.Size = new System.Drawing.Size(258, 84);
     
    357365      // groupBox3
    358366      //
     367      this.groupBox3.Controls.Add(this.label18);
    359368      this.groupBox3.Controls.Add(this.label12);
    360369      this.groupBox3.Controls.Add(this.label11);
     
    362371      this.groupBox3.Controls.Add(this.label1);
    363372      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);
    365376      this.groupBox3.Controls.Add(this.label10);
    366       this.groupBox3.Controls.Add(this.axisComboBox);
    367       this.groupBox3.Controls.Add(this.titleComboBox);
    368       this.groupBox3.Location = new System.Drawing.Point(13, 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);
    369380      this.groupBox3.Name = "groupBox3";
    370       this.groupBox3.Size = new System.Drawing.Size(258, 105);
     381      this.groupBox3.Size = new System.Drawing.Size(258, 131);
    371382      this.groupBox3.TabIndex = 4;
    372383      this.groupBox3.TabStop = false;
    373384      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";
    374394      //
    375395      // label12
     
    400420      this.label7.Text = "pt";
    401421      //
    402       // titleComboBox
    403       //
    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)
    405425                  | 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[] {
    408465            "6",
    409466            "8",
     
    417474            "36",
    418475            "72"});
    419       this.titleComboBox.Location = new System.Drawing.Point(54, 19);
    420       this.titleComboBox.Name = "titleComboBox";
    421       this.titleComboBox.Size = new System.Drawing.Size(84, 21);
    422       this.titleComboBox.TabIndex = 1;
    423       this.titleComboBox.TextChanged += new System.EventHandler(this.titleComboBox_TextChanged);
    424       this.titleComboBox.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);
    425482      //
    426483      // label16
     
    435492      // heightNumericUD
    436493      //
    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});
    438500      this.heightNumericUD.Location = new System.Drawing.Point(76, 436);
    439501      this.heightNumericUD.Maximum = new decimal(new int[] {
    440             42,
     502            1000,
    441503            0,
    442504            0,
     
    446508            0,
    447509            0,
    448             0});
     510            131072});
    449511      this.heightNumericUD.Name = "heightNumericUD";
    450512      this.heightNumericUD.Size = new System.Drawing.Size(75, 20);
     
    497559      this.chartAreaComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    498560      this.chartAreaComboBox.FormattingEnabled = true;
    499       this.chartAreaComboBox.Location = new System.Drawing.Point(76, 46);
     561      this.chartAreaComboBox.Location = new System.Drawing.Point(76, 37);
    500562      this.chartAreaComboBox.Name = "chartAreaComboBox";
    501563      this.chartAreaComboBox.Size = new System.Drawing.Size(189, 21);
     
    521583      this.lengthUnitComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    522584      this.lengthUnitComboBox.FormattingEnabled = true;
    523       this.lengthUnitComboBox.Items.AddRange(new object[] {
    524             "inch",
    525             "cm"});
    526585      this.lengthUnitComboBox.Location = new System.Drawing.Point(157, 422);
    527586      this.lengthUnitComboBox.Name = "lengthUnitComboBox";
     
    534593      this.resolutionUnitComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    535594      this.resolutionUnitComboBox.FormattingEnabled = true;
    536       this.resolutionUnitComboBox.Items.AddRange(new object[] {
    537             "dpi",
    538             "dpcm"});
    539595      this.resolutionUnitComboBox.Location = new System.Drawing.Point(157, 383);
    540596      this.resolutionUnitComboBox.Name = "resolutionUnitComboBox";
     
    546602      //
    547603      this.label8.AutoSize = true;
    548       this.label8.Location = new System.Drawing.Point(10, 49);
     604      this.label8.Location = new System.Drawing.Point(10, 40);
    549605      this.label8.Name = "label8";
    550606      this.label8.Size = new System.Drawing.Size(60, 13);
     
    634690    private System.Windows.Forms.Label label5;
    635691    private System.Windows.Forms.Label label6;
    636     private System.Windows.Forms.ComboBox axisComboBox;
    637     private System.Windows.Forms.ComboBox scalesComboBox;
     692    private System.Windows.Forms.ComboBox axisFontSizeComboBox;
     693    private System.Windows.Forms.ComboBox scalesFontSizeComboBox;
    638694    private System.Windows.Forms.Button cancelButton;
    639695    private System.Windows.Forms.Label label9;
     
    654710    private System.Windows.Forms.Label label11;
    655711    private System.Windows.Forms.Label label7;
    656     private System.Windows.Forms.ComboBox titleComboBox;
     712    private System.Windows.Forms.ComboBox titleFontSizeComboBox;
    657713    private System.Windows.Forms.ComboBox lengthUnitComboBox;
    658714    private System.Windows.Forms.ComboBox resolutionUnitComboBox;
     
    662718    private System.Windows.Forms.Label label13;
    663719    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;
    664723  }
    665724}
  • trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ImageExportDialog.cs

    r6640 r6641  
    2929
    3030namespace HeuristicLab.Visualization.ChartControlsExtensions {
    31   public enum LengthUnit { Centimeters = 1, Inches = 2 };
    32 
    3331  public sealed partial class ImageExportDialog : Form {
    3432    private const float CMPERINCH = 2.54f;
     33    private static readonly string DPI = "dpi", DPCM = "dpcm", INCH = "inch", CM = "cm";
    3534    private Chart originalChart, workingChart;
    3635    private bool SuppressEvents { get; set; }
     
    4746      this.originalChart = chart;
    4847      InitializeComponent();
     48      #region Custom Initialization
    4949      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
    5871    }
    5972
     
    6477        SuppressEvents = true;
    6578
    66         if (workingChart.Titles.Count == 0) titleComboBox.Text = "12";
     79        if (workingChart.Titles.Count == 0) titleFontSizeComboBox.Text = "12";
    6780        else {
    6881          titleTextBox.Text = workingChart.Titles[0].Text;
    69           titleComboBox.Text = workingChart.Titles[0].Font.SizeInPoints.ToString();
     82          titleFontSizeComboBox.Text = workingChart.Titles[0].Font.SizeInPoints.ToString();
    7083        }
    7184
     
    7588        secondaryYTextBox.Text = area.AxisY2.Title;
    7689
    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();
    7994      } finally {
    8095        SuppressEvents = false;
     
    87102
    88103    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
    98114      int previewWidth, previewHeight;
    99115      if (width / height >= 1.0) {
     
    104120        previewWidth = (int)Math.Round(width / height * previewHeight);
    105121      }
     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
    106130      Bitmap image = new Bitmap(previewWidth, previewHeight);
    107131      image.SetResolution(dpi, dpi);
    108132      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)));
    116135      }
    117136      previewPictureBox.Image = image;
    118137    }
    119138
     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
    120150    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;
    122154      originalChart.Serializer.Content = SerializationContents.Default;
     155      originalChart.Serializer.Format = SerializationFormat.Binary;
    123156      MemoryStream ms = new MemoryStream();
    124157      originalChart.Serializer.Save(ms);
    125       originalChart.Serializer.Content = prev;
     158      originalChart.Serializer.Content = prevContent;
     159      originalChart.Serializer.Format = prevFormat;
    126160
    127161      ms.Seek(0, SeekOrigin.Begin);
     
    129163      workingChart.Serializer.Load(ms);
    130164      ms.Close();
     165      #endregion
    131166
    132167      chartAreaComboBox.Items.Clear();
     
    161196        } else {
    162197          Title t = new Title(titleTextBox.Text);
     198          t.Font = ChangeFontSizePt(t.Font, float.Parse(titleFontSizeComboBox.Text));
    163199          workingChart.Titles.Add(t);
    164200        }
     
    207243    }
    208244
    209     private void titleComboBox_TextChanged(object sender, EventArgs e) {
     245    private void titleFontSizeComboBox_TextChanged(object sender, EventArgs e) {
    210246      if (!SuppressEvents) {
    211247        float fontSize;
    212         if (float.TryParse(titleComboBox.Text, out fontSize)) {
     248        if (float.TryParse(titleFontSizeComboBox.Text, out fontSize)) {
    213249          if (workingChart.Titles.Count > 0) {
    214250            workingChart.Titles[0].Font = ChangeFontSizePt(workingChart.Titles[0].Font, fontSize);
     
    219255    }
    220256
    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) {
    227258      if (!SuppressEvents) {
    228259        float fontSize;
    229         if (float.TryParse(axisComboBox.Text, out fontSize)) {
     260        if (float.TryParse(axisFontSizeComboBox.Text, out fontSize)) {
    230261          ChartArea area = GetCurrentChartArea();
    231262          foreach (Axis a in area.Axes) {
     
    237268    }
    238269
    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) {
    245271      if (!SuppressEvents) {
    246272        float fontSize;
    247         if (float.TryParse(scalesComboBox.Text, out fontSize)) {
     273        if (float.TryParse(scalesFontSizeComboBox.Text, out fontSize)) {
    248274          ChartArea area = GetCurrentChartArea();
    249275          foreach (Axis a in area.Axes) {
     
    255281    }
    256282
    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;
    258297      float number;
    259       e.Cancel = !float.TryParse(scalesComboBox.Text, out number);
     298      e.Cancel = !float.TryParse((sender as ComboBox).Text, out number);
    260299    }
    261300
     
    281320
    282321    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));
    292328      image.SetResolution(dpi, dpi);
    293329      using (Graphics graphics = Graphics.FromImage(image)) {
     
    295331      }
    296332
     333      if (titleTextBox.Text.Trim() != String.Empty) saveFileDialog.FileName = titleTextBox.Text.Trim();
    297334      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
    298335        ImageFormat format = ImageFormat.Bmp;
Note: See TracChangeset for help on using the changeset viewer.