source: trunk/CrypPlugins/BoolToInt/BoolToInt.cs @ 1597

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

shortened license text to boilerplate notice in all source files

File size: 4.9 KB
Line 
1/*
2   Copyright 2008 Sebastian Przybylski, 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 Cryptool.PluginBase;
22using Cryptool.PluginBase.Cryptography;
23
24using System.IO;
25using System.ComponentModel;
26using Cryptool.PluginBase.IO;
27using System.Windows.Controls;
28// for [MethodImpl(MethodImplOptions.Synchronized)]
29using System.Runtime.CompilerServices;
30
31namespace Cryptool.BoolToInt
32{
33    [Author("Soeren Rinne", "soeren.rinne@cryptool.de", "Ruhr-Universitaet Bochum, Chair for System Security", "http://www.trust.rub.de/")]
34    [PluginInfo(false, "BoolToInt", "Converts Boolean to Integer", "BoolToInt/DetailedDescription/Description.xaml", "BoolToInt/Images/icon.png", "BoolToInt/Images/icon.png", "BoolToInt/Images/icon.png")]
35    public class BoolToInt : IThroughput
36    {
37
38        #region Private variables
39
40        private BoolToIntSettings settings;
41        private bool input;
42        private int output;
43
44        #endregion
45
46        #region Public interface
47
48        /// <summary>
49        /// Contructor
50        /// </summary>
51        public BoolToInt()
52        {
53            this.settings = new BoolToIntSettings();
54            ((BoolToIntSettings)(this.settings)).LogMessage += Xor_LogMessage;
55        }
56
57        /// <summary>
58        /// Get or set all settings for this algorithm
59        /// </summary>
60        public ISettings Settings
61        {
62            get { return (ISettings)this.settings;
63            }
64            set { this.settings = (BoolToIntSettings)value;
65            }
66        }
67
68        [PropertyInfo(Direction.InputData, "Input", "Input a boolean value to be processed", "", true, false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
69        public bool Input
70        {
71            [MethodImpl(MethodImplOptions.Synchronized)]
72            get { return this.input; }
73            [MethodImpl(MethodImplOptions.Synchronized)]
74            set
75            {
76                this.input = value;
77                OnPropertyChanged("Input");
78                // clean inputOne
79            }
80        }
81
82        [PropertyInfo(Direction.OutputData, "Output", "Output after converting Boolean to Integer.", "", false, false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
83        public int Output
84        {
85            [MethodImpl(MethodImplOptions.Synchronized)]
86            get
87            {
88                return output;
89            }
90            set
91            {   // is readonly
92            }
93        }
94
95        #endregion
96
97        #region IPlugin members
98
99        public void Initialize()
100        {
101        }
102
103        public void Dispose()
104        {
105        }
106
107        public UserControl Presentation
108        {
109            get { return null; }
110        }
111
112        public UserControl QuickWatchPresentation
113        {
114            get { return null; }
115        }
116
117        public void Stop()
118        {
119        }
120
121        public void PostExecution()
122        {
123        }
124
125        public void PreExecution()
126        {
127        }
128
129        #endregion
130
131        #region INotifyPropertyChanged Members
132
133        public event PropertyChangedEventHandler PropertyChanged;
134
135        public void OnPropertyChanged(string name)
136        {
137            if (PropertyChanged != null)
138            {
139                PropertyChanged(this, new PropertyChangedEventArgs(name));
140            }
141        }
142
143        #endregion
144
145        #region Private methods
146
147        private void Xor_LogMessage(string msg, NotificationLevel logLevel)
148        {
149            /*if (OnGuiLogNotificationOccured != null)
150            {
151                OnGuiLogNotificationOccured(this, new GuiLogEventArgs(msg, this, logLevel));
152            }*/
153        }
154
155        #endregion
156
157        #region IPlugin Members
158
159#pragma warning disable 67
160        public event StatusChangedEventHandler OnPluginStatusChanged;
161        public event GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
162        public event PluginProgressChangedEventHandler OnPluginProgressChanged;
163#pragma warning restore
164
165        public void Execute()
166        {
167            if (input) output = 1; else output = 0;
168            OnPropertyChanged("Output");
169        }
170
171        public void Pause()
172        {
173        }
174
175        #endregion
176    }
177}
Note: See TracBrowser for help on using the repository browser.