source: trunk/CrypPlugins/VigenereAutokeyAnalyser/VigenereAutokeyAnalyserSettings.cs @ 1597

Last change on this file since 1597 was 1597, checked in by nolte, 11 years ago

Added the VigenereAutokey-Analyser to the solution/CrypPlugInBase.
It can be found under the cryptanalyse-statistical tools...
it's already working...Missing Sample,Description and a new icon will follow soon.
I will also rewrite the code/comments soon so it will be more comfortable to read (on Thursday I suppose).

File size: 4.2 KB
Line 
1/* HOWTO: Change year, author name and organization.
2   Copyright 2010 Your Name, University of Duckburg
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*/
16using System;
17using System.Collections.Generic;
18using System.Linq;
19using System.Text;
20using Cryptool.PluginBase;
21using System.ComponentModel;
22
23namespace Cryptool.Plugins.VigenereAutokeyAnalyser
24{
25    public class VigenereAutokeyAnalyserSettings : ISettings
26    {
27        #region Private Variables
28
29        private bool hasChanges = false;
30        private int language = 0;
31        private String alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
32
33        #endregion
34
35        #region TaskPane Settings
36
37        [ContextMenu("Expected Language", "Select the language you expect the plaintext to be", 2, DisplayLevel.Beginner, ContextMenuControlType.ComboBox, null, new String[] { "English", "German", "French", "Spanish" })]
38        [TaskPane("Expected Language", "Select the language you expect the plaintext to be", null, 2, false, DisplayLevel.Experienced, ControlType.ComboBox, new String[] { "English", "German", "French", "Spanish" })]
39        public int Language // Expected Letter Frequencies
40        {
41            get { return this.language; }
42            set
43            {
44                if (((int)value) != language) hasChanges = true;
45                this.language = (int)value;
46                OnPropertyChanged("Language");
47            }
48        }
49
50        [TaskPane("Alphabet", "This is the used alphabet.", null, 7, false, DisplayLevel.Expert, ControlType.TextBox, null)]
51        public string AlphabetSymbols
52        {
53            get { return this.alphabet; }
54            set
55            {
56                string a = removeEqualChars(value);
57                if (a.Length == 0) //cannot accept empty alphabets and will just use the standard;
58                {
59                   
60                }
61                else if (!alphabet.Equals(a))
62                {
63                    hasChanges = true;
64                    this.alphabet = a;
65                    OnPropertyChanged("AlphabetSymbols");
66                }
67            }
68        }
69
70        #endregion
71
72        #region ISettings Members
73
74        /// <summary>
75        /// HOWTO: This flags indicates whether some setting has been changed since the last save.
76        /// If a property was changed, this becomes true, hence CrypTool will ask automatically if you want to save your changes.
77        /// </summary>
78        public bool HasChanges
79        {
80            get
81            {
82                return hasChanges;
83            }
84            set
85            {
86                hasChanges = value;
87            }
88        }
89
90        #endregion
91
92        #region Private methods
93       
94        private string removeEqualChars(string value)
95        {
96            int length = value.Length;
97
98            for (int i = 0; i < length; i++)
99            {
100                for (int j = i + 1; j < length; j++)
101                {
102                    if ((value[i]) == (value[j]))
103                    {                       
104                        value = value.Remove(j, 1);
105                        j--;
106                        length--;
107                    }
108                }
109            }
110            return value;
111        }
112
113        #endregion
114
115        #region INotifyPropertyChanged Members
116
117        public event PropertyChangedEventHandler PropertyChanged;
118
119        protected void OnPropertyChanged(string name)
120        {
121            if (PropertyChanged != null)
122            {
123                PropertyChanged(this, new PropertyChangedEventArgs(name));
124            }
125        }
126
127
128        #endregion
129    }
130}
Note: See TracBrowser for help on using the repository browser.