source: trunk/CrypPlugins/Vernam/VernamSettings.cs @ 1941

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

shortened license text to boilerplate notice in all source files

File size: 3.1 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 System.IO;
22using Cryptool.PluginBase;
23using System.ComponentModel;
24
25namespace Cryptool.Vernam
26{
27    public class VernamSettings : ISettings
28    {
29        #region Puglic Xor specific interface
30
31        /// <summary>
32        /// We use this delegate to send log messages from the settings class to the Vernam plugin
33        /// </summary>
34        /// <param name="sender"></param>
35        /// <param name="msg"></param>
36        /// <param name="logLevel"></param>
37        public delegate void VernamLogMessage(string msg, NotificationLevel logLevel);
38
39        /// <summary>
40        /// Fire if a new message has to be shown in the status bar
41        /// </summary>
42        public event VernamLogMessage LogMessage;
43
44        /// <summary>
45        /// Returns true if some settings have been changed. This value should be set
46        /// externally to fales e.g. when a project was saved.
47        /// </summary>
48        [PropertySaveOrder(0)]
49        public bool HasChanges
50        {
51            get { return hasChanges; }
52            set { hasChanges = value; }
53        }
54
55        #endregion
56
57        #region Private variables
58
59        private bool hasChanges;
60        private int selectedAction = 0;
61
62        #endregion
63
64        #region Algorithm settings properties (visible in the settings pane)
65
66        [PropertySaveOrder(1)]
67        [ContextMenu("Action","Select the Algorithm action",1,DisplayLevel.Beginner,ContextMenuControlType.ComboBox,new int[] {1,2},"Encrypt","Decrypt")]
68        [TaskPane("Action", "Select the Algorithm action", null, 1, false, DisplayLevel.Beginner, ControlType.ComboBox, new string[] { "Encrypt", "Decrypt"})]
69        public int Action
70        {
71            get { return this.selectedAction; }
72            set
73            {
74                if((value) != selectedAction) HasChanges = true;
75                this.selectedAction = value;
76                OnPropertyChanged("Action");
77            }
78        }
79
80        #endregion
81
82        #region INotifyPropertyChanged Members
83
84        public event PropertyChangedEventHandler PropertyChanged;
85
86        protected void OnPropertyChanged(string name)
87        {
88            if (PropertyChanged != null)
89            {
90                PropertyChanged(this, new PropertyChangedEventArgs(name));
91            }
92        }
93
94        #endregion
95    }
96}
Note: See TracBrowser for help on using the repository browser.