source: trunk/CrypPlugins/StreamToStringConverter/StreamToStringConverterSettings.cs @ 1785

Last change on this file since 1785 was 1259, checked in by Matthäus Wander, 12 years ago

shortened license text to boilerplate notice in all source files

File size: 4.5 KB
Line 
1/*
2   Copyright 2008 Dr. Arno Wacker, University of Duisburg-Essen
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*/
16
17using System;
18using System.Collections.Generic;
19using System.Linq;
20using System.Text;
21using Cryptool.PluginBase;
22using System.ComponentModel;
23
24namespace Cryptool.Plugins.Convertor
25{
26    public class StreamToStringConverterSettings : ISettings
27    {
28        #region Private variables
29        private EncodingTypes encoding = EncodingTypes.Default;
30        private int maxLength = 65536; //64kB
31        private bool hasChanges = false;
32        #endregion
33
34        #region Public StreamToStringConverter specific properties
35
36        public enum EncodingTypes { Default = 0, Base64Binary = 1, HexStringBinary = 2, OctalStringBinary = 3, Unicode = 4, UTF7 = 5, UTF8 = 6, UTF32 = 7, ASCII = 8, BigEndianUnicode = 9 };
37
38        /// <summary>
39        /// Retrieves the current used encoding, or sets it.
40        /// </summary>
41        public EncodingTypes Encoding
42        { 
43            get { return this.encoding; }
44            set 
45            {
46                if (this.Encoding != value) hasChanges = true;
47                this.encoding = value; 
48                OnPropertyChanged("EncodingSetting"); 
49            }
50        }
51
52        /// <summary>
53        /// Returns true if some properties where changed.
54        /// </summary>
55        public bool HasChanges
56        {
57            get { return hasChanges; }
58            set { hasChanges = value; }
59        }
60
61        #endregion
62
63
64        #region Algorithm settings properties (visible in the Settings pane)
65
66        /// <summary>
67        /// Encoding property used in the Settings pane.
68        /// </summary>
69        [ContextMenu("Input stream encoding", "Choose the expected encoding of the input stream.", 1, DisplayLevel.Experienced, ContextMenuControlType.ComboBox, null, new string[] { "Default system encoding", "Binary data (convert to base64)", "Binary data (convert to hex-string)", "Binary data (convert to octal-string)", "Unicode", "UTF-7", "UTF-8", "UTF-32", "ASCII", "Big endian unicode" })]
70        [TaskPane("Input stream encoding", "Choose the expected encoding of the input stream. (The stream will be interpreted as set here, no matter what the bytes really mean)", null, 1, false, DisplayLevel.Experienced, ControlType.ComboBox, new string[] { "Default system encoding", "Binary data (convert to base64)", "Binary data (convert to hex-string)", "Binary data (convert to octal-string)", "Unicode", "UTF-7", "UTF-8", "UTF-32", "ASCII", "Big endian unicode" })]
71        public int EncodingSetting
72        {
73            get
74            {
75                return (int)this.encoding;
76            }
77            set
78            {
79                if (this.encoding != (EncodingTypes)value) hasChanges = true;
80                this.encoding = (EncodingTypes)value;
81                OnPropertyChanged("EncodingSetting");
82            }
83        }
84
85
86        /// <summary>
87        /// Maximum size property used in the settings pane.
88        /// </summary>       
89        [TaskPane("Maximum length", "Provide the maximum number of bytes to convert.", null, 2, false, DisplayLevel.Professional, ControlType.NumericUpDown, ValidationType.RangeInteger, 1, int.MaxValue)]
90        public int MaxLength
91        {
92            get
93            {
94              return maxLength;
95            }
96            set
97            {
98              if (value != maxLength)
99              {
100                HasChanges = true;
101                maxLength = value;
102                OnPropertyChanged("MaxLength");
103              }
104            }
105        }
106
107        #endregion
108
109        #region INotifyPropertyChanged Members
110
111        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
112
113        public void OnPropertyChanged(string name)
114        {
115            if (PropertyChanged != null)
116            {
117                PropertyChanged(this, new PropertyChangedEventArgs(name));
118            }
119        }
120
121        #endregion
122
123    }
124}
Note: See TracBrowser for help on using the repository browser.