source: trunk/CrypPlugins/IncDec/IncDecSettings.cs @ 1709

Last change on this file since 1709 was 1259, checked in by Matthäus Wander, 12 years ago

shortened license text to boilerplate notice in all source files

File size: 2.8 KB
Line 
1/*
2   Copyright 2008 Thomas Schmid, University of Siegen
3
4   Licensed under the Apache License, Version 2.0 (the "License");
5   you may not use this file except in compliance with the License.
6   You may obtain a copy of the License at
7
8       http://www.apache.org/licenses/LICENSE-2.0
9
10   Unless required by applicable law or agreed to in writing, software
11   distributed under the License is distributed on an "AS IS" BASIS,
12   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   See the License for the specific language governing permissions and
14   limitations under the License.
15*/
16
17using System;
18using System.Collections.Generic;
19using System.Linq;
20using System.Text;
21using Cryptool.PluginBase;
22using System.ComponentModel;
23
24namespace IncDec
25{
26  public class IncDecSettings : ISettings
27  {
28    # region private variables
29    private bool hasChanges;
30    private int value = 1;
31    private Operator currentMode = Operator.Increment;
32    # endregion private variables
33
34    public enum Operator
35    {
36      Increment, 
37      Decrement
38    }
39
40    public Operator CurrentMode
41    {
42      get { return currentMode; }     
43    }
44
45    [ContextMenu("Mode", "Please select increment or decrement operator.", 0, DisplayLevel.Beginner, ContextMenuControlType.ComboBox, null, new string[] { "Increment", "Decrement"})]
46    [TaskPane("Mode", "Please select increment or decrement operator.", "", 0, false, DisplayLevel.Beginner, ControlType.ComboBox, new string[] { "Increment", "Decrement" })]
47    public int ModeSelect
48    {
49      get { return (int)this.currentMode; }
50      set
51      {
52        if (value != (int)currentMode) HasChanges = true;
53        this.currentMode = (Operator)value;
54        OnPropertyChanged("ModeSelect");
55      }
56    }
57
58   
59    [TaskPane("Inc/Dec value", "Value to add or subtract.", null, 1, false, DisplayLevel.Beginner, ControlType.NumericUpDown, ValidationType.RangeInteger, 0, int.MaxValue)]
60    public int Value
61    {
62      get { return this.value; }
63      set
64      {
65        if (value != this.value)
66        {
67          this.value = value;
68          OnPropertyChanged("Value");
69          HasChanges = true;
70        }
71      }
72    }
73
74    #region ISettings Members
75
76    public bool HasChanges
77    {
78      get { return hasChanges; }
79      set 
80      {
81        if (value != hasChanges)
82        {
83          hasChanges = value;
84          OnPropertyChanged("HasChanges");
85        }
86      }
87    }
88
89    #endregion
90
91    #region INotifyPropertyChanged Members
92
93    public event PropertyChangedEventHandler PropertyChanged;
94    public void OnPropertyChanged(string name)
95    {
96      if (PropertyChanged != null)
97      {
98        PropertyChanged(this, new PropertyChangedEventArgs(name));
99      }
100    }
101
102    #endregion
103  }
104}
Note: See TracBrowser for help on using the repository browser.