/// <summary> /// Заполняет графический элемент из бизнес коллекции /// </summary> public override void FillUIElementsFromCollection() { int count = Collection.Count; aircraftItems = new List <AircraftReferenceStatusImageLinkLabel>(); flowLayoutPanelAircrafts.Controls.Clear(); for (int i = 0; i < count; i++) { AircraftReferenceStatusImageLinkLabel tempLabel = new AircraftReferenceStatusImageLinkLabel(Collection[i]); tempLabel.Text = Collection[i].RegistrationNumber; tempLabel.Width = 150; tempLabel.Enabled = true; if (OperatorCollection.Instance.Count == 1) { tempLabel.DisplayerText = Collection[i].RegistrationNumber; } else { tempLabel.DisplayerText = Collection[i].Operator.Name + ". " + Collection[i].RegistrationNumber; } tempLabel.DisplayerRequested += tempButton_DisplayerRequested; tempLabel.ReflectionType = ReflectionTypes.DisplayInNew; aircraftItems.Add(tempLabel); aircraftCollection[i].Saved -= AircraftCollectionControl_Saved; aircraftCollection[i].Saved += AircraftCollectionControl_Saved; } aircraftsListStatistics.Amount = aircraftItems.Count; aircraftItems.Sort(new AircraftReferenceStatusImageLinkLabelComparer()); flowLayoutPanelAircrafts.Controls.AddRange(aircraftItems.ToArray()); }
private void tempButton_DisplayerRequested(object sender, ReferenceEventArgs e) { tempAircraft = (Aircraft)((AircraftReferenceStatusImageLinkLabel)sender).Aircraft; if (animatedThreadWorker == null) { if (TaskStart != null) { TaskStart(this, new EventArgs()); } tempAircraftListItemReference = (AircraftReferenceStatusImageLinkLabel)sender; e.Cancel = true; animatedThreadWorker = new AnimatedThreadWorker(BackgroundAircraftLoad, sender, this); animatedThreadWorker.State = "Loading " + tempAircraft.RegistrationNumber; animatedThreadWorker.StartThread(); animatedThreadWorker.WorkFinished += animatedThreadWorker_WorkFinished; } else { e.RequestedEntity = new DispatcheredAircraftScreen(tempAircraft); } }
private void animatedThreadWorker_WorkFinished(object sender, EventArgs e) { tempAircraftListItemReference.DisplayRequested(); animatedThreadWorker.StopThread(); animatedThreadWorker = null; tempAircraftListItemReference = null; if (TaskEnd != null) { TaskEnd(this, new EventArgs()); } }