Free cookie consent management tool by TermsFeed Policy Generator

Changeset 6020 for branches


Ignore:
Timestamp:
04/18/11 17:33:13 (13 years ago)
Author:
abeham
Message:

#1465

  • Fixed some bugs
  • Fixed out-of-sync issue in DataRowVisualPropertiesControl
  • Added border in histogram (white for very dark colors)
  • Added serializer for System.Drawing.Font
  • Added option to choose the font of the title as well as the axis of the chart
Location:
branches/histogram
Files:
1 added
7 edited

Legend:

Unmodified
Added
Removed
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableView.cs

    r6016 r6020  
    164164      series.BorderWidth = 1;
    165165      series.BorderDashStyle = ChartDashStyle.Solid;
     166      series.BorderColor = Color.Empty;
     167
     168      if (row.VisualProperties.Color != Color.Empty)
     169        series.Color = row.VisualProperties.Color;
     170      else series.Color = Color.Empty;
    166171
    167172      switch (row.VisualProperties.ChartType) {
     
    172177          break;
    173178        case DataRowVisualProperties.DataRowChartType.Bars:
     179          // Bar is incompatible with anything but Bar and StackedBar*
    174180          if (!chart.Series.Any(x => x.ChartType != SeriesChartType.Bar && x.ChartType != SeriesChartType.StackedBar && x.ChartType != SeriesChartType.StackedBar100))
    175181            series.ChartType = SeriesChartType.Bar;
     
    188194          series.ChartType = SeriesChartType.Column;
    189195          series.SetCustomProperty("PointWidth", "1");
     196          if (!series.Color.IsEmpty && series.Color.GetBrightness() < 0.25)
     197            series.BorderColor = Color.White;
     198          else series.BorderColor = Color.Black;
    190199          break;
    191200        default:
     
    195204      series.YAxisType = row.VisualProperties.SecondYAxis ? AxisType.Secondary : AxisType.Primary;
    196205      series.XAxisType = row.VisualProperties.SecondXAxis ? AxisType.Secondary : AxisType.Primary;
    197       if (row.VisualProperties.Color != Color.Empty)
    198         series.Color = row.VisualProperties.Color;
    199       else series.Color = Color.Empty;
    200206      series.ToolTip = row.Name + " X = #INDEX, Y = #VAL";
    201207    }
    202208
    203209    private void ConfigureChartArea(ChartArea area) {
     210      if (Content.VisualProperties.TitleFont != null)
     211        chart.Titles[0].Font = Content.VisualProperties.TitleFont;
     212      if (!Content.VisualProperties.TitleColor.IsEmpty)
     213        chart.Titles[0].ForeColor = Content.VisualProperties.TitleColor;
     214
     215      if (Content.VisualProperties.AxisTitleFont != null)
     216        area.AxisX.TitleFont = Content.VisualProperties.AxisTitleFont;
     217      if (!Content.VisualProperties.AxisTitleColor.IsEmpty)
     218        area.AxisX.TitleForeColor = Content.VisualProperties.AxisTitleColor;
    204219      area.AxisX.Title = Content.VisualProperties.XAxisTitle;
     220
     221      if (Content.VisualProperties.AxisTitleFont != null)
     222        area.AxisX2.TitleFont = Content.VisualProperties.AxisTitleFont;
     223      if (!Content.VisualProperties.AxisTitleColor.IsEmpty)
     224        area.AxisX2.TitleForeColor = Content.VisualProperties.AxisTitleColor;
    205225      area.AxisX2.Title = Content.VisualProperties.SecondXAxisTitle;
     226
     227      if (Content.VisualProperties.AxisTitleFont != null)
     228        area.AxisY.TitleFont = Content.VisualProperties.AxisTitleFont;
     229      if (!Content.VisualProperties.AxisTitleColor.IsEmpty)
     230        area.AxisY.TitleForeColor = Content.VisualProperties.AxisTitleColor;
    206231      area.AxisY.Title = Content.VisualProperties.YAxisTitle;
     232
     233      if (Content.VisualProperties.AxisTitleFont != null)
     234        area.AxisY2.TitleFont = Content.VisualProperties.AxisTitleFont;
     235      if (!Content.VisualProperties.AxisTitleColor.IsEmpty)
     236        area.AxisY2.TitleForeColor = Content.VisualProperties.AxisTitleColor;
    207237      area.AxisY2.Title = Content.VisualProperties.SecondYAxisTitle;
     238
    208239      area.RecalculateAxesScale();
    209240      area.AxisX.Minimum = Content.VisualProperties.XAxisMinimumFixedValue;
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableVisualPropertiesControl.Designer.cs

    r6014 r6020  
    7777      this.xAxisSecondaryMinimumAutoRadioButton = new System.Windows.Forms.RadioButton();
    7878      this.axisTabControl = new System.Windows.Forms.TabControl();
     79      this.mainTabPage = new System.Windows.Forms.TabPage();
     80      this.axisFontLabel = new System.Windows.Forms.Label();
     81      this.titleFontLabel = new System.Windows.Forms.Label();
     82      this.axisFontButton = new System.Windows.Forms.Button();
     83      this.label3 = new System.Windows.Forms.Label();
     84      this.titleFontButton = new System.Windows.Forms.Button();
     85      this.label2 = new System.Windows.Forms.Label();
    7986      this.xAxisTabPage = new System.Windows.Forms.TabPage();
    8087      this.yAxisTabPage = new System.Windows.Forms.TabPage();
     
    102109      this.yAxisPrimaryMinimumAutoRadioButton = new System.Windows.Forms.RadioButton();
    103110      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
     111      this.titleFontDialog = new System.Windows.Forms.FontDialog();
     112      this.axisFontDialog = new System.Windows.Forms.FontDialog();
    104113      this.xAxisPrimaryGroupBox.SuspendLayout();
    105114      this.xAxisPrimaryMaximumPanel.SuspendLayout();
     
    109118      this.xAxisSecondaryMinimumPanel.SuspendLayout();
    110119      this.axisTabControl.SuspendLayout();
     120      this.mainTabPage.SuspendLayout();
    111121      this.xAxisTabPage.SuspendLayout();
    112122      this.yAxisTabPage.SuspendLayout();
     
    435445                  | System.Windows.Forms.AnchorStyles.Left)
    436446                  | System.Windows.Forms.AnchorStyles.Right)));
     447      this.axisTabControl.Controls.Add(this.mainTabPage);
    437448      this.axisTabControl.Controls.Add(this.xAxisTabPage);
    438449      this.axisTabControl.Controls.Add(this.yAxisTabPage);
     
    442453      this.axisTabControl.Size = new System.Drawing.Size(336, 257);
    443454      this.axisTabControl.TabIndex = 0;
     455      //
     456      // mainTabPage
     457      //
     458      this.mainTabPage.Controls.Add(this.axisFontLabel);
     459      this.mainTabPage.Controls.Add(this.titleFontLabel);
     460      this.mainTabPage.Controls.Add(this.axisFontButton);
     461      this.mainTabPage.Controls.Add(this.label3);
     462      this.mainTabPage.Controls.Add(this.titleFontButton);
     463      this.mainTabPage.Controls.Add(this.label2);
     464      this.mainTabPage.Location = new System.Drawing.Point(4, 22);
     465      this.mainTabPage.Name = "mainTabPage";
     466      this.mainTabPage.Size = new System.Drawing.Size(328, 231);
     467      this.mainTabPage.TabIndex = 2;
     468      this.mainTabPage.Text = "Main";
     469      this.mainTabPage.UseVisualStyleBackColor = true;
     470      //
     471      // axisFontLabel
     472      //
     473      this.axisFontLabel.AutoSize = true;
     474      this.axisFontLabel.Location = new System.Drawing.Point(101, 44);
     475      this.axisFontLabel.Name = "axisFontLabel";
     476      this.axisFontLabel.Size = new System.Drawing.Size(13, 13);
     477      this.axisFontLabel.TabIndex = 2;
     478      this.axisFontLabel.Text = "()";
     479      //
     480      // titleFontLabel
     481      //
     482      this.titleFontLabel.AutoSize = true;
     483      this.titleFontLabel.Location = new System.Drawing.Point(101, 15);
     484      this.titleFontLabel.Name = "titleFontLabel";
     485      this.titleFontLabel.Size = new System.Drawing.Size(13, 13);
     486      this.titleFontLabel.TabIndex = 2;
     487      this.titleFontLabel.Text = "()";
     488      //
     489      // axisFontButton
     490      //
     491      this.axisFontButton.Location = new System.Drawing.Point(69, 39);
     492      this.axisFontButton.Name = "axisFontButton";
     493      this.axisFontButton.Size = new System.Drawing.Size(26, 23);
     494      this.axisFontButton.TabIndex = 1;
     495      this.axisFontButton.Text = "...";
     496      this.axisFontButton.UseVisualStyleBackColor = true;
     497      this.axisFontButton.Click += new System.EventHandler(this.axisFontButton_Click);
     498      //
     499      // label3
     500      //
     501      this.label3.AutoSize = true;
     502      this.label3.Location = new System.Drawing.Point(9, 44);
     503      this.label3.Name = "label3";
     504      this.label3.Size = new System.Drawing.Size(53, 13);
     505      this.label3.TabIndex = 0;
     506      this.label3.Text = "Axis Font:";
     507      //
     508      // titleFontButton
     509      //
     510      this.titleFontButton.Location = new System.Drawing.Point(69, 10);
     511      this.titleFontButton.Name = "titleFontButton";
     512      this.titleFontButton.Size = new System.Drawing.Size(26, 23);
     513      this.titleFontButton.TabIndex = 1;
     514      this.titleFontButton.Text = "...";
     515      this.titleFontButton.UseVisualStyleBackColor = true;
     516      this.titleFontButton.Click += new System.EventHandler(this.titleFontButton_Click);
     517      //
     518      // label2
     519      //
     520      this.label2.AutoSize = true;
     521      this.label2.Location = new System.Drawing.Point(9, 15);
     522      this.label2.Name = "label2";
     523      this.label2.Size = new System.Drawing.Size(54, 13);
     524      this.label2.TabIndex = 0;
     525      this.label2.Text = "Title Font:";
    444526      //
    445527      // xAxisTabPage
     
    704786      //
    705787      this.errorProvider.ContainerControl = this;
     788      //
     789      // titleFontDialog
     790      //
     791      this.titleFontDialog.FontMustExist = true;
     792      this.titleFontDialog.ShowColor = true;
    706793      //
    707794      // DataTableVisualPropertiesControl
     
    725812      this.xAxisSecondaryMinimumPanel.PerformLayout();
    726813      this.axisTabControl.ResumeLayout(false);
     814      this.mainTabPage.ResumeLayout(false);
     815      this.mainTabPage.PerformLayout();
    727816      this.xAxisTabPage.ResumeLayout(false);
    728817      this.yAxisTabPage.ResumeLayout(false);
     
    802891    private System.Windows.Forms.RadioButton yAxisPrimaryMinimumAutoRadioButton;
    803892    private System.Windows.Forms.ErrorProvider errorProvider;
     893    private System.Windows.Forms.TabPage mainTabPage;
     894    private System.Windows.Forms.FontDialog titleFontDialog;
     895    private System.Windows.Forms.Button titleFontButton;
     896    private System.Windows.Forms.Label label2;
     897    private System.Windows.Forms.Button axisFontButton;
     898    private System.Windows.Forms.Label label3;
     899    private System.Windows.Forms.Label axisFontLabel;
     900    private System.Windows.Forms.Label titleFontLabel;
     901    private System.Windows.Forms.FontDialog axisFontDialog;
    804902  }
    805903}
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableVisualPropertiesControl.cs

    r6014 r6020  
    2020#endregion
    2121
     22using System.Drawing;
    2223using System.Windows.Forms;
    2324using HeuristicLab.MainForm;
     
    4748      try {
    4849        if (Content == null) {
     50          titleFontLabel.Text = "(  )";
     51          axisFontLabel.Text = "(  )";
     52
    4953          xAxisPrimaryTitleTextBox.Text = string.Empty;
    5054          xAxisPrimaryMinimumAutoRadioButton.Checked = false;
     
    7781          yAxisSecondaryMaximumFixedTextBox.Text = string.Empty;
    7882        } else {
     83          titleFontLabel.Text = "( " + FormatFont(Content.TitleFont) + " )";
     84          axisFontLabel.Text = "( " + FormatFont(Content.AxisTitleFont) + " )";
     85
    7986          xAxisPrimaryTitleTextBox.Text = Content.XAxisTitle;
    8087          xAxisPrimaryMinimumAutoRadioButton.Checked = Content.XAxisMinimumAuto;
     
    348355      }
    349356    }
     357
     358    private void titleFontButton_Click(object sender, System.EventArgs e) {
     359      titleFontDialog.Font = Content.TitleFont;
     360      titleFontDialog.Color = Content.TitleColor;
     361      if (titleFontDialog.ShowDialog() == DialogResult.OK) {
     362        Content.TitleFont = titleFontDialog.Font;
     363        Content.TitleColor = titleFontDialog.Color;
     364        titleFontLabel.Text = "( " + FormatFont(Content.TitleFont) + " )";
     365      }
     366    }
     367
     368    private void axisFontButton_Click(object sender, System.EventArgs e) {
     369      axisFontDialog.Font = Content.AxisTitleFont;
     370      axisFontDialog.Color = Content.AxisTitleColor;
     371      if (axisFontDialog.ShowDialog() == DialogResult.OK) {
     372        Content.AxisTitleFont = axisFontDialog.Font;
     373        Content.AxisTitleColor = axisFontDialog.Color;
     374        axisFontLabel.Text = "( " + FormatFont(Content.AxisTitleFont) + " )";
     375      }
     376    }
    350377    #endregion
     378
     379    private string FormatFont(Font f) {
     380      if (f == null) return string.Empty;
     381      else return f.Name + ", " + f.SizeInPoints.ToString() + "pt, " + f.Style.ToString();
     382    }
    351383  }
    352384}
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableVisualPropertiesControl.resx

    r6014 r6020  
    121121    <value>17, 17</value>
    122122  </metadata>
     123  <metadata name="titleFontDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     124    <value>140, 17</value>
     125  </metadata>
     126  <metadata name="axisFontDialog.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
     127    <value>272, 17</value>
     128  </metadata>
    123129</root>
  • branches/histogram/HeuristicLab.Analysis.Views/3.3/DataTableVisualPropertiesDialog.cs

    r6016 r6020  
    2121
    2222using System.Collections.Generic;
     23using System.Linq;
    2324using System.Windows.Forms;
    2425using HeuristicLab.Common.Resources;
    25 using HeuristicLab.Core;
    2626
    2727namespace HeuristicLab.Analysis.Views {
    2828  public partial class DataTableVisualPropertiesDialog : Form {
     29    protected bool SuppressEvents { get; set; }
    2930    protected DataTable Content { get; private set; }
    3031    private DataTableVisualProperties originalDataTableVPs;
     
    5859
    5960    private void seriesListView_SelectedIndexChanged(object sender, System.EventArgs e) {
    60       if (seriesListView.SelectedItems.Count == 0) return;
    61       string rowName = seriesListView.SelectedItems[0].Text;
    62       dataRowVisualPropertiesControl.Content = Content.Rows[rowName].VisualProperties;
     61      if (!SuppressEvents) {
     62        if (seriesListView.SelectedItems.Count != 1) {
     63          dataRowVisualPropertiesControl.Content = null;
     64        } else {
     65          string rowName = seriesListView.SelectedItems[0].Text;
     66          dataRowVisualPropertiesControl.Content = Content.Rows[rowName].VisualProperties;
     67        }
     68      }
    6369    }
    6470
     
    8086      if (seriesListView.SelectedIndices.Count == 1 && seriesListView.SelectedIndices[0] > 0) {
    8187        int index = seriesListView.SelectedIndices[0];
    82         seriesListView.BeginUpdate();
    83         ListViewItem selectedSeriesItem = seriesListView.Items[index];
    84         seriesListView.Items.RemoveAt(index);
    85         ListViewItem temp = seriesListView.Items[index - 1];
    86         seriesListView.Items.RemoveAt(index - 1);
    87         seriesListView.Items.Insert(index - 1, selectedSeriesItem);
    88         seriesListView.Items.Insert(index, temp);
    89         seriesListView.EndUpdate();
     88        SuppressEvents = true;
     89        try {
     90          seriesListView.BeginUpdate();
     91          ListViewItem selectedSeriesItem = seriesListView.Items[index];
     92          seriesListView.Items.RemoveAt(index);
     93          ListViewItem temp = seriesListView.Items[index - 1];
     94          seriesListView.Items.RemoveAt(index - 1);
     95          seriesListView.Items.Insert(index - 1, selectedSeriesItem);
     96          seriesListView.Items.Insert(index, temp);
     97          seriesListView.SelectedIndices.Clear();
     98          seriesListView.EndUpdate();
     99        } finally { SuppressEvents = false; }
     100        seriesListView.SelectedIndices.Add(index - 1);
    90101        UpdateAllSeriesPositions();
    91102      }
     
    95106      if (seriesListView.SelectedIndices.Count == 1 && seriesListView.SelectedIndices[0] < seriesListView.Items.Count - 1) {
    96107        int index = seriesListView.SelectedIndices[0];
    97         seriesListView.BeginUpdate();
    98         ListViewItem temp = seriesListView.Items[index + 1];
    99         seriesListView.Items.RemoveAt(index + 1);
    100         ListViewItem selectedSeriesItem = seriesListView.Items[index];
    101         seriesListView.Items.RemoveAt(index);
    102         seriesListView.Items.Insert(index, temp);
    103         seriesListView.Items.Insert(index + 1, selectedSeriesItem);
    104         seriesListView.EndUpdate();
     108        SuppressEvents = true;
     109        try {
     110          seriesListView.BeginUpdate();
     111          ListViewItem temp = seriesListView.Items[index + 1];
     112          seriesListView.Items.RemoveAt(index + 1);
     113          ListViewItem selectedSeriesItem = seriesListView.Items[index];
     114          seriesListView.Items.RemoveAt(index);
     115          seriesListView.Items.Insert(index, temp);
     116          seriesListView.Items.Insert(index + 1, selectedSeriesItem);
     117          seriesListView.SelectedIndices.Clear();
     118          seriesListView.EndUpdate();
     119        } finally { SuppressEvents = false; }
     120        seriesListView.SelectedIndices.Add(index + 1);
    105121        UpdateAllSeriesPositions();
    106122      }
     
    109125    #region Helpers
    110126    private void UpdateAllSeriesPositions() {
    111       NamedItemCollection<DataRow> rows = (NamedItemCollection<DataRow>)Content.Rows.Clone();
     127      Dictionary<string, DataRow> rows = Content.Rows.ToDictionary(x => x.Name);
    112128      Content.Rows.Clear();
    113129      for (int i = 0; i < seriesListView.Items.Count; i++) {
  • branches/histogram/HeuristicLab.Analysis/3.3/DataVisualization/DataTableVisualProperties.cs

    r6014 r6020  
    2121
    2222using System.ComponentModel;
     23using System.Drawing;
    2324using HeuristicLab.Common;
    2425using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     
    3031  [StorableClass]
    3132  public class DataTableVisualProperties : DeepCloneable, INotifyPropertyChanged {
     33    private Font titleFont;
     34    public Font TitleFont {
     35      get { return titleFont; }
     36      set {
     37        if (titleFont == null || value == null
     38          || titleFont.Name != value.Name || titleFont.Size != value.Size || titleFont.Style != value.Style) {
     39          titleFont = value;
     40          OnPropertyChanged("TitleFont");
     41        }
     42      }
     43    }
     44    private Color titleColor;
     45    public Color TitleColor {
     46      get { return titleColor; }
     47      set {
     48        if (titleColor != value) {
     49          titleColor = value;
     50          OnPropertyChanged("TitleFontColor");
     51        }
     52      }
     53    }
     54    private Font axisTitleFont;
     55    public Font AxisTitleFont {
     56      get { return axisTitleFont; }
     57      set {
     58        if (axisTitleFont == null || axisTitleFont == null
     59          || axisTitleFont.Name != value.Name || axisTitleFont.Size != value.Size || axisTitleFont.Style != value.Style) {
     60          axisTitleFont = value;
     61          OnPropertyChanged("AxisTitleFont");
     62        }
     63      }
     64    }
     65    private Color axisTitleColor;
     66    public Color AxisTitleColor {
     67      get { return axisTitleColor; }
     68      set {
     69        if (axisTitleColor != value) {
     70          axisTitleColor = value;
     71          OnPropertyChanged("AxisTitleColor");
     72        }
     73      }
     74    }
    3275    private string xAxisTitle;
    3376    public string XAxisTitle {
     
    263306
    264307    #region Persistence Properties
     308    [Storable(Name = "TitleFont")]
     309    private Font StorableTitleFont {
     310      get { return titleFont; }
     311      set { titleFont = value; }
     312    }
     313    [Storable(Name = "TitleColor")]
     314    private Color StorableTitleColor {
     315      get { return titleColor; }
     316      set { titleColor = value; }
     317    }
     318    [Storable(Name = "AxisTitleFont")]
     319    private Font StorableAxisTitleFont {
     320      get { return axisTitleFont; }
     321      set { axisTitleFont = value; }
     322    }
     323    [Storable(Name = "AxisTitleColor")]
     324    private Color StorableAxisTitleColor {
     325      get { return axisTitleColor; }
     326      set { axisTitleColor = value; }
     327    }
    265328    [Storable(Name = "XAxisTitle")]
    266329    private string StorableXAxisTitle {
     
    369432    protected DataTableVisualProperties(DataTableVisualProperties original, Cloner cloner)
    370433      : base(original, cloner) {
     434      if (original.titleFont != null)
     435        this.titleFont = (Font)original.titleFont.Clone();
     436      if (original.axisTitleFont != null)
     437        this.axisTitleFont = (Font)original.axisTitleFont.Clone();
    371438      this.xAxisTitle = original.xAxisTitle;
    372439      this.yAxisTitle = original.yAxisTitle;
     
    391458    }
    392459    public DataTableVisualProperties() {
     460      titleColor = Color.Black;
     461      axisTitleColor = Color.Black;
    393462      this.xAxisTitle = string.Empty;
    394463      this.yAxisTitle = string.Empty;
  • branches/histogram/HeuristicLab.Persistence/3.3/HeuristicLab.Persistence-3.3.csproj

    r5698 r6020  
    208208    <Compile Include="Default\Xml\Primitive\SimpleNumber2XmlSerializerBase.cs" />
    209209    <Compile Include="Default\Xml\Primitive\String2XmlSerializer.cs" />
     210    <Compile Include="Default\Xml\Primitive\System.Drawing\Font2XmlSerializer.cs" />
    210211    <Compile Include="Default\Xml\Primitive\TimeSpan2XmlSerializer.cs" />
    211212    <Compile Include="Default\Xml\Primitive\UInt2XmlSerializer.cs" />
Note: See TracChangeset for help on using the changeset viewer.