source: trunk/CrypPlugins/Nihilist/NihilistSettings.cs @ 2334

Last change on this file since 2334 was 2334, checked in by Matthäus Wander, 11 years ago

removed 1006 occurences of DisplayLevel in 218 files (see #122)

File size: 3.0 KB
Line 
1/*                             
2   Copyright 2009 Fabian Enkler
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.ComponentModel;
19using Cryptool.PluginBase;
20
21namespace Nihilist
22{
23    class NihilistSettings : ISettings
24    {
25        private enum Actions
26        {
27            Encrypt,
28            Decrypt
29        }
30
31        private Actions action = Actions.Encrypt;
32        [ContextMenu("Action", "Select the Algorithm action", 0, ContextMenuControlType.ComboBox, null, new[] { "Encrypt", "Decrypt" })]
33        [TaskPane("Action", "Select the Algorithm action", null, 0, false, ControlType.ComboBox, new[] { "Encrypt", "Decrypt" })]
34        public int Action
35        {
36            get { return (int)action; }
37            set
38            {
39                try
40                {
41                    action = (Actions)value;
42                    OnPropertyChanged("Action");
43                }
44                catch (Exception)
45                {
46                    action = Actions.Encrypt;
47                }
48            }
49        }
50
51        private string keyWord = string.Empty;
52        [TaskPane("Keyword", "This is the key used to en/decrypt.", null, 0, false, ControlType.TextBox)]
53        public string KeyWord
54        {
55            get { return keyWord; }
56            set
57            {
58                keyWord = value;
59                OnPropertyChanged("KeyWord");
60            }
61        }
62
63        private string secondKeyWord = string.Empty;
64        [TaskPane("Second Keyword", "This is the second key used to en/decrypt.", null, 0, false, ControlType.TextBox)]
65        public string SecondKeyWord
66        {
67            get { return secondKeyWord; }
68            set
69            {
70                secondKeyWord = value;
71                OnPropertyChanged("SecondKeyWord");
72            }
73        }
74
75        private bool hasChanges;
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        public event PropertyChangedEventHandler PropertyChanged;
90
91        private void OnPropertyChanged(string name)
92        {
93            if (PropertyChanged != null)
94                PropertyChanged(this, new PropertyChangedEventArgs(name));
95            if (name.ToLower() != "haschanges")
96                HasChanges = true;
97        }
98    }
99}
Note: See TracBrowser for help on using the repository browser.