/// <summary>
        /// Prompts the user to view the values of a trend.
        /// </summary>
        public bool ShowDialog(TsCHdaServer server, TsCHdaItemValueCollection values, bool readOnly)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            if (values == null)
            {
                throw new ArgumentNullException("values");
            }

            // initialize controls.
            TrendCTRL.Initialize(server, values);
            TrendCTRL.ReadOnly = readOnly;

            // show the dialog.
            if (ShowDialog() != DialogResult.OK)
            {
                return(false);
            }

            // update collection if not read only.
            if (!readOnly)
            {
                values.Clear();

                foreach (TsCHdaItemValue value in TrendCTRL.GetValues())
                {
                    values.Add(value);
                }
            }

            return(true);
        }
        /// <summary>
        /// Updates the values of the item.
        /// </summary>
        private void DoInsert()
        {
            // get the values to insert/replace.
            m_values = new TsCHdaItemValueCollection[] { ValuesCTRL.GetValues() };

            // check if there is nothing to do.
            if (m_values[0] == null || m_values[0].Count == 0)
            {
                return;
            }

            // create item (if necessary).
            TsCHdaItem item = m_trend.Items[m_item];

            if (item == null)
            {
                item = m_trend.AddItem(m_item);
            }

            // add the item identifier information to the collection.
            m_values[0].ItemName     = item.ItemName;
            m_values[0].ItemPath     = item.ItemPath;
            m_values[0].ServerHandle = item.ServerHandle;
            m_values[0].ClientHandle = item.ClientHandle;

            if (m_synchronous)
            {
                // insert data.
                TsCHdaResultCollection[] results = m_server.Insert(m_values, m_replace);

                if (results == null || results.Length != 1)
                {
                    ////throw new InvalidResponseException();
                }

                // display results.
                ResultsCTRL.Initialize(m_server, m_values, results);

                // save results.
                m_results = results;
            }
            else
            {
                // check if already waiting for results.
                if (m_asyncSent)
                {
                    return;
                }

                // begin insert data.
                OpcItemResult[] results = m_server.Insert(
                    m_values,
                    m_replace,
                    null,
                    new TsCHdaUpdateCompleteEventHandler(OnUpdateComplete),
                    out m_request);

                if (results == null || results.Length != 1)
                {
                    ////throw new InvalidResponseException();
                }

                // display initial results.
                AsyncResultsCTRL.Initialize(m_server, results);
                m_asyncSent = true;
            }
        }