Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.Clients.Access/3.3/ServiceClients/AccessItem.cs @ 14113

Last change on this file since 14113 was 13656, checked in by ascheibe, 9 years ago

#2582 created branch for Hive Web Job Manager

File size: 3.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 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.ComponentModel;
24using System.Drawing;
25using System.Runtime.Serialization;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28
29namespace HeuristicLab.Clients.Access {
30  [Item("AccessItem", "Base class for all AccessService items.")]
31  public partial class AccessItem : IAccessItem {
32    public virtual string ItemName
33    {
34      get { return ItemAttribute.GetName(this.GetType()); }
35    }
36    public virtual string ItemDescription
37    {
38      get { return ItemAttribute.GetDescription(this.GetType()); }
39    }
40    public Version ItemVersion
41    {
42      get { return ItemAttribute.GetVersion(this.GetType()); }
43    }
44
45    public virtual Image ItemImage
46    {
47      get
48      {
49        if (Modified)
50          return HeuristicLab.Common.Resources.VSImageLibrary.DatabaseModified;
51        else
52          return ItemAttribute.GetImage(this.GetType());
53      }
54    }
55
56    private bool modified;
57    public bool Modified
58    {
59      get { return modified; }
60      private set
61      {
62        if (value != modified) {
63          modified = value;
64          OnModifiedChanged();
65          RaisePropertyChanged("Modified");
66          OnItemImageChanged();
67          RaisePropertyChanged("ItemImage");
68        }
69      }
70    }
71
72    public void SetUnmodified() {
73      Modified = false;
74    }
75
76    protected AccessItem(AccessItem original, Cloner cloner) {
77      cloner.RegisterClonedObject(original, this);
78      modified = true;
79    }
80    protected AccessItem() {
81      modified = true;
82    }
83
84    [OnDeserialized]
85    private void OnDeserialized(StreamingContext context) {
86      modified = false;
87    }
88
89    public object Clone() {
90      return Clone(new Cloner());
91    }
92    public virtual IDeepCloneable Clone(Cloner cloner) {
93      return new AccessItem(this, cloner);
94    }
95
96    public override string ToString() {
97      return ItemName;
98    }
99
100    protected void RaisePropertyChanged(string propertyName) {
101      OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
102      if ((propertyName != "Id") && (propertyName != "Modified") && (propertyName != "ItemImage")) {
103        Modified = true;
104      }
105    }
106    protected virtual void OnPropertyChanged(PropertyChangedEventArgs e) {
107      PropertyChangedEventHandler handler = PropertyChanged;
108      if (handler != null) handler(this, e);
109    }
110    public event EventHandler ModifiedChanged;
111    protected virtual void OnModifiedChanged() {
112      EventHandler handler = ModifiedChanged;
113      if (handler != null) handler(this, EventArgs.Empty);
114    }
115    public event EventHandler ItemImageChanged;
116    protected virtual void OnItemImageChanged() {
117      EventHandler handler = ItemImageChanged;
118      if (handler != null) handler(this, EventArgs.Empty);
119    }
120    public event EventHandler ToStringChanged;
121    protected virtual void OnToStringChanged() {
122      EventHandler handler = ToStringChanged;
123      if (handler != null) handler(this, EventArgs.Empty);
124    }
125  }
126}
Note: See TracBrowser for help on using the repository browser.