예제 #1
0
파일: Tabs.cs 프로젝트: sharad2/dcmslive
        /// <summary>
        /// Returns the index of the tab in which the control exists. Throws exception if
        /// control not found.
        /// </summary>
        /// <param name="ctl"></param>
        /// <returns></returns>
        /// <remarks>
        /// Keep looking at the parent until we find one of our JPanels. Then figure out its
        /// index and return it.
        /// </remarks>
        public int TabIndexOfControl(Control ctl)
        {
            JPanel jpChild = null;
            // save this control for the purpose of using in the case of exception.
            Control passedControl = ctl;

            while (ctl != this && ctl != null)
            {
                ctl = ctl.Parent;
                JPanel jp = ctl as JPanel;
                if (jp != null && jp.Parent == this)
                {
                    jpChild = jp;
                    break;
                }
            }
            if (jpChild == null)
            {
                // control id does not exist in tab container ...
                throw new ArgumentOutOfRangeException(string.Format("Control {0} not found.", passedControl.ID));
            }
            int index = this.Controls.IndexOf(jpChild);

            return(index);
        }
예제 #2
0
        /// <summary>
        /// Ensure that only <c>JPanel</c> can be added as a child
        /// </summary>
        /// <param name="obj"></param>
        protected override void AddParsedSubObject(object obj)
        {
            JPanel objTabPanel = obj as JPanel;

            if (null != objTabPanel)
            {
                Controls.Add(objTabPanel);
            }
            else if (!(obj is LiteralControl))
            {
                throw new HttpException(string.Format("The children {0}, ID {1} must be of type {2}. Type {2} is not allowed.",
                                                      this.GetType(), this.ID, typeof(JPanel), obj.GetType()));
            }
        }