private void ControlSubscription_DataChange(DaSubscription aDaSubscription, DaItem[] changedItems, ValueQT[] newValues, int[] results) { try { int count = changedItems.Length; ControlDaItem[] controlItems = new ControlDaItem[count]; for (int i = 0; i < count; i++) { if (this.Contains(changedItems[i])) { int index = this.IndexOf(changedItems[i]); ((DaItem)this[index]).ValueQT = newValues[i]; if (null != ListChanged) { ListChanged(this, new ListChangedEventArgs(ListChangedType.ItemChanged, i)); } // end if } // end if controlItems[i] = (ControlDaItem)changedItems[i]; } // end for this.OnDataChange((ControlDaSubscription)aDaSubscription, controlItems, newValues, results); } catch (Exception exc) { m_instance.Trace(EnumTraceLevel.ERR, EnumTraceGroup.CLIENT, "DataControl.DataControl_DataChange", exc.Message); } }
//- #endregion #region //PrivateMethods //---------------------- private int CompareProperties(ControlDaItem x, ControlDaItem y) { int result = 0; int directionModifier = 0; if ((m_SortDirection == ListSortDirection.Ascending)) { directionModifier = 1; } else { directionModifier = -1; } if ((x == null)) { result = -1 * directionModifier; } else if ((y == null)) { result = 1 * directionModifier; } else if ((System.Convert.ToDouble(m_SortProperty.GetValue(x)) < System.Convert.ToDouble(m_SortProperty.GetValue(y)))) { result = -1 * directionModifier; } else if ((System.Convert.ToDouble(m_SortProperty.GetValue(x)) > System.Convert.ToDouble(m_SortProperty.GetValue(y)))) { result = 1 * directionModifier; } else { result = 0; } return(result); }
internal void CancelAddNew(ControlDaItem item, bool Remove) { item.CancelAddNew -= new ControlDaItem.CancelAddNewEventHandler(this.CancelAddNew); if ((Remove)) { this.Remove(item); } }
/// <summary> /// Adds a new item to the list. /// </summary> /// <returns>The item added to the list.</returns> internal object AddNew() { ControlDaItem item = new ControlDaItem(true); this.Add(item); item.CancelAddNew += new ControlDaItem.CancelAddNewEventHandler(this.CancelAddNew); return(item); }
/// <summary> /// Removes the first occurrence of a specific <see cref="ControlDaItem">ControlDaItem</see> from the collection. /// </summary> /// <param name="item"></param> internal void Remove(ControlDaItem item) { this.List.Remove(item); }
/// <summary> /// Inserts a <see cref="ControlDaItem">ControlDaItem</see> into the collection at the specified index. /// </summary> /// <param name="index">The zero-based index at which the item should be inserted. </param> /// <param name="item">The <b>ControlDaItem</b> to insert.</param> internal void Insert(int index, ControlDaItem item) { this.List.Insert(index, item); }
} // end OnValidate /// <summary> /// Adds a <see cref="ControlDaItem">ControlDaItem</see> to the end of the collection. /// </summary> /// <param name="item">The <see cref="ControlDaItem">ControlDaItem</see> to be added to the end of the collection.</param> internal void Add(ControlDaItem item) { this.List.Add(item); } // end Add
//- #endregion #region Public Methods //---------------------- /// <summary> /// Starts the <see cref="DataControl">DataControl.</see> /// </summary> /// <remarks> /// After starting the <B>DataControl</B> the client will be notified about the <see cref="ValueQT">value</see> changes for all the /// <see cref="ControlDaItem">items</see> selected in the configuration phase. If an item is bound to a /// Windows Forms Control then the new values will be displayed in this one. /// </remarks> /// <include /// file='TBNC.doc.xml' /// path='//class[@name="DataControl"]/method[@name="Start"]/doc/*' /// /> public void Start() { try { if (m_session == null) { return; } this.Clear(); if (this.BinaryLicenseDa != string.Empty) { m_instance.Activate(EnumFeature.DA_CLIENT, this.BinaryLicenseDa); } if (this.BinaryLicenseXmlDa != string.Empty) { m_instance.Activate(EnumFeature.DA_CLIENT, this.BinaryLicenseXmlDa); } m_instance.Initialize(); m_newSession = new ControlDaSession(m_session.StoredUrl); m_newSession.Connect(false, true, new ExecutionOptions()); m_newSession.ShutdownRequest += new ShutdownEventHandler(HandleSessionShutdownWithReconnection); if (m_session.SubscriptionList.Length == 0) { return; } foreach (ControlDaSubscription currentSubscription in m_session.SubscriptionList) { ControlDaSubscription controlSubscription = new ControlDaSubscription( currentSubscription.StoredUpdateRate, m_newSession); if (controlSubscription.Valid) { controlSubscription.Name = currentSubscription.StoredName; controlSubscription.StoredName = controlSubscription.Name; controlSubscription.StoredUpdateRate = controlSubscription.RequestedUpdateRate; controlSubscription.IsActivated = currentSubscription.IsActivated; controlSubscription.DataChanged += new DataChangedEventHandler(ControlSubscription_DataChange); DaItem[] items = currentSubscription.ItemList; for (int i = 0; i < items.Length; i++) { ControlDaItem controlItem = new ControlDaItem( ((ControlDaItem)items[i]).StoredId, controlSubscription); this.Add(controlItem); } // end for if (controlSubscription.IsActivated) { controlSubscription.Connect(true, true, new ExecutionOptions()); } // end if } // end if } // end foreach m_session.Handle = m_newSession.Handle; } catch (Exception exc) { m_instance.Trace( EnumTraceLevel.ERR, EnumTraceGroup.CLIENT, "DataControl.Start", exc.ToString()); } } // end Start