source: trunk/CrypPlugins/BigNumber/BigNumberOperationSettings.cs @ 1709

Last change on this file since 1709 was 973, checked in by kopal, 12 years ago
  • icons of BigNumberOperators now are set correctly after loading
  • "BooleanInput and BoolButton" -> merged functions into BooleanInput and deleted BoolButton (only need one BooleanInput)
  • BooleanFunctions now have a new setting (set if an update needs both inputs changed or not)
File size: 3.6 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;
21using Cryptool.PluginBase;
22using System.ComponentModel;
23
24namespace Cryptool.Plugins.BigNumber
25{
26    class BigNumberOperationSettings : ISettings
27    {
28        #region private variables
29
30        private int operat;
31
32        #endregion
33        #region taskpane
34
35        /// <summary>
36        /// The checkbox with its options.
37        ///
38        /// Based on the option chosen, the icon for this plug-in will also change.
39        /// </summary>
40        [TaskPane("Operat", "Choose the operator.", null, 1, false, DisplayLevel.Beginner, ControlType.ComboBox, new string[] { "x+y","x-y","x*y","x/y","x^y","GCD"})]
41        public int Operat
42        {
43            get { return this.operat; }
44            set
45            {
46                if ((int)value != this.operat)
47                {
48                    this.operat = (int)value;
49                    OnPropertyChanged("Operat");
50                    HasChanges = true;
51
52                    changeToCorrectIcon(operat);
53                }
54            }
55        }
56
57        /// <summary>
58        /// Changes the plugins icon to the icon fitting to actual selected arithmetic function
59        /// </summary>
60        /// <param name="operat"></param>
61        public void changeToCorrectIcon(int operat)
62        {
63            switch (operat)
64            {
65                //x+y
66                case 0:
67                    ChangePluginIcon(0);
68                    break;
69                //x-y
70                case 1:
71                    ChangePluginIcon(1);
72                    break;
73                //x*y
74                case 2:
75                    ChangePluginIcon(2);
76                    break;
77                //x/y
78                case 3:
79                    ChangePluginIcon(3);
80                    break;
81                //x^y
82                case 4:
83                    ChangePluginIcon(4);
84                    break;
85                //gcd(x,y)
86                case 5:
87                    ChangePluginIcon(5);
88                    break;
89            }
90        }
91
92        private void ChangePluginIcon(int p)
93        {
94            OnPluginStatusChanged(null, new StatusEventArgs(StatusChangedMode.ImageUpdate, p));
95        }
96        #endregion
97        #region ISettings Members
98
99        private bool hasChanges;
100        public bool HasChanges
101        {
102            get { return hasChanges; }
103            set { hasChanges = value; }
104        }
105
106        #endregion
107
108        #region INotifyPropertyChanged Members
109
110        public event System.ComponentModel.PropertyChangedEventHandler PropertyChanged;
111
112        private void OnPropertyChanged(string p)
113        {
114            if (PropertyChanged != null)
115                PropertyChanged(this, new PropertyChangedEventArgs(p));
116        }
117        public event StatusChangedEventHandler OnPluginStatusChanged;
118
119        #endregion
120    }
121}
Note: See TracBrowser for help on using the repository browser.