source: branches/HeuristicLab.Data Path DataTypes/HeuristicLab.Data.Views/3.3/Path Views/DirectoryValueView.cs @ 9697

Last change on this file since 9697 was 9697, checked in by mkommend, 8 years ago

#2081: Updated branches from trunk and implemented all review comments.

File size: 2.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Windows.Forms;
24using HeuristicLab.MainForm;
25
26namespace HeuristicLab.Data.Views {
27  [View("DirectoryValueView")]
28  [Content(typeof(DirectoryValue), true)]
29  public partial class DirectoryValueView : StringConvertibleValueView {
30    public new DirectoryValue Content {
31      get { return (DirectoryValue)base.Content; }
32      set { base.Content = value; }
33    }
34
35    public override bool ReadOnly {
36      get {
37        if ((Content != null) && Content.ReadOnly) return true;
38        return base.ReadOnly;
39      }
40      set { base.ReadOnly = value; }
41    }
42
43    public DirectoryValueView() {
44      InitializeComponent();
45    }
46
47    protected override void SetEnabledStateOfControls() {
48      base.SetEnabledStateOfControls();
49      valueTextBox.Enabled = !Locked && !ReadOnly && Content != null;
50      valueTextBox.ReadOnly = Locked || ReadOnly || Content == null;
51      openButton.Enabled = !Locked && !ReadOnly && Content != null;
52    }
53
54    protected override void OnContentChanged() {
55      base.OnContentChanged();
56      if (Content == null) {
57        valueTextBox.Text = string.Empty;
58        return;
59      }
60
61      valueTextBox.Text = Content.Value;
62      openButton.Enabled = !Content.ReadOnly;
63    }
64
65    protected virtual void openButton_Click(object sender, EventArgs e) {
66      if (folderBrowserDialog.ShowDialog(this) != DialogResult.OK) return;
67      Content.Value = folderBrowserDialog.SelectedPath;
68    }
69  }
70}
Note: See TracBrowser for help on using the repository browser.