public CollectionChangingEventArgs(CollectionChangeAction action, T element)
        {
            Action  = action;
            Element = element;

            Cancel = false;
        }
 private void ResetEventData()
 {
     times        = 0;
     eventhandled = false;
     Element      = null;
     Action       = (CollectionChangeAction)0;
 }
Beispiel #3
0
 private void OnUnitCollectionChange(CollectionChangeAction action, object element)
 {
     if (this.StandardUnitCollectionChange != null)
     {
         this.StandardUnitCollectionChange(this, new CollectionChangeEventArgs(action, element));
     }
 }
 public CollectionChangingEventArgs(T item, int index, CollectionChangeAction action)
 {
     Cancel = false;
     Item   = item;
     Index  = index;
     Action = action;
 }
Beispiel #5
0
 protected void OnCollectionChange(CollectionChangeAction action, object element)
 {
     if (CollectionChanged != null)
     {
         CollectionChanged(this, new CollectionChangeEventArgs(action, element));
     }
 }
Beispiel #6
0
 private void OnCollectionChanged(CollectionChangeAction action, ConfigurationElement element)
 {
     if (PropertyChanged != null)
     {
         CollectionChanged(this, new CollectionChangeEventArgs(action, element));
     }
 }
Beispiel #7
0
 private void OnCityImprovementCollectionChange(CollectionChangeAction action, object element)
 {
     if (this.CityImprovementCollectionChange != null)
     {
         this.CityImprovementCollectionChange(this, new CollectionChangeEventArgs(action, element));
     }
 }
 private void Add_CustRefChanged
     (object sender, CollectionChangeEventArgs e)
 {
     CollectionChangeAction act = e.Action;
     var custOnOtherEnd         = (Contact)e.Element;
     //add your logic here
 }
Beispiel #9
0
        public void Ctor_Action_Element(CollectionChangeAction action, object element)
        {
            var args = new CollectionChangeEventArgs(action, element);

            Assert.Equal(action, args.Action);
            Assert.Same(element, args.Element);
        }
 private void NotifyChanged(CollectionChangeAction action, CodeStatement option, int index)
 {
     if (_changed != null)
     {
         _changed(action, option, index);
     }
 }
        //private void OnEventHandler (object sender, EventArgs e)
        //{
        //        eventhandled = true;
        //}

        private void OnCollectionEventHandler(object sender, CollectionChangeEventArgs e)
        {
            eventhandled = true;
            Element      = e.Element;
            Action       = e.Action;
            times++;
        }
Beispiel #12
0
 private void OnFortressDistrictCollectionChange(CollectionChangeAction action, object element)
 {
     if (this.FortressDistrictCollectionChange != null)
     {
         this.FortressDistrictCollectionChange(this, new CollectionChangeEventArgs(action, element));
     }
 }
Beispiel #13
0
        private bool OnCollectionChanging(CollectionChangeAction action, T item)
        {
            var eventArgs = new CollectionChangingEventArgs <T>(action, item);

            CollectionChanging(this, eventArgs);

            return(eventArgs.Cancel);
        }
 public CollectionChangedEventArgs(IEnumerable <Highlight> highlights)
 {
     Index        = -1;
     OldItem      = null;
     NewItem      = null;
     RemovedItems = highlights.ToArray();
     Action       = CollectionChangeAction.Clear;
 }
 public CollectionChangedEventArgs(int index, Highlight oldItem, Highlight newItem)
 {
     Index        = index;
     OldItem      = oldItem;
     NewItem      = newItem;
     RemovedItems = new Highlight[0];
     Action       = CollectionChangeAction.Change;
 }
 public CollectionChangedEventArgs(int index, Highlight oldItem)
 {
     Index        = index;
     OldItem      = oldItem;
     NewItem      = null;
     RemovedItems = new Highlight[] { oldItem };
     Action       = CollectionChangeAction.Remove;
 }
 public CollectionChangedEventArgs(Highlight newItem, int index)
 {
     Index        = index;
     OldItem      = null;
     NewItem      = newItem;
     RemovedItems = new Highlight[0];
     Action       = CollectionChangeAction.Change;
 }
 private void ProcessExportGroup(ExportGroupVm exportGroup, CollectionChangeAction action)
 {
     foreach (var exportGroupVm in exportGroup.ExportGroups)
     {
         this.ProcessExportGroup(exportGroupVm, action);
     }
     this.ProcessExports(exportGroup, action);
 }
 private void checkLockModifyChangeAction(CollectionChangeAction collectionChangeAction)
 {
     if (lockModifyChangeActionsKeys.ContainsKey(collectionChangeAction))
     {
         throw new ObservableComputationsException(this,
                                                   "Modifying of '{collectionChangeAction.ToString()}' change action is locked. Unlock first.");
     }
 }
 public ElementCollectionChangedEventArgs(IElementCollection collection,
                                          CollectionChangeAction action,
                                          IEnumerable <CollectionChangeItemInfo> changedItems)
 {
     Collection   = collection;
     Action       = action;
     ChangedItems = changedItems.ToArray();
     ElementType  = ChangedItems[0].Element.GetElementType();
 }
Beispiel #21
0
 private void fireEvent(CollectionChangeAction collectionChangeAction, Object collection,
                        CollectionChangeEventHandler e)
 {
     if (e != null)
     {
         CollectionChangeEventArgs args = new CollectionChangeEventArgs(collectionChangeAction, collection);
         e(this, args);
     }
 }
 private DataSourceChangedEventArgs(DataSourceChangeTypeEnum changeType, bool dataWasChanged, string propertyName,
                                    CollectionChangeAction action, object element)
 {
     ChangeType     = changeType;
     DataWasUpdated = dataWasChanged;
     PropertyName   = propertyName;
     Action         = action;
     Element        = element;
 }
        private void ProcessExports(ExportGroupVm exportGroup, CollectionChangeAction action)
        {
            foreach (var snooperExport in  exportGroup.ExportGroup.Exports)
            {
                var exports = (snooperExport as SnooperExportBase)?.ExportObjects;
                if (exports == null)
                {
                    continue;
                }

                foreach (var snooperExportedObjectBase in exports)
                {
                    var sipMessages = (snooperExportedObjectBase as SIPEvent)?.SipMessages;
                    if (sipMessages == null)
                    {
                        continue;
                    }
                    foreach (var sipMsg in sipMessages)
                    {
                        switch (action)
                        {
                        case CollectionChangeAction.Add:
                        {
                            DispatcherHelper.CheckBeginInvokeOnUI(() => { this.SipMessages.AddNew(sipMsg); });
                            if (sipMsg.RequestLine?.Method == "INVITE")
                            {
                                var to        = sipMsg.Headers.To.Substring(sipMsg.Headers.To.IndexOf("sip:") + 4).TrimEnd('>');
                                var reverseTo = ReverseString(to);
                                this.PrefixTrie.Add(reverseTo, sipMsg);
                            }
                        }
                        break;

                        case CollectionChangeAction.Remove:
                        {
                            DispatcherHelper.CheckBeginInvokeOnUI(() => { this.SipMessages.Remove(sipMsg); });
                            if (sipMsg.RequestLine?.Method == "INVITE")
                            {
                                var to        = sipMsg.Headers.To.Substring(sipMsg.Headers.To.IndexOf("sip:") + 4).TrimEnd('>');
                                var reverseTo = ReverseString(to);
                                if (this.PrefixTrie.Contains(reverseTo, sipMsg))
                                {
                                    this.PrefixTrie.Remove(reverseTo);
                                }
                            }
                        }
                        break;
                        }
                    }
                }
            }
        }
Beispiel #24
0
 public ElementCollectionChangedEventArgs(IElementCollection collection,
                                          CollectionChangeAction action,
                                          IEnumerable <CollectionChangeItemInfo> changedItems)
 {
     Collection   = collection;
     Action       = action;
     ChangedItems = changedItems.ToArray();
     ElementType  = CollectionExtensions.GetCollectionType(collection.GetType());
     if (ElementType == null)
     {
         ElementType = ChangedItems[0].Element.GetElementType();
     }
 }
Beispiel #25
0
        // -------
        // Methods
        // -------

        internal override void OnAssociationChanged(CollectionChangeAction collectionChangeAction, object entity)
        {
            Debug.Assert(!(entity is IEntityWrapper), "Object is an IEntityWrapper instance instead of the raw entity.");
            if (!_suppressEvents)
            {
                if (_onAssociationChangedforObjectView != null)
                {
                    _onAssociationChangedforObjectView(this, (new CollectionChangeEventArgs(collectionChangeAction, entity)));
                }
                if (_onAssociationChanged != null)
                {
                    _onAssociationChanged(this, (new CollectionChangeEventArgs(collectionChangeAction, entity)));
                }
            }
        }
Beispiel #26
0
        private void CheckMessage(XenAPI.Message m, CollectionChangeAction a)
        {
            if (!m.ShowOnGraphs() || m.cls != cls.VM)
            {
                return;
            }

            Host h = XenObject as Host;

            if (h != null)
            {
                List <VM> resVMs = h.Connection.ResolveAll <VM>(h.resident_VMs);
                foreach (VM v in resVMs)
                {
                    if (v.uuid == m.obj_uuid)
                    {
                        if (a == CollectionChangeAction.Add)
                        {
                            DataEventList.AddEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m));
                        }
                        else
                        {
                            DataEventList.RemoveEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m));
                        }

                        break;
                    }
                }
            }
            else if (XenObject is VM)
            {
                if (m.obj_uuid != Helpers.GetUuid(XenObject))
                {
                    return;
                }

                if (a == CollectionChangeAction.Add)
                {
                    DataEventList.AddEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m));
                }
                else
                {
                    DataEventList.RemoveEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m));
                }
            }
        }
        public void LockModifyChangeAction(CollectionChangeAction collectionChangeAction, object key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            if (!lockModifyChangeActionsKeys.ContainsKey(collectionChangeAction))
            {
                lockModifyChangeActionsKeys[collectionChangeAction] = key;
            }
            else
            {
                throw new ObservableComputationsException(this,
                                                          $"Modifying of '{collectionChangeAction.ToString()}' change action is already locked. Unlock first.");
            }
        }
    private void DepartmentOfTheInterior_CitiesCollectionChanged(object sender, CollectionChangeEventArgs e)
    {
        CollectionChangeAction action = e.Action;

        if (action == CollectionChangeAction.Remove)
        {
            City city = e.Element as City;
            Diagnostics.Assert(city != null);
            ApprovalStatus oldStatus = null;
            if (this.approvalStatusByGameEntity.ContainsKey(city.GUID))
            {
                oldStatus = this.approvalStatusByGameEntity[city.GUID];
                this.approvalStatusByGameEntity.Remove(city.GUID);
            }
            this.SwapApprovalStatus(city, oldStatus, null);
        }
        this.RefreshApprovalStatus();
    }
 internal override void OnAssociationChanged(
     CollectionChangeAction collectionChangeAction,
     object entity)
 {
     if (this._suppressEvents)
     {
         return;
     }
     if (this._onAssociationChangedforObjectView != null)
     {
         this._onAssociationChangedforObjectView((object)this, new CollectionChangeEventArgs(collectionChangeAction, entity));
     }
     if (this._onAssociationChanged == null)
     {
         return;
     }
     this._onAssociationChanged((object)this, new CollectionChangeEventArgs(collectionChangeAction, entity));
 }
        private void DataBindings_CollectionChanged(object sender, CollectionChangeEventArgs e)
        {
            Binding binding = (Binding)e.Element;
            CollectionChangeAction action = e.Action;

            if (action != CollectionChangeAction.Add)
            {
                return;
            }
            if (binding.PropertyName == this.ExposedPropertyName)
            {
                binding.DataSourceNullValue = null;
                (binding.DataSource as BindingSource).DataSourceChanged += delegate(object param0, EventArgs param1)
                {
                    if (!this.checkBox.Checked)
                    {
                        this.pickerLauncherTextBox.SelectedValue = null;
                    }
                    this.pickerLauncherTextBox.UpdateDisplay();
                };
            }
        }
        public void CollectionChangingTest()
        {
            Control c = new Control();

            c.BindingContext = new BindingContext();
            c.CreateControl();

            ControlBindingsCollection binding_coll = c.DataBindings;

            Binding binding  = new Binding("Text", new MockItem("A", 0), "Text");
            Binding binding2 = new Binding("Name", new MockItem("B", 0), "Text");

            binding_coll.Add(binding);

            binding_coll.CollectionChanging += CollectionChangingHandler;

            collection_expected_count   = 1;
            collection_action_expected  = CollectionChangeAction.Add;
            collection_element_expected = binding2;
            collection_expected_assert  = "#A0";
            binding_coll.Add(binding2);
            Assert.IsTrue(collection_changing_called, "#A1");

            collection_changing_called  = false;
            collection_expected_count   = 2;
            collection_action_expected  = CollectionChangeAction.Remove;
            collection_element_expected = binding;
            collection_expected_assert  = "#B0";
            binding_coll.Remove(binding);
            Assert.IsTrue(collection_changing_called, "#B1");

            collection_changing_called  = false;
            collection_expected_count   = 1;
            collection_element_expected = null;
            collection_action_expected  = CollectionChangeAction.Refresh;
            collection_expected_assert  = "#C0";
            binding_coll.Clear();
            Assert.IsTrue(collection_changing_called, "#C1");
        }
Beispiel #32
0
		public void CollectionChangingTest ()
		{
			Control c = new Control ();
			c.BindingContext = new BindingContext ();
			c.CreateControl ();

			ControlBindingsCollection binding_coll = c.DataBindings;

			Binding binding = new Binding ("Text", new MockItem ("A", 0), "Text");
			Binding binding2 = new Binding ("Name", new MockItem ("B", 0), "Text");
			binding_coll.Add (binding);

			binding_coll.CollectionChanging += CollectionChangingHandler;

			collection_expected_count = 1;
			collection_action_expected = CollectionChangeAction.Add;
			collection_element_expected = binding2;
			collection_expected_assert = "#A0";
			binding_coll.Add (binding2);
			Assert.IsTrue (collection_changing_called, "#A1");

			collection_changing_called = false;
			collection_expected_count = 2;
			collection_action_expected = CollectionChangeAction.Remove;
			collection_element_expected = binding;
			collection_expected_assert = "#B0";
			binding_coll.Remove (binding);
			Assert.IsTrue (collection_changing_called, "#B1");

			collection_changing_called = false;
			collection_expected_count = 1;
			collection_element_expected = null;
			collection_action_expected = CollectionChangeAction.Refresh;
			collection_expected_assert = "#C0";
			binding_coll.Clear ();
			Assert.IsTrue (collection_changing_called, "#C1");
		}
        private void OptionsChanged(CollectionChangeAction action, CodeSwitchOption option)
        {
            if (action == CollectionChangeAction.Add)
            {
                option.SetTarget(_target);
            }
            else if (action == CollectionChangeAction.Remove)
            {
                option.SetTarget(null);
            }

            Refresh();
        }
		//private void OnEventHandler (object sender, EventArgs e)
		//{
		//        eventhandled = true;
		//}

	        private void OnCollectionEventHandler (object sender, CollectionChangeEventArgs e)
	        {	        	
	            	eventhandled = true;
	            	Element = e.Element;
			Action = e.Action;
			times++;
	        }
		private void ResetEventData ()
		{
			times = 0;
			eventhandled = false;
			Element = null;
			Action = (CollectionChangeAction) 0;
		}
        private void OnCollectionChanged(
            CollectionChangeAction action, object value)
        {
            for (int i = 0; i < Count; i++)
                ((GridColumn)List[i]).ColumnIndex = i;

            InvalidateDisplayIndexes();
            InvalidateLayout();

            if (CollectionChanged != null)
            {
                CollectionChangeEventArgs e = new
                    CollectionChangeEventArgs(action, value);

                CollectionChanged(this, e);
            }
        }
        private void OnCollectionChanged_PreNotification(CollectionChangeAction cca, 
                                                         int rowIndex,
                                                         int rowCount,
                                                         ref DataGridViewRow dataGridViewRow, 
                                                         bool changeIsInsertion)
        {
            Debug.Assert(this.DataGridView != null);
            bool useRowShortcut = false;
            bool computeVisibleRows = false;
            switch (cca)
            {
                case CollectionChangeAction.Add:
                {
                    int firstDisplayedRowHeight = 0;
                    UpdateRowCaches(rowIndex, ref dataGridViewRow, true);
                    if ((GetRowState(rowIndex) & DataGridViewElementStates.Visible) == 0)
                    {
                        // Adding an invisible row - no need for repaint
                        useRowShortcut = true;
                        computeVisibleRows = changeIsInsertion;
                    }
                    else
                    {
                        int firstDisplayedRowIndex = this.DataGridView.FirstDisplayedRowIndex;
                        if (firstDisplayedRowIndex != -1)
                        {
                            firstDisplayedRowHeight = SharedRow(firstDisplayedRowIndex).GetHeight(firstDisplayedRowIndex);
                        }
                    }
                    if (changeIsInsertion)
                    {
                        this.DataGridView.OnInsertedRow_PreNotification(rowIndex, 1);
                        if (!useRowShortcut)
                        {
                            if ((GetRowState(rowIndex) & DataGridViewElementStates.Frozen) != 0)
                            {
                                // Inserted row is frozen
                                useRowShortcut = this.DataGridView.FirstDisplayedScrollingRowIndex == -1 && 
                                                 GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height);
                            }
                            else if (this.DataGridView.FirstDisplayedScrollingRowIndex != -1 &&
                                     rowIndex > this.DataGridView.FirstDisplayedScrollingRowIndex)
                            {
                                useRowShortcut = GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height + this.DataGridView.VerticalScrollingOffset) &&
                                                 firstDisplayedRowHeight <= this.DataGridView.LayoutInfo.Data.Height;
                            }
                        }
                    }
                    else
                    {
                        this.DataGridView.OnAddedRow_PreNotification(rowIndex);
                        if (!useRowShortcut)
                        {
                            int displayedRowsHeightBeforeAddition = GetRowsHeight(DataGridViewElementStates.Visible) - this.DataGridView.VerticalScrollingOffset - dataGridViewRow.GetHeight(rowIndex);
                            dataGridViewRow = SharedRow(rowIndex);
                            useRowShortcut = this.DataGridView.LayoutInfo.Data.Height < displayedRowsHeightBeforeAddition &&
                                             firstDisplayedRowHeight <= this.DataGridView.LayoutInfo.Data.Height;
                        }
                    }
                    break;
                }

                case CollectionChangeAction.Remove:
                {
                    Debug.Assert(rowCount == 1);
                    DataGridViewElementStates rowStates = GetRowState(rowIndex);
                    bool deletedRowVisible = (rowStates & DataGridViewElementStates.Visible) != 0;
                    bool deletedRowFrozen = (rowStates & DataGridViewElementStates.Frozen) != 0;

                    // Can't do this earlier since it would break UpdateRowCaches
                    this.rowStates.RemoveAt(rowIndex);
                    this.SharedList.RemoveAt(rowIndex);
#if DEBUG
                    this.DataGridView.dataStoreAccessAllowed = false;
#endif
                    this.DataGridView.OnRemovedRow_PreNotification(rowIndex);
                    if (deletedRowVisible)
                    {
                        if (deletedRowFrozen)
                        {
                            // Delete row is frozen
                            useRowShortcut = this.DataGridView.FirstDisplayedScrollingRowIndex == -1 &&
                                             GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height + SystemInformation.HorizontalScrollBarHeight);
                        }
                        else if (this.DataGridView.FirstDisplayedScrollingRowIndex != -1 &&
                                 rowIndex > this.DataGridView.FirstDisplayedScrollingRowIndex)
                        {
                            int firstDisplayedRowHeight = 0;
                            int firstDisplayedRowIndex = this.DataGridView.FirstDisplayedRowIndex;
                            if (firstDisplayedRowIndex != -1)
                            {
                                firstDisplayedRowHeight = SharedRow(firstDisplayedRowIndex).GetHeight(firstDisplayedRowIndex);
                            }
                            useRowShortcut = GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height + this.DataGridView.VerticalScrollingOffset + SystemInformation.HorizontalScrollBarHeight) &&
                                             firstDisplayedRowHeight <= this.DataGridView.LayoutInfo.Data.Height;
                        }
                    }
                    else
                    {
                        // Deleting an invisible row - no need for repaint
                        useRowShortcut = true;
                    }
                    break;
                }

                case CollectionChangeAction.Refresh:
                {
                    InvalidateCachedRowCounts();
                    InvalidateCachedRowsHeights();
                    break;
                }

                default:
                {
                    Debug.Fail("Unexpected cca value in DataGridViewRowCollecttion.OnCollectionChanged");
                    break;
                }
            }
            this.DataGridView.ResetUIState(useRowShortcut, computeVisibleRows);
        }
        private void OnCollectionChanged_PostNotification(CollectionChangeAction cca, int rowIndex, int rowCount, DataGridViewRow dataGridViewRow, bool changeIsDeletion, bool changeIsInsertion, bool recreateNewRow, Point newCurrentCell)
        {
            if (changeIsDeletion)
            {
                this.DataGridView.OnRowsRemovedInternal(rowIndex, rowCount);
            }
            else
            {
                this.DataGridView.OnRowsAddedInternal(rowIndex, rowCount);
            }
            switch (cca)
            {
                case CollectionChangeAction.Add:
                    if (!changeIsInsertion)
                    {
                        this.DataGridView.OnAddedRow_PostNotification(rowIndex);
                        break;
                    }
                    this.DataGridView.OnInsertedRow_PostNotification(rowIndex, newCurrentCell, true);
                    break;

                case CollectionChangeAction.Remove:
                    this.DataGridView.OnRemovedRow_PostNotification(dataGridViewRow, newCurrentCell);
                    break;

                case CollectionChangeAction.Refresh:
                    if (changeIsDeletion)
                    {
                        this.DataGridView.OnClearedRows();
                    }
                    break;
            }
            this.DataGridView.OnRowCollectionChanged_PostNotification(recreateNewRow, newCurrentCell.X == -1, cca, dataGridViewRow, rowIndex);
        }
 /// <summary>
 /// <para>Initializes a new instance of the <see cref='System.ComponentModel.CollectionChangeEventArgs'/> class.</para>
 /// </summary>
 public CollectionChangeEventArgs(CollectionChangeAction action, object element)
 {
     Action = action;
     Element = element;
 }
Beispiel #40
0
			private void UpdateCollection (SWF.DataGridViewColumn column, 
			                               CollectionChangeAction change)
			{
				if (change == CollectionChangeAction.Remove) {
					DataGridViewDataItemChildProvider child = columns [column];
					RemoveChildProvider (child);
					child.Terminate ();
					columns.Remove (child.Column);
				} else if (change == CollectionChangeAction.Add) {
					DataGridViewDataItemChildProvider child;

					if ((column as SWF.DataGridViewButtonColumn) != null)
						child = new DataGridViewDataItemButtonProvider (this, column);
					else if ((column as SWF.DataGridViewCheckBoxColumn) != null)
						child = new DataGridViewDataItemCheckBoxProvider (this, column);
					else if ((column as SWF.DataGridViewLinkColumn) != null)
						child = new DataGridViewDataItemLinkProvider (this, column);
					else if ((column as SWF.DataGridViewImageColumn) != null)
						child = new DataGridViewDataItemImageProvider (this, column);
					else if ((column as SWF.DataGridViewComboBoxColumn) != null)
						child = new DataGridViewDataItemComboBoxProvider (this, column);
					else
						child = new DataGridViewDataItemEditProvider (this, column);

					child.Initialize ();
					AddChildProvider (child);
					columns [child.Column] = child;
				}
			}
	// Constructor.
	public CollectionChangeEventArgs
				(CollectionChangeAction action, Object element)
			{
				this.action = action;
				this.element = element;
			}
Beispiel #42
0
		private CollectionChangeEventArgs CreateCollectionChangeEvent (CollectionChangeAction action)
		{
			return new CollectionChangeEventArgs (action, this);
		}
 private void StatementsChanged(CollectionChangeAction action, CodeStatement stmt, int index)
 {
     if (action == CollectionChangeAction.Add)
     {
         base.TrueStatements.Insert(index, stmt);
         SetTargets(stmt, TargetPlaceholder, _target);
     }
     else if (action == CollectionChangeAction.Remove)
     {
         base.TrueStatements.Remove(stmt);
         SetTargets(stmt, _target, TargetPlaceholder);
     }
     else
     {
         SetAllTargets(base.TrueStatements, _target, TargetPlaceholder);
         base.TrueStatements.Clear();
     }
 }
        internal void OnRowCollectionChanged_PostNotification(bool recreateNewRow, 
                                                              bool allowSettingCurrentCell, 
                                                              CollectionChangeAction cca, 
                                                              DataGridViewRow dataGridViewRow, 
                                                              int rowIndex)
        {
            if (recreateNewRow &&
                cca == CollectionChangeAction.Refresh &&
                this.Columns.Count != 0 &&
                this.Rows.Count == 0 &&
                this.AllowUserToAddRowsInternal)
            {
                AddNewRow(false);
            }

            if (cca == CollectionChangeAction.Refresh)
            {
                FlushSelectionChanged();
            }

            if ((cca == CollectionChangeAction.Refresh || cca == CollectionChangeAction.Add) &&
                this.ptCurrentCell.X == -1 && allowSettingCurrentCell && !this.InSortOperation)
            {
                MakeFirstDisplayedCellCurrentCell(false /*includeNewRow*/);
            }

            if (this.AutoSize)
            {
                bool invalidatePreferredSizeCache = true;
                switch (cca)
                {
                    case CollectionChangeAction.Add:
                        Debug.Assert(rowIndex >= 0);
                        DataGridViewElementStates rowState = this.Rows.GetRowState(rowIndex);
                        invalidatePreferredSizeCache = ((rowState & DataGridViewElementStates.Visible) != 0);
                        break;
                    case CollectionChangeAction.Remove:
                        invalidatePreferredSizeCache = dataGridViewRow.DataGridView == null && dataGridViewRow.Visible;
                        break;
                    // case CollectionChangeAction.Refresh: invalidatePreferredSizeCache stays true
                }
                if (invalidatePreferredSizeCache)
                {
                    LayoutTransaction.DoLayout(this.ParentInternal, this, PropertyNames.Rows);
                }
            }
        }
Beispiel #45
0
        private void CheckMessage(XenAPI.Message m, CollectionChangeAction a)
        {
            if (!m.ShowOnGraphs || m.cls != cls.VM)
                return;

            Host h = XenObject as Host;
            if (h != null)
            {
                List<VM> resVMs = h.Connection.ResolveAll<VM>(h.resident_VMs);
                foreach (VM v in resVMs)
                {
                    if (v.uuid == m.obj_uuid)
                    {
                        if (a == CollectionChangeAction.Add)
                            DataEventList.AddEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m));
                        else
                            DataEventList.RemoveEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m));

                        break;
                    }
                }

            }
            else if (XenObject is VM)
            {
                if (m.obj_uuid != Helpers.GetUuid(XenObject))
                    return;

                if (a == CollectionChangeAction.Add)
                    DataEventList.AddEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m));
                else
                    DataEventList.RemoveEvent(new DataEvent(m.timestamp.ToLocalTime().Ticks, 0, m));
            }
        }
Beispiel #46
0
 private void OnPropertyChanged(string name, CollectionChangeAction action)
 {
     if (_PropertyChanged != null)
     {
         _PropertyChanged(this, new CollectionPropertyChangedEventArgs(name) { Action = action });
     }
 }
 private void NotifyChanged(CollectionChangeAction action, CodeSwitchOption option)
 {
     if (_changed != null)
     {
         _changed(action, option);
     }
 }
Beispiel #48
0
			private void UpdateCollection (SWF.DataGridViewColumn column, 
			                               CollectionChangeAction change)
			{
				if (change == CollectionChangeAction.Remove) {
					DataGridViewHeaderItemProvider headerItem = headers [column];
					RemoveChildProvider (headerItem);
					headers.Remove (column);
				} else if (change == CollectionChangeAction.Add) {
					DataGridViewHeaderItemProvider headerItem 
						= new DataGridViewHeaderItemProvider (this, column);
					headerItem.Initialize ();
					AddChildProvider (headerItem);
					headers [column] = headerItem;
				}
			}
        private void OnCollectionChanged_PostNotification(CollectionChangeAction cca, 
                                                          int rowIndex, 
                                                          int rowCount,
                                                          DataGridViewRow dataGridViewRow,
                                                          bool changeIsDeletion,
                                                          bool changeIsInsertion,
                                                          bool recreateNewRow,
                                                          Point newCurrentCell)
        {
            Debug.Assert(this.DataGridView != null);
            if (changeIsDeletion)
            {
                this.DataGridView.OnRowsRemovedInternal(rowIndex, rowCount);
            }
            else
            {
                this.DataGridView.OnRowsAddedInternal(rowIndex, rowCount);
            }

#if DEBUG
            this.DataGridView.dataStoreAccessAllowed = true;
#endif
            switch (cca)
            {
                case CollectionChangeAction.Add:
                {
                    if (changeIsInsertion)
                    {
                        this.DataGridView.OnInsertedRow_PostNotification(rowIndex, newCurrentCell, true);
                    }
                    else
                    {
                        this.DataGridView.OnAddedRow_PostNotification(rowIndex);
                    }
                    break;
                }

                case CollectionChangeAction.Remove:
                {
                    this.DataGridView.OnRemovedRow_PostNotification(dataGridViewRow, newCurrentCell);
                    break;
                }

                case CollectionChangeAction.Refresh:
                {
                    if (changeIsDeletion)
                    {
                        this.DataGridView.OnClearedRows();
                    }
                    break;
                }
            }

            this.DataGridView.OnRowCollectionChanged_PostNotification(recreateNewRow, newCurrentCell.X == -1, cca, dataGridViewRow, rowIndex);
        }
Beispiel #50
0
 /// <summary>
 /// Initializes a new instance of the ItemCollectionChangedEventArgs class.
 /// </summary>
 /// <param name="action">The type of action causing the change.</param>
 /// <param name="item">The item that is the target of this event. This parameter will be null
 /// if the collection is cleared.</param>
 public ItemCollectionChangedEventArgs(CollectionChangeAction action, ImageListViewItem item)
 {
     Action = action;
     Item = item;
 }
        private void OnCollectionChanged_PreNotification(CollectionChangeAction cca, int rowIndex, int rowCount, ref DataGridViewRow dataGridViewRow, bool changeIsInsertion)
        {
            int height;
            bool useRowShortcut = false;
            bool computeVisibleRows = false;
            switch (cca)
            {
                case CollectionChangeAction.Add:
                    height = 0;
                    this.UpdateRowCaches(rowIndex, ref dataGridViewRow, true);
                    if ((this.GetRowState(rowIndex) & DataGridViewElementStates.Visible) != DataGridViewElementStates.None)
                    {
                        int firstDisplayedRowIndex = this.DataGridView.FirstDisplayedRowIndex;
                        if (firstDisplayedRowIndex != -1)
                        {
                            height = this.SharedRow(firstDisplayedRowIndex).GetHeight(firstDisplayedRowIndex);
                        }
                        break;
                    }
                    useRowShortcut = true;
                    computeVisibleRows = changeIsInsertion;
                    break;

                case CollectionChangeAction.Remove:
                {
                    DataGridViewElementStates rowState = this.GetRowState(rowIndex);
                    bool flag3 = (rowState & DataGridViewElementStates.Visible) != DataGridViewElementStates.None;
                    bool flag4 = (rowState & DataGridViewElementStates.Frozen) != DataGridViewElementStates.None;
                    this.rowStates.RemoveAt(rowIndex);
                    this.SharedList.RemoveAt(rowIndex);
                    this.DataGridView.OnRemovedRow_PreNotification(rowIndex);
                    if (!flag3)
                    {
                        useRowShortcut = true;
                    }
                    else if (!flag4)
                    {
                        if ((this.DataGridView.FirstDisplayedScrollingRowIndex != -1) && (rowIndex > this.DataGridView.FirstDisplayedScrollingRowIndex))
                        {
                            int num4 = 0;
                            int num5 = this.DataGridView.FirstDisplayedRowIndex;
                            if (num5 != -1)
                            {
                                num4 = this.SharedRow(num5).GetHeight(num5);
                            }
                            useRowShortcut = this.GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, (this.DataGridView.LayoutInfo.Data.Height + this.DataGridView.VerticalScrollingOffset) + SystemInformation.HorizontalScrollBarHeight) && (num4 <= this.DataGridView.LayoutInfo.Data.Height);
                        }
                    }
                    else
                    {
                        useRowShortcut = (this.DataGridView.FirstDisplayedScrollingRowIndex == -1) && this.GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height + SystemInformation.HorizontalScrollBarHeight);
                    }
                    goto Label_02DF;
                }
                case CollectionChangeAction.Refresh:
                    this.InvalidateCachedRowCounts();
                    this.InvalidateCachedRowsHeights();
                    goto Label_02DF;

                default:
                    goto Label_02DF;
            }
            if (changeIsInsertion)
            {
                this.DataGridView.OnInsertedRow_PreNotification(rowIndex, 1);
                if (!useRowShortcut)
                {
                    if ((this.GetRowState(rowIndex) & DataGridViewElementStates.Frozen) != DataGridViewElementStates.None)
                    {
                        useRowShortcut = (this.DataGridView.FirstDisplayedScrollingRowIndex == -1) && this.GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height);
                    }
                    else if ((this.DataGridView.FirstDisplayedScrollingRowIndex != -1) && (rowIndex > this.DataGridView.FirstDisplayedScrollingRowIndex))
                    {
                        useRowShortcut = this.GetRowsHeightExceedLimit(DataGridViewElementStates.Visible, 0, rowIndex, this.DataGridView.LayoutInfo.Data.Height + this.DataGridView.VerticalScrollingOffset) && (height <= this.DataGridView.LayoutInfo.Data.Height);
                    }
                }
            }
            else
            {
                this.DataGridView.OnAddedRow_PreNotification(rowIndex);
                if (!useRowShortcut)
                {
                    int num3 = (this.GetRowsHeight(DataGridViewElementStates.Visible) - this.DataGridView.VerticalScrollingOffset) - dataGridViewRow.GetHeight(rowIndex);
                    dataGridViewRow = this.SharedRow(rowIndex);
                    useRowShortcut = (this.DataGridView.LayoutInfo.Data.Height < num3) && (height <= this.DataGridView.LayoutInfo.Data.Height);
                }
            }
        Label_02DF:
            this.DataGridView.ResetUIState(useRowShortcut, computeVisibleRows);
        }
 public CollectionChangeEventArgs(CollectionChangeAction action, Object element)
 {
 }