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

Last change on this file since 1448 was 1448, checked in by Sven Rech, 12 years ago

replaced all BigInteger stuff with the new BigInteger class from .net 4.0

But there are still problems with some plugins (Keysearcher, BigInteger Operations...)

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