Beispiel #1
0
        public MockReliableDictionary(Uri uri)
            : base(uri)
        {
            // Set the OnDictionaryChanged callback to fire the DictionaryChanged event.
            InternalDictionaryChanged +=
                (sender, c) =>
            {
                if (DictionaryChanged != null)
                {
                    NotifyDictionaryChangedEventArgs <TKey, TValue> e = null;
                    switch (c.ChangeType)
                    {
                    case ChangeType.Added:
                        e = new NotifyDictionaryItemAddedEventArgs <TKey, TValue>(c.Transaction, c.Key, c.Added);
                        break;

                    case ChangeType.Removed:
                        e = new NotifyDictionaryItemRemovedEventArgs <TKey, TValue>(c.Transaction, c.Key);
                        break;

                    case ChangeType.Updated:
                        e = new NotifyDictionaryItemUpdatedEventArgs <TKey, TValue>(c.Transaction, c.Key, c.Added);
                        break;
                    }

                    DictionaryChanged.Invoke(this, e);
                }

                MockDictionaryChanged?.Invoke(this, c);
            };
        }
Beispiel #2
0
 protected virtual void OnDictionaryChanged(NotifyDictionaryChangedEventArgs <TKey, TValue> e)
 {
     if (DictionaryChanged == null)
     {
         return;
     }
     using (BlockReentrancy()) { DictionaryChanged?.Invoke(this, e); }
 }
Beispiel #3
0
        private void description_TextChanged(object sender, EventArgs e)
        {
            if (_updating)
                return;

            int index = dtgrdAttributes.CurrentCell.RowIndex;
            if (index >= 0)
            {
                AttributeArray[index]._description = description.Text;
                if (DictionaryChanged != null) DictionaryChanged.Invoke(this, EventArgs.Empty);
            }
        }
Beispiel #4
0
        private void radioButtonsChanged(object sender, EventArgs e)
        {
            if (dtgrdAttributes.CurrentCell == null)
                return;
            int index = dtgrdAttributes.CurrentCell.RowIndex;
            int ntype =
                rdoFloat.Checked ? 0
                : rdoInt.Checked ? 1
                : rdoDegrees.Checked ? 2
                : -1;
			if (ntype != AttributeArray[index]._type) {
				AttributeArray[index]._type = ntype;
				if (DictionaryChanged != null) DictionaryChanged.Invoke(this, EventArgs.Empty);
				RefreshRow(index);
			}
        }
Beispiel #5
0
        public MockReliableDictionary(Uri uri)
            : base(uri, null)
        {
            // Set the OnDictionaryChanged callback to fire the DictionaryChanged event.
            OnDictionaryChanged =
                (c) =>
            {
                if (DictionaryChanged != null)
                {
                    NotifyDictionaryChangedEventArgs <TKey, TValue> e;
                    switch (c.ChangeType)
                    {
                    case ChangeType.Added:
                        e = new NotifyDictionaryItemAddedEventArgs <TKey, TValue>(c.Transaction, c.Key, c.Added);
                        break;

                    case ChangeType.Removed:
                        e = new NotifyDictionaryItemRemovedEventArgs <TKey, TValue>(c.Transaction, c.Key);
                        break;

                    case ChangeType.Updated:
                        e = new NotifyDictionaryItemUpdatedEventArgs <TKey, TValue>(c.Transaction, c.Key, c.Added);
                        break;

                    default:
                        return(false);
                    }

                    DictionaryChanged.Invoke(this, e);
                }

                MockDictionaryChanged?.Invoke(this, c);

                return(true);
            };
        }
 private void OnDictionaryChanged(NotifyDictionaryChangedEventArgs <TKey, TValue> e)
 {
     DictionaryChanged?.Invoke(this, e);
 }
 protected virtual void OnDictionaryChanged(NotifyDictionaryChangedEventArgs <TKey, TValue> e)
 {
     DictionaryChanged?.Invoke(this, e);
 }
Beispiel #8
0
        private unsafe void dtgrdAttributes_CellEndEdit(object sender, DataGridViewCellEventArgs e)
        {
            if (dtgrdAttributes.CurrentCell == null)
            {
                return;
            }
            int    index = dtgrdAttributes.CurrentCell.RowIndex;
            string value = attributes.Rows[index][1].ToString();

            string name = attributes.Rows[index][0].ToString();

            if (AttributeArray[index]._name != name)
            {
                AttributeArray[index]._name = name;
                if (DictionaryChanged != null)
                {
                    DictionaryChanged.Invoke(this, EventArgs.Empty);
                }
                return;
            }

            byte *buffer = (byte *)TargetNode.AttributeAddress;

            if (AttributeArray[index]._type == 2) //degrees
            {
                float val;
                if (!float.TryParse(value, out val))
                {
                    value = ((float)(((bfloat *)buffer)[index])).ToString();
                }
                else
                {
                    if (((bfloat *)buffer)[index] != val * Maths._deg2radf)
                    {
                        ((bfloat *)buffer)[index] = val * Maths._deg2radf;
                        TargetNode.SignalPropertyChange();
                    }
                }
            }
            else if (AttributeArray[index]._type == 1) //int
            {
                int val;
                if (!int.TryParse(value, out val))
                {
                    value = ((int)(((bint *)buffer)[index])).ToString();
                }
                else
                {
                    if (((bint *)buffer)[index] != val)
                    {
                        ((bint *)buffer)[index] = val;
                        TargetNode.SignalPropertyChange();
                    }
                }
            }
            else //float/radians
            {
                float val;
                if (!float.TryParse(value, out val))
                {
                    value = ((float)(((bfloat *)buffer)[index])).ToString();
                }
                else
                {
                    if (((bfloat *)buffer)[index] != val)
                    {
                        ((bfloat *)buffer)[index] = val;
                        TargetNode.SignalPropertyChange();
                    }
                }
            }

            attributes.Rows[index][1] = value;
            if (CellEdited != null)
            {
                CellEdited.Invoke(this, EventArgs.Empty);
            }
        }
 protected virtual void OnDictionaryChanged(NotifyDictionaryChangedEventArgs <TKey, TResult> e) =>
 DictionaryChanged?.Invoke(this, e);
Beispiel #10
0
 /// <summary>
 /// Fires the <see cref="DictionaryChanged"/> event.
 /// </summary>
 protected virtual void OnDictionaryChanged(CollectionChange change, TKey key, TValue value)
 {
     DictionaryChanged?.Invoke(this, new DictionaryChangedEventArgs <TKey, TValue>(change, key, value));
 }
 public EventEmittingDictionary(DictionaryChanged modifyCallback)
 {
     _modifyCallback = modifyCallback;
 }
Beispiel #12
0
 /// <summary>Raises the <see cref="DictionaryChanged" /> event.</summary>
 /// <param name="eventArgs">The <see cref="NotifyDictionaryChangedEventArgs{TKey, TValue}" /> for the event.</param>
 private void OnDictionaryChanged(NotifyDictionaryChangedEventArgs <string, object> eventArgs)
 {
     DictionaryChanged?.Invoke(this, eventArgs);
 }