/// <summary>
        /// Updates categories with selected attributes to dictionary.
        /// </summary>
        private void SetSelectedCategories(TreeNode parent, OpcClientSdk.Ae.TsCAeAttributeDictionary attributes)
        {
            foreach (TreeNode child in parent.Nodes)
            {
                if (!typeof(OpcClientSdk.Ae.TsCAeCategory).IsInstanceOfType(child.Tag))
                {
                    continue;
                }

                // check if category exists.
                OpcClientSdk.Ae.TsCAeCategory category = (OpcClientSdk.Ae.TsCAeCategory)child.Tag;

                if (!attributes.Contains(category.ID))
                {
                    child.Checked = false;
                    continue;
                }

                // check if attributes need to be fetched.
                if (child.Nodes.Count == 1 && child.Nodes[0].Text.Length == 0)
                {
                    child.Nodes.Clear();
                    ShowEventAttributes(child.Nodes, category);
                }

                // update individual attributes.
                SetSelectedAttributes(child, category, attributes);
            }
        }
 /// <summary>
 /// Sets the currently selected attributes.
 /// </summary>
 public void SetSelectedAttributes(OpcClientSdk.Ae.TsCAeAttributeDictionary attributes)
 {
     foreach (TreeNode child in AttributesTV.Nodes)
     {
         SetSelectedCategories(child, attributes);
     }
 }
        /// <summary>
        /// Returns currently selected attributes
        /// </summary>
        public OpcClientSdk.Ae.TsCAeAttributeDictionary GetSelectedAttributes()
        {
            OpcClientSdk.Ae.TsCAeAttributeDictionary attributes = new OpcClientSdk.Ae.TsCAeAttributeDictionary();

            foreach (TreeNode child in AttributesTV.Nodes)
            {
                GetSelectedCategories(child, attributes);
            }

            return(attributes);
        }
        /// <summary>
        /// Adds categories with selected attributes to dictionary.
        /// </summary>
        private void GetSelectedCategories(TreeNode parent, OpcClientSdk.Ae.TsCAeAttributeDictionary attributes)
        {
            foreach (TreeNode child in parent.Nodes)
            {
                if (!typeof(OpcClientSdk.Ae.TsCAeCategory).IsInstanceOfType(child.Tag))
                {
                    continue;
                }

                GetSelectedAttributes(child, (OpcClientSdk.Ae.TsCAeCategory)child.Tag, attributes);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Prompts a user to create a new subscription with a modal dialog.
        /// </summary>
        public Ae.TsCAeSubscription ShowDialog(TsCAeServer server, Ae.TsCAeSubscription subscription)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }

            m_server       = server;
            m_subscription = subscription;

            // go to the initial stage.
            m_stage = 0;
            ChangeStage(0);

            // initialize controls.
            StateCTRL.SetDefaults();
            FiltersCTRL.SetDefaults();
            CategoriesCTRL.ShowCategories(m_server);
            AttributesCTRL.ShowAttributes(m_server);
            BrowseCTRL.ShowAreas(m_server);

            if (m_subscription != null)
            {
                m_state      = m_subscription.GetState();
                m_filters    = m_subscription.GetFilters();
                m_attributes = m_subscription.GetAttributes();
                m_areas      = m_subscription.Areas.ToArray();
                m_sources    = m_subscription.Sources.ToArray();
            }
            else
            {
                m_state.Name = String.Format("Subscription{0,3:000}", ++m_count);
            }

            // set current values.
            StateCTRL.Set(m_state);
            FiltersCTRL.Set(m_filters);
            CategoriesCTRL.SetSelectedCategories(m_filters.Categories.ToArray());
            AttributesCTRL.SetSelectedAttributes(m_attributes);
            AreaSourcesListCTRL.AddAreas(m_areas);
            AreaSourcesListCTRL.AddSources(m_sources);

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

            // return updated/created subscription.
            return(m_subscription);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Called when the next button is clicked.
        /// </summary>
        private void NextBTN_Click(object sender, System.EventArgs e)
        {
            if (m_stage == 0)
            {
                m_state   = (Ae.TsCAeSubscriptionState)StateCTRL.Get();
                m_filters = (Ae.TsCAeSubscriptionFilters)FiltersCTRL.Get();

                m_filters.Categories.Clear();
                m_filters.Categories.AddRange(CategoriesCTRL.GetSelectedCategories());

                m_attributes = AttributesCTRL.GetSelectedAttributes();
            }

            ChangeStage(++m_stage);
        }
        /// <summary>
        /// Updates the selected attributes to the dictionary.
        /// </summary>
        private void SetSelectedAttributes(TreeNode parent, OpcClientSdk.Ae.TsCAeCategory category, OpcClientSdk.Ae.TsCAeAttributeDictionary attributes)
        {
            foreach (TreeNode child in parent.Nodes)
            {
                if (!typeof(TsCAeAttribute).IsInstanceOfType(child.Tag))
                {
                    continue;
                }

                OpcClientSdk.Ae.TsCAeAttribute attribute = (OpcClientSdk.Ae.TsCAeAttribute)child.Tag;

                if (attributes[category.ID].Contains(attribute.ID))
                {
                    child.Checked = true;
                }
                else
                {
                    child.Checked = false;
                }
            }
        }
        /// <summary>
        /// Adds selected attributes to the dictionary.
        /// </summary>
        private void GetSelectedAttributes(TreeNode parent, OpcClientSdk.Ae.TsCAeCategory category, OpcClientSdk.Ae.TsCAeAttributeDictionary attributes)
        {
            foreach (TreeNode child in parent.Nodes)
            {
                if (!typeof(OpcClientSdk.Ae.TsCAeAttribute).IsInstanceOfType(child.Tag))
                {
                    continue;
                }

                if (child.Checked)
                {
                    OpcClientSdk.Ae.TsCAeAttributeCollection collection = attributes[category.ID];

                    if (collection == null)
                    {
                        attributes.Add(category.ID, null);
                        collection = attributes[category.ID];
                    }

                    collection.Add(((OpcClientSdk.Ae.TsCAeAttribute)child.Tag).ID);
                }
            }
        }