コード例 #1
0
        protected override void AnimatedThreadWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            if (e.Cancelled)
            {
                return;
            }

            if (firstLoad)
            {
                if (_initialPeriodArray.Count > 0)
                {
                    dateTimePickerDateFrom.Value = _initialPeriodArray.Min(f => f.DepartureDate);
                    dateTimePickerDateTo.Value   = _initialPeriodArray.Max(f => f.ArrivalDate);
                }
                else
                {
                    dateTimePickerDateFrom.Value = DateTimeExtend.GetCASMinDateTime();
                    dateTimePickerDateTo.Value   = DateTime.Today;
                }
            }

            firstLoad    = false;
            filterPeriod = false;

            foreach (var flightNumber in _resultFlightsArray.OrderBy(f => f.FlightNo.FullName))
            {
                var periods = _resultPeriodArray.Where(f => f.FlightNumberId == flightNumber.ItemId);
                if (periods.Any())
                {
                    _result.Add(flightNumber);
                    foreach (var period in periods)
                    {
                        _result.Add(period);
                    }
                }
            }

            var res = new List <IFlightNumberParams>();

            foreach (var item in _result)
            {
                if (item is FlightNumber)
                {
                    res.Add(item as FlightNumber);

                    var component = (FlightNumber)item;
                    var items     = _result
                                    .Where(lvi =>
                                           lvi is FlightNumberPeriod &&
                                           ((FlightNumberPeriod)lvi).FlightNumberId == component.ItemId).Select(i => i);
                    res.AddRange(items.OfType <FlightNumberPeriod>());
                }
            }

            _directivesViewer.SetItemsArray(res.ToArray());
            _directivesViewer.Focus();

            headerControl.PrintButtonEnabled = _directivesViewer.ItemsCount != 0;
        }