/// <summary> /// Toggles the active/inactive state for a subscription. /// </summary> private void ActiveMI_Click(object sender, System.EventArgs e) { try { ListViewItem item = SubscriptionsLV.SelectedItems[0]; Ae.TsCAeSubscription subscription = (Ae.TsCAeSubscription)item.Tag; Ae.TsCAeSubscriptionState state = new Ae.TsCAeSubscriptionState(); state.Active = !ActiveMI.Checked; subscription.ModifyState((int)TsCAeStateMask.Active, state); // toggle checkbox. ActiveMI.Checked = !ActiveMI.Checked; // update list. Update(item); // receive notifications. if (m_SubscriptionAction != null) { m_SubscriptionAction(subscription, !subscription.Active); } // adjust columns. AdjustColumns(SubscriptionsLV); } catch (Exception exception) { MessageBox.Show(exception.Message); } }
/// <summary> /// Copy values from control into object - throw exceptions on error. /// </summary> public object Get() { Ae.TsCAeSubscriptionState state = new Ae.TsCAeSubscriptionState(); state.Name = NameTB.Text; state.Active = ActiveCB.Checked; state.BufferTime = (int)BufferTimeCTRL.Value; state.KeepAlive = (int)KeepAliveCTRL.Value; state.MaxSize = (int)MaxSizeCTRL.Value; return(state); }
/// <summary> /// Prompts a user to create a new subscription with a modal dialog. /// </summary> public Ae.TsCAeSubscription ShowDialog(TsCAeServer server, Ae.TsCAeSubscription subscription) { if (server == null) { throw new ArgumentNullException("server"); } m_server = server; m_subscription = subscription; // go to the initial stage. m_stage = 0; ChangeStage(0); // initialize controls. StateCTRL.SetDefaults(); FiltersCTRL.SetDefaults(); CategoriesCTRL.ShowCategories(m_server); AttributesCTRL.ShowAttributes(m_server); BrowseCTRL.ShowAreas(m_server); if (m_subscription != null) { m_state = m_subscription.GetState(); m_filters = m_subscription.GetFilters(); m_attributes = m_subscription.GetAttributes(); m_areas = m_subscription.Areas.ToArray(); m_sources = m_subscription.Sources.ToArray(); } else { m_state.Name = String.Format("Subscription{0,3:000}", ++m_count); } // set current values. StateCTRL.Set(m_state); FiltersCTRL.Set(m_filters); CategoriesCTRL.SetSelectedCategories(m_filters.Categories.ToArray()); AttributesCTRL.SetSelectedAttributes(m_attributes); AreaSourcesListCTRL.AddAreas(m_areas); AreaSourcesListCTRL.AddSources(m_sources); // show dialog. if (ShowDialog() != DialogResult.OK) { return(null); } // return updated/created subscription. return(m_subscription); }
/// <summary> /// Called when the next button is clicked. /// </summary> private void NextBTN_Click(object sender, System.EventArgs e) { if (m_stage == 0) { m_state = (Ae.TsCAeSubscriptionState)StateCTRL.Get(); m_filters = (Ae.TsCAeSubscriptionFilters)FiltersCTRL.Get(); m_filters.Categories.Clear(); m_filters.Categories.AddRange(CategoriesCTRL.GetSelectedCategories()); m_attributes = AttributesCTRL.GetSelectedAttributes(); } ChangeStage(++m_stage); }
/// <summary> /// Copy object values into controls. /// </summary> public void Set(object value) { // check for null value. if (value == null) { SetDefaults(); return; } Ae.TsCAeSubscriptionState state = (Ae.TsCAeSubscriptionState)value; NameTB.Text = state.Name; ActiveCB.Checked = state.Active; BufferTimeCTRL.Value = (decimal)state.BufferTime; KeepAliveCTRL.Value = (decimal)state.KeepAlive; MaxSizeCTRL.Value = (decimal)state.MaxSize; }
/// <summary> /// Changes the state of a subscription. /// </summary> /// <param name="masks">A bit mask that indicates which elements of the subscription state are changing.</param> /// <param name="state">The new subscription state.</param> /// <returns>The actual subscription state after applying the changes.</returns> public Ae.TsCAeSubscriptionState ModifyState(int masks, Ae.TsCAeSubscriptionState state) { if (_subscription == null) { throw new NotConnectedException(); } _state = _subscription.ModifyState(masks, state); if ((masks & (int)TsCAeStateMask.Name) != 0) { _state.Name = _name = state.Name; } else { _state.Name = _name; } return((Ae.TsCAeSubscriptionState)_state.Clone()); }
/// <summary> /// Creates a new event subscription. /// </summary> /// <param name="state">The initial state for the subscription.</param> /// <returns>The new subscription object.</returns> public ITsCAeSubscription CreateSubscription(Ae.TsCAeSubscriptionState state) { if (_server == null) { throw new NotConnectedException(); } // create remote object. ITsCAeSubscription subscription = ((ITsCAeServer)_server).CreateSubscription(state); if (subscription != null) { // create wrapper. Ae.TsCAeSubscription wrapper = new Ae.TsCAeSubscription(this, subscription, state); _subscriptions.Add(wrapper); return(wrapper); } // should never happen. return(null); }
/// <summary> /// Creates a new object. /// </summary> public object Create() { Ae.TsCAeSubscriptionState state = new Ae.TsCAeSubscriptionState(); state.BufferTime = 1000; return(state); }