Beispiel #1
0
        private void PropertyValueChanged(object sender, string propertyname, string propertyvalue)
        {
            var val = _values.FirstOrDefault(x => x.OriginalKey == propertyname);
            var li  = KeyValuesList.Items.OfType <ListViewItem>().FirstOrDefault(x => ((string)x.Tag) == propertyname);

            if (val == null)
            {
                if (li != null)
                {
                    KeyValuesList.Items.Remove(li);
                }
                return;
            }
            val.IsModified = true;
            val.Value      = propertyvalue;
            if (li == null)
            {
                var dt = SmartEditButton.Checked ? val.DisplayText(Document.GameData) : val.OriginalKey;
                var dv = SmartEditButton.Checked ? val.DisplayValue(Document.GameData) : val.Value;
                li = new ListViewItem(dt)
                {
                    Tag = val.OriginalKey, BackColor = val.GetColour()
                };
                KeyValuesList.Items.Add(li).SubItems.Add(dv);
            }
            else
            {
                li.BackColor        = val.GetColour();
                li.SubItems[1].Text = SmartEditButton.Checked ? val.DisplayValue(Document.GameData) : val.Value;
            }
            if (propertyname == "angles" && propertyvalue != Angles.GetAnglePropertyString())
            {
                Angles.SetAnglePropertyString(propertyvalue);
            }
        }
Beispiel #2
0
        private void UpdateKeyValues()
        {
            _populating = true;

            var smartEdit     = SmartEditButton.Checked;
            var selectedIndex = KeyValuesList.SelectedIndices.Count == 0 ? -1 : KeyValuesList.SelectedIndices[0];

            KeyValuesList.Items.Clear();
            foreach (var tv in _values)
            {
                var dt = smartEdit ? tv.DisplayText(Document.GameData) : tv.OriginalKey;
                var dv = smartEdit ? tv.DisplayValue(Document.GameData) : tv.Value;
                KeyValuesList.Items.Add(new ListViewItem(dt)
                {
                    Tag = tv.OriginalKey, BackColor = tv.GetColour()
                }).SubItems.Add(dv);
            }

            Angles.Enabled = false;
            var angleVal = _values.FirstOrDefault(x => x.OriginalKey == "angles");

            if (angleVal != null)
            {
                Angles.Enabled = !_changingClass;
                Angles.SetAnglePropertyString(angleVal.Value);
            }

            if (selectedIndex >= 0 && KeyValuesList.Items.Count > selectedIndex)
            {
                KeyValuesList.SelectedIndices.Add(selectedIndex);
            }
            else
            {
                KeyValuesListSelectedIndexChanged(null, null);
            }

            _populating = false;
        }