Beispiel #1
0
        /// <summary>
        /// Creates a new item.
        /// </summary>
        private void NewMI_Click(object sender, System.EventArgs e)
        {
            OpcDa::ItemValue template = null;

            // copy the current selection.
            if (ItemListLV.SelectedItems.Count > 0)
            {
                template = (OpcDa::ItemValue)((OpcDa::ItemValue)ItemListLV.SelectedItems[0].Tag).Clone();
            }

            // prompt user to edit new item.
            OpcDa::ItemValue[] items = new ItemValueListEditDlg().ShowDialog(new OpcDa::ItemValue[] { template }, true);

            if (items == null)
            {
                return;
            }

            // add new items.
            foreach (OpcDa::ItemValue item in items)
            {
                AddItem(item);
            }

            // adjust columns to fit data.
            AdjustColumns();
        }
Beispiel #2
0
        /// <summary>
        /// Edits the item template.
        /// </summary>
        private void EditTemplate(OpcDa::ItemValue template)
        {
            // prompt user to edit the template.
            OpcDa::ItemValue[] templates = new ItemValueListEditDlg().ShowDialog(new OpcDa::ItemValue[] { template }, false);

            if (templates == null || templates.Length != 1)
            {
                return;
            }

            // get existing items without applying defaults.
            ArrayList items = new ArrayList();

            foreach (ListViewItem item in ItemListLV.Items)
            {
                if (item.Tag != null && item.Tag.GetType() == typeof(OpcDa::ItemValue))
                {
                    if (item.Tag != m_template)
                    {
                        items.Add(item.Tag);
                    }
                }
            }

            // re-initialize the list with the new template.
            Initialize(m_server, templates[0]);

            // add items back.
            foreach (OpcDa::ItemValue item in items)
            {
                AddItem(item);
            }
        }
Beispiel #3
0
        /// <summary>
        /// Edits a group of items.
        /// </summary>
        private void EditMI_Click(object sender, System.EventArgs e)
        {
            // check if the template if being editied.
            if (ItemListLV.SelectedItems.Count == 1)
            {
                if (ItemListLV.SelectedItems[0].Tag == m_template)
                {
                    EditTemplate(m_template);
                    return;
                }
            }

            // build list of items to edit (exclude template).
            ArrayList itemList = new ArrayList(ItemListLV.SelectedItems.Count);

            foreach (ListViewItem item in ItemListLV.SelectedItems)
            {
                if (item.Tag != null && item.Tag.GetType() == typeof(OpcDa::ItemValue))
                {
                    if (item.Tag != m_template)
                    {
                        itemList.Add(item.Tag);
                    }
                }
            }

            // prompt user to edit list of items.
            OpcDa::ItemValue[] items = new ItemValueListEditDlg().ShowDialog((OpcDa::ItemValue[])itemList.ToArray(typeof(OpcDa::ItemValue)), false);

            if (items == null)
            {
                return;
            }

            // remove changed items.
            RemoveMI_Click(sender, e);

            // add changed items.
            foreach (OpcDa::ItemValue item in items)
            {
                // clear values only flag if quality or timestamp specified.
                if (item.QualitySpecified || item.TimestampSpecified)
                {
                    ValuesOnlyMI.Checked = false;
                }

                AddItem(item);
            }

            // adjust columns to fit data.
            AdjustColumns();
        }