コード例 #1
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();
        }
コード例 #2
0
        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);
        }
コード例 #3
0
        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));
                }
            }
        }
コード例 #4
0
        /// <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));
        }
コード例 #5
0
        /// <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));
        }
コード例 #6
0
        /// <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);
        }
コード例 #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();
        }
コード例 #8
0
        /// <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);
        }
コード例 #9
0
        /// <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);
        }
コード例 #10
0
        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);
        }
コード例 #11
0
 /// <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);
 }
コード例 #12
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();
 }
コード例 #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();
 }
コード例 #14
0
        /// <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;
        }
コード例 #15
0
        /// <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);
        }
コード例 #16
0
        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));
            }
        }
コード例 #17
0
 void InitGUI(EditorNPCChatConditionalCollectionItem item)
 {
     chkNot.Checked = item.Not;
     cmbConditionalType.SelectedItem         = item.Conditional;
     lstParameters.ConditionalCollectionItem = item;
 }
コード例 #18
0
        /// <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;
        }
コード例 #19
0
 void InitGUI(EditorNPCChatConditionalCollectionItem item)
 {
     chkNot.Checked = item.Not;
     cmbConditionalType.SelectedItem = item.Conditional;
     lstParameters.ConditionalCollectionItem = item;
 }