Exemple #1
0
 /// <summary>
 /// Removes a PropertyPage item to the collection.
 /// </summary>
 /// <param name="item">The item to remove.</param>
 public void Remove(PropertyTabPage item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     List.Remove(item);
 }
Exemple #2
0
 /// <summary>
 /// Inserts a PropertyPage instance into the collection.
 /// </summary>
 /// <param name="item">The item to add.</param>
 public void Insert(int index, PropertyTabPage item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     List.Insert(index, item);
 }
Exemple #3
0
 /// <summary>
 /// Discovers if the given item is in the collection.
 /// </summary>
 /// <param name="item">The item to find.</param>
 /// <returns>Returns true if the given item is in the collection.</returns>
 public bool Contains(PropertyTabPage item)
 {
     if (IndexOf(item) == -1)
     {
         return(false);
     }
     else
     {
         return(true);
     }
 }
Exemple #4
0
        /// <summary>
        /// Updates the view.
        /// </summary>
        private void RefreshView()
        {
            this.tabs.SuspendLayout();
            try
            {
                // clear...
                this.tabs.TabPages.Clear();

                // create...
                if (this.DataSource != null)
                {
                    // set...
                    this.Text = this.DataSource.ToString() + " " + BaseCaption;

                    // get the controls...
                    Control[] controls = this.GetControls(this.DataSource.GetType());
                    if (controls == null)
                    {
                        throw new InvalidOperationException("controls is null.");
                    }

                    // do we have any pages?
                    if (controls.Length > 0)
                    {
                        // create the pages...
                        PropertyTabPageCollection tabPages = new PropertyTabPageCollection();

                        // walk and create...
                        foreach (Control control in controls)
                        {
                            // add the page...
                            PropertyTabPage tabPage = new PropertyTabPage(control);
                            this.tabs.TabPages.Add(tabPage);

                            // do the binding...
                            if (control is IDataControl)
                            {
                                ((IDataControl)control).DataSource = this.DataSource;
                            }
                        }
                    }
                }
                else
                {
                    this.Text = BaseCaption;
                }
            }
            finally
            {
                this.tabs.ResumeLayout();
            }
        }
Exemple #5
0
        /// <summary>
        /// Gets the pages.
        /// </summary>
        /// <returns></returns>
        private Control[] GetControls(Type entityType)
        {
            if (entityType == null)
            {
                throw new ArgumentNullException("entityType");
            }

            // get the types...
            Type[] types = GetControlTypesForEntityType(entityType);
            if (types == null)
            {
                throw new InvalidOperationException("types is null.");
            }

            // create...
            IDictionary controls  = new HybridDictionary();
            ArrayList   names     = new ArrayList();
            int         generalAt = -1;

            for (int index = 0; index < types.Length; index++)
            {
                // create...
                Control control = (Control)Activator.CreateInstance(types[index]);
                if (control == null)
                {
                    throw new InvalidOperationException("control is null.");
                }

                // name...
                string name = PropertyTabPage.GetPropertyPageName(control);
                if (string.Compare(name, "general", true, System.Globalization.CultureInfo.InvariantCulture) == 0)
                {
                    generalAt = names.Count;
                }

                // get...
                controls[name] = control;
                names.Add(name);
            }

            // sort...
            names.Sort();

            // move...
            if (generalAt != -1)
            {
                string name = (string)names[generalAt];
                names.RemoveAt(generalAt);
                names.Insert(0, name);
            }

            // walk...
            Control[] results = new Control[names.Count];
            for (int index = 0; index < names.Count; index++)
            {
                results[index] = (Control)controls[names[index]];
            }

            // create then...
            return(results);
        }
Exemple #6
0
 /// <summary>
 /// Returns the index of the item in the collection.
 /// </summary>
 /// <param name="item">The item to find.</param>
 /// <returns>The index of the item, or -1 if it is not found.</returns>
 public int IndexOf(PropertyTabPage item)
 {
     return(List.IndexOf(item));
 }