source: trunk/CrypPlugins/Scytale/ScytaleSettings.cs @ 2214

Last change on this file since 2214 was 575, checked in by Arno Wacker, 12 years ago

Caesar, Scytale: Added license text
Scytal: Completed info/contact fields

File size: 2.8 KB
Line 
1/*                             
2   Copyright 2009 Fabian Enkler, Arno Wacker, Uni Duisburg-Essen
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 Cryptool.Scytale
22{
23
24    public class ScytaleSettings : ISettings
25    {
26        private enum Actions
27        {
28          Encrypt,
29          Decrypt
30        }
31
32        private Actions action = Actions.Encrypt;
33        [ContextMenu("Action","Select the Algorithm action",0,DisplayLevel.Beginner,ContextMenuControlType.ComboBox,null, new [] { "Encrypt", "Decrypt" })]
34        [TaskPane("Action", "Select the Algorithm action", null, 0, false, DisplayLevel.Beginner, ControlType.ComboBox, new [] { "Encrypt", "Decrypt" })]
35        public int Action
36        {
37            get { return (int)action; }
38            set
39            {
40                try
41                {
42                    action = (Actions)value;
43                    OnPropertyChanged("Action");
44                }
45                catch (Exception)
46                {
47                    action = Actions.Encrypt;
48                }
49            }
50        }
51
52        private int stickSize = 1;
53        [TaskPane("Stick size", "This is the size of the used stick.", null, 1, false, DisplayLevel.Beginner, ControlType.NumericUpDown, ValidationType.RangeInteger, 2, 100)]
54        public int StickSize
55        {
56            get { return stickSize; }
57            set
58            {
59                stickSize = value;
60                OnPropertyChanged("StickSize");
61            }
62        }
63
64        private bool hasChanges;
65        public bool HasChanges
66        {
67            get { return hasChanges; }
68            set
69            {
70                if (value != hasChanges)
71                {
72                    hasChanges = value;
73                    OnPropertyChanged("HasChanges");
74                }
75            }
76        }
77
78        public event PropertyChangedEventHandler PropertyChanged;
79
80        private void OnPropertyChanged(string name)
81        {
82            if (PropertyChanged != null)
83                PropertyChanged(this, new PropertyChangedEventArgs(name));
84            if (name.ToLower() != "haschanges")
85                HasChanges = true;
86        }
87    }
88}
Note: See TracBrowser for help on using the repository browser.