Ignore:
Timestamp:
05/23/13 22:24:47 (8 years ago)
Author:
abeham
Message:

#2054:

  • Do not include in legend series that have no points
  • Added ability to changed legend docking (top, right, bottom, left) in addition to font size
  • Also added ability to hide legend
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

    r9496 r9520  
    8484      this.heightNumericUD = new System.Windows.Forms.NumericUpDown();
    8585      this.splitContainer = new System.Windows.Forms.SplitContainer();
     86      this.legendGroupBox = new System.Windows.Forms.GroupBox();
     87      this.label20 = new System.Windows.Forms.Label();
     88      this.legendPositionComboBox = new System.Windows.Forms.ComboBox();
    8689      this.chartAreaComboBox = new System.Windows.Forms.ComboBox();
    8790      this.togglePreviewCheckBox = new System.Windows.Forms.CheckBox();
     
    105108      this.splitContainer.Panel2.SuspendLayout();
    106109      this.splitContainer.SuspendLayout();
     110      this.legendGroupBox.SuspendLayout();
    107111      ((System.ComponentModel.ISupportInitialize)(this.previewPictureBox)).BeginInit();
    108112      this.SuspendLayout();
     
    130134      this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
    131135      this.okButton.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
    132       this.okButton.Location = new System.Drawing.Point(141, 487);
     136      this.okButton.Location = new System.Drawing.Point(141, 552);
    133137      this.okButton.Name = "okButton";
    134138      this.okButton.Size = new System.Drawing.Size(75, 23);
     
    198202            "800",
    199203            "1200"});
    200       this.resolutionComboBox.Location = new System.Drawing.Point(84, 383);
     204      this.resolutionComboBox.Location = new System.Drawing.Point(84, 450);
    201205      this.resolutionComboBox.Name = "resolutionComboBox";
    202206      this.resolutionComboBox.Size = new System.Drawing.Size(83, 21);
     
    215219            0,
    216220            65536});
    217       this.widthNumericUD.Location = new System.Drawing.Point(84, 410);
     221      this.widthNumericUD.Location = new System.Drawing.Point(84, 477);
    218222      this.widthNumericUD.Minimum = new decimal(new int[] {
    219223            1,
     
    234238      //
    235239      this.label5.AutoSize = true;
    236       this.label5.Location = new System.Drawing.Point(18, 386);
     240      this.label5.Location = new System.Drawing.Point(18, 453);
    237241      this.label5.Name = "label5";
    238242      this.label5.Size = new System.Drawing.Size(60, 13);
     
    243247      //
    244248      this.label6.AutoSize = true;
    245       this.label6.Location = new System.Drawing.Point(18, 412);
     249      this.label6.Location = new System.Drawing.Point(18, 479);
    246250      this.label6.Name = "label6";
    247251      this.label6.Size = new System.Drawing.Size(38, 13);
     
    306310      //
    307311      this.cancelButton.DialogResult = System.Windows.Forms.DialogResult.Cancel;
    308       this.cancelButton.Location = new System.Drawing.Point(222, 487);
     312      this.cancelButton.Location = new System.Drawing.Point(222, 552);
    309313      this.cancelButton.Name = "cancelButton";
    310314      this.cancelButton.Size = new System.Drawing.Size(75, 23);
     
    340344      this.groupBox1.Controls.Add(this.label4);
    341345      this.groupBox1.Controls.Add(this.label3);
    342       this.groupBox1.Location = new System.Drawing.Point(12, 154);
     346      this.groupBox1.Location = new System.Drawing.Point(12, 221);
    343347      this.groupBox1.Name = "groupBox1";
    344348      this.groupBox1.Size = new System.Drawing.Size(258, 82);
     
    377381      this.groupBox2.Controls.Add(this.label14);
    378382      this.groupBox2.Controls.Add(this.label15);
    379       this.groupBox2.Location = new System.Drawing.Point(12, 64);
     383      this.groupBox2.Location = new System.Drawing.Point(12, 131);
    380384      this.groupBox2.Name = "groupBox2";
    381385      this.groupBox2.Size = new System.Drawing.Size(258, 84);
     
    460464      this.groupBox3.Controls.Add(this.axisFontSizeComboBox);
    461465      this.groupBox3.Controls.Add(this.titleFontSizeComboBox);
    462       this.groupBox3.Location = new System.Drawing.Point(12, 242);
     466      this.groupBox3.Location = new System.Drawing.Point(12, 309);
    463467      this.groupBox3.Name = "groupBox3";
    464468      this.groupBox3.Size = new System.Drawing.Size(258, 131);
     
    569573      //
    570574      this.label16.AutoSize = true;
    571       this.label16.Location = new System.Drawing.Point(18, 438);
     575      this.label16.Location = new System.Drawing.Point(18, 505);
    572576      this.label16.Name = "label16";
    573577      this.label16.Size = new System.Drawing.Size(41, 13);
     
    583587            0,
    584588            65536});
    585       this.heightNumericUD.Location = new System.Drawing.Point(84, 436);
     589      this.heightNumericUD.Location = new System.Drawing.Point(84, 503);
    586590      this.heightNumericUD.Minimum = new decimal(new int[] {
    587591            1,
     
    608612      // splitContainer.Panel1
    609613      //
     614      this.splitContainer.Panel1.Controls.Add(this.legendGroupBox);
    610615      this.splitContainer.Panel1.Controls.Add(this.chartAreaComboBox);
    611616      this.splitContainer.Panel1.Controls.Add(this.togglePreviewCheckBox);
     
    632637      this.splitContainer.Panel2.Controls.Add(this.rawImageSizeLabel);
    633638      this.splitContainer.Panel2.Controls.Add(this.previewZoomLabel);
    634       this.splitContainer.Size = new System.Drawing.Size(793, 478);
     639      this.splitContainer.Size = new System.Drawing.Size(793, 542);
    635640      this.splitContainer.SplitterDistance = 300;
    636641      this.splitContainer.SplitterWidth = 1;
    637642      this.splitContainer.TabIndex = 1;
     643      //
     644      // legendGroupBox
     645      //
     646      this.legendGroupBox.Controls.Add(this.label20);
     647      this.legendGroupBox.Controls.Add(this.legendPositionComboBox);
     648      this.legendGroupBox.Location = new System.Drawing.Point(12, 64);
     649      this.legendGroupBox.Name = "legendGroupBox";
     650      this.legendGroupBox.Size = new System.Drawing.Size(258, 61);
     651      this.legendGroupBox.TabIndex = 17;
     652      this.legendGroupBox.TabStop = false;
     653      this.legendGroupBox.Text = "Legend";
     654      //
     655      // label20
     656      //
     657      this.label20.AutoSize = true;
     658      this.label20.Location = new System.Drawing.Point(6, 27);
     659      this.label20.Name = "label20";
     660      this.label20.Size = new System.Drawing.Size(47, 13);
     661      this.label20.TabIndex = 0;
     662      this.label20.Text = "Position:";
     663      //
     664      // legendPositionComboBox
     665      //
     666      this.legendPositionComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
     667      this.legendPositionComboBox.FormattingEnabled = true;
     668      this.legendPositionComboBox.Items.AddRange(new object[] {
     669            "Top",
     670            "Right",
     671            "Bottom",
     672            "Left",
     673            "Hidden"});
     674      this.legendPositionComboBox.Location = new System.Drawing.Point(72, 24);
     675      this.legendPositionComboBox.Name = "legendPositionComboBox";
     676      this.legendPositionComboBox.Size = new System.Drawing.Size(159, 21);
     677      this.legendPositionComboBox.TabIndex = 3;
     678      this.legendPositionComboBox.SelectedIndexChanged += new System.EventHandler(this.legendPositionComboBox_SelectedIndexChanged);
    638679      //
    639680      // chartAreaComboBox
     
    656697      this.togglePreviewCheckBox.Location = new System.Drawing.Point(277, 3);
    657698      this.togglePreviewCheckBox.Name = "togglePreviewCheckBox";
    658       this.togglePreviewCheckBox.Size = new System.Drawing.Size(20, 472);
     699      this.togglePreviewCheckBox.Size = new System.Drawing.Size(20, 536);
    659700      this.togglePreviewCheckBox.TabIndex = 16;
    660701      this.togglePreviewCheckBox.Text = ">";
     
    667708      this.lengthUnitComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    668709      this.lengthUnitComboBox.FormattingEnabled = true;
    669       this.lengthUnitComboBox.Location = new System.Drawing.Point(173, 422);
     710      this.lengthUnitComboBox.Location = new System.Drawing.Point(173, 489);
    670711      this.lengthUnitComboBox.Name = "lengthUnitComboBox";
    671712      this.lengthUnitComboBox.Size = new System.Drawing.Size(70, 21);
     
    677718      this.resolutionUnitComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
    678719      this.resolutionUnitComboBox.FormattingEnabled = true;
    679       this.resolutionUnitComboBox.Location = new System.Drawing.Point(173, 383);
     720      this.resolutionUnitComboBox.Location = new System.Drawing.Point(173, 450);
    680721      this.resolutionUnitComboBox.Name = "resolutionUnitComboBox";
    681722      this.resolutionUnitComboBox.Size = new System.Drawing.Size(70, 21);
     
    696737      this.previewPictureBox.Location = new System.Drawing.Point(0, 3);
    697738      this.previewPictureBox.Name = "previewPictureBox";
    698       this.previewPictureBox.Size = new System.Drawing.Size(492, 453);
     739      this.previewPictureBox.Size = new System.Drawing.Size(492, 520);
    699740      this.previewPictureBox.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
    700741      this.previewPictureBox.TabIndex = 0;
     
    704745      //
    705746      this.label19.AutoSize = true;
    706       this.label19.Location = new System.Drawing.Point(85, 459);
     747      this.label19.Location = new System.Drawing.Point(84, 526);
    707748      this.label19.Name = "label19";
    708749      this.label19.Size = new System.Drawing.Size(84, 13);
     
    713754      //
    714755      this.label13.AutoSize = true;
    715       this.label13.Location = new System.Drawing.Point(3, 459);
     756      this.label13.Location = new System.Drawing.Point(2, 526);
    716757      this.label13.Name = "label13";
    717758      this.label13.Size = new System.Drawing.Size(37, 13);
     
    722763      //
    723764      this.rawImageSizeLabel.AutoSize = true;
    724       this.rawImageSizeLabel.Location = new System.Drawing.Point(175, 459);
     765      this.rawImageSizeLabel.Location = new System.Drawing.Point(174, 526);
    725766      this.rawImageSizeLabel.Name = "rawImageSizeLabel";
    726767      this.rawImageSizeLabel.Size = new System.Drawing.Size(37, 13);
     
    731772      //
    732773      this.previewZoomLabel.AutoSize = true;
    733       this.previewZoomLabel.Location = new System.Drawing.Point(46, 459);
     774      this.previewZoomLabel.Location = new System.Drawing.Point(45, 526);
    734775      this.previewZoomLabel.Name = "previewZoomLabel";
    735776      this.previewZoomLabel.Size = new System.Drawing.Size(33, 13);
     
    748789      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    749790      this.CancelButton = this.cancelButton;
    750       this.ClientSize = new System.Drawing.Size(794, 522);
     791      this.ClientSize = new System.Drawing.Size(794, 587);
    751792      this.ControlBox = false;
    752793      this.Controls.Add(this.splitContainer);
     
    772813      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    773814      this.splitContainer.ResumeLayout(false);
     815      this.legendGroupBox.ResumeLayout(false);
     816      this.legendGroupBox.PerformLayout();
    774817      ((System.ComponentModel.ISupportInitialize)(this.previewPictureBox)).EndInit();
    775818      this.ResumeLayout(false);
     
    829872    private System.Windows.Forms.CheckBox showPrimaryXAxisCheckBox;
    830873    private System.Windows.Forms.ToolTip toolTip;
     874    private System.Windows.Forms.GroupBox legendGroupBox;
     875    private System.Windows.Forms.Label label20;
     876    private System.Windows.Forms.ComboBox legendPositionComboBox;
    831877  }
    832878}
  • trunk/sources/HeuristicLab.Visualization.ChartControlsExtensions/3.3/ImageExportDialog.cs

    r9496 r9520  
    6767        splitContainer.Panel2Collapsed = true;
    6868        Width = 305;
    69         Height = 560;
     69        Height = 625;
    7070      } finally { SuppressEvents = false; }
    7171      #endregion
     
    156156      originalChart.Serializer.Content = SerializationContents.Default;
    157157      originalChart.Serializer.Format = SerializationFormat.Binary;
    158       var ms = new MemoryStream();
    159       originalChart.Serializer.Save(ms);
    160 
    161       ms.Seek(0, SeekOrigin.Begin);
    162       workingChart = new EnhancedChart();
    163       workingChart.Serializer.Format = originalChart.Serializer.Format;
    164       workingChart.Serializer.Load(ms);
    165       ms.Close();
     158      using (var ms = new MemoryStream()) {
     159        originalChart.Serializer.Save(ms);
     160
     161        ms.Seek(0, SeekOrigin.Begin);
     162        workingChart = new EnhancedChart();
     163        workingChart.Serializer.Format = originalChart.Serializer.Format;
     164        workingChart.Serializer.Load(ms);
     165      }
     166
     167      foreach (var s in workingChart.Series.Where(x => !x.Points.Any()).ToArray())
     168        s.IsVisibleInLegend = false;
    166169
    167170      originalChart.Serializer.Content = prevContent;
     
    180183        showSecondaryXAxisCheckBox.Checked = originalChart.Series.Any(x => x.XAxisType == AxisType.Secondary);
    181184        showSecondaryYAxisCheckBox.Checked = originalChart.Series.Any(x => x.YAxisType == AxisType.Secondary);
     185
     186        if (!workingChart.Legends.Any()) {
     187          legendPositionComboBox.Enabled = false;
     188          legendFontSizeComboBox.Enabled = false;
     189        } else {
     190          legendPositionComboBox.Enabled = true;
     191          legendFontSizeComboBox.Enabled = true;
     192          if (workingChart.Legends[0].Enabled) {
     193            switch (workingChart.Legends[0].Docking) {
     194              case Docking.Top:
     195                legendPositionComboBox.SelectedItem = "Top";
     196                break;
     197              case Docking.Right:
     198                legendPositionComboBox.SelectedItem = "Right";
     199                break;
     200              case Docking.Bottom:
     201                legendPositionComboBox.SelectedItem = "Bottom";
     202                break;
     203              case Docking.Left:
     204                legendPositionComboBox.SelectedItem = "Left";
     205                break;
     206            }
     207          } else {
     208            legendPositionComboBox.SelectedItem = "Hidden";
     209          }
     210        }
    182211      } finally { SuppressEvents = false; }
    183212      base.OnShown(e);
     
    199228      if (chartAreaComboBox.SelectedIndex >= 0)
    200229        UpdateFields();
     230    }
     231
     232    private void legendPositionComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     233      if (!SuppressEvents) {
     234        if (legendPositionComboBox.SelectedIndex >= 0) {
     235          var legend = workingChart.Legends[0];
     236          var legendPosition = legendPositionComboBox.Items[legendPositionComboBox.SelectedIndex].ToString();
     237          if (legendPosition != "Hidden" && !legend.Enabled)
     238            legend.Enabled = true;
     239          switch (legendPosition) {
     240            case "Top":
     241              legend.Docking = Docking.Top;
     242              break;
     243            case "Right":
     244              legend.Docking = Docking.Right;
     245              break;
     246            case "Bottom":
     247              legend.Docking = Docking.Bottom;
     248              break;
     249            case "Left":
     250              legend.Docking = Docking.Left;
     251              break;
     252            case "Hidden":
     253              legend.Enabled = false;
     254              break;
     255          }
     256        }
     257        UpdatePreview();
     258      }
    201259    }
    202260
Note: See TracChangeset for help on using the changeset viewer.