Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Core/EditorBase.cs @ 833

Last change on this file since 833 was 776, checked in by vdorfer, 16 years ago

Created API documentation for HeuristicLab.Core namespace (#331)

File size: 2.6 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2008 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.Collections.Generic;
24using System.ComponentModel;
25using System.Drawing;
26using System.Data;
27using System.Text;
28using System.Windows.Forms;
29
30namespace HeuristicLab.Core {
31  /// <summary>
32  /// Base class for views that can load and save data.
33  /// </summary>
34  public partial class EditorBase : ViewBase, IEditor {
35    private string myFilename;
36    /// <summary>
37    /// Gets or sets the filename of the current editor.
38    /// </summary>
39    /// <remarks>Calls <see cref="OnFilenameChanged"/> in the setter if the filename is new.</remarks>
40    public string Filename {
41      get { return myFilename; }
42      set {
43        if (value != myFilename) {
44          myFilename = value;
45          OnFilenameChanged();
46        }
47      }
48    }
49
50    /// <summary>
51    /// Initializes a new instance of <see cref="EditorBase"/> with the caption "Editor".
52    /// </summary>
53    public EditorBase() {
54      InitializeComponent();
55      Caption = "Editor";
56    }
57
58    /// <summary>
59    /// Updates all controls with the latest data of the model.
60    /// </summary>
61    /// <remarks>Calls <see cref="ViewBase.UpdateControls"/> of base class <see cref="ViewBase"/>.</remarks>
62    protected override void UpdateControls() {
63      base.UpdateControls();
64      if (Item == null)
65        Caption = "Editor";
66      else
67        Caption = "Editor (" + Item.GetType().Name + ")";
68    }
69
70    /// <summary>
71    /// Occurs when the filename is changed.
72    /// </summary>
73    public event EventHandler FilenameChanged;
74    /// <summary>
75    /// Fires a new <c>FilenameChanged</c> event.
76    /// </summary>
77    protected virtual void OnFilenameChanged() {
78      if (FilenameChanged != null)
79        FilenameChanged(this, new EventArgs());
80    }
81  }
82}
Note: See TracBrowser for help on using the repository browser.