/// <summary>
        /// Adds a filter to this collection.
        /// </summary>
        /// <param name="name">The name of the filter to add.</param>
        /// <param name="filter">The <see cref="MapDrawFilterHelper"/>.</param>
        /// <returns>True if the filter was successfully added; otherwise false.</returns>
        public bool AddFilter(string name, MapDrawFilterHelper filter)
        {
            // Validate the name
            if (string.IsNullOrEmpty(name))
            {
                return(false);
            }

            // Validate the filter object
            if (filter == null)
            {
                return(false);
            }

            // Check if the name is already in use
            if (_filters.ContainsKey(name))
            {
                return(false);
            }

            // Add
            _filters.Add(name, filter);

            // Raise events
            if (Added != null)
            {
                Added.Raise(this, new MapDrawFilterHelperCollectionEventArgs(name, filter));
            }

            return(true);
        }
示例#2
0
文件: GrhInfo.cs 项目: wtfcolt/game
        /// <summary>
        /// Handles when a <see cref="GrhData"/> is added to the <see cref="GrhData"/>s DArray.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="e">The <see cref="NetGore.Collections.DArrayEventArgs{T}"/> instance containing the event data.</param>
        static void AddHandler(DArray <GrhData> sender, DArrayEventArgs <GrhData> e)
        {
            Debug.Assert(e.Index != GrhIndex.Invalid);

            var gd = e.Item;

            if (gd == null)
            {
                Debug.Fail("gd is null.");
                return;
            }

            // Set the categorization event so we can keep up with any changes to the categorization.
            gd.CategorizationChanged -= ChangeCategorizationHandler;
            gd.CategorizationChanged += ChangeCategorizationHandler;

            AddToDictionary(gd);

            if (Added != null)
            {
                Added.Raise(gd, EventArgs.Empty);
            }

            if (!_isLoading)
            {
                if (AddedNew != null)
                {
                    AddedNew.Raise(gd, EventArgs.Empty);
                }
            }
        }
        /// <summary>
        /// Adds a <see cref="IToolTargetContainer"/> to this collection.
        /// </summary>
        /// <param name="c">The <see cref="IToolTargetContainer"/> to add.</param>
        /// <returns>True if <paramref name="c"/> was added; false if <paramref name="c"/> was invalid or already added.</returns>
        public bool Add(IToolTargetContainer c)
        {
            // Check for a valid value
            if (c == null)
            {
                const string errmsg = "Tried to add null IToolTargetContainer to ToolTargetContainerCollection `{0}`.";
                if (log.IsWarnEnabled)
                {
                    log.WarnFormat(errmsg, this);
                }
                Debug.Fail(string.Format(errmsg, this));
                return(false);
            }

            // Do not add if already in the collection
            if (_buffer.Contains(c))
            {
                return(false);
            }

            // Add
            _buffer.Add(c);

            // Raise the event
            if (Added != null)
            {
                Added.Raise(this, EventArgsHelper.Create(c));
            }

            return(true);
        }
示例#4
0
        /// <summary>
        /// Occurs when the <see cref="CharacterStatusEffects.Added"/> event is raised.
        /// </summary>
        /// <param name="statusEffect">The <see cref="ActiveStatusEffect"/> that was added.</param>
        protected virtual void OnAdded(ActiveStatusEffect statusEffect)
        {
            statusEffect.AddBonusesTo(_modStats);

            if (Added != null)
            {
                Added.Raise(this, EventArgsHelper.Create(statusEffect));
            }

            AssertModStatsAreCorrect();
        }
示例#5
0
        public void AddDay(Day day)
        {
            if (_days.Contains(day))
            {
                return;
            }

            _days.Add(day);
            _days = _days.OrderBy(d => d).ToList();
            Added.Raise(this, day);
        }
示例#6
0
        public void AddActivity(Activity activity)
        {
            if (_activities.Contains(activity))
            {
                return;
            }

            _activities.Add(activity);

            Added.Raise(this, activity);
            NotifyPropertyChanged(() => Activities);
        }
示例#7
0
        public void ProcessDelta()
        {
            if (_added.Count != 0)
            {
                CollectionChangedEventArgs <Serial> list = new CollectionChangedEventArgs <Serial>(_added);
                _added.Clear();
                Added.Raise(list);
            }

            if (_removed.Count != 0)
            {
                CollectionChangedEventArgs <Serial> list = new CollectionChangedEventArgs <Serial>(_removed);
                _removed.Clear();
                Removed.Raise(list);
            }
        }
示例#8
0
        private void OnDrop(object sender, DragEventArgs dragEventArgs)
        {
            var data = (Dictionary<string, object>)dragEventArgs.Data.GetData("data");
            var activity = (Activity)data["activity"];
            var source = (ActivityListControl)data["source"];

            if (activity != null && !source.Equals(this))
            {
                dragEventArgs.Effects = DragDropEffects.Move;
                Added.Raise(this, activity);                
            }
            else
            {
                dragEventArgs.Effects = DragDropEffects.None;                
            }

            dragEventArgs.Handled = true;
        }
示例#9
0
        public void AddNewDay()
        {
            var  lastDay = Days.LastOrDefault();
            Date lastDate;

            if (lastDay == null || lastDay.Date < Date.Today)
            {
                var today = DateTime.Now;
                lastDate = new Date(today.Year, today.Month, today.Day);
            }
            else
            {
                lastDate = lastDay.Date.AddDays(1);
            }

            var day = new Day(lastDate)
            {
                BeginTime = _defaultStartTime
            };

            _days.Add(day);
            Added.Raise(this, day);
        }