Exemplo n.º 1
0
        /// <summary>
        /// Prompts the user to specify values to insert for an item.
        /// </summary>
        public bool ShowDialog(TsCHdaServer server, OpcItem item, bool synchronous)
        {
            if (server == null) throw new ArgumentNullException("server");

            mServer_      = server;
            mSynchronous_ = synchronous;
            mItem_        = item;
            mValues_      = null;
            mResults_     = null;

            // create new trend.
            mTrend_ = new TsCHdaTrend(mServer_);

            // set reasonable defaults.
            mTrend_.StartTime = new TsCHdaTime("YEAR");
            mTrend_.EndTime   = new TsCHdaTime("YEAR+1H");

            browseCtrl_.Browse(mServer_, null);
            valuesCtrl_.Initialize(mServer_, null);
            resultsCtrl_.Initialize(mServer_, mValues_, mResults_);
            asyncResultsCtrl_.Initialize(mServer_, null);

            // update dialog state.
            SetState();

            // show dialog.
            bool result = (ShowDialog() == DialogResult.OK);

            // release item handles.
            mTrend_.ClearItems();

            // return dialog result.
            return result;
        }
        /// <summary>
        /// Prompts the user to select an item and specify trend properties.
        /// </summary>
        public TsCHdaAnnotationValueCollection ShowDialog(TsCHdaServer server, bool synchronous)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            mServer_      = server;
            mSingleItem_  = true;
            mSynchronous_ = synchronous;
            mResults_     = null;

            // create new trend.
            mTrend_ = new TsCHdaTrend(mServer_);

            // set reasonable defaults.
            mTrend_.StartTime = new TsCHdaTime("YEAR");
            mTrend_.EndTime   = new TsCHdaTime("YEAR+1H");

            browseCtrl_.Browse(mServer_, null);
            trendItemsCtrl_.Initialize(mTrend_, false, null);
            trendCtrl_.Initialize(mTrend_, RequestType.ReadAnnotations);
            itemsCtrl_.Initialize(null);
            resultsCtrl_.Initialize(mServer_, null);
            asyncResultsCtrl_.Initialize(mServer_, null);

            // update dialog state.
            SetState();

            // show dialog.
            bool result = (ShowDialog() == DialogResult.OK);

            // release item handles.
            mTrend_.ClearItems();

            // return item values.
            return((result)?mResults_[0]:null);
        }