/// <summary>
        /// Displays a dialog to edit a complex value.
        /// </summary>
        private void EditComplexValue(TsCCpxComplexValue complexValue)
        {
            object value = null;

            if (!complexValue.Value.GetType().IsArray)
            {
                value = new EditValueDlg().ShowDialog(complexValue.Value, true);
            }
            else if (complexValue.Value.GetType() == typeof(byte[]))
            {
                value = new EditBinaryDlg().ShowDialog((byte[])complexValue.Value);
            }
            else
            {
                if (complexValue.Value.GetType() != typeof(TsCCpxComplexValue[]))
                {
                    value = new EditArrayDlg().ShowDialog(complexValue.Value, m_readOnly);
                }
            }

            if (value != null)
            {
                // update the complex value.
                complexValue.Value = value;

                // serialize the entire complex value starting with the root object.
                m_rawValue = m_binaryValue.Parse(m_complexValue);

                // update the diplay.
                UpdateView();
            }
        }
示例#2
0
        /// <summary>
        /// Shows the edit array dialog for an element.
        /// </summary>
        private void ViewMI_Click(object sender, System.EventArgs e)
        {
            if (ArrayLV.SelectedItems.Count == 1)
            {
                ListViewItem item = ArrayLV.SelectedItems[0];

                if (item.Tag == null || !item.Tag.GetType().IsArray)
                {
                    return;
                }

                try
                {
                    int index = ArrayLV.SelectedIndices[0];

                    // get and convert the new value.
                    object value = new EditArrayDlg().ShowDialog(item.Tag, m_readOnly);

                    if (m_readOnly || value == null)
                    {
                        return;
                    }

                    // update the array.
                    ((Array)m_value).SetValue(value, index);

                    // update the list view.
                    ArrayLV.Items[index].Tag = value;
                    ArrayLV.Items[index].SubItems[1].Text = Technosoftware.DaAeHdaClient.OpcConvert.ToString(value);

                    // clear index.
                    m_index = -1;
                    ArrayLV.SelectedItems.Clear();
                    item.Selected = true;
                }
                catch (Exception exception)
                {
                    MessageBox.Show(exception.Message);
                }
            }
        }
示例#3
0
        /// <summary>
        /// Called when the edit array button is clicked.
        /// </summary>
        private void EditBTN_Click(object sender, System.EventArgs e)
        {
            try
            {
                object            value       = null;
                TsCCpxComplexItem complexItem = TsCCpxComplexTypeCache.GetComplexItem(m_itemID);

                if (complexItem != null)
                {
                    value = new EditComplexValueDlg().ShowDialog(complexItem, m_value, m_readOnly, true);
                }

                else
                if (m_value.GetType().IsArray)
                {
                    value = new EditArrayDlg().ShowDialog(m_value, m_readOnly);
                }

                if (m_readOnly || value == null)
                {
                    return;
                }

                // update the array.
                Set(value, m_readOnly);

                // send change notification.
                if (ValueChanged != null)
                {
                    ValueChanged(this, m_value);
                }
            }
            catch (Exception exception)
            {
                MessageBox.Show(exception.Message);
            }
        }