source: trunk/CrypPlugins/NLFSR/NLFSRSettings.cs @ 752

Last change on this file since 752 was 752, checked in by Sören Rinne, 12 years ago
  • new CubeAttackParser-Sample.cte
  • BFP now needs only one presentation for Cube Attack
  • adjusted Trivium
File size: 9.1 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5
6using System.IO;
7using System.Security.Cryptography;
8using Cryptool.PluginBase;
9using System.ComponentModel;
10using Cryptool.PluginBase.Cryptography;
11using Cryptool.PluginBase.IO;
12using System.Runtime.CompilerServices;
13using Cryptool.PluginBase.Miscellaneous;
14using System.Runtime.Remoting.Contexts;
15// for Visibility
16using System.Windows;
17
18namespace Cryptool.NLFSR
19{
20    public class NLFSRSettings : ISettings
21    {
22        #region ISettings Members
23
24        private bool hasChanges = false;
25
26        [TaskPane("Draw NLFSR", "Initializes NLFSR and draws the presentation. This is used to view the NLFSR before pressing play.", null, 0, false, DisplayLevel.Beginner, ControlType.Button)]
27        public void initNLFSR()
28        {
29            OnPropertyChanged("InitNLFSR");
30        }
31       
32        private int rounds = 1; //how many bits will be generated
33        //[ContextMenu("Rounds", "How many bits shall be generated?", 1, DisplayLevel.Beginner, ContextMenuControlType.ComboBox, new int[] { 10, 50, 100 }, "10 bits", "50 bits", "100 bits")]
34        //[TaskPane("Rounds", "How many bits shall be generated?", null, 1, false, DisplayLevel.Beginner, ControlType.TextBox)]
35        [TaskPane("Number of rounds", "How many bits shall be generated? Note: This only applies if no boolean clock is used.", null, 2, false, DisplayLevel.Beginner, ControlType.NumericUpDown, ValidationType.RangeInteger, 0, int.MaxValue)]
36        public int Rounds
37        {
38            get { return this.rounds; }
39            set { 
40                this.rounds = value;
41                OnPropertyChanged("Rounds");
42                HasChanges = true;
43            }
44        }
45
46        string polynomial;
47        [TaskPane("Polynomial", "Define the feedback polynomial. For example x^5 * x^2 + 1.", null, 0, false, DisplayLevel.Beginner, ControlType.TextBox)]
48        public string Polynomial
49        {
50            get { return this.polynomial; }
51            set
52            {
53                this.polynomial = value;
54                OnPropertyChanged("Polynomial");
55                HasChanges = true;
56            }
57        }
58
59        string seed;
60        [TaskPane("Seed", "Define the seed of the LFSR. For example 11100", null, 1, false, DisplayLevel.Beginner, ControlType.TextBox)]
61        public string Seed
62        {
63            get { return this.seed; }
64            set
65            {
66                this.seed = value;
67                OnPropertyChanged("Seed");
68                HasChanges = true;
69            }
70        }
71
72        private bool noQuickwatch = false;
73        [ContextMenu("Do not display Quickwatch", "With this checkbox enabled, no quickwatch will be generated for better performance.", 0, DisplayLevel.Experienced, ContextMenuControlType.CheckBox, null, new string[] { "Display Quickwatch?" })]
74        [TaskPane("Do not display Quickwatch", "With this checkbox enabled, no quickwatch will be generated for better performance.", null, 1, true, DisplayLevel.Beginner, ControlType.CheckBox, "", null)]
75        public bool NoQuickwatch
76        {
77            get { return this.noQuickwatch; }
78            set
79            {
80                this.noQuickwatch = (bool)value;
81                OnPropertyChanged("NoQuickwatch");
82                HasChanges = true;
83            }
84        }
85
86        private bool useClockingBit = false;
87        [ContextMenu("Generate add. output bit", "With this checkbox enabled, the additional output bit will be generated.", 0, DisplayLevel.Experienced, ContextMenuControlType.CheckBox, null, new string[] { "Generate additional output bit?" })]
88        [TaskPane("Generate add. output bit", "With this checkbox enabled, the additional output bit will be generated.", "Additional Output Bit", 0, false, DisplayLevel.Beginner, ControlType.CheckBox, "", null)]
89        public bool UseClockingBit
90        {
91            get { return this.useClockingBit; }
92            set
93            {
94                this.useClockingBit = (bool)value;
95                OnPropertyChanged("UseClockingBit");
96                HasChanges = true;
97                if (this.useClockingBit)
98                    SettingChanged("ClockingBit", Visibility.Visible);
99                else
100                    SettingChanged("ClockingBit", Visibility.Collapsed);
101            }
102        }
103       
104        private int clockingBit = 0;
105        [TaskPane("Additional output bit #", "Which bit shall be generated as an additional output? For example as an clocking bit.", "Additional Output Bit", 1, false, DisplayLevel.Beginner, ControlType.NumericUpDown, ValidationType.RangeInteger, 0, int.MaxValue)]
106        public int ClockingBit
107        {
108            get { return this.clockingBit; }
109            set
110            {
111                this.clockingBit = value;
112                OnPropertyChanged("ClockingBit");
113                HasChanges = true;
114            }
115        }
116
117        private bool useBoolClock = false;
118        [ContextMenu("Use BoolClock", "With this checkbox enabled, BoolClock will be used.", 0, DisplayLevel.Experienced, ContextMenuControlType.CheckBox, null, new string[] { "Use Boolean clock?" })]
119        [TaskPane("Use BoolClock", "With this checkbox enabled, BoolClock will be used.", "Clock Properties", 0, false, DisplayLevel.Beginner, ControlType.CheckBox, "", null)]
120        public bool UseBoolClock
121        {
122            get { return this.useBoolClock; }
123            set
124            {
125                this.useBoolClock = (bool)value;
126                OnPropertyChanged("UseBoolClock");
127                HasChanges = true;
128                if (this.useBoolClock)
129                    SettingChanged("Rounds", Visibility.Collapsed);
130                else
131                    SettingChanged("Rounds", Visibility.Visible);
132            }
133        }
134
135        private bool alwaysCreateOutput = false;
136        [ContextMenu("Always create output", "With this checkbox enabled, an output will be generated, even though the clock is set to false. The output bit will be the bit from the last clock cycle.", 1, DisplayLevel.Experienced, ContextMenuControlType.CheckBox, null, new string[] { "Always generate output?" })]
137        [TaskPane("Always create output", "With this checkbox enabled, an output will be generated, even though the clock is set to false. The output bit will be the bit from the last clock cycle.", "Clock Properties", 1, false, DisplayLevel.Beginner, ControlType.CheckBox, "", null)]
138        public bool AlwaysCreateOutput
139        {
140            get { return this.alwaysCreateOutput; }
141            set
142            {
143                this.alwaysCreateOutput = (bool)value;
144                OnPropertyChanged("AlwaysCreateOutput");
145                HasChanges = true;
146            }
147        }
148
149        private bool createDirtyOutputOnFalseClock = false;
150        [ContextMenu("Create dirty output on false clock", "With this checkbox enabled, an the output is the dirty (-1) if the clock is set to false.", 2, DisplayLevel.Experienced, ContextMenuControlType.CheckBox, null, new string[] { "Create dirty output?" })]
151        [TaskPane("Create dirty output on false clock", "With this checkbox enabled, an the output is the dirty (-1) if the clock is set to false.", "Clock Properties", 2, false, DisplayLevel.Beginner, ControlType.CheckBox, "", null)]
152        public bool CreateDirtyOutputOnFalseClock
153        {
154            get { return this.createDirtyOutputOnFalseClock; }
155            set
156            {
157                this.createDirtyOutputOnFalseClock = (bool)value;
158                OnPropertyChanged("CreateDirtyOutputOnFalseClock");
159                HasChanges = true;
160            }
161        }
162
163        public bool HasChanges
164        {
165            get { return hasChanges; }
166            set { hasChanges = value; }
167        }
168
169        #endregion
170
171        #region INotifyPropertyChanged Members
172
173        public event PropertyChangedEventHandler PropertyChanged;
174
175        // this event is for disabling stuff in the settings pane
176        public event TaskPaneAttributeChangedHandler TaskPaneAttributeChanged;
177
178        public void OnPropertyChanged(string name)
179        {
180            if (PropertyChanged != null)
181            {
182                EventsHelper.PropertyChanged(PropertyChanged, this, new PropertyChangedEventArgs(name));
183            }
184        }
185
186        // these 2 functions are for disabling stuff in the settings pane
187        private void SettingChanged(string setting, Visibility vis)
188        {
189            if (TaskPaneAttributeChanged != null)
190            {
191                TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer(setting, vis)));
192            }
193        }
194
195        private void SettingChanged(string setting, Visibility vis, TaskPaneAttribute tpa)
196        {
197            if (TaskPaneAttributeChanged != null)
198            {
199                TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer(setting, vis, tpa)));
200            }
201        }
202
203        #endregion
204    }
205}
Note: See TracBrowser for help on using the repository browser.