source: trunk/CrypPlugins/Splitter/Splitter.cs @ 2334

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

removed 1006 occurences of DisplayLevel in 218 files (see #122)

File size: 4.5 KB
Line 
1/*
2   Copyright 2008 Thomas Schmid, 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.IO;
22using Cryptool.PluginBase;
23using System.Windows.Controls;
24using System.ComponentModel;
25using Cryptool.PluginBase.Miscellaneous;
26
27namespace Splitter
28{
29  [Author("Thomas Schmid", "thomas.schmid@cryptool.org", "Uni Siegen", "http://www.uni-siegen.de")]
30  [PluginInfo(false, "Splitter", "Splits a dictionary input based on delimiter and fires words on event.", null, "Splitter/icon.png")]
31  public class Splitter : IThroughput
32  {
33    # region private variables
34    private SplitterSettings settings = new SplitterSettings();
35    private string dictionaryInputString;
36    private List<string> listWords = new List<string>();
37    # endregion
38
39    # region public interfacde
40
41    [PropertyInfo(Direction.InputData, "Dictionary", "The dictionary to split.", "", true, false, QuickWatchFormat.Text, null)]
42    public string DictionaryInputString
43    {
44      get { return this.dictionaryInputString; }
45      set
46      {
47        // no unequal check here, because new dic input should create new word list.
48        dictionaryInputString = value;
49        listWords.Clear();
50        if (value != null)
51          listWords.AddRange(value.Split(settings.DelimiterDictionary[0]));         
52        OnPropertyChanged("DictionaryInputString");
53      }
54    }
55
56    private bool fireNext;
57    [PropertyInfo(Direction.InputData, "Fire next", "If dictionary is set and true/false (depends on settings) arrives here one word is fires and deleted from list.", "", true, false, QuickWatchFormat.Text, null)]
58    public bool FireNext
59    {
60      get { return fireNext; }
61      set
62      {
63        fireNext = value;
64        if (listWords.Count > 0 && ((value && settings.FireOnValue == 0) || (!value && settings.FireOnValue == 1)))
65        {
66          OutputString = listWords[0];
67          listWords.RemoveAt(0);
68        }
69        OnPropertyChanged("FireNext");
70      }
71    }
72
73
74    private string outputString;
75    [PropertyInfo(Direction.OutputData, "Text output", "The words will be fired on this output", "", false, false, QuickWatchFormat.Text, null)]
76    public string OutputString
77    {
78      get { return this.outputString; }
79      set
80      {
81        outputString = value;
82        OnPropertyChanged("OutputString");
83      }
84    }
85
86    # endregion
87
88
89    #region IPlugin Members
90
91#pragma warning disable 67
92                public event StatusChangedEventHandler OnPluginStatusChanged;
93                public event PluginProgressChangedEventHandler OnPluginProgressChanged;
94#pragma warning restore
95   
96    public event GuiLogNotificationEventHandler OnGuiLogNotificationOccured;
97    private void GuiLogMessage(string message, NotificationLevel logLevel)
98    {
99      EventsHelper.GuiLogMessage(OnGuiLogNotificationOccured, this, new GuiLogEventArgs(message, this, logLevel));
100    }
101
102
103    public ISettings Settings
104    {
105      get { return settings; }
106    }
107
108    public UserControl Presentation
109    {
110      get { return null; }
111    }
112
113    public UserControl QuickWatchPresentation
114    {
115      get { return null; }
116    }
117
118    public void PreExecution()
119    {
120    }
121
122    public void Execute()
123    {
124      if (DictionaryInputString == null)
125        GuiLogMessage("Got null value for dictionary.", NotificationLevel.Warning); 
126    }
127
128    public void PostExecution()
129    {
130    }
131
132    public void Pause()
133    {
134    }
135
136    public void Stop()
137    {
138    }
139
140    public void Initialize()
141    {
142    }
143
144    public void Dispose()
145    {
146    }
147
148    #endregion
149
150    #region INotifyPropertyChanged Members
151
152    public event PropertyChangedEventHandler PropertyChanged;
153
154    protected void OnPropertyChanged(string name)
155    {
156      EventsHelper.PropertyChanged(PropertyChanged, this, new PropertyChangedEventArgs(name));
157    }
158
159    #endregion
160  }
161}
Note: See TracBrowser for help on using the repository browser.