source: trunk/CrypPlugins/RandomInput/RandomInputSettings.cs @ 1709

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

shortened license text to boilerplate notice in all source files

File size: 2.9 KB
Line 
1/*
2   Copyright 2008 Timm Korte, University of Siegen
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 System.IO;
22using Cryptool.PluginBase;
23using System.Security.Cryptography;
24using System.ComponentModel;
25
26namespace RandomInput
27{
28  public class RandomInputSettings : ISettings
29  {
30    private bool hasChanges = false;
31    private int bytes = 1;
32    private int keepRND = 0; //0 = each stream / array will be filled with fresh random numbers
33
34    [TaskPane("Counter", "Number of random bytes to be created. (1 - 10496000)", null, 1, false, DisplayLevel.Beginner, ControlType.NumericUpDown, ValidationType.RangeInteger, 1, 10496000)]
35    public int Bytes
36    {
37      get { return this.bytes; }
38      set
39      {
40        this.bytes = value;
41        OnPropertyChanged("Bytes");
42      }
43    }
44
45    [ContextMenu("Static", "Generate and keep random bytes only once", 2, DisplayLevel.Beginner, ContextMenuControlType.ComboBox, null, new String[] { "no", "yes" })]
46    [TaskPane("Static", "Generate and keep random bytes only once", null, 2, false, DisplayLevel.Beginner, ControlType.ComboBox, new String[] { "no", "yes" })]
47    public int KeepRND
48    {
49      get { return this.keepRND; }
50      set
51      {
52        this.keepRND = (int)value;
53        OnPropertyChanged("KeepRND");
54      }
55    }
56
57    public UInt64 NumBytes
58    {
59      get
60      {
61        return UInt64.Parse(this.Bytes.ToString());
62      }
63      set
64      {
65        this.Bytes = int.Parse(value.ToString());
66        OnPropertyChanged("NumBytes");
67      }
68    }
69
70    #region IInputSettings Member
71
72    public string SaveAndRestoreState { get; set; }
73
74    #endregion
75
76    #region INotifyPropertyChanged Members
77
78    public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
79
80    protected void OnPropertyChanged(string name)
81    {
82      if (PropertyChanged != null)
83      {
84        PropertyChanged(this, new PropertyChangedEventArgs(name));
85      }
86    }
87
88    #endregion
89
90    #region ISettings Members
91
92    public bool HasChanges
93    {
94      get
95      {
96        return hasChanges;
97      }
98      set
99      {
100        if (value != HasChanges)
101        {
102          hasChanges = value;
103          OnPropertyChanged("HasChanges");
104        }
105      }
106    }
107
108    #endregion
109  }
110}
Note: See TracBrowser for help on using the repository browser.