Ejemplo n.º 1
0
        /// <summary>
        /// Save view state
        /// </summary>
        /// <returns>The view state for the object</returns>
        public object SaveViewState()
        {
            EWSoftware.ImageMaps.Web.Controls.ImageAreaBase area;
            int idx, count = this.Count;

            if (count == 0)
            {
                return(null);
            }

            // If something was inserted or removed, save the whole collection regardless of whether the objects
            // have changed view state or not.
            if (saveAll)
            {
                ImageAreaShape[] shapes = new ImageAreaShape[count];
                object[]         states = new object[count];

                for (idx = 0; idx < count; idx++)
                {
                    area        = (EWSoftware.ImageMaps.Web.Controls.ImageAreaBase) this[idx];
                    shapes[idx] = area.Shape;

                    // All properties must be saved so mark them all dirty
                    area.MarkAsDirty();
                    states[idx] = area.SaveViewState();
                }

                return(new Triplet(count, shapes, states));
            }

            // If not saving all, just save the changed items
            ArrayList changedIndices = new ArrayList(count);
            ArrayList changedShapes  = new ArrayList(count);
            ArrayList changedStates  = new ArrayList(count);
            object    state;

            for (idx = 0; idx < count; idx++)
            {
                state = ((EWSoftware.ImageMaps.Web.Controls.ImageAreaBase) this[idx]).SaveViewState();

                if (state != null)
                {
                    changedIndices.Add(idx);
                    changedShapes.Add(this[idx].Shape);
                    changedStates.Add(state);
                }
            }

            if (changedIndices.Count > 0)
            {
                return(new Triplet(changedIndices, changedShapes, changedStates));
            }

            return(null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Save view state
        /// </summary>
        /// <returns>The view state for the object</returns>
        public object SaveViewState()
        {
            EWSoftware.ImageMaps.Web.Controls.ImageAreaBase area;
            int idx, count = this.Count;

            if(count == 0)
                return null;

            // If something was inserted or removed, save the whole collection regardless of whether the objects
            // have changed view state or not.
            if(saveAll)
            {
                ImageAreaShape[] shapes = new ImageAreaShape[count];
                object[] states = new object[count];

                for(idx = 0; idx < count; idx++)
                {
                    area = (EWSoftware.ImageMaps.Web.Controls.ImageAreaBase)this[idx];
                    shapes[idx] = area.Shape;

                    // All properties must be saved so mark them all dirty
                    area.MarkAsDirty();
                    states[idx] = area.SaveViewState();
                }

                return new Triplet(count, shapes, states);
            }

            // If not saving all, just save the changed items
            ArrayList changedIndices = new ArrayList(count);
            ArrayList changedShapes = new ArrayList(count);
            ArrayList changedStates = new ArrayList(count);
            object state;

            for(idx = 0; idx < count; idx++)
            {
                state = ((EWSoftware.ImageMaps.Web.Controls.ImageAreaBase)this[idx]).SaveViewState();

                if(state != null)
                {
                    changedIndices.Add(idx);
                    changedShapes.Add(this[idx].Shape);
                    changedStates.Add(state);
                }
            }

            if(changedIndices.Count > 0)
                return new Triplet(changedIndices, changedShapes, changedStates);

            return null;
        }