Example #1
0
        private void AddSelectedWebParts()
        {
            WebPartZoneBase zone = null;

            if (base.WebPartManager != null)
            {
                zone = base.WebPartManager.Zones[this._selectedZoneID];
            }
            CatalogPart selectedCatalogPart = this.SelectedCatalogPart;
            WebPartDescriptionCollection availableWebPartDescriptions = null;

            if (selectedCatalogPart != null)
            {
                availableWebPartDescriptions = selectedCatalogPart.GetAvailableWebPartDescriptions();
            }
            if (((zone != null) && zone.AllowLayoutChange) && ((this._selectedCheckBoxValues != null) && (availableWebPartDescriptions != null)))
            {
                ArrayList webParts = new ArrayList();
                for (int i = 0; i < this._selectedCheckBoxValues.Length; i++)
                {
                    string             str         = this._selectedCheckBoxValues[i];
                    WebPartDescription description = availableWebPartDescriptions[str];
                    if (description != null)
                    {
                        WebPart webPart = selectedCatalogPart.GetWebPart(description);
                        if (webPart != null)
                        {
                            webParts.Add(webPart);
                        }
                    }
                }
                this.AddWebParts(webParts, zone);
            }
        }
 public WebPartChrome(WebPartZoneBase zone, System.Web.UI.WebControls.WebParts.WebPartManager manager)
 {
     if (zone == null)
     {
         throw new ArgumentNullException("zone");
     }
     this._zone = zone;
     this._page = zone.Page;
     this._designMode = zone.DesignMode;
     this._manager = manager;
     if (this._designMode)
     {
         this._personalizationEnabled = true;
     }
     else
     {
         this._personalizationEnabled = (manager != null) && manager.Personalization.IsModifiable;
     }
     if (manager != null)
     {
         this._personalizationScope = manager.Personalization.Scope;
     }
     else
     {
         this._personalizationScope = PersonalizationScope.Shared;
     }
 }
Example #3
0
        public WebPartChrome(WebPartZoneBase zone, WebPartManager manager)
        {
            if (zone == null)
            {
                throw new ArgumentNullException("zone");
            }
            _zone       = zone;
            _page       = zone.Page;
            _designMode = zone.DesignMode;
            _manager    = manager;

            if (_designMode)
            {
                // Consider personalization to be enabled at design-time
                _personalizationEnabled = true;
            }
            else
            {
                _personalizationEnabled = (manager != null && manager.Personalization.IsModifiable);
            }

            if (manager != null)
            {
                _personalizationScope = manager.Personalization.Scope;
            }
            else
            {
                // Consider scope to be shared at design-time
                _personalizationScope = PersonalizationScope.Shared;
            }
        }
Example #4
0
        public override void AddItemToPage(System.Web.UI.WebControls.WebParts.WebPartZoneBase zone, int zoneIndex, WebPartGalleryItem item, string wpid)
        {
            if (zone == null)
            {
                throw new ArgumentNullException("zone");
            }
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }
            System.Web.UI.WebControls.WebParts.WebPart webPart = ((WebPartGalleryItemBase)item).Instantiate();

            /*
             * if (!item.IsSafeAgainstScript)
             * {
             *  SPWebPartManager currentWebPartManager = WebPartManager.GetCurrentWebPartManager(this.Page) as SPWebPartManager;
             *  if (!CanUserScript(SPContext.Current.Web))
             *  {
             *      currentWebPartManager.SafeForScriptingManager.ProcessAllowContributorScriptPropertiesRollback(webPart);
             *  }
             * }
             */
            if (!string.IsNullOrEmpty(wpid))
            {
                webPart.ID = wpid;
                webPart.TitleIconImageUrl = webPart.CatalogIconImageUrl;
                webPart.ChromeType        = PartChromeType.None;
            }

            this.AddItemToPage(zone, zoneIndex, webPart);
        }
Example #5
0
 public WebPartChrome(WebPartZoneBase zone, System.Web.UI.WebControls.WebParts.WebPartManager manager)
 {
     if (zone == null)
     {
         throw new ArgumentNullException("zone");
     }
     this._zone       = zone;
     this._page       = zone.Page;
     this._designMode = zone.DesignMode;
     this._manager    = manager;
     if (this._designMode)
     {
         this._personalizationEnabled = true;
     }
     else
     {
         this._personalizationEnabled = (manager != null) && manager.Personalization.IsModifiable;
     }
     if (manager != null)
     {
         this._personalizationScope = manager.Personalization.Scope;
     }
     else
     {
         this._personalizationScope = PersonalizationScope.Shared;
     }
 }
        public WebPartChrome(WebPartZoneBase zone, WebPartManager manager) {
            if (zone == null) {
                throw new ArgumentNullException("zone");
            }
            _zone = zone;
            _page = zone.Page;
            _designMode = zone.DesignMode;
            _manager = manager;

            if (_designMode) {
                // Consider personalization to be enabled at design-time
                _personalizationEnabled = true;
            }
            else {
                _personalizationEnabled = (manager != null && manager.Personalization.IsModifiable);
            }

            if (manager != null) {
                _personalizationScope = manager.Personalization.Scope;
            }
            else {
                // Consider scope to be shared at design-time
                _personalizationScope = PersonalizationScope.Shared;
            }
        }
Example #7
0
        public override bool ApplyChanges()
        {
            WebPart webPart = WebPartToEdit;

            if (webPart != null)
            {
                EnsureChildControls();

                try {
                    if (CanChangeChromeState)
                    {
                        TypeConverter chromeStateConverter = TypeDescriptor.GetConverter(typeof(PartChromeState));
                        webPart.ChromeState = (PartChromeState)chromeStateConverter.ConvertFromString(_chromeState.SelectedValue);
                    }
                }
                catch (Exception e) {
                    _chromeStateErrorMessage = CreateErrorMessage(e.Message);
                }

                int zoneIndex = webPart.ZoneIndex;
                if (CanChangeZoneIndex)
                {
                    if (Int32.TryParse(_zoneIndex.Text, NumberStyles.Integer, CultureInfo.CurrentCulture, out zoneIndex))
                    {
                        if (zoneIndex < MinZoneIndex)
                        {
                            _zoneIndexErrorMessage = SR.GetString(SR.EditorPart_PropertyMinValue, MinZoneIndex.ToString(CultureInfo.CurrentCulture));
                        }
                    }
                    else
                    {
                        _zoneIndexErrorMessage = SR.GetString(SR.EditorPart_PropertyMustBeInteger);
                    }
                }

                WebPartZoneBase oldZone = webPart.Zone;
                WebPartZoneBase newZone = oldZone;
                if (CanChangeZone)
                {
                    newZone = WebPartManager.Zones[_zone.SelectedValue];
                }

                // Do not call MoveWebPart if the WebPart is currently in the correct position (VSWhidbey 374634)
                if (_zoneIndexErrorMessage == null && oldZone.AllowLayoutChange && newZone.AllowLayoutChange &&
                    (webPart.Zone != newZone || webPart.ZoneIndex != zoneIndex))
                {
                    try {
                        WebPartManager.MoveWebPart(webPart, newZone, zoneIndex);
                    }
                    catch (Exception e) {
                        // Zone and ZoneIndex are set at the same time.  Use the _zoneIndexErrorMessage, since it is
                        // more likely that a bogus ZoneIndex would cause an error.
                        _zoneIndexErrorMessage = CreateErrorMessage(e.Message);
                    }
                }
            }

            return(!HasError);
        }
        protected override void AddAttributesToRender(HtmlTextWriter writer)
        {
            WebPartZoneBase zone = base.Zone;

            if ((zone != null) && !zone.ErrorStyle.IsEmpty)
            {
                zone.ErrorStyle.AddAttributesToRender(writer, this);
            }
            base.AddAttributesToRender(writer);
        }
Example #9
0
        public override bool ApplyChanges()
        {
            WebPart webPartToEdit = base.WebPartToEdit;

            if (webPartToEdit != null)
            {
                this.EnsureChildControls();
                try
                {
                    if (this.CanChangeChromeState)
                    {
                        TypeConverter converter = TypeDescriptor.GetConverter(typeof(PartChromeState));
                        webPartToEdit.ChromeState = (PartChromeState)converter.ConvertFromString(this._chromeState.SelectedValue);
                    }
                }
                catch (Exception exception)
                {
                    this._chromeStateErrorMessage = base.CreateErrorMessage(exception.Message);
                }
                int zoneIndex = webPartToEdit.ZoneIndex;
                if (this.CanChangeZoneIndex)
                {
                    if (int.TryParse(this._zoneIndex.Text, NumberStyles.Integer, CultureInfo.CurrentCulture, out zoneIndex))
                    {
                        if (zoneIndex < 0)
                        {
                            object[] args = new object[] { 0.ToString(CultureInfo.CurrentCulture) };
                            this._zoneIndexErrorMessage = System.Web.SR.GetString("EditorPart_PropertyMinValue", args);
                        }
                    }
                    else
                    {
                        this._zoneIndexErrorMessage = System.Web.SR.GetString("EditorPart_PropertyMustBeInteger");
                    }
                }
                WebPartZoneBase zone  = webPartToEdit.Zone;
                WebPartZoneBase base3 = zone;
                if (this.CanChangeZone)
                {
                    base3 = base.WebPartManager.Zones[this._zone.SelectedValue];
                }
                if ((((this._zoneIndexErrorMessage == null) && zone.AllowLayoutChange) && base3.AllowLayoutChange) && ((webPartToEdit.Zone != base3) || (webPartToEdit.ZoneIndex != zoneIndex)))
                {
                    try
                    {
                        base.WebPartManager.MoveWebPart(webPartToEdit, base3, zoneIndex);
                    }
                    catch (Exception exception2)
                    {
                        this._zoneIndexErrorMessage = base.CreateErrorMessage(exception2.Message);
                    }
                }
            }
            return(!this.HasError);
        }
 private void AddWebParts(ArrayList webParts, WebPartZoneBase zone)
 {
     webParts.Reverse();
     foreach (WebPart part in webParts)
     {
         WebPartZoneBase base2 = zone;
         if (!part.AllowZoneChange && (part.Zone != null))
         {
             base2 = part.Zone;
         }
         base.WebPartManager.AddWebPart(part, base2, 0);
     }
 }
Example #11
0
 private void AddWebParts(ArrayList webParts, WebPartZoneBase zone)
 {
     webParts.Reverse();
     foreach (WebPart part in webParts)
     {
         WebPartZoneBase base2 = zone;
         if (!part.AllowZoneChange && (part.Zone != null))
         {
             base2 = part.Zone;
         }
         base.WebPartManager.AddWebPart(part, base2, 0);
     }
 }
Example #12
0
        public override void SyncChanges()
        {
            WebPart webPart = WebPartToEdit;

            Debug.Assert(webPart != null);
            if (webPart != null)
            {
                WebPartZoneBase currentZone       = webPart.Zone;
                bool            allowLayoutChange = currentZone.AllowLayoutChange;

                EnsureChildControls();

                TypeConverter chromeStateConverter = TypeDescriptor.GetConverter(typeof(PartChromeState));
                _chromeState.SelectedValue = chromeStateConverter.ConvertToString(webPart.ChromeState);
                _chromeState.Enabled       = CanChangeChromeState;

                WebPartManager manager = WebPartManager;
                Debug.Assert(manager != null);
                if (manager != null)
                {
                    WebPartZoneCollection zones = manager.Zones;
                    bool allowZoneChange        = webPart.AllowZoneChange;

                    _zone.ClearSelection();
                    foreach (ListItem item in _zone.Items)
                    {
                        string          zoneID = item.Value;
                        WebPartZoneBase zone   = zones[zoneID];
                        if (zone == currentZone || (allowZoneChange && zone.AllowLayoutChange))
                        {
                            item.Enabled = true;
                        }
                        else
                        {
                            item.Enabled = false;
                        }

                        if (zone == currentZone)
                        {
                            item.Selected = true;
                        }
                    }

                    _zone.Enabled = CanChangeZone;
                }

                _zoneIndex.Text    = webPart.ZoneIndex.ToString(CultureInfo.CurrentCulture);
                _zoneIndex.Enabled = CanChangeZoneIndex;
            }
        }
Example #13
0
        protected override void AddItemToPage(System.Web.UI.WebControls.WebParts.WebPartZoneBase zone, int zoneIndex, System.Web.UI.WebControls.WebParts.WebPart webPart)
        {
            WebPartManager   currentWebPartManager = WebPartManager.GetCurrentWebPartManager(this.Page);
            SPWebPartManager spmanager             = currentWebPartManager as SPWebPartManager;

            if (spmanager != null)
            {
                webPart = spmanager.AddWebPart(webPart, zone, zoneIndex);
            }
            else
            {
                webPart = currentWebPartManager.AddWebPart(webPart, zone, zoneIndex);
            }
        }
Example #14
0
        public WebPartZoneBase this[string id] {
            get {
                WebPartZoneBase selectedZone = null;

                foreach (WebPartZoneBase zone in InnerList)
                {
                    if (String.Equals(zone.ID, id, StringComparison.OrdinalIgnoreCase))
                    {
                        selectedZone = zone;
                        break;
                    }
                }

                return(selectedZone);
            }
        }
Example #15
0
        private void AddSelectedWebParts()
        {
            WebPartZoneBase selectedZone = null;

            if (WebPartManager != null)
            {
                selectedZone = WebPartManager.Zones[_selectedZoneID];
            }

            CatalogPart selectedCatalogPart = SelectedCatalogPart;
            WebPartDescriptionCollection availableWebParts = null;

            if (selectedCatalogPart != null)
            {
                availableWebParts = selectedCatalogPart.GetAvailableWebPartDescriptions();
            }

            if (selectedZone != null && selectedZone.AllowLayoutChange &&
                _selectedCheckBoxValues != null && availableWebParts != null)
            {
                ArrayList selectedWebParts = new ArrayList();

                // Fetch all of the WebParts before calling AddWebPart() on any of them.
                // This is necessary if the CatalogPart would refresh its list of
                // AvailableWebPartDescriptions in response to adding a WebPart.
                // PageCatalogPart is an example of this. (VSWhidbey 337539)
                for (int i = 0; i < _selectedCheckBoxValues.Length; i++)
                {
                    string             value = _selectedCheckBoxValues[i];
                    WebPartDescription webPartDescription = availableWebParts[value];
                    if (webPartDescription != null)
                    {
                        WebPart part = selectedCatalogPart.GetWebPart(webPartDescription);
                        if (part != null)
                        {
                            selectedWebParts.Add(part);
                        }
                    }
                }

                AddWebParts(selectedWebParts, selectedZone);
            }
        }
Example #16
0
        private void AddWebParts(ArrayList webParts, WebPartZoneBase zone)
        {
            // Add web parts from the list in reverse order, so they appear in the zone in the same
            // order they were returned from the catalog part. (VSWhidbey 77750)
            webParts.Reverse();

            foreach (WebPart part in webParts)
            {
                WebPartZoneBase targetZone = zone;
                if (part.AllowZoneChange == false && part.Zone != null)
                {
                    targetZone = part.Zone;
                }

                // WebPartManager is checked for null in AddWebParts()
                Debug.Assert(WebPartManager != null);
                // Add new parts to the top of the Zone, so the user will see them without scrolling the page
                WebPartManager.AddWebPart(part, targetZone, 0);
            }
        }
Example #17
0
        public override void SyncChanges()
        {
            WebPart webPartToEdit = base.WebPartToEdit;

            if (webPartToEdit != null)
            {
                WebPartZoneBase zone = webPartToEdit.Zone;
                bool            allowLayoutChange = zone.AllowLayoutChange;
                this.EnsureChildControls();
                this._chromeState.SelectedValue = TypeDescriptor.GetConverter(typeof(PartChromeState)).ConvertToString(webPartToEdit.ChromeState);
                this._chromeState.Enabled       = this.CanChangeChromeState;
                WebPartManager webPartManager = base.WebPartManager;
                if (webPartManager != null)
                {
                    WebPartZoneCollection zones = webPartManager.Zones;
                    bool allowZoneChange        = webPartToEdit.AllowZoneChange;
                    this._zone.ClearSelection();
                    foreach (ListItem item in this._zone.Items)
                    {
                        string          str   = item.Value;
                        WebPartZoneBase base3 = zones[str];
                        if ((base3 == zone) || (allowZoneChange && base3.AllowLayoutChange))
                        {
                            item.Enabled = true;
                        }
                        else
                        {
                            item.Enabled = false;
                        }
                        if (base3 == zone)
                        {
                            item.Selected = true;
                        }
                    }
                    this._zone.Enabled = this.CanChangeZone;
                }
                this._zoneIndex.Text    = webPartToEdit.ZoneIndex.ToString(CultureInfo.CurrentCulture);
                this._zoneIndex.Enabled = this.CanChangeZoneIndex;
            }
        }
 public WebPartChrome(WebPartZoneBase zone, WebPartManager manager)
 {
 }
Example #19
0
 public bool Contains(WebPartZoneBase value)
 {
     return(base.InnerList.Contains(value));
 }
 public WebPartAddingEventArgs(WebPart webPart, WebPartZoneBase zone, int zoneIndex) : base(default(WebPart))
 {
 }
Example #21
0
 public WebPart AddWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex)
 {
     return(default(WebPart));
 }
 public virtual new void MoveWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex)
 {
 }
 public WebPartChrome (WebPartZoneBase zone, WebPartManager manager)
 {
   Contract.Requires (manager.Personalization != null);
 }
Example #24
0
 public bool Contains(WebPartZoneBase value)
 {
   return default(bool);
 }
        private WebPart AddDynamicWebPartToZone(WebPart webPart, WebPartZoneBase zone, int zoneIndex) {
            Debug.Assert(Personalization.IsModifiable);

            // Zone should not be set on a dynamic web part being added to the page for the first time
            Debug.Assert(webPart.Zone == null);

            // Only add WebPart if IsAuthorized(webPart) == true
            if (!IsAuthorized(webPart)) {
                return null;
            }

            WebPart newWebPart = CopyWebPart(webPart);
            Internals.SetIsStatic(newWebPart, false);
            Internals.SetIsShared(newWebPart, Personalization.Scope == PersonalizationScope.Shared);

            AddWebPartToZone(newWebPart, zone, zoneIndex);
            Internals.AddWebPart(newWebPart);

            // We set the personalized properties on the added WebPart AFTER it has been added to the
            // control tree, since we want to exactly recreate the process the WebPart will go through
            // when it is added from Personalization.
            Personalization.CopyPersonalizationState(webPart, newWebPart);

            // Raise event at very end of Add method
            OnWebPartAdded(new WebPartEventArgs(newWebPart));

            return newWebPart;
        }
 public WebPartChrome(WebPartZoneBase zone, WebPartManager manager)
 {
     Contract.Requires(manager.Personalization != null);
 }
 public WebPartMovingEventArgs(WebPart webPart, WebPartZoneBase zone, int zoneIndex) : base(webPart)
 {
     _zone      = zone;
     _zoneIndex = zoneIndex;
 }
 public bool Contains(WebPartZoneBase value) {
     return InnerList.Contains(value);
 }
        // Returns the WebPart that was actually added.  For an existing Closed WebPart, this is a reference
        // to the webPart parameter.  For a new DynamicWebPart, this will be a copy of the webPart parameter.
        public WebPart AddWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex) {
            Personalization.EnsureEnabled(/* ensureModifiable */ true);

            if (webPart == null) {
                throw new ArgumentNullException("webPart");
            }
            // Do not check that Controls.Contains(webPart), since this will be called on a WebPart
            // before it is added to the Controls collection.
            if (zone == null) {
                throw new ArgumentNullException("zone");
            }
            if (_webPartZones.Contains(zone) == false) {
                throw new ArgumentException(SR.GetString(SR.WebPartManager_MustRegister), "zone");
            }
            if (zoneIndex < 0) {
                throw new ArgumentOutOfRangeException("zoneIndex");
            }
            if (webPart.Zone != null && !webPart.IsClosed) {
                throw new ArgumentException(SR.GetString(SR.WebPartManager_AlreadyInZone), "webPart");
            }

            WebPartAddingEventArgs e = new WebPartAddingEventArgs(webPart, zone, zoneIndex);
            OnWebPartAdding(e);
            if (_allowEventCancellation && e.Cancel) {
                return null;
            }

            WebPart addedWebPart;

            // If a part is already in the controls collection, dynamic or static, just make it
            // not closed and add it to the specified zone
            if (Controls.Contains(webPart)) {
                addedWebPart = webPart;
                AddWebPartToZone(webPart, zone, zoneIndex);
                OnWebPartAdded(new WebPartEventArgs(addedWebPart));
            } else {
                addedWebPart = AddDynamicWebPartToZone(webPart, zone, zoneIndex);
                // OnWebPartAdded() is called by AddDynamicWebPartToZone
            }

#if DEBUG
            CheckPartZoneIndexes(zone);
#endif

            return addedWebPart;
        }
 /// <devdoc>
 /// <para>Copies contents from the collection to a specified array with a
 /// specified starting index.</para>
 /// </devdoc>
 public void CopyTo(WebPartZoneBase[] array, int index) {
     InnerList.CopyTo(array, index);
 }
        /// <devdoc>
        /// Adds a web part to a zone at the specified zoneIndex, and renumbers all the parts in the zone
        /// sequentially.
        /// </devdoc>
        private void AddWebPartToZone(WebPart webPart, WebPartZoneBase zone, int zoneIndex) {
            Debug.Assert(webPart.Zone == null || webPart.IsClosed);

            // All the parts for the zone
            IList allParts = GetAllWebPartsForZone(zone);

            // The parts for the zone that were actually rendered
            WebPartCollection renderedParts = GetWebPartsForZone(zone);

            // The zoneIndex parameter is the desired index in the renderedParts collection.
            // Calculate the destination index into the allParts collection. (VSWhidbey 77719)
            int allPartsDestinationIndex;
            if (zoneIndex < renderedParts.Count) {
                WebPart successor = renderedParts[zoneIndex];
                Debug.Assert(allParts.Contains(successor));
                allPartsDestinationIndex = allParts.IndexOf(successor);
            }
            else {
                allPartsDestinationIndex = allParts.Count;
            }

            // Renumber all parts in the zone, leaving room for the added part
            for (int i = 0; i < allPartsDestinationIndex; i++) {
                WebPart part = ((WebPart)allParts[i]);
                Internals.SetZoneIndex(part, i);
            }
            for (int i = allPartsDestinationIndex; i < allParts.Count; i++) {
                WebPart part = ((WebPart)allParts[i]);
                Internals.SetZoneIndex(part, i + 1);
            }

            // Set the part index and add to destination zone
            Internals.SetZoneIndex(webPart, allPartsDestinationIndex);
            Internals.SetZoneID(webPart, zone.ID);
            Internals.SetIsClosed(webPart, false);

            _hasDataChanged = true;

            AddWebPartToDictionary(webPart);
        }
Example #32
0
 public WebPartAddingEventArgs(WebPart webPart, WebPartZoneBase zone, int zoneIndex) : base(webPart)
 {
     this._zone      = zone;
     this._zoneIndex = zoneIndex;
 }
        public int IndexOf(WebPartZoneBase value)
        {
            Contract.Ensures(Contract.Result <int>() >= -1);

            return(default(int));
        }
 public virtual new void MoveWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex)
 {
     Contract.Requires(this.Personalization != null);
 }
 private IList GetAllWebPartsForZone(WebPartZoneBase zone)
 {
     if (this._partsForZone == null)
     {
         this._partsForZone = new HybridDictionary(true);
         foreach (WebPart part in this.Controls)
         {
             if (!part.IsClosed)
             {
                 string zoneID = this.Internals.GetZoneID(part);
                 if (!string.IsNullOrEmpty(zoneID))
                 {
                     SortedList list = (SortedList) this._partsForZone[zoneID];
                     if (list == null)
                     {
                         list = new SortedList(new WebPart.ZoneIndexComparer());
                         this._partsForZone[zoneID] = list;
                     }
                     list.Add(part, null);
                 }
             }
         }
     }
     SortedList list2 = (SortedList) this._partsForZone[zone.ID];
     if (list2 == null)
     {
         list2 = new SortedList();
     }
     return list2.GetKeyList();
 }
 public WebPart AddWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex)
 {
   return default(WebPart);
 }
 public virtual void MoveWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex)
 {
     this.Personalization.EnsureEnabled(true);
     if (webPart == null)
     {
         throw new ArgumentNullException("webPart");
     }
     if (!this.Controls.Contains(webPart))
     {
         throw new ArgumentException(System.Web.SR.GetString("UnknownWebPart"), "webPart");
     }
     if (zone == null)
     {
         throw new ArgumentNullException("zone");
     }
     if (!this._webPartZones.Contains(zone))
     {
         throw new ArgumentException(System.Web.SR.GetString("WebPartManager_MustRegister"), "zone");
     }
     if (zoneIndex < 0)
     {
         throw new ArgumentOutOfRangeException("zoneIndex");
     }
     if ((webPart.Zone == null) || webPart.IsClosed)
     {
         throw new ArgumentException(System.Web.SR.GetString("WebPartManager_MustBeInZone"), "webPart");
     }
     if ((webPart.Zone != zone) || (webPart.ZoneIndex != zoneIndex))
     {
         WebPartMovingEventArgs e = new WebPartMovingEventArgs(webPart, zone, zoneIndex);
         this.OnWebPartMoving(e);
         if (!this._allowEventCancellation || !e.Cancel)
         {
             this.RemoveWebPartFromZone(webPart);
             this.AddWebPartToZone(webPart, zone, zoneIndex);
             this.OnWebPartMoved(new WebPartEventArgs(webPart));
         }
     }
 }
Example #38
0
 public virtual new void MoveWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex)
 {
 }
 private WebPart AddDynamicWebPartToZone(WebPart webPart, WebPartZoneBase zone, int zoneIndex)
 {
     if (!this.IsAuthorized(webPart))
     {
         return null;
     }
     WebPart part = this.CopyWebPart(webPart);
     this.Internals.SetIsStatic(part, false);
     this.Internals.SetIsShared(part, this.Personalization.Scope == PersonalizationScope.Shared);
     this.AddWebPartToZone(part, zone, zoneIndex);
     this.Internals.AddWebPart(part);
     this.Personalization.CopyPersonalizationState(webPart, part);
     this.OnWebPartAdded(new WebPartEventArgs(part));
     return part;
 }
Example #40
0
 internal int Add(WebPartZoneBase value)
 {
     return(base.InnerList.Add(value));
 }
 internal void AddWebPartsFromZone(WebPartZoneBase zone, WebPartCollection webParts)
 {
     if ((webParts != null) && (webParts.Count != 0))
     {
         string errorMsg = base.SetCollectionReadOnly(null);
         try
         {
             try
             {
                 string iD = zone.ID;
                 int zoneIndex = 0;
                 foreach (WebPart part in webParts)
                 {
                     this._manager.Internals.SetIsShared(part, true);
                     WebPart webPart = part;
                     if (!this._manager.IsAuthorized(part))
                     {
                         webPart = new UnauthorizedWebPart(part);
                     }
                     this._manager.Internals.SetIsStatic(webPart, true);
                     this._manager.Internals.SetIsShared(webPart, true);
                     this._manager.Internals.SetZoneID(webPart, iD);
                     this._manager.Internals.SetZoneIndex(webPart, zoneIndex);
                     this.AddWebPartHelper(webPart);
                     zoneIndex++;
                 }
             }
             finally
             {
                 base.SetCollectionReadOnly(errorMsg);
             }
         }
         catch
         {
             throw;
         }
     }
 }
Example #42
0
 public int IndexOf(WebPartZoneBase value)
 {
     return(base.InnerList.IndexOf(value));
 }
        public WebPart AddWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex)
        {
            Contract.Requires(this.Personalization != null);

            return(default(WebPart));
        }
 internal int Add(WebPartZoneBase value) {
     return InnerList.Add(value);
 }
Example #45
0
        private void AddWebParts(ArrayList webParts, WebPartZoneBase zone) {
            // Add web parts from the list in reverse order, so they appear in the zone in the same
            // order they were returned from the catalog part. (VSWhidbey 77750)
            webParts.Reverse();

            foreach (WebPart part in webParts) {
                WebPartZoneBase targetZone = zone;
                if (part.AllowZoneChange == false && part.Zone != null) {
                    targetZone = part.Zone;
                }

                // WebPartManager is checked for null in AddWebParts()
                Debug.Assert(WebPartManager != null);
                // Add new parts to the top of the Zone, so the user will see them without scrolling the page
                WebPartManager.AddWebPart(part, targetZone, 0);
            }
        }
 public int IndexOf(WebPartZoneBase value) {
     return InnerList.IndexOf(value);
 }
 public WebPartMovingEventArgs(WebPart webPart, WebPartZoneBase zone, int zoneIndex) : base(webPart) {
     _zone = zone;
     _zoneIndex = zoneIndex;
 }
 public WebPartEditableDesignerRegion(WebPartZoneBase zone, TemplateDefinition templateDefinition) : base(templateDefinition)
 {
     this._zone = zone;
 }
 public WebPartMovingEventArgs (WebPart webPart, WebPartZoneBase zone, int zoneIndex) : base (default(WebPart))
 {
 }
Example #50
0
 public int IndexOf(WebPartZoneBase value)
 {
   return default(int);
 }
 public WebPartChrome(WebPartZoneBase zone, WebPartManager manager)
 {
 }
 internal WebPartCollection GetWebPartsForZone(WebPartZoneBase zone)
 {
     if (zone == null)
     {
         throw new ArgumentNullException("zone");
     }
     if (!this._webPartZones.Contains(zone))
     {
         throw new ArgumentException(System.Web.SR.GetString("WebPartManager_MustRegister"), "zone");
     }
     IList allWebPartsForZone = this.GetAllWebPartsForZone(zone);
     WebPartCollection parts = new WebPartCollection();
     if (allWebPartsForZone.Count > 0)
     {
         foreach (WebPart part in allWebPartsForZone)
         {
             if (this.ShouldRenderWebPartInZone(part, zone))
             {
                 parts.Add(part);
             }
         }
     }
     return parts;
 }
 public DesignerWebPartChrome(WebPartZoneBase zone) : base(zone, null)
 {
 }
 private bool ShouldRenderWebPartInZone(WebPart part, WebPartZoneBase zone)
 {
     if (part is UnauthorizedWebPart)
     {
         return false;
     }
     return true;
 }
 public virtual new void MoveWebPart (WebPart webPart, WebPartZoneBase zone, int zoneIndex)
 {
   Contract.Requires (this.Personalization != null);
 }
 public WebPart AddWebPart(WebPart webPart, WebPartZoneBase zone, int zoneIndex)
 {
     this.Personalization.EnsureEnabled(true);
     if (webPart == null)
     {
         throw new ArgumentNullException("webPart");
     }
     if (zone == null)
     {
         throw new ArgumentNullException("zone");
     }
     if (!this._webPartZones.Contains(zone))
     {
         throw new ArgumentException(System.Web.SR.GetString("WebPartManager_MustRegister"), "zone");
     }
     if (zoneIndex < 0)
     {
         throw new ArgumentOutOfRangeException("zoneIndex");
     }
     if ((webPart.Zone != null) && !webPart.IsClosed)
     {
         throw new ArgumentException(System.Web.SR.GetString("WebPartManager_AlreadyInZone"), "webPart");
     }
     WebPartAddingEventArgs e = new WebPartAddingEventArgs(webPart, zone, zoneIndex);
     this.OnWebPartAdding(e);
     if (this._allowEventCancellation && e.Cancel)
     {
         return null;
     }
     if (this.Controls.Contains(webPart))
     {
         WebPart part = webPart;
         this.AddWebPartToZone(webPart, zone, zoneIndex);
         this.OnWebPartAdded(new WebPartEventArgs(part));
         return part;
     }
     return this.AddDynamicWebPartToZone(webPart, zone, zoneIndex);
 }
    public WebPart AddWebPart (WebPart webPart, WebPartZoneBase zone, int zoneIndex)
    {
      Contract.Requires (this.Personalization != null);

      return default(WebPart);
    }
 private void AddWebPartToZone(WebPart webPart, WebPartZoneBase zone, int zoneIndex)
 {
     int index;
     IList allWebPartsForZone = this.GetAllWebPartsForZone(zone);
     WebPartCollection webPartsForZone = this.GetWebPartsForZone(zone);
     if (zoneIndex < webPartsForZone.Count)
     {
         WebPart part = webPartsForZone[zoneIndex];
         index = allWebPartsForZone.IndexOf(part);
     }
     else
     {
         index = allWebPartsForZone.Count;
     }
     for (int i = 0; i < index; i++)
     {
         WebPart part2 = (WebPart) allWebPartsForZone[i];
         this.Internals.SetZoneIndex(part2, i);
     }
     for (int j = index; j < allWebPartsForZone.Count; j++)
     {
         WebPart part3 = (WebPart) allWebPartsForZone[j];
         this.Internals.SetZoneIndex(part3, j + 1);
     }
     this.Internals.SetZoneIndex(webPart, index);
     this.Internals.SetZoneID(webPart, zone.ID);
     this.Internals.SetIsClosed(webPart, false);
     this._hasDataChanged = true;
     this.AddWebPartToDictionary(webPart);
 }
Example #59
0
 public CustomWebPartChrome(WebPartZoneBase zone, WebPartManager manager)
     : base(zone, manager)
 {
 }