SECI  1
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties Events
LVRadioButtons.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections;
3 using System.Collections.Generic;
4 using System.Text;
5 
6 namespace Seci.LabView.Controls
7 {
12  {
16  private String[] _items;
17 
24  public LvRadioButtons(String name, String[] items, SerialisableList<int> indices)
25  {
26  _name = name;
27 
28  _items = items;
29 
30  if (indices != null)
31  {
32  _clusterIndices = (Seci.SerialisableList<int>) indices.Clone();
33  }
34  }
35 
40  public override String GetNameAndType()
41  {
42  return _name + " (Radio Buttons)";
43  }
44 
45  public override String GetControlType()
46  {
47  return "RADIO BUTTONS";
48  }
49 
57  public override String[] GetValue(ref strongnameLabview.VirtualInstrument vi)
58  {
59  String temp;
60 
61  if (_clusterIndices == null)
62  {
63  temp = _items[Convert.ToInt16(vi.GetControlValue(_name))];
64  }
65  else
66  {
67  temp = _items[Convert.ToInt16(GetValueFromCluster(vi)[_clusterIndices[_clusterIndices.Count - 1]])];
68  }
69 
70  String[] result = { temp };
71 
72  return result;
73  }
74 
83  public override void SetValue(ref strongnameLabview.VirtualInstrument vi, Object value)
84  {
85  //Check that value is either the index to set or the name of the value to set
86  int val = 0;
87 
88  if (value.GetType() == typeof(Int16))
89  {
90  val = Convert.ToInt16(value);
91  }
92  else if (value.GetType() == typeof(String))
93  {
94  for (int i = 0; i < _items.GetLength(0); ++i)
95  {
96  if (_items[i] == value.ToString())
97  {
98  val = i;
99  break;
100  }
101  }
102  }
103  else
104  {
105  //Invalid value
106  throw new ArgumentException("Value sent to radio button was invalid.");
107  }
108 
109  if (_clusterIndices == null)
110  {
111  vi.SetControlValue(_name, val);
112  }
113  else
114  {
115  SetValueInCluster(ref vi, val);
116  }
117  }
118  }
119 }
override String[] GetValue(ref strongnameLabview.VirtualInstrument vi)
Overriden method for getting the current selected value of the Control. LabVIEW returns an int corres...
String[] _items
Stores the values of the selectable options.
LvRadioButtons(String name, String[] items, SerialisableList< int > indices)
Constructor
override String GetNameAndType()
Overriden method which return the name and type of the control.
This class is the abstract base class of the objects used to store the VI control information...
Definition: LVControl.cs:12
This class inherits from LVControl class and is specialised for Radio Button controls.
override void SetValue(ref strongnameLabview.VirtualInstrument vi, Object value)
Overriden method for setting the selected value in the Control. The value received could be a String ...