Exemple #1
0
        /// <summary>
        /// This is responsible for creating and initializing a <c>Control</c>
        /// and adding it to a view, if does not already exist.
        /// </summary>
        /// <param name="view">must not be null,
        /// and either <c>this.View == view</c> or <c>this.Document == view.Document</c>
        /// </param>
        /// <returns>A <c>Control</c>, added to the <pararef name="view" />.</returns>
        /// <remarks>
        /// This calls <see cref="M:Northwoods.Go.GoControl.FindControl(Northwoods.Go.GoView)" />.
        /// If the result is null, this calls <see cref="M:Northwoods.Go.GoControl.CreateControl(Northwoods.Go.GoView)" /> and
        /// remembers the resulting <c>Control</c> in the <see cref="P:Northwoods.Go.GoControl.Map" />,
        /// for <see cref="M:Northwoods.Go.GoControl.FindControl(Northwoods.Go.GoView)" /> to return.
        /// </remarks>
        public virtual Control GetControl(GoView view)
        {
            if (view == null)
            {
                return(null);
            }
            if (base.IsInView && base.View != view)
            {
                return(null);
            }
            if (base.IsInDocument && base.Document != view.Document)
            {
                return(null);
            }
            Control control = FindControl(view);

            if (control == null)
            {
                control = CreateControl(view);
                if (control != null)
                {
                    Map[view] = control;
                    view.AddGoControl(this, control);
                }
            }
            return(control);
        }