/// <summary> /// Method gets count of details /// </summary> /// <param name="wrapper"></param> /// <returns></returns> private int _GetDetailsCount(MessageWindowDataWrapper wrapper) { int result = 0; if (null != wrapper.Details) { foreach (object obj in wrapper.Details) { result++; } } return(result); }
private void _AddMessage(MessageType type, string timeMark, string message, Link link, IEnumerable <MessageDetail> details) { // convert to wrapper List <MessageDetailDataWrap> detailsWrap = null; if (null != details) { detailsWrap = new List <MessageDetailDataWrap>(); IEnumerator <MessageDetail> enumerator = details.GetEnumerator(); while ((null != enumerator) && enumerator.MoveNext()) { MessageDetail detail = enumerator.Current; detailsWrap.Add(new MessageDetailDataWrap(detail.Type, detail.Description)); } } // add message MessageWindowTextDataWrapper textWrapper = new MessageWindowTextDataWrapper(message, link); MessageWindowDataWrapper wrapper = new MessageWindowDataWrapper(type, timeMark, textWrapper, detailsWrap); if (0 == _data.Count) { _data.Add(wrapper); } else { _data.Insert(0, wrapper); } _collectionSource.Source = _data; // NOTE: XceedGrid issue - refresh logical children if (null != _collectionSource.View) { _collectionSource.View.Refresh(); } // auto open window if (MessageType.Error == type) { // error - open the message window _timer.Enabled = false; _timer.Stop(); _isAutoOpened = false; _isNeedClose = false; if (Visibility.Visible != this.Visibility) { App.Current.MainWindow.ToggleMessageWindowState(); } // expand error details if (null != details) { DataGridContext dgc = xceedGrid.CurrentContext; xceedGrid.ExpandDetails(dgc.Items.GetItemAt(0)); } } else if (MessageType.Warning == type) { // warning - pop the message window if (Visibility.Visible != this.Visibility) { App.Current.MainWindow.ToggleMessageWindowState(); _isAutoOpened = true; _timer.Interval = SHOW_POPUP_MESSAGE_TIMER_INTERVAL; _timer.Start(); _timer.Enabled = true; _isNeedClose = false; } else if (_isAutoOpened) { // reinit timer _timer.Enabled = false; _timer.Stop(); _timer.Interval = SHOW_POPUP_MESSAGE_TIMER_INTERVAL; _timer.Start(); _timer.Enabled = true; _isNeedClose = false; } // Expand error details. if (null != details) { DataGridContext dgc = xceedGrid.CurrentContext; xceedGrid.ExpandDetails(dgc.Items.GetItemAt(0)); } } // else info don't change state of the message window }