Index: VerpakkingsDefinitie/UI/ProductDetailScherm.pas =================================================================== diff -u -r569 -r571 --- VerpakkingsDefinitie/UI/ProductDetailScherm.pas (.../ProductDetailScherm.pas) (revision 569) +++ VerpakkingsDefinitie/UI/ProductDetailScherm.pas (.../ProductDetailScherm.pas) (revision 571) @@ -66,6 +66,7 @@ CheckComboBoxRichting: TCheckedComboBox; procedure UpdateGui(Sender: TObject); + procedure UpdateGuiDataAanwezigheid(Aanwezig: boolean); public Constructor Create(AOwner: TComponent; Navigator: INavigator; ApplicationContext: TApplicationContext; ProductDetailsSubject: TSubject); @@ -110,38 +111,16 @@ var ProductDetailInformatie: OptiServerService.pxBoxData; PPSPrioriteitEl: OptiServerService.pxemPPSPrioriteit; - SchermControl: TControl; - I: Integer; TempStr: string; begin - { TODO : Als er geen product is om detail van te tonen, verberg alle componenten en toon een bericht in het midden van het scherm } if (ApplicationContext.ProductDetailContext.GeselecteerdProduct = nil) or (ApplicationContext.ProductDetailContext.ProductDetailInformatie = nil) then begin - // Geen resultaten, verberg kinderen, toon melding (label) en stop. - for I := 0 to self.ControlCount - 1 do - self.Controls[I].Visible := false; - // Label tonen - LabelGeenData := TLabel.Create(self); - with LabelGeenData do - begin - Parent := self; - Caption := GEEN_DATA_CAPTION; - Font.Size := 15; - // Centreren: https://stackoverflow.com/questions/18545937/make-a-component-appear-in-the-middle-of-form-no-matter-what-screen-resolution - Left := (self.Width - Width) div 2; - Top := (self.Height - Height) div 2; - Anchors := []; // Relatief tegenover parent - end; + UpdateGuiDataAanwezigheid(False); exit; end else - begin - // Wel resultaten, toon alles en ga verder. - for I := 0 to self.ControlCount - 1 do - self.Controls[I].Visible := true; - LabelGeenData.Free(); - end; + UpdateGuiDataAanwezigheid(True); // Update with data from ApplicationContext LabelOmschrijving1.Caption := ApplicationContext.ProductDetailContext.GeselecteerdProduct.Omschrijving1; @@ -203,7 +182,7 @@ CheckComboBoxPositie.Items.Add(TempStr); end; if CheckComboBoxPositie.Items.IndexOf(ProductDetailInformatie.Positie) >= 0 then - CheckComboBoxPositie.Checked[CheckComboBoxPositie.Items.IndexOf(ProductDetailInformatie.Positie)] := true; + CheckComboBoxPositie.Checked[CheckComboBoxPositie.Items.IndexOf(ProductDetailInformatie.Positie)] := True; // Richting CheckComboBoxRichting.Items.Clear(); @@ -213,10 +192,52 @@ CheckComboBoxRichting.Items.Add(TempStr); end; if CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.Rotatie) >= 0 then - CheckComboBoxRichting.Checked[CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.Rotatie)] := true + CheckComboBoxRichting.Checked[CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.Rotatie)] := True else if CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.DefaultData.Rotatie) >= 0 then - CheckComboBoxRichting.Checked[CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.DefaultData.Rotatie)] := true + CheckComboBoxRichting.Checked[CheckComboBoxRichting.Items.IndexOf(ProductDetailInformatie.DefaultData.Rotatie)] := True end; end; +procedure TFormProductDetail.UpdateGuiDataAanwezigheid(Aanwezig: boolean); +var + I: Integer; +begin + if Aanwezig then + begin + // Skip update als alles al zichtbaar staat. + if Assigned(LabelGeenData) = False then + exit; + + // Wel resultaten, toon alles. + for I := 0 to self.ControlCount - 1 do + if Assigned(self.Controls[I]) then + self.Controls[I].Visible := True; + + FreeAndNil(LabelGeenData); + end + else + begin + // Skip update als melding al getoond wordt en alles onzichtbaar staat. + if Assigned(LabelGeenData) then + exit; + + // Geen resultaten, verberg kinderen, toon melding (label) en stop. + for I := 0 to self.ControlCount - 1 do + if Assigned(self.Controls[I]) then + self.Controls[I].Visible := False; + // Label tonen + LabelGeenData := TLabel.Create(self); + with LabelGeenData do + begin + Parent := self; + Caption := GEEN_DATA_CAPTION; + Font.Size := 15; + // Centreren: https://stackoverflow.com/questions/18545937/make-a-component-appear-in-the-middle-of-form-no-matter-what-screen-resolution + Left := (self.Width - Width) div 2; + Top := (self.Height - Height) div 2; + Anchors := []; // Relatief tegenover parent + end; + end +end; + end.