source: trunk/CrypPlugins/FrequencyTest/FrequencyTestSettings.cs @ 737

Last change on this file since 737 was 737, checked in by Arno Wacker, 12 years ago
  • Minor changes to FrequencyTest
  • Updated Enigma-samples to avoid loading warnings
File size: 7.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using Cryptool.PluginBase;
6using System.ComponentModel;
7using System.Windows;
8
9namespace Cryptool.FrequencyTest
10{
11    public class FrequencyTestSettings : ISettings
12    {
13        #region ISettings Members
14
15        private bool hasChanges;
16        public bool HasChanges
17        {
18            get { return hasChanges; }
19            set { hasChanges = value; }
20        }
21
22        #endregion
23
24        #region INotifyPropertyChanged Members
25
26        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
27
28        protected void OnPropertyChanged(string name)
29        {
30            if (PropertyChanged != null)
31            {
32                PropertyChanged(this, new PropertyChangedEventArgs(name));
33            }
34        }
35
36        #endregion
37
38
39
40        #region Private variables
41
42        private int unknownSymbolHandling = 0;
43        //private int trimInputString=0;
44        private int caseSensitivity = 0;
45        private int grammLength = 1;
46        private int boundaryFragments = 0;
47        private bool autozoom = true;
48        private int chartHeight = 160;
49        private int scale = 1000; // = 1 , factor of 1000
50
51        #endregion
52
53        #region Private helper methods
54
55        private void showSettingsElement(string element)
56        {
57            if (TaskPaneAttributeChanged != null)
58            {
59                TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer(element, Visibility.Visible)));
60            }
61        }
62
63        private void hideSettingsElement(string element)
64        {
65            if (TaskPaneAttributeChanged != null)
66            {
67                TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer(element, Visibility.Collapsed)));
68            }
69        }
70
71        #endregion
72
73        #region Public events and methods
74
75        /// <summary>
76        /// This event is needed in order to render settings elements visible/invisible
77        /// </summary>
78        public event TaskPaneAttributeChangedHandler TaskPaneAttributeChanged;
79
80        #endregion
81
82        #region Visible settings
83       
84        /// <summary>
85        /// Visible setting how to deal with alphabet case. 0 = case insentive, 1 = case sensitive
86        /// </summary>
87        [PropertySaveOrder(1)]
88        [ContextMenu("Alphabet case sensitivity", "Should upper and lower case be treated differently? (Should a == A)", 7, DisplayLevel.Expert, ContextMenuControlType.ComboBox, null, new string[] { "Case insensitive", "Case sensitive" })]
89        [TaskPane("Alphabet case sensitivity", "Should upper and lower case be treated differently? (Should a == A)", "", 7,false, DisplayLevel.Expert, ControlType.ComboBox, new string[] { "Case insensitive", "Case sensitive" })]
90        public int CaseSensitivity
91        {
92            get { return this.caseSensitivity; }
93            set
94            {
95                if (value != caseSensitivity)
96                {
97                    HasChanges = true;
98                    caseSensitivity = value;
99                }
100
101                OnPropertyChanged("CaseSensitivity");
102            }
103        }
104
105        [PropertySaveOrder(2)]
106        [TaskPane("Enter the length of the gramms to be investigated.", "Groups of how many characters should be checked?", "", 1, false, DisplayLevel.Expert, ControlType.NumericUpDown, ValidationType.RangeInteger, 0, 100)]
107        public int GrammLength
108        {
109            get { return this.grammLength; }
110            set
111            {
112                if (value != grammLength)
113                {
114                    HasChanges = true;
115                    grammLength = value;
116                }
117            }
118        }
119
120        [PropertySaveOrder(3)]
121        [ContextMenu("Handling of unknown characters", "What should be done with encountered characters in the word which are not in the alphabet?", 4, DisplayLevel.Expert, ContextMenuControlType.ComboBox, null, new string[] { "Don't count", "Count" })]
122        [TaskPane("Handling of unknown characters", "What should be done with encountered characters in the word which are not in the alphabet?", null, 4, false, DisplayLevel.Expert, ControlType.ComboBox, new string[] { "Don't count", "Count" })]
123        public int ProcessUnknownSymbols
124        {
125            get { return this.unknownSymbolHandling; }
126            set
127            {
128                if (value != unknownSymbolHandling)
129                {
130                    HasChanges = true;
131                    unknownSymbolHandling = value;
132                }
133
134                OnPropertyChanged("ProcessUnknownSymbols");
135            }
136        }
137
138        /// <summary>
139        /// This option is to choose whether additional n-grams shall be used at word boundary for n-grams with n>=2.
140        /// Example trigrams for the word "cherry":
141        /// che
142        /// her
143        /// err
144        /// rry
145        /// The following fragments at word boundary may be included optionally:
146        /// __c
147        /// _ch
148        /// ry_
149        /// y__
150        /// The underline char represents a whitespace.
151        /// </summary>
152        [PropertySaveOrder(4)]
153        [TaskPane("Word boundary fragments", "Include additional fragments with whitespaces at word boundary? Only relevant for gramlength >= 2.", "", 10, false, DisplayLevel.Expert, ControlType.ComboBox, new string[] { "No fragments at boundary", "Include fragments" })]
154        public int BoundaryFragments
155        {
156            get { return this.boundaryFragments; }
157            set
158            {
159                if (value != boundaryFragments)
160                {
161                    HasChanges = true;
162                    boundaryFragments = value;
163                }
164
165                OnPropertyChanged("BoundaryFragments");
166            }
167        }
168
169        [PropertySaveOrder(5)]
170        [TaskPane("Autozoom", "Should the chart perform autozoom?", "Presentation", 20, true, DisplayLevel.Beginner, ControlType.CheckBox)]
171        public bool Autozoom
172        {
173            get { return this.autozoom; }
174            set
175            {
176                if (value != autozoom)
177                {
178                    HasChanges = true;
179                    autozoom = value;
180                }
181
182                if (autozoom)
183                    hideSettingsElement("ChartHeight");
184                else
185                    showSettingsElement("ChartHeight");
186               
187
188                OnPropertyChanged("Autozoom");
189            }
190        }
191
192
193        [PropertySaveOrder(6)]
194        [TaskPane("Chart height", "This is the chart height, if autozoom is disabled", "Presentation", 21, true, DisplayLevel.Beginner, ControlType.NumericUpDown, ValidationType.RangeInteger, 10, 1000)]
195        public int ChartHeight
196        {
197            get { return this.chartHeight; }
198            set
199            {
200                if (value != chartHeight)
201                {
202                    HasChanges = true;
203                    chartHeight = value;
204                }
205
206                OnPropertyChanged("ChartHeight");
207            }
208        }
209
210
211        [PropertySaveOrder(7)]
212        [TaskPane("Zoom", "Zoom the chart", "Presentation", 22, true, DisplayLevel.Beginner, ControlType.Slider, 5, 2000)]
213        public int Scale
214        {
215            get { return scale; }
216            set
217            {
218                scale = value;
219                HasChanges = true;
220                OnPropertyChanged("Scale");
221            }
222        }
223
224        #endregion
225       
226    }
227}
Note: See TracBrowser for help on using the repository browser.