|
void ChangeItemAmountV_Safe(APieces : Integer) var TempPieceLbl : TclProLabel; TempButton: TclProButton; labelName: String; LPieceStr : String; currentAmount: Integer; { Try if (MainForm.ClSender == nil) { Exit; } TempButton = MainForm.ClSender as TclProButton; if (TempButton == nil) { Exit; } Try labelName = TempButton.Hint; except Exit; } if (Trim(labelName) == '') { Exit; } TempPieceLbl = MainForm.clFindComponent(labelName) as TclProLabel; if (TempPieceLbl == nil) { Exit; } LPieceStr = TempPieceLbl.Text; if (Pos('x', LPieceStr) == 1) { LPieceStr = Copy(LPieceStr, 2, Length(LPieceStr) - 1); } Try currentAmount = StrToInt(Trim(LPieceStr)); except currentAmount = 0; } // Miktarı güncelle currentAmount = currentAmount + APieces; if (currentAmount < 0) { currentAmount = 0; } TempPieceLbl.Text = 'x' + IntToStr(currentAmount); except // Sessizce devam et } } void ItemDecreaseV { ChangeItemAmountV_Safe(-1); }
void ItemIncreaseV { ChangeItemAmountV_Safe(1); }
// BUTON OLUŞTURMA - HINT İLE
void CreateButtonsWithHint(I: Integer) var IncreaseBtn, DecreaseBtn: TclProButton; PieceLbl: TclProLabel; { Try IncreaseBtn = MainForm.AddNewProButton(ValuePnl, 'IncreaseBtn' + IntToStr(I), '+'); IncreaseBtn.Width = (MainForm.clWidth * 0.0967); IncreaseBtn.Height = (MainForm.clHeight * 0.0453); IncreaseBtn.Margins.Bottom = (MainForm.clHeight * 0.0477); IncreaseBtn.clProSettings.BorderWidth = 2; IncreaseBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#1e1e1e'); IncreaseBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#3a3a3a'); IncreaseBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#ffffff'); IncreaseBtn.clProSettings.FontSize = 20; IncreaseBtn.SetclProSettings(IncreaseBtn.clProSettings); MainForm.AddNewEvent(IncreaseBtn, tbeOnClick, 'ItemIncreaseV'); IncreaseBtn.Hint = 'PieceLbl' + IntToStr(I); IncreaseBtn.clTagInt = I; DecreaseBtn = MainForm.AddNewProButton(ValuePnl, 'DecreaseBtn' + IntToStr(I), '-'); DecreaseBtn.Width = (MainForm.clWidth * 0.0967); DecreaseBtn.Height = (MainForm.clHeight * 0.0453); DecreaseBtn.Margins.Top = (MainForm.clHeight * 0.0500); DecreaseBtn.clProSettings.BorderWidth = 2; DecreaseBtn.clProSettings.BackgroundColor = clAlphaColor.clHexToColor('#1e1e1e'); DecreaseBtn.clProSettings.BorderColor = clAlphaColor.clHexToColor('#3a3a3a'); DecreaseBtn.clProSettings.FontColor = clAlphaColor.clHexToColor('#ffffff'); DecreaseBtn.clProSettings.FontSize = 20; DecreaseBtn.SetclProSettings(DecreaseBtn.clProSettings); MainForm.AddNewEvent(DecreaseBtn, tbeOnClick, 'ItemDecreaseV'); DecreaseBtn.Hint = 'PieceLbl' + IntToStr(I); DecreaseBtn.clTagInt = I; PieceLbl = MainForm.AddNewProLabel(DetailsPnl, 'PieceLbl' + IntToStr(I), 'x' + FieldByName('amount').AsString); PieceLbl.Width = (MainForm.clWidth * 0.0636); PieceLbl.Height = (MainForm.clHeight * 0.0298); PieceLbl.Margins.Left = (MainForm.clWidth * 0.4071); PieceLbl.Margins.Top = (MainForm.clHeight * 0.0417); PieceLbl.clProSettings.FontSize = 16; PieceLbl.clProSettings.FontVertAlign = palcenter; PieceLbl.clProSettings.FontHorzAlign = palLeading; PieceLbl.clProSettings.FontColor = clAlphaColor.clHexToColor('#ffffff'); PieceLbl.clProSettings.TextSettings.Font.Style = [fsBold]; PieceLbl.SetclProSettings(PieceLbl.clProSettings); except ShowMessage('CreateButtonsWithHint hatası: ' + LastExceptionMessage); } }
|