source: trunk/CrypPlugins/Alphabets/Alphabet.cs @ 1778

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

shortened license text to boilerplate notice in all source files

File size: 4.2 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 System.ComponentModel;
23using System.Windows.Controls;
24using Cryptool.PluginBase.IO;
25using Cryptool.PluginBase.Miscellaneous;
26
27namespace Cryptool.Alphabets
28{
29    [Author("Sebastian Przybylski", "sebastian@przybylski.org", "Uni-Siegen", "http://www.uni-siegen.de")]
30    [PluginInfo(true, "Alphabets", "Alphabets Plugin", "", "Alphabets/icon.gif")]   
31    public class Alphabet : IInput
32    {
33      private AlphabetPresentation alphabetPresentation;
34
35      private AlphabetSettings settings = new AlphabetSettings();
36      public ISettings Settings
37      {
38        get { return settings; }
39        set { settings = (AlphabetSettings)value; }
40      }
41     
42
43      public Alphabet()
44      {         
45          alphabetPresentation = new AlphabetPresentation(this);
46          Presentation = this.alphabetPresentation;
47          alphabetPresentation.OnGuiLogNotificationOccured += alphabetPresentation_OnGuiLogNotificationOccured;
48          settings.PropertyChanged += settings_PropertyChanged;
49      }
50
51      void alphabetPresentation_OnGuiLogNotificationOccured(IPlugin sender, GuiLogEventArgs args)
52      {
53          GuiLogMessage(args.Message, args.NotificationLevel); 
54      }
55
56      void settings_PropertyChanged(object sender, PropertyChangedEventArgs e)
57      {
58        if (e.PropertyName == "Alphabet")
59        {
60          OnPropertyChanged("AlphabetOutput");
61        }
62      }
63
64      [PropertyInfo(Direction.OutputData, "Alphabet Output", "Alphabet output to use as alphabet input for classical ciphers", "", false, false, DisplayLevel.Beginner, QuickWatchFormat.Text, null)]
65      public string AlphabetOutput
66      {
67          get { return settings.Alphabet; }
68          set { } //readonly
69      }
70
71
72      public UserControl Presentation { get; private set; }
73
74      public void Initialize()
75      {
76      }
77
78      public void Dispose()
79      {
80      }
81
82      public void Stop()
83      {
84      }
85
86      public void PreExecution()
87      {
88      }
89
90      public void PostExecution()
91      {
92      }
93
94      public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
95
96      public void OnPropertyChanged(string name)
97      {
98          if (PropertyChanged != null)
99          {
100              PropertyChanged(this, new PropertyChangedEventArgs(name));
101          }
102      }
103
104      #region IPlugin Members
105
106#pragma warning disable 67
107                        public event StatusChangedEventHandler OnPluginStatusChanged;
108#pragma warning restore
109            public event GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
110            public event PluginProgressChangedEventHandler OnPluginProgressChanged;
111     
112      private void GuiLogMessage(string message, NotificationLevel logLevel)
113      {
114        if (OnGuiLogNotificationOccured != null)
115        {
116          OnGuiLogNotificationOccured(this, new GuiLogEventArgs(message, this, logLevel));
117        }
118      }
119
120      public UserControl QuickWatchPresentation
121      {
122        get { return null; }
123      }
124
125      public void Execute()
126      {
127          OnPropertyChanged("AlphabetOutput");
128          ShowProgress(100, 100);
129      }
130
131      public void Pause()
132      {
133       
134      }
135
136      #endregion
137
138      #region Private
139      private void ShowProgress(double value, double max)
140      {
141          EventsHelper.ProgressChanged(OnPluginProgressChanged, this, new PluginProgressEventArgs(value, max));
142      }
143      #endregion
144    }
145}
Note: See TracBrowser for help on using the repository browser.