Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1389


Ignore:
Timestamp:
03/21/09 13:41:51 (15 years ago)
Author:
dwagner
Message:

Added Functionality: Changes in dialog are directly applied to the linechart & reset button resets the values (#478)

Location:
trunk/sources/HeuristicLab.Visualization/Options
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.Designer.cs

    r1345 r1389  
    2626      this.OptionsDialogCancelButton = new System.Windows.Forms.Button();
    2727      this.OptionsDialogOkButton = new System.Windows.Forms.Button();
    28       this.OptionsDialogApplyBtn = new System.Windows.Forms.Button();
    2928      this.fdFont = new System.Windows.Forms.FontDialog();
    3029      this.tpTitle = new System.Windows.Forms.TabPage();
     
    6564      this.OptionsDialogCancelButton.Size = new System.Drawing.Size(75, 23);
    6665      this.OptionsDialogCancelButton.TabIndex = 1;
    67       this.OptionsDialogCancelButton.Text = "Cancel";
     66      this.OptionsDialogCancelButton.Text = "Reset";
    6867      this.OptionsDialogCancelButton.UseVisualStyleBackColor = true;
    69       this.OptionsDialogCancelButton.Click += new System.EventHandler(this.OptionsDialogCancelButton_Click);
     68      this.OptionsDialogCancelButton.Click += new System.EventHandler(this.OptionsDialogResetButton_Click);
    7069      //
    7170      // OptionsDialogOkButton
    7271      //
    73       this.OptionsDialogOkButton.Location = new System.Drawing.Point(43, 232);
     72      this.OptionsDialogOkButton.Location = new System.Drawing.Point(132, 232);
    7473      this.OptionsDialogOkButton.Name = "OptionsDialogOkButton";
    7574      this.OptionsDialogOkButton.Size = new System.Drawing.Size(75, 23);
     
    7877      this.OptionsDialogOkButton.UseVisualStyleBackColor = true;
    7978      this.OptionsDialogOkButton.Click += new System.EventHandler(this.OptionsDialogOkButton_Click);
    80       //
    81       // OptionsDialogApplyBtn
    82       //
    83       this.OptionsDialogApplyBtn.Location = new System.Drawing.Point(128, 231);
    84       this.OptionsDialogApplyBtn.Name = "OptionsDialogApplyBtn";
    85       this.OptionsDialogApplyBtn.Size = new System.Drawing.Size(75, 23);
    86       this.OptionsDialogApplyBtn.TabIndex = 3;
    87       this.OptionsDialogApplyBtn.Text = "Apply";
    88       this.OptionsDialogApplyBtn.UseVisualStyleBackColor = true;
    89       this.OptionsDialogApplyBtn.Click += new System.EventHandler(this.OptionsDialogApplyBtn_Click);
    9079      //
    9180      // fdFont
     
    207196      this.LinestyleCB.Size = new System.Drawing.Size(121, 21);
    208197      this.LinestyleCB.TabIndex = 2;
     198      this.LinestyleCB.SelectedIndexChanged += new System.EventHandler(this.LinestyleCB_SelectedIndexChanged);
    209199      //
    210200      // label1
     
    256246      this.LineThicknessCB.Size = new System.Drawing.Size(121, 21);
    257247      this.LineThicknessCB.TabIndex = 4;
     248      this.LineThicknessCB.SelectedIndexChanged += new System.EventHandler(this.LineThicknessCB_SelectedIndexChanged);
    258249      //
    259250      // label3
     
    324315      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    325316      this.ClientSize = new System.Drawing.Size(292, 266);
    326       this.Controls.Add(this.OptionsDialogApplyBtn);
    327317      this.Controls.Add(this.OptionsDialogOkButton);
    328318      this.Controls.Add(this.OptionsDialogCancelButton);
     
    351341    private System.Windows.Forms.Button OptionsDialogCancelButton;
    352342    private System.Windows.Forms.Button OptionsDialogOkButton;
    353     private System.Windows.Forms.Button OptionsDialogApplyBtn;
    354343    private System.Windows.Forms.FontDialog fdFont;
    355344    private System.Windows.Forms.TabPage tpTitle;
  • trunk/sources/HeuristicLab.Visualization/Options/OptionsDialog.cs

    r1388 r1389  
    11using System;
    22using System.Collections.Generic;
     3using System.Drawing;
    34using System.Windows.Forms;
    45using HeuristicLab.Visualization.Legend;
     
    89    private readonly IChartDataRowsModel model;
    910    private readonly ViewSettings viewSettings;
     11    private readonly ViewSettings oldViewSettings;
     12    private LineParams[] oldLineParams;
     13    private Dictionary<CheckBox,bool> ShowYAxisBoxes;
     14
     15    internal class LineParams {
     16      string Label { get; set; }
     17      Color Color { get; set; }
     18      int Thickness { get; set; }
     19      DrawingStyle Style { get; set; }
     20      private readonly IDataRow row;
     21
     22      public LineParams(IDataRow row) {
     23        Label = row.Label;
     24        Color = row.Color;
     25        Thickness = row.Thickness;
     26        Style = row.Style;
     27        this.row = row;
     28      }
     29
     30      public void applySettings() {
     31        row.Label = Label;
     32        row.Color = Color;
     33        row.Thickness = Thickness;
     34        row.Style = Style;
     35      }
     36    }
    1037
    1138    public OptionsDialog(IChartDataRowsModel model) {
     
    1441      this.model = model;
    1542      viewSettings = model.ViewSettings;
     43      oldViewSettings = new ViewSettings(model.ViewSettings);
    1644
    1745      cbLegendPosition.Items.Add(LegendPosition.Top);
     
    2755      dlg.ShowDialog();
    2856      ColorPreviewTB.BackColor = dlg.Color;
     57      ((IDataRow)LineSelectCB.SelectedValue).Color = dlg.Color;
    2958    }
    3059
    3160    public IList<int> GetThicknesses() {
    32       return new List<int>(new int[] {0, 1, 2, 3, 4, 5, 6, 7, 8});
     61      return new List<int>(new int[] {1, 2, 3, 4, 5, 6, 7, 8});
    3362    }
    3463
     
    3867
    3968    private void OptionsDialog_Load(object sender, EventArgs e) {
     69      InitTabPageLines();
     70      InitTabPageYAxes();
     71    }
     72
     73    private void InitTabPageLines() {
    4074      if (model.Rows.Count != 0) {
     75        int index = 0;
     76        oldLineParams = new LineParams[model.Rows.Count];
     77        foreach (var row in model.Rows) {
     78          oldLineParams[index++]= new LineParams(row);
     79        }
     80        LineThicknessCB.DataSource = GetThicknesses();
     81        LinestyleCB.DataSource = GetStyles();
     82        LinestyleCB.SelectedItem = model.Rows[0].Style;
     83        LineThicknessCB.SelectedItem = model.Rows[0].Thickness;
     84
    4185        LineSelectCB.DataSource = model.Rows;
    4286        LineSelectCB.DisplayMember = "Label";
    4387
    44         LineThicknessCB.DataSource = GetThicknesses();
    45         LinestyleCB.DataSource = GetStyles();
     88       
    4689        LineSelectCB.SelectedIndex = 0;
    4790        LineSelectCB_SelectedIndexChanged(this, null);
    48       }
    49 
    50       InitTabPageYAxes();
     91       
     92      }
    5193    }
    5294
    5395    private void InitTabPageYAxes() {
     96      ShowYAxisBoxes = new Dictionary<CheckBox, bool>();
    5497      for (int i = 0; i < model.YAxes.Count; i++) {
    5598        YAxisDescriptor yAxisDescriptor = model.YAxes[i];
     
    58101        chkbox.Text = yAxisDescriptor.Label;
    59102        chkbox.Checked = yAxisDescriptor.ShowYAxis;
     103        ShowYAxisBoxes[chkbox] = yAxisDescriptor.ShowYAxis;
    60104        chkbox.CheckedChanged += delegate { yAxisDescriptor.ShowYAxis = chkbox.Checked; };
    61105       
     
    66110    private void LineSelectCB_SelectedIndexChanged(object sender, EventArgs e) {
    67111      if (LineSelectCB.SelectedValue != null) {
    68         int index =
     112      /*  int index =
    69113          LineThicknessCB.FindStringExact(((IDataRow)LineSelectCB.SelectedValue).Thickness.ToString());
    70114        LineThicknessCB.SelectedIndex = index;
    71115        index = LinestyleCB.FindStringExact(((IDataRow)LineSelectCB.SelectedValue).Style.ToString());
    72         LinestyleCB.SelectedIndex = index;
    73         ColorPreviewTB.BackColor = ((IDataRow)LineSelectCB.SelectedValue).Color;
    74       }
    75     }
    76 
    77     private void OptionsDialogCancelButton_Click(object sender, EventArgs e) {
     116        LinestyleCB.SelectedIndex = index;  */
     117        LineThicknessCB.SelectedItem = ((IDataRow) LineSelectCB.SelectedValue).Thickness;
     118        LinestyleCB.SelectedItem = ((IDataRow)LineSelectCB.SelectedValue).Style;
     119        ColorPreviewTB.BackColor = ((IDataRow)LineSelectCB.SelectedValue).Color;   
     120      }
     121    }
     122
     123   
     124    private void OptionsDialogOkButton_Click(object sender, EventArgs e) {
    78125      Close();
    79126    }
    80 
    81     private void OptionsDialogOkButton_Click(object sender, EventArgs e) {
    82       ApplyChanges();
    83 
    84       Close();
    85     }
    86 
    87     private void OptionsDialogApplyBtn_Click(object sender, EventArgs e) {
    88       ApplyChanges(); 
    89     }
    90 
    91     private void ApplyChanges() {
    92       if (LineSelectCB.SelectedValue != null) {
    93         ((IDataRow)LineSelectCB.SelectedValue).Thickness = (int)LineThicknessCB.SelectedItem;
    94         ((IDataRow)LineSelectCB.SelectedValue).Color = ColorPreviewTB.BackColor;
    95         ((IDataRow)LineSelectCB.SelectedValue).Style = (DrawingStyle)LinestyleCB.SelectedItem;
    96       }
    97       viewSettings.UpdateView();
    98     }
     127   
     128
     129   
    99130
    100131    private void cbLegendPosition_SelectedIndexChanged(object sender, EventArgs e) {
    101132      viewSettings.LegendPosition = (LegendPosition)cbLegendPosition.SelectedItem;
     133      viewSettings.UpdateView();
    102134    }
    103135
     
    143175      }
    144176    }
     177
     178    private void OptionsDialogResetButton_Click(object sender, EventArgs e) {
     179      foreach (var param in oldLineParams) {
     180        param.applySettings();
     181      }
     182
     183      foreach (var box in ShowYAxisBoxes) {
     184        box.Key.Checked = box.Value;
     185      }
     186      viewSettings.LegendColor = oldViewSettings.LegendColor;
     187      viewSettings.LegendPosition = oldViewSettings.LegendPosition;
     188      viewSettings.LegendFont = oldViewSettings.LegendFont;
     189      viewSettings.TitleColor = oldViewSettings.TitleColor;
     190      viewSettings.TitleFont = oldViewSettings.TitleFont;
     191      viewSettings.XAxisColor = oldViewSettings.LegendColor;
     192      viewSettings.XAxisFont = oldViewSettings.XAxisFont;
     193      viewSettings.UpdateView();
     194      cbLegendPosition.SelectedItem = viewSettings.LegendPosition;
     195      this.LineSelectCB_SelectedIndexChanged(this,null);
     196    }
     197
     198    private void LinestyleCB_SelectedIndexChanged(object sender, EventArgs e) {
     199      if (LineSelectCB.SelectedValue != null)
     200        ((IDataRow)LineSelectCB.SelectedValue).Style = (DrawingStyle)LinestyleCB.SelectedItem;
     201    }
     202
     203    private void LineThicknessCB_SelectedIndexChanged(object sender, EventArgs e) {
     204      if (LineSelectCB.SelectedValue != null)
     205        ((IDataRow)LineSelectCB.SelectedValue).Thickness = (int)LineThicknessCB.SelectedItem;
     206    }
     207
     208
     209
     210
    145211  }
    146212}
  • trunk/sources/HeuristicLab.Visualization/Options/ViewSettings.cs

    r1388 r1389  
    2525
    2626      legendPosition = LegendPosition.Bottom;
     27    }
     28
     29    public ViewSettings(ViewSettings src) {
     30     
     31      titleFont = (Font)(src.titleFont.Clone());
     32      titleColor = src.TitleColor;
     33
     34      legendFont = (Font)(src.legendFont.Clone());
     35      legendColor = src.LegendColor;
     36
     37      xAxisFont = (Font) (src.xAxisFont.Clone());
     38      xAxisColor = src.XAxisColor;
     39
     40      legendPosition = src.LegendPosition;
    2741    }
    2842
Note: See TracChangeset for help on using the changeset viewer.