/// <summary>
        /// Initializes a new instance of the <see cref="NPCChatConditionalEditorForm"/> class.
        /// </summary>
        /// <param name="conditionalItem">The conditional item.</param>
        /// <param name="conditionals">The conditionals.</param>
        /// <exception cref="ArgumentNullException"><paramref name="conditionalItem" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="conditionals" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="conditionals"/> array cannot be empty.</exception>
        public NPCChatConditionalEditorForm(EditorNPCChatConditionalCollectionItem conditionalItem,
                                            NPCChatConditionalBase[] conditionals)
        {
            if (conditionalItem == null)
                throw new ArgumentNullException("conditionalItem");
            if (conditionals == null)
                throw new ArgumentNullException("conditionals");
            if (conditionals.Length == 0)
                throw new ArgumentException("Conditionals array cannot be empty.", "conditionals");

            _item = conditionalItem;
            _conditionals = conditionals;

            InitializeComponent();
        }
        public void CopyValuesTo(EditorNPCChatConditionalCollectionItem dest)
        {
            var stream = new BitStream(256);

            using (var writer = BinaryValueWriter.Create(stream))
            {
                Write(writer);
            }

            stream.PositionBits = 0;

            var reader = BinaryValueReader.Create(stream);

            dest.Read(reader);
        }
        protected override void OnSelectedIndexChanged(EventArgs e)
        {
            base.OnSelectedIndexChanged(e);

            var item = SelectedItem as EditorNPCChatConditionalCollectionItem;

            if (item != SelectedConditionalItem)
            {
                _selectedConditionalItem = item;
                if (ConditionalItemChanged != null)
                {
                    ConditionalItemChanged.Raise(this, EventArgsHelper.Create(item));
                }
            }
        }
        /// <summary>
        /// Tries to remove a <see cref="EditorNPCChatConditionalCollectionItem"/> from the
        /// <see cref="ConditionalCollection"/>.
        /// </summary>
        /// <param name="item">The conditional item to remove.</param>
        /// <returns>True if the <paramref name="item"/> was successfully removed; otherwise false.</returns>
        public bool TryDeleteConditionalItem(EditorNPCChatConditionalCollectionItem item)
        {
            if (item == null)
            {
                return(false);
            }

            var cc = ConditionalCollection;

            if (cc == null)
            {
                return(false);
            }

            return(cc.TryRemoveItem(item));
        }
        /// <summary>
        /// Tries to add a NPCChatConditionalCollectionItemBase to the collection.
        /// </summary>
        /// <param name="item">The NPCChatConditionalCollectionItemBase to add.</param>
        /// <returns>True if the <paramref name="item"/> was successfully added; otherwise false.</returns>
        public bool TryAddItem(NPCChatConditionalCollectionItemBase item)
        {
            if (item == null)
            {
                return(false);
            }

            if (item is EditorNPCChatConditionalCollectionItem)
            {
                return(TryAddItem((EditorNPCChatConditionalCollectionItem)item));
            }

            var newItem = new EditorNPCChatConditionalCollectionItem(item);

            return(TryAddItem(newItem));
        }
        /// <summary>
        /// Tries to remove a <see cref="EditorNPCChatConditionalCollectionItem"/> from the collection.
        /// </summary>
        /// <param name="item">The item to remove.</param>
        /// <returns>True if the <paramref name="item"/> was successfully removed; otherwise false.</returns>
        public bool TryRemoveItem(EditorNPCChatConditionalCollectionItem item)
        {
            if (item == null)
            {
                return(false);
            }

            var success = _items.Remove(item);

            if (success)
            {
                if (Changed != null)
                {
                    Changed.Raise(this, EventArgs.Empty);
                }
            }

            return(success);
        }
Exemple #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="NPCChatConditionalEditorForm"/> class.
        /// </summary>
        /// <param name="conditionalItem">The conditional item.</param>
        /// <param name="conditionals">The conditionals.</param>
        /// <exception cref="ArgumentNullException"><paramref name="conditionalItem" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentNullException"><paramref name="conditionals" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException"><paramref name="conditionals"/> array cannot be empty.</exception>
        public NPCChatConditionalEditorForm(EditorNPCChatConditionalCollectionItem conditionalItem,
                                            NPCChatConditionalBase[] conditionals)
        {
            if (conditionalItem == null)
            {
                throw new ArgumentNullException("conditionalItem");
            }
            if (conditionals == null)
            {
                throw new ArgumentNullException("conditionals");
            }
            if (conditionals.Length == 0)
            {
                throw new ArgumentException("Conditionals array cannot be empty.", "conditionals");
            }

            _item         = conditionalItem;
            _conditionals = conditionals;

            InitializeComponent();
        }
        /// <summary>
        /// Tries to add a EditorNPCChatConditionalCollectionItem to the collection.
        /// </summary>
        /// <param name="item">The NPCChatConditionalCollectionItemBase to add.</param>
        /// <returns>True if the <paramref name="item"/> was successfully added; otherwise false.</returns>
        public bool TryAddItem(EditorNPCChatConditionalCollectionItem item)
        {
            if (item == null)
            {
                return(false);
            }

            if (_items.Contains(item))
            {
                return(false);
            }

            _items.Add(item);

            if (Changed != null)
            {
                Changed.Raise(this, EventArgs.Empty);
            }

            return(true);
        }
        /// <summary>
        /// Tries to add a NPCChatConditionalCollectionItemBase to the collection.
        /// </summary>
        /// <param name="item">The NPCChatConditionalCollectionItemBase to add.</param>
        /// <returns>True if the <paramref name="item"/> was successfully added; otherwise false.</returns>
        public bool TryAddItem(NPCChatConditionalCollectionItemBase item)
        {
            if (item == null)
                return false;

            if (item is EditorNPCChatConditionalCollectionItem)
                return TryAddItem((EditorNPCChatConditionalCollectionItem)item);

            var newItem = new EditorNPCChatConditionalCollectionItem(item);
            return TryAddItem(newItem);
        }
        public void CopyValuesTo(EditorNPCChatConditionalCollectionItem dest)
        {
            var stream = new BitStream(256);

            using (var writer = BinaryValueWriter.Create(stream))
            {
                Write(writer);
            }

            stream.PositionBits = 0;

            var reader = BinaryValueReader.Create(stream);

            dest.Read(reader);
        }
 /// <summary>
 /// Handles the Click event of the btnAddConditional control.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
 void btnAddConditional_Click(object sender, EventArgs e)
 {
     var newItem = new EditorNPCChatConditionalCollectionItem(_npcChatConditionals[0]);
     lstConditionals.TryAddToConditionalCollection(newItem);
 }
 /// <summary>
 /// Handles the corresponding event.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 void ConditionalCollectionItem_Changed(EditorNPCChatConditionalCollectionItem sender, EventArgs e)
 {
     RebuildItemList();
 }
Exemple #13
0
 /// <summary>
 /// Handles the corresponding event.
 /// </summary>
 /// <param name="sender">The source of the event.</param>
 /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
 void ConditionalCollectionItem_Changed(EditorNPCChatConditionalCollectionItem sender, EventArgs e)
 {
     RebuildItemList();
 }
        /// <summary>
        /// Tries to add a EditorNPCChatConditionalCollectionItem to the collection.
        /// </summary>
        /// <param name="item">The NPCChatConditionalCollectionItemBase to add.</param>
        /// <returns>True if the <paramref name="item"/> was successfully added; otherwise false.</returns>
        public bool TryAddItem(EditorNPCChatConditionalCollectionItem item)
        {
            if (item == null)
                return false;

            if (_items.Contains(item))
                return false;

            _items.Add(item);

            if (Changed != null)
                Changed.Raise(this, EventArgs.Empty);

            return true;
        }
        /// <summary>
        /// Tries to remove a <see cref="EditorNPCChatConditionalCollectionItem"/> from the
        /// <see cref="ConditionalCollection"/>.
        /// </summary>
        /// <param name="item">The conditional item to remove.</param>
        /// <returns>True if the <paramref name="item"/> was successfully removed; otherwise false.</returns>
        public bool TryDeleteConditionalItem(EditorNPCChatConditionalCollectionItem item)
        {
            if (item == null)
                return false;

            var cc = ConditionalCollection;
            if (cc == null)
                return false;

            return cc.TryRemoveItem(item);
        }
        protected override void OnSelectedIndexChanged(EventArgs e)
        {
            base.OnSelectedIndexChanged(e);

            var item = SelectedItem as EditorNPCChatConditionalCollectionItem;
            if (item != SelectedConditionalItem)
            {
                _selectedConditionalItem = item;
                if (ConditionalItemChanged != null)
                    ConditionalItemChanged.Raise(this, EventArgsHelper.Create(item));
            }
        }
Exemple #17
0
 void InitGUI(EditorNPCChatConditionalCollectionItem item)
 {
     chkNot.Checked = item.Not;
     cmbConditionalType.SelectedItem         = item.Conditional;
     lstParameters.ConditionalCollectionItem = item;
 }
        /// <summary>
        /// Tries to remove a <see cref="EditorNPCChatConditionalCollectionItem"/> from the collection.
        /// </summary>
        /// <param name="item">The item to remove.</param>
        /// <returns>True if the <paramref name="item"/> was successfully removed; otherwise false.</returns>
        public bool TryRemoveItem(EditorNPCChatConditionalCollectionItem item)
        {
            if (item == null)
                return false;

            var success = _items.Remove(item);

            if (success)
            {
                if (Changed != null)
                    Changed.Raise(this, EventArgs.Empty);
            }

            return success;
        }
 void InitGUI(EditorNPCChatConditionalCollectionItem item)
 {
     chkNot.Checked = item.Not;
     cmbConditionalType.SelectedItem = item.Conditional;
     lstParameters.ConditionalCollectionItem = item;
 }