source: trunk/CrypPlugins/BigNumber/BigNumberInput.cs @ 807

Last change on this file since 807 was 807, checked in by nolte, 12 years ago

added the descriptions

File size: 4.5 KB
Line 
1/*                             
2   Copyright 2009 Team CrypTool (Sven Rech,Dennis Nolte,Raoul Falk,Nils Kopal), Uni 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;
21
22using Cryptool.PluginBase.Miscellaneous;
23using Cryptool.PluginBase.IO;
24using Cryptool.PluginBase;
25using System.ComponentModel;
26
27namespace Cryptool.Plugins.BigNumber
28{
29    [Author("Sven Rech", "sven.rech@cryptool.org", "Uni Duisburg-Essen", "http://www.uni-due.de")]
30    [PluginInfo(true, "BigNumberInput", "Big Number Input", "BigNumber/DetailedDescription/DescriptionInput.xaml", "BigNumber/icons/inputIcon.png")]
31    class BigNumberInput : IInput
32    {
33
34        public BigNumberInput()
35        {
36            settings = new BigNumberInputSettings();
37        }
38
39        #region Properties
40
41        private BigInteger numberOutput = null;
42        /// <summary>
43        /// The output is defined
44        /// </summary>
45        [PropertyInfo(Direction.OutputData, "Number Output", "Number Output", "", DisplayLevel.Beginner)]
46        public BigInteger NumberOutput
47        {
48            get
49            {
50                return numberOutput;
51            }
52            set
53            {
54                numberOutput = value;
55                OnPropertyChanged("NumberOutput");
56            }
57        }
58
59        #endregion
60
61        #region IPlugin Members
62
63        public event Cryptool.PluginBase.StatusChangedEventHandler OnPluginStatusChanged;
64
65        public event Cryptool.PluginBase.GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
66
67        private void GuiLogMessage(string p, NotificationLevel notificationLevel)
68        {
69            EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(p, this, notificationLevel));
70        }
71
72        public event Cryptool.PluginBase.PluginProgressChangedEventHandler OnPluginProgressChanged;
73
74        private void ProgressChanged(double value, double max)
75        {
76            EventsHelper.ProgressChanged(OnPluginProgressChanged, this, new PluginProgressEventArgs(value, max));
77        }
78
79        private BigNumberInputSettings settings;
80        public ISettings Settings
81        {
82            get { return settings; }
83            set { settings = (BigNumberInputSettings)value; }
84        }
85
86        public System.Windows.Controls.UserControl Presentation
87        {
88            get { return null; }
89        }
90
91        public System.Windows.Controls.UserControl QuickWatchPresentation
92        {
93            get { return null; }
94        }
95
96        public void PreExecution()
97        {
98            Dispose();
99        }
100
101        public void Execute()
102        {
103            BigInteger bi;
104            //The input from the taskpane is convertet to a BigNumber and is send to the output.
105            try
106            {
107                bi = BigInteger.parseExpression(settings.Number);               
108            }
109            catch (Exception ex)
110            {
111                GuiLogMessage("Invalid Big Number input: " + ex.Message, NotificationLevel.Error);
112                return;
113            }
114            NumberOutput = bi;
115            ProgressChanged(1.0, 1.0);
116        }
117
118        public void PostExecution()
119        {
120            Dispose();
121        }
122
123        public void Pause()
124        {
125           
126        }
127
128        public void Stop()
129        {
130           
131        }
132
133        public void Initialize()
134        {
135           
136        }
137
138        public void Dispose()
139        {
140        }
141
142        #endregion
143
144        #region INotifyPropertyChanged Members
145
146        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
147
148        private void OnPropertyChanged(string p)
149        {
150            EventsHelper.PropertyChanged(PropertyChanged, this, new PropertyChangedEventArgs(p));
151        }
152
153        #endregion
154    }
155}
Note: See TracBrowser for help on using the repository browser.