source: trunk/CrypPlugins/TranspositionAnalyser/TranspositionAnalyserSettings.cs @ 1087

Last change on this file since 1087 was 1087, checked in by malischewski, 12 years ago

Fixed IControl issues with Transposition Slave / TranspositionAnalyzer, Plugin working again.

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;
8namespace TranspositionAnalyser
9{
10    class TranspositionAnalyserSettings : ISettings
11    {
12        private bool has_Changes = false;
13
14        #region ISettings Member
15
16     
17
18        private int selected_method = 0;
19
20        internal void UpdateTaskPaneVisibility()
21        {
22            if (TaskPaneAttributeChanged == null)
23                return;
24
25            switch (selected_method)
26            {
27                case 0: TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("MaxLength", Visibility.Visible)));
28                        TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("RowColumnColumn", Visibility.Visible)));
29                        TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("RowColumnRow", Visibility.Visible)));
30                        TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("ColumnColumnRow", Visibility.Visible)));
31                        TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("ColumnColumnColumn", Visibility.Visible)));
32                        break;
33                case 1: TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("MaxLength", Visibility.Hidden)));
34                        TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("RowColumnColumn", Visibility.Hidden)));
35                        TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("RowColumnRow", Visibility.Hidden)));
36                        TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("ColumnColumnRow", Visibility.Hidden)));
37                        TaskPaneAttributeChanged(this, new TaskPaneAttributeChangedEventArgs(new TaskPaneAttribteContainer("ColumnColumnColumn", Visibility.Hidden)));
38                        break;
39            }
40        }
41        //[PropertySaveOrder(1)]
42        [TaskPane("Analysis Method", "Select the Analysis Method", null, 1, false, DisplayLevel.Beginner, ControlType.ComboBox, new string[] { "Bruteforce Analysis", "Analysis with Crib" })]
43        public int Analysis_method
44        {
45            get
46            {
47                return this.selected_method;
48            }
49            set
50            {
51                if (value != selected_method) HasChanges = true;
52                this.selected_method = value;
53                UpdateTaskPaneVisibility();
54                OnPropertyChanged("Analysis_method");
55               
56            }
57
58        }
59
60        // FIX: REGEX
61        private int bruteforce_length = 8;
62        [PropertySaveOrder(2)]
63        [TaskPaneAttribute("Transposition Bruteforce length", "Enter the max length to be bruteforced (max: 20)", null, 2, true, DisplayLevel.Beginner, ControlType.TextBox, ValidationType.RegEx, "[0-9]{1,2}")]
64        public int MaxLength
65        {
66            get { return bruteforce_length; }
67            set
68            {
69                bruteforce_length = value;
70               
71            }
72        }
73
74        private Boolean row_colum_column = true;
75        [PropertySaveOrder(3)]
76        [ContextMenu("Bruteforce Row-Column-Column", "Bruteforce this transposition settings: Read in by row. Permute by column. Read out by Column", 4, DisplayLevel.Beginner, ContextMenuControlType.CheckBox, null, "Row-Column-Column")]
77        [TaskPane("Bruteforce Row-Column-Column", "Bruteforce this transposition settings: Read in by row. Permute by column. Read out by Column", null, 4, false, DisplayLevel.Expert, ControlType.CheckBox, "")]
78        public bool RowColumnColumn
79        {
80            get { return this.row_colum_column; }
81            set
82            {
83                if (value != this.row_colum_column) HasChanges = true;
84                this.row_colum_column= value;
85                OnPropertyChanged("RowColumnColumn");
86            }
87        }
88
89        private Boolean row_colum_row = true;
90        [PropertySaveOrder(4)]
91        [ContextMenu("Bruteforce Row-Column-Row", "Bruteforce this transposition settings: Read in by row. Permute by column. Read out by Row", 4, DisplayLevel.Beginner, ContextMenuControlType.CheckBox, null, "Row-Column-Column")]
92        [TaskPane("Bruteforce Row-Column-Row", "Bruteforce this transposition settings: Read in by row. Permute by column. Read out by Row", null, 4, false, DisplayLevel.Expert, ControlType.CheckBox, "")]
93        public bool RowColumnRow
94        {
95            get { return this.row_colum_row; }
96            set
97            {
98                if (value != this.row_colum_row) HasChanges = true;
99                this.row_colum_row = value;
100                OnPropertyChanged("RowColumnRow");
101            }
102        }
103
104
105        private Boolean column_colum_row = true;
106        [PropertySaveOrder(5)]
107        [ContextMenu("Bruteforce Column-Column-Row", "Bruteforce this transposition settings: Read in by column. Permute by column. Read out by Row", 4, DisplayLevel.Beginner, ContextMenuControlType.CheckBox, null, "Row-Column-Column")]
108        [TaskPane("Bruteforce Column-Column-Row", "Bruteforce this transposition settings: Read in by column. Permute by column. Read out by Row", null, 4, false, DisplayLevel.Expert, ControlType.CheckBox, "")]
109        public bool ColumnColumnRow
110        {
111            get { return this.column_colum_row; }
112            set
113            {
114                if (value != this.column_colum_row) HasChanges = true;
115                this.column_colum_row = value;
116                OnPropertyChanged("ColumnColumnRow");
117            }
118        }
119
120        private Boolean column_colum_column = true;
121        [PropertySaveOrder(6)]
122        [ContextMenu("Bruteforce Column-Column-Column", "Bruteforce this transposition settings: Read in by column. Permute by column. Read out by column", 4, DisplayLevel.Beginner, ContextMenuControlType.CheckBox, null, "Row-Column-Column")]
123        [TaskPane("Bruteforce Column-Column-Column", "Bruteforce this transposition settings: Read in by column. Permute by column. Read out by column", null, 4, false, DisplayLevel.Expert, ControlType.CheckBox, "")]
124        public bool ColumnColumnColumn
125        {
126            get { return this.column_colum_column; }
127            set
128            {
129                if (value != this.column_colum_column) HasChanges = true;
130                this.column_colum_column = value;
131                OnPropertyChanged("ColumnColumnColumn");
132            }
133        }
134
135     
136
137        public bool HasChanges
138        {
139            get
140            {
141                return has_Changes;
142            }
143            set
144            {
145                has_Changes = true;
146            }
147        }
148
149        protected void OnPropertyChanged(string name)
150        {
151            if (PropertyChanged != null)
152            {
153                PropertyChanged(this, new PropertyChangedEventArgs(name));
154            }
155        }
156
157        #endregion
158
159        #region Events
160        public event TaskPaneAttributeChangedHandler TaskPaneAttributeChanged;
161        #endregion
162
163
164        #region INotifyPropertyChanged Member
165
166        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
167
168        #endregion
169    }
170}
Note: See TracBrowser for help on using the repository browser.