/// <summary> /// Shows the form as a dialog and the specified discovery event. /// </summary> /// <param name="owner">The owner window.</param> /// <param name="evt">The event.</param> /// <returns>The dialog result.</returns> public DialogResult ShowDialog(IWin32Window owner, AjaxViewsHistoryDiscoveryEvent evt) { // Set the event. this.controlHistoryDiscoveryEvent.Event = evt; // Set the title. this.Text = "Event {0} at {1} Properties".FormatWith(evt.Name, evt.Marker.Value.Time.ToString()); // Open the dialog. return base.ShowDialog(owner); }
/// <summary> /// Adds a new views history discovery event. /// </summary> /// <param name="evt">The discovery event.</param> public void AddViewsDiscoveryEvent(AjaxViewsHistoryDiscoveryEvent evt) { // Check if the history already contains the event name. if (this.events.ContainsKey(evt.Name)) throw new AjaxException("Cannot add a new discovery event: an event with the name \"{0}\" already exists.".FormatWith(evt.Name)); // Set the event marker. evt.Marker = this.Markers.First(marker => marker.Name == evt.Name); // Check that the marker is not null. if (evt.Marker == null) throw new AjaxException("Cannot add a new discovery event: the event with the name \"{0}\" does not have an associated marker.".FormatWith(evt.Name)); // Add the event. this.events.Add(evt.Name, evt); }
// Protected methods. /// <summary> /// An event handler called when a new discovery event has been set. /// </summary> /// <param name="oldEvent">The old event.</param> /// <param name="newEvent">The new event.</param> protected virtual void OnEventSet(AjaxViewsHistoryDiscoveryEvent oldEvent, AjaxViewsHistoryDiscoveryEvent newEvent) { // If the old and new events are the same, do nothing. if (oldEvent == newEvent) return; if (null == newEvent) { this.labelTitle.Text = "No history discovery event selected."; this.tabControl.Visible = false; } else { this.labelTitle.Text = "{0} at {1}".FormatWith(newEvent.Name, newEvent.Marker.Value.Time.ToString()); this.textBoxName.Text = newEvent.Name; this.textBoxTime.Text = newEvent.Marker.Value.Time.ToString(); this.textBoxType.Text = "[{0}] {1}".FormatWith(((int)newEvent.Type).ToString(), newEvent.Type.ToString()); this.textBoxDescription.Text = AjaxViewsHistoryDiscoveryEvent.GetTypeDescription(newEvent.Type); this.textBoxData.Text = newEvent.Extra; this.tabControl.Visible = true; } this.tabControl.SelectedTab = this.tabPageGeneral; if (this.Focused) { this.textBoxName.Select(); this.textBoxName.SelectionStart = 0; this.textBoxName.SelectionLength = 0; } }