source: trunk/CrypPlugins/ExamplePluginCT2/ExamplePluginCT2.cs @ 740

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

CrypWin:

  • changed string Beta 01 -> 02
  • TextBoxHidden now loads its value when loading a project file
  • see #98 for an open issue

BigInteger/BigNumber:

  • added sanity checks for == operator and Equals()
  • setting input properties to null in PreExecution (addresses #90)

Tokenizer:

  • added \t as word delimiter (fixes problem with Enigma-Challenge_II)

Enigma:

  • added null reference sanity check

WordPatterns:

  • improved PostBuild events

ExamplePluginCT2:

  • added example plugin which serves as plugin template
  • the template is located in Documentation/Template/
File size: 4.5 KB
Line 
1/*
2   Copyright 2009 Matthäus Wander, Universität 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*/
16using System;
17using System.Collections.Generic;
18using System.Linq;
19using System.Text;
20using Cryptool.PluginBase.IO;
21using Cryptool.PluginBase;
22using System.ComponentModel;
23using Cryptool.PluginBase.Miscellaneous;
24using System.Windows.Controls;
25
26namespace Cryptool.Plugin.ExamplePluginCT2
27{
28    [Author("Matthäus Wander", "wander@cryptool.org", "Universität Duisburg-Essen, Fachgebiet Verteilte Systeme", "http://www.vs.uni-due.de")]
29    [PluginInfo(false, "Example Plugin", "Subtract one number from another", null, "CrypWin/images/default.png")]
30    public class ExamplePluginCT2 : IIOMisc
31    {
32        #region Private Variables
33
34        private ExamplePluginCT2Settings settings = new ExamplePluginCT2Settings();
35
36        #endregion
37
38        #region Data Properties
39
40        /// <summary>
41        /// Input interface to read the input data.
42        /// You can add more input properties of other type if needed.
43        /// </summary>
44        [PropertyInfo(Direction.InputData, "Minuend", "Input number", null, DisplayLevel.Beginner)]
45        public int Minuend
46        {
47            get;
48            set;
49        }
50
51        /// <summary>
52        /// Output interface to write the output data.
53        /// You can add more output properties ot other type if needed.
54        /// </summary>
55        [PropertyInfo(Direction.OutputData, "Difference", "Result", null, DisplayLevel.Beginner)]
56        public int Difference
57        {
58            get;
59            set;
60        }
61
62        #endregion
63
64        #region IPlugin Members
65
66        public ISettings Settings
67        {
68            get { return settings; }
69        }
70
71        /// <summary>
72        /// Optional: provide custom (tabbed) presentation to visualize your algorithm
73        /// </summary>
74        public UserControl Presentation
75        {
76            get { return null; }
77        }
78
79        /// <summary>
80        /// Optional: provide custom (quickwatch) presentation to visualize your algorithm
81        /// </summary>
82        public UserControl QuickWatchPresentation
83        {
84            get { return null; }
85        }
86
87        public void PreExecution()
88        {
89        }
90
91        /// <summary>
92        /// The algorithm you'd like to implement
93        /// </summary>
94        public void Execute()
95        {
96            ProgressChanged(0, 1);
97
98            Difference = Minuend - settings.Subtrahend;
99            OnPropertyChanged("Difference");
100
101            if (settings.Subtrahend < 0)
102                GuiLogMessage("Subtrahend is negative", NotificationLevel.Debug);
103
104            ProgressChanged(1, 1);
105        }
106
107        public void PostExecution()
108        {
109        }
110
111        public void Pause()
112        {
113        }
114
115        public void Stop()
116        {
117        }
118
119        public void Initialize()
120        {
121        }
122
123        public void Dispose()
124        {
125        }
126
127        #endregion
128
129        #region Event Handling
130
131        public event StatusChangedEventHandler OnPluginStatusChanged;
132
133        public event GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
134
135        public event PluginProgressChangedEventHandler OnPluginProgressChanged;
136
137        public event PropertyChangedEventHandler PropertyChanged;
138
139        private void GuiLogMessage(string message, NotificationLevel logLevel)
140        {
141            EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(message, this, logLevel));
142        }
143
144        private void OnPropertyChanged(string name)
145        {
146            EventsHelper.PropertyChanged(PropertyChanged, this, new PropertyChangedEventArgs(name));
147        }
148
149        private void ProgressChanged(double value, double max)
150        {
151            EventsHelper.ProgressChanged(OnPluginProgressChanged, this, new PluginProgressEventArgs(value, max));
152        }
153
154        #endregion
155    }
156}
Note: See TracBrowser for help on using the repository browser.