public ModifyValueDialog(Gurux.Device.GXProperty property, bool editable, bool uiValue) { try { Type type = property.ValueType; m_TmpProperty = property.Clone(); m_UIValue = uiValue; InitializeComponent(); btnCancel.Text = Gurux.DeviceSuite.Properties.Resources.CancelTxt; btnOK.Text = Gurux.DeviceSuite.Properties.Resources.OKTxt; lblValue.Text = Gurux.DeviceSuite.Properties.Resources.ValueTxt; this.GeneralTab.Text = Gurux.DeviceSuite.Properties.Resources.GeneralTxt; this.Text = Gurux.DeviceSuite.Properties.Resources.EditValueTxt + " - " + property.Name; m_Property = property; // Check th eproperty type, i.e. do we use the textbox or dropdown list. m_UseBitMask = m_Property.BitMask; m_UseCombobox = !m_UseBitMask; if (!m_UseBitMask && type == typeof(bool) || property.Values.Count != 0) { m_UseCombobox = true; } //Disable OK Btn if property is not settable. Gurux.Device.AccessMode Mode = property.AccessMode; bool readOnly = (property.Device.Status & Gurux.Device.DeviceStates.Connected) == 0 || (Mode & Gurux.Device.AccessMode.Write) == 0; txtValue.ReadOnly = readOnly; ValueLB.Enabled = cbValue.Enabled = !readOnly; ValueLB.Visible = m_UseBitMask; if (m_UseCombobox) { if (type == typeof(bool)) { cbValue.Items.Add(bool.FalseString); cbValue.Items.Add(bool.TrueString); } else { foreach (object it in m_Property.Values) { cbValue.Items.Add(it.ToString()); } } string str = Convert.ToString(property.GetValue(m_UIValue)); cbValue.SelectedIndex = cbValue.FindStringExact(str); if (m_Property.ForcePresetValues || type == typeof(bool)) { cbValue.DropDownStyle = ComboBoxStyle.DropDownList; } else { cbValue.DropDownStyle = ComboBoxStyle.DropDown; cbValue.Text = Convert.ToString(property.GetValue(m_UIValue)); } } else { if (m_UseBitMask) { txtValue.ReadOnly = true; /* TODO: long val = Convert.ToInt64(m_Property.GetValue(true)); foreach (Gurux.Device.GXValue it in m_Property.LocalizedValueItems) { long tmp = Convert.ToInt64(it.DeviceValue); ListViewItem item = ValueLB.Items.Add(it.UIValue.ToString()); item.Checked = (val & tmp) != 0; item.Tag = tmp; } * */ } //If data type is string show multiline textbox. txtValue.Multiline = type == typeof(string); HexCB.Checked = (m_Property.DisplayType != DisplayTypes.None && type != typeof(string)) || type.IsArray; txtValue.Text = HexCB.Checked ? property.GetValueAsHex(m_UIValue) : Convert.ToString(property.GetValue(m_UIValue)); } // Hide the textbox and show the combo box. cbValue.Visible = m_UseCombobox; ValueLB.Visible = m_UseBitMask; txtValue.Visible = !m_UseCombobox; HexCB.Visible = !m_UseBitMask && !m_UseCombobox;//TODO: && m_Property.IsTypeNumeric; //Add disabled actions. //TODO: if (!m_Property.IsNotify) { m_DisActions = new DisabledAction(property.DisabledActions); tabControl1.TabPages.Add(m_DisActions.DisabledActionsTB); } } catch (Exception Ex) { GXCommon.ShowError(Ex); } }