コード例 #1
0
 /// <summary>
 /// Gets the index of the given setting.
 /// </summary>
 public int IndexOf(DefaultButtonSetting item)
 {
     if (item == null)
     {
         throw new ArgumentNullException("item");
     }
     return(settings.IndexOf(item));
 }
コード例 #2
0
 /// <summary>
 /// Determines if the collection contains the given setting.
 /// </summary>
 public bool Contains(DefaultButtonSetting item)
 {
     if (item == null)
     {
         return(false);
     }
     return(settings.Contains(item));
 }
コード例 #3
0
        /// <summary>
        /// Removes the given setting from the collection
        /// </summary>
        /// <param name="item"></param>
        public void Remove(DefaultButtonSetting item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            int index = IndexOf(item);

            if (index >= 0)
            {
                RemoveAt(index);
            }
        }
コード例 #4
0
        /// <summary>
        /// Adds the given setting to the collection at the given index
        /// </summary>
        public void Insert(int index, DefaultButtonSetting item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            settings.Insert(index, item);
            if (_isTrackingViewState)
            {
                ((IStateManager)item).TrackViewState();
                _saveAll = true;
            }
        }
コード例 #5
0
        /// <summary>
        /// Adds a setting to the collection
        /// </summary>
        public int Add(DefaultButtonSetting item)
        {
            if (item == null)
            {
                throw new ArgumentNullException("item");
            }

            settings.Add(item);
            if (_isTrackingViewState)
            {
                ((IStateManager)item).TrackViewState();
                item.SetDirty();
            }

            return(settings.Count - 1);
        }
コード例 #6
0
        object IStateManager.SaveViewState()
        {
            if (_saveAll == true)
            {
                // Save all items.
                ArrayList states = new ArrayList(Count);
                for (int i = 0; i < Count; i++)
                {
                    DefaultButtonSetting setting = (DefaultButtonSetting)settings[i];
                    setting.SetDirty();
                    states.Add(((IStateManager)setting).SaveViewState());
                }
                if (states.Count > 0)
                {
                    return(states);
                }
                else
                {
                    return(null);
                }
            }
            else
            {
                // Save only the dirty items.
                ArrayList indices = new ArrayList();
                ArrayList states  = new ArrayList();

                for (int i = 0; i < Count; i++)
                {
                    DefaultButtonSetting setting = (DefaultButtonSetting)settings[i];
                    object state = ((IStateManager)setting).SaveViewState();
                    if (state != null)
                    {
                        states.Add(state);
                        indices.Add(i);
                    }
                }

                if (indices.Count > 0)
                {
                    return(new Pair(indices, states));
                }

                return(null);
            }
        }
コード例 #7
0
        /// <summary>
        /// sets the property value for the given control
        /// </summary>
        public void SetDefaultButton(Control control, String value)
        {
            if (value == null)
            {
                value = String.Empty;
            }

            DefaultButtonSetting newSetting = null;

            // search the current settings for the control given
            foreach (DefaultButtonSetting setting in Settings)
            {
                if (setting.Parent == control.ID)
                {
                    newSetting = setting;
                    break;
                }
            }

            if (newSetting == null)
            {
                // the setting wasn't found, so add it
                if (value.Length > 0)
                {
                    newSetting        = new DefaultButtonSetting();
                    newSetting.Parent = control.ID;
                    newSetting.Button = value;
                    this.Settings.Add(newSetting);
                }
            }
            else
            {
                // change or remove the setting as needed.
                if (value.Length > 0)
                {
                    newSetting.Button = value;
                }
                else
                {
                    this.Settings.Remove(newSetting);
                }
            }

            notifyDesignerOfChange();
        }
コード例 #8
0
        void IStateManager.LoadViewState(object savedState)
        {
            if (savedState == null)
            {
                return;
            }

            if (savedState is ArrayList)
            {
                // All items were saved.
                // Create new DefaultButtonSettings collection using view state.
                _saveAll = true;
                ArrayList states = (ArrayList)savedState;

                settings = new ArrayList(states.Count);
                for (int i = 0; i < states.Count; i++)
                {
                    DefaultButtonSetting setting = new DefaultButtonSetting();
                    Add(setting);
                    ((IStateManager)setting).LoadViewState(states[i]);
                }
            }
            else
            {
                // Load modified items.
                Pair      p       = (Pair)savedState;
                ArrayList indices = (ArrayList)p.First;
                ArrayList states  = (ArrayList)p.Second;

                for (int i = 0; i < indices.Count; i++)
                {
                    int index = (int)indices[i];
                    if (index < this.Count)
                    {
                        ((IStateManager)settings[index]).LoadViewState(states[i]);
                    }
                    else
                    {
                        DefaultButtonSetting setting = new DefaultButtonSetting();
                        Add(setting);
                        ((IStateManager)setting).LoadViewState(states[i]);
                    }
                }
            }
        }
コード例 #9
0
        /// <summary>
        /// Removes the given setting from the collection
        /// </summary>
        /// <param name="item"></param>
        public void Remove(DefaultButtonSetting item)
        {
            if (item == null) {
                throw new ArgumentNullException("item");
            }

            int index = IndexOf(item);
            if (index >= 0) {
                RemoveAt(index);
            }
        }
コード例 #10
0
        void IStateManager.LoadViewState(object savedState)
        {
            if (savedState == null) {
                return;
            }

            if (savedState is ArrayList) {
                // All items were saved.
                // Create new DefaultButtonSettings collection using view state.
                _saveAll = true;
                ArrayList states = (ArrayList) savedState;

                settings = new ArrayList(states.Count);
                for (int i = 0; i < states.Count; i++) {
                    DefaultButtonSetting setting = new DefaultButtonSetting();
                    Add(setting);
                    ((IStateManager)setting).LoadViewState(states[i]);
                }
            }
            else {
                // Load modified items.
                Pair p = (Pair) savedState;
                ArrayList indices = (ArrayList)p.First;
                ArrayList states = (ArrayList)p.Second;

                for (int i = 0 ;  i < indices.Count; i++) {
                    int index = (int)indices[i];
                    if (index < this.Count) {
                        ((IStateManager)settings[index]).LoadViewState(states[i]);
                    }
                    else {
                        DefaultButtonSetting setting = new DefaultButtonSetting();
                        Add(setting);
                        ((IStateManager)setting).LoadViewState(states[i]);
                    }
                }
            }
        }
コード例 #11
0
        /// <summary>
        /// Adds the given setting to the collection at the given index
        /// </summary>
        public void Insert(int index, DefaultButtonSetting item)
        {
            if (item == null) {
                throw new ArgumentNullException("item");
            }

            settings.Insert(index,item);
            if (_isTrackingViewState) {
                ((IStateManager)item).TrackViewState();
                _saveAll = true;
            }
        }
コード例 #12
0
 /// <summary>
 /// Gets the index of the given setting.
 /// </summary>
 public int IndexOf(DefaultButtonSetting item)
 {
     if (item == null) {
         throw new ArgumentNullException("item");
     }
     return settings.IndexOf(item);
 }
コード例 #13
0
 /// <summary>
 /// Determines if the collection contains the given setting.
 /// </summary>
 public bool Contains(DefaultButtonSetting item)
 {
     if (item == null) {
         return false;
     }
     return settings.Contains(item);
 }
コード例 #14
0
        /// <summary>
        /// Adds a setting to the collection
        /// </summary>
        public int Add(DefaultButtonSetting item)
        {
            if (item == null) {
                throw new ArgumentNullException("item");
            }

            settings.Add(item);
            if (_isTrackingViewState) {
                ((IStateManager)item).TrackViewState();
                item.SetDirty();
            }

            return settings.Count - 1;
        }
コード例 #15
0
ファイル: DefaultButtons.cs プロジェクト: bnantz/NCS-V1-1
		/// <summary>
		/// sets the property value for the given control
		/// </summary>
		public void SetDefaultButton(Control control, String value) {
			if (value == null) {
				value = String.Empty;
			}

			DefaultButtonSetting newSetting = null;

			// search the current settings for the control given
			foreach( DefaultButtonSetting setting in Settings ) {
				if ( setting.Parent == control.ID ) {
					newSetting = setting;
					break;
				}
			}

			if ( newSetting == null ) {

				// the setting wasn't found, so add it
				if ( value.Length > 0 ) {
					newSetting = new DefaultButtonSetting();
					newSetting.Parent = control.ID;
					newSetting.Button = value;
					this.Settings.Add( newSetting );
				}
			} else {

				// change or remove the setting as needed.
				if ( value.Length  > 0) {
					newSetting.Button = value;
				} else {
					this.Settings.Remove( newSetting );
				}
			}

			notifyDesignerOfChange();
		}