source: trunk/CrypPlugins/LFSR/LFSRSettings.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.6 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
16// for Visibility
17using System.Windows;
18
19namespace Cryptool.LFSR
20{
21    public class LFSRSettings : ISettings
22    {
23        #region ISettings Members
24
25        private bool hasChanges = false;
26
27        [TaskPane("Draw LFSR", "Initializes LFSR and draws the presentation. This is used to view the LFSR before pressing play.", null, 0, false, DisplayLevel.Beginner, ControlType.Button)]
28        public void initLFSR()
29        {
30            OnPropertyChanged("InitLFSR");
31        }
32       
33        private int rounds = 1; //how many bits will be generated
34        //[ContextMenu("Rounds", "How many bits shall be generated?", 1, DisplayLevel.Beginner, ContextMenuControlType.ComboBox, new int[] { 10, 50, 100 }, "10 bits", "50 bits", "100 bits")]
35        //[TaskPane("Rounds", "How many bits shall be generated?", null, 1, false, DisplayLevel.Beginner, ControlType.TextBox)]
36        [TaskPane("Number of rounds", "How many bits shall be generated? Note: This only applies if no external clock is used.", null, 2, false, DisplayLevel.Beginner, ControlType.NumericUpDown, ValidationType.RangeInteger, 0, int.MaxValue)]
37        public int Rounds
38        {
39            get { return this.rounds; }
40            set { 
41                this.rounds = value;
42                OnPropertyChanged("Rounds");
43                HasChanges = true;
44            }
45        }
46
47        string polynomial;
48        [TaskPane("Polynomial", "Define the feedback polynomial either in a textual or a numeric way. For example x^5 + x^2 + 1 which is equal to 10010.", null, 0, false, DisplayLevel.Beginner, ControlType.TextBox)]
49        public string Polynomial
50        {
51            get { return this.polynomial; }
52            set
53            {
54                this.polynomial = value;
55                OnPropertyChanged("Polynomial");
56                HasChanges = true;
57            }
58        }
59       
60        string seed;
61        [TaskPane("Seed", "Define the seed of the LFSR. For example 11100", null, 1, false, DisplayLevel.Beginner, ControlType.TextBox)]
62        public string Seed
63        {
64            get { return this.seed; }
65            set
66            {
67                this.seed = value;
68                OnPropertyChanged("Seed");
69                HasChanges = true;
70            }
71        }
72
73        private bool noQuickwatch = false;
74        [ContextMenu("Do not display Quickwatch", "With this checkbox enabled, no quickwatch will be generated for a better performance.", 0, DisplayLevel.Experienced, ContextMenuControlType.CheckBox, null, new string[] { "Display Quickwatch?" })]
75        [TaskPane("Do not display Quickwatch", "With this checkbox enabled, no quickwatch will be generated for a better performance.", null, 3, true, DisplayLevel.Experienced, ControlType.CheckBox, "", null)]
76        public bool NoQuickwatch
77        {
78            get { return this.noQuickwatch; }
79            set
80            {
81                this.noQuickwatch = (bool)value;
82                OnPropertyChanged("NoQuickwatch");
83                HasChanges = true;
84            }
85        }
86
87        private bool useAdditionalOutputBit = false;
88        [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?" })]
89        [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)]
90        public bool UseAdditionalOutputBit
91        {
92            get { return this.useAdditionalOutputBit; }
93            set
94            {
95                this.useAdditionalOutputBit = (bool)value;
96                OnPropertyChanged("UseClockingBit");
97                HasChanges = true;
98                if (this.useAdditionalOutputBit)
99                    SettingChanged("ClockingBit", Visibility.Visible);
100                else
101                    SettingChanged("ClockingBit", Visibility.Collapsed);
102            }
103        }
104
105        private int clockingBit = 0;
106        [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)]
107        public int ClockingBit
108        {
109            get { return this.clockingBit; }
110            set
111            {
112                this.clockingBit = value;
113                OnPropertyChanged("ClockingBit");
114                HasChanges = true;
115            }
116        }
117
118        private bool useBoolClock = false;
119        [ContextMenu("Use external clock", "With this checkbox enabled, an external clock will be used.", 0, DisplayLevel.Experienced, ContextMenuControlType.CheckBox, null, new string[] { "Use external clock?" })]
120        [TaskPane("Use external clock", "With this checkbox enabled, an external clock will be used (i.e. the CLK-Plugin)", "Clock Properties", 0, false, DisplayLevel.Beginner, ControlType.CheckBox, "", null)]
121        public bool UseBoolClock
122        {
123            get { return this.useBoolClock; }
124            set
125            {
126                this.useBoolClock = (bool)value;
127                OnPropertyChanged("UseBoolClock");
128                HasChanges = true;
129                if (this.useBoolClock)
130                    SettingChanged("Rounds", Visibility.Collapsed);
131                else
132                    SettingChanged("Rounds", Visibility.Visible);
133            }
134        }
135
136        private bool alwaysCreateOutput = false;
137        [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?" })]
138        [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)]
139        public bool AlwaysCreateOutput
140        {
141            get { return this.alwaysCreateOutput; }
142            set
143            {
144                this.alwaysCreateOutput = (bool)value;
145                OnPropertyChanged("AlwaysCreateOutput");
146                HasChanges = true;
147            }
148        }
149
150        /*private bool createDirtyOutputOnFalseClock = false;
151        [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?" })]
152        [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)]
153        public bool CreateDirtyOutputOnFalseClock
154        {
155            get { return this.createDirtyOutputOnFalseClock; }
156            set
157            {
158                this.createDirtyOutputOnFalseClock = (bool)value;
159                OnPropertyChanged("CreateDirtyOutputOnFalseClock");
160                HasChanges = true;
161            }
162        }*/
163
164        public bool HasChanges
165        {
166            get { return hasChanges; }
167            set { hasChanges = value; }
168        }
169
170        #endregion
171
172        #region INotifyPropertyChanged Members
173
174        public event PropertyChangedEventHandler PropertyChanged;
175
176        // this event is for disabling stuff in the settings pane
177        public event TaskPaneAttributeChangedHandler TaskPaneAttributeChanged;
178
179        public void OnPropertyChanged(string name)
180        {
181            if (PropertyChanged != null)
182            {
183                EventsHelper.PropertyChanged(PropertyChanged, this, new PropertyChangedEventArgs(name));
184            }
185        }
186
187        /* SettingChanged(MEM_USAGE_PROPERTY, Visibility.Visible);
188        SettingChanged(BUTTON_MEM_USAGE_PROPERTY, Visibility.Visible, new TaskPaneAttribute(Properties.Visuals.settingMemUsageOff,
189            Properties.Visuals.settingMemUsageOff_ToolTip, Properties.Visuals.settingGroupMisc, 5, false, DisplayLevel.Beginner, ControlType.Button));
190         */
191
192        // these 2 functions are for disabling stuff in the settings pane
193        private void SettingChanged(string setting, Visibility vis)
194        {
195          if (TaskPaneAttributeChanged != null)
196          {
197            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer(setting, vis)));
198          }
199        }
200
201        private void SettingChanged(string setting, Visibility vis, TaskPaneAttribute tpa)
202        {
203          if (TaskPaneAttributeChanged != null)
204          {
205            TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer(setting, vis, tpa)));
206          }
207        }
208
209        #endregion
210    }
211}
Note: See TracBrowser for help on using the repository browser.